diff options
Diffstat (limited to 'include/drawinglayer/processor2d')
8 files changed, 699 insertions, 0 deletions
diff --git a/include/drawinglayer/processor2d/baseprocessor2d.hxx b/include/drawinglayer/processor2d/baseprocessor2d.hxx new file mode 100644 index 000000000..789a267ec --- /dev/null +++ b/include/drawinglayer/processor2d/baseprocessor2d.hxx @@ -0,0 +1,197 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_BASEPROCESSOR2D_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_BASEPROCESSOR2D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <drawinglayer/geometry/viewinformation2d.hxx> + + +namespace drawinglayer +{ + namespace processor2d + { + /** BaseProcessor2D class + + Base class for all C++ implementations of instances which process + primitives. + + Instances which process primitives can be renderers, but also stuff + for HitTests, BoundRect calculations and/or animation processing. The + main usage are renderers, but they are supposed to handle any primitive + processing. + + The base implementation is constructed with a ViewInformation2D which + is accessible throughout the processor implementations. The idea is + to construct any processor with a given ViewInformation2D. To be able + to handle primitives which need to change the current transformation + (as e.g. TransformPrimitive2D) it is allowed for the processor implementation + to change its local value using updateViewInformation. + + The basic processing method is process(..) which gets handed over the + sequence of primitives to process. For convenience of the C++ implementations, + the default implementation of process(..) maps all accesses to primitives to + single calls to processBasePrimitive2D(..) where the primitive in question is + already casted to the C++ implementation class. + + The process(..) implementation makes a complete iteration over the given + sequence of primitives. If the Primitive is not derived from BasePrimitive2D + and thus not part of the C++ implementations, it converts ViewInformation2D + to the corresponding API implementation (a uno::Sequence< beans::PropertyValue >) + and recursively calls the method process(..) at the primitive with the decomposition + derived from that primitive. This is the preparation to handle unknown implementations + of the css::graphic::XPrimitive2D interface in the future. + + So, to implement a basic processor, it is necessary to override and implement the + processBasePrimitive2D(..) method. A minimal renderer has to support the + Basic Primitives (see baseprimitive2d.hxx) and the Grouping Primitives (see + groupprimitive2d.hxx). These are (currently): + + Basic Primitives: + + - BitmapPrimitive2D (bitmap data, possibly with transparency) + - PointArrayPrimitive2D (single points) + - PolygonHairlinePrimitive2D (hairline curves/polygons) + - PolyPolygonColorPrimitive2D (colored polygons) + + Grouping Primitives: + + - TransparencePrimitive2D (objects with freely defined transparence) + - InvertPrimitive2D (for XOR) + - MaskPrimitive2D (for masking) + - ModifiedColorPrimitive2D (for a stack of color modifications) + - TransformPrimitive2D (for a transformation stack) + + A processor doing so is a minimal processor. Of course a processor may + handle any higher-level primitive (that has a decomposition implementation) + for more direct data access or performance reasons, too. + + The main part of a processBasePrimitive2D implementation is a switch..case + construct, looking like the following: + + void foo::processBasePrimitive2D(const BasePrimitive2D& rCandidate) + { + switch(rCandidate.getPrimitive2DID()) + { + case PRIMITIVE2D_ID_??? : + { + // process PRIMITIVE2D_ID_??? here... + + ... + + break; + } + + ... + + default : + { + // process recursively + process(rCandidate.get2DDecomposition(getViewInformation2D())); + break; + } + } + } + + The default case makes the processor work with all complex primitives + by recursively using their decomposition. + + You can also add a case for ignoring primitives by using: + + case PRIMITIVE2D_ID_...IGNORE.A.. : + case PRIMITIVE2D_ID_...IGNORE.B.. : + case PRIMITIVE2D_ID_...IGNORE.C.. : + { + // ignore these primitives by neither processing nor + // recursively processing their decomposition + break; + } + + Another useful case is embedding the processing of a complex primitive by + bracketing it with some actions: + + case PRIMITIVE2D_ID_SOME_TEXT : + { + // encapsulate e.g. with changing local variables, e.g. + // sometimes it's good to know if a basic primitive is + // part of a text, especially when not handling the text + // self but by purpose want to handle the decomposed + // geometries in the processor + startText(); + process(rCandidate.get2DDecomposition(getViewInformation2D())); + endText(); + break; + } + + As an example a processor collecting the outlines of a sequence of primitives + only needs to handle some Basic Primitives and create outline and collect + outline polygons e.g. for primitives with area like BitmapPrimitive2D (a + rectangle) and PolyPolygonColorPrimitive2D. When also handling the Grouping + Primitives MaskPrimitive2D (e.g. ignoring its content, using the mask polyPolygon) + and TransformPrimitive2D (to have the correct local transformation), a processor + creating the outline can be written using just four (4) primitives. As a tipp, it can + be helpful to add many for the purpose not interesting higher level primitives + to not force their decomposition to be created and/or parsed. + */ + class DRAWINGLAYER_DLLPUBLIC BaseProcessor2D + { + private: + /// The ViewInformation2D itself. It's private to isolate accesses to it + geometry::ViewInformation2D maViewInformation2D; + + protected: + /* access method to allow the implementations to change the current + ViewInformation2D if needed. This allows isolating these accesses + later if needed + */ + void updateViewInformation(const geometry::ViewInformation2D& rViewInformation2D) + { + maViewInformation2D = rViewInformation2D; + } + + /* as tooling, the process() implementation takes over API handling and calls this + virtual render method when the primitive implementation is BasePrimitive2D-based. + Default implementation does nothing + */ + virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); + + void process(const primitive2d::BasePrimitive2D& rCandidate); + + + public: + /// constructor/destructor + explicit BaseProcessor2D(const geometry::ViewInformation2D& rViewInformation); + virtual ~BaseProcessor2D(); + + /// the central processing method + void process(const primitive2d::Primitive2DContainer& rSource); + + /// data read access + const geometry::ViewInformation2D& getViewInformation2D() const { return maViewInformation2D; } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + + +#endif //INCLUDED_DRAWINGLAYER_PROCESSOR2D_BASEPROCESSOR2D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/processor2d/contourextractor2d.hxx b/include/drawinglayer/processor2d/contourextractor2d.hxx new file mode 100644 index 000000000..44c7e55eb --- /dev/null +++ b/include/drawinglayer/processor2d/contourextractor2d.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_CONTOUREXTRACTOR2D_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_CONTOUREXTRACTOR2D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/processor2d/baseprocessor2d.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> + + +namespace drawinglayer +{ + namespace processor2d + { + /** ContourExtractor2D class + + A processor who extracts the contour of the primitives fed to it + in the single local PolyPolygon + */ + class DRAWINGLAYER_DLLPUBLIC ContourExtractor2D final : public BaseProcessor2D + { + private: + /// the extracted contour + basegfx::B2DPolyPolygonVector maExtractedContour; + + bool mbExtractFillOnly : 1; + + /// tooling methods + void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override; + + public: + explicit ContourExtractor2D( + const geometry::ViewInformation2D& rViewInformation, + bool bExtractFillOnly); + + virtual ~ContourExtractor2D() override; + + const basegfx::B2DPolyPolygonVector& getExtractedContour() const { return maExtractedContour; } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + + +#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_CONTOUREXTRACTOR2D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/processor2d/hittestprocessor2d.hxx b/include/drawinglayer/processor2d/hittestprocessor2d.hxx new file mode 100644 index 000000000..3b044b451 --- /dev/null +++ b/include/drawinglayer/processor2d/hittestprocessor2d.hxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/processor2d/baseprocessor2d.hxx> + +namespace basegfx { class B2DPolygon; } +namespace basegfx { class B2DPolyPolygon; } +namespace drawinglayer::primitive2d { class ScenePrimitive2D; } + +namespace drawinglayer +{ + namespace processor2d + { + /** HitTestProcessor2D class + + This processor implements a HitTest with the fed primitives, + given tolerance and extras + */ + class DRAWINGLAYER_DLLPUBLIC HitTestProcessor2D final : public BaseProcessor2D + { + private: + /// discrete HitTest position + basegfx::B2DPoint maDiscreteHitPosition; + + /// discrete HitTolerance + double mfDiscreteHitTolerance; + + /// stack of HitPrimitives, taken care of during HitTest run + primitive2d::Primitive2DContainer maHitStack; + + /// flag if HitStack shall be collected as part of the result, default is false + bool mbCollectHitStack : 1; + + /// Boolean to flag if a hit was found. If yes, fast exit is taken + bool mbHit : 1; + + /// flag to concentrate on text hits only + bool mbHitTextOnly : 1; + + /// tooling methods + void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override; + bool checkHairlineHitWithTolerance( + const basegfx::B2DPolygon& rPolygon, + double fDiscreteHitTolerance) const; + bool checkFillHitWithTolerance( + const basegfx::B2DPolyPolygon& rPolyPolygon, + double fDiscreteHitTolerance) const; + void check3DHit(const primitive2d::ScenePrimitive2D& rCandidate); + + public: + HitTestProcessor2D( + const geometry::ViewInformation2D& rViewInformation, + const basegfx::B2DPoint& rLogicHitPosition, + double fLogicHitTolerance, + bool bHitTextOnly); + virtual ~HitTestProcessor2D() override; + + /// switch on collecting primitives for a found hit on maHitStack, default is off + void collectHitStack(bool bCollect) { mbCollectHitStack = bCollect; } + + /// get HitStack of primitives, first is the one that created the hit, last is the + /// top-most + const primitive2d::Primitive2DContainer& getHitStack() const { return maHitStack; } + + /// data read access + const basegfx::B2DPoint& getDiscreteHitPosition() const { return maDiscreteHitPosition; } + double getDiscreteHitTolerance() const { return mfDiscreteHitTolerance; } + bool getCollectHitStack() const { return mbCollectHitStack; } + bool getHit() const { return mbHit; } + bool getHitTextOnly() const { return mbHitTextOnly; } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + +#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/processor2d/linegeometryextractor2d.hxx b/include/drawinglayer/processor2d/linegeometryextractor2d.hxx new file mode 100644 index 000000000..4ea00c669 --- /dev/null +++ b/include/drawinglayer/processor2d/linegeometryextractor2d.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_LINEGEOMETRYEXTRACTOR2D_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_LINEGEOMETRYEXTRACTOR2D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/processor2d/baseprocessor2d.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> + + +namespace drawinglayer +{ + namespace processor2d + { + /** LineGeometryExtractor2D class + + This processor can extract the line geometry from fed primitives. The + hairlines and the fill geometry from fat lines are separated. + */ + class DRAWINGLAYER_DLLPUBLIC LineGeometryExtractor2D final : public BaseProcessor2D + { + private: + basegfx::B2DPolygonVector maExtractedHairlines; + basegfx::B2DPolyPolygonVector maExtractedLineFills; + + bool mbInLineGeometry : 1; + + /// tooling methods + void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override; + + public: + LineGeometryExtractor2D(const geometry::ViewInformation2D& rViewInformation); + virtual ~LineGeometryExtractor2D() override; + + const basegfx::B2DPolygonVector& getExtractedHairlines() const { return maExtractedHairlines; } + const basegfx::B2DPolyPolygonVector& getExtractedLineFills() const { return maExtractedLineFills; } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + + +#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_LINEGEOMETRYEXTRACTOR2D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/processor2d/objectinfoextractor2d.hxx b/include/drawinglayer/processor2d/objectinfoextractor2d.hxx new file mode 100644 index 000000000..59d8fc2b1 --- /dev/null +++ b/include/drawinglayer/processor2d/objectinfoextractor2d.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_OBJECTINFOEXTRACTOR2D_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_OBJECTINFOEXTRACTOR2D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> +#include <drawinglayer/processor2d/baseprocessor2d.hxx> + +namespace drawinglayer::primitive2d { class ObjectInfoPrimitive2D; } + +namespace drawinglayer +{ + namespace processor2d + { + /** ObjectInfoPrimitiveExtractor2D class + + A processor to find the first incarnation of ObjectInfoPrimitive2D + in a given hierarchy + */ + class DRAWINGLAYER_DLLPUBLIC ObjectInfoPrimitiveExtractor2D final : public BaseProcessor2D + { + private: + /// the target + const primitive2d::ObjectInfoPrimitive2D* mpFound; + + /// tooling methods + void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override; + + public: + ObjectInfoPrimitiveExtractor2D(const geometry::ViewInformation2D& rViewInformation); + virtual ~ObjectInfoPrimitiveExtractor2D() override; + + const primitive2d::ObjectInfoPrimitive2D* getResult() const { return mpFound; } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + +#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_OBJECTINFOEXTRACTOR2D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/processor2d/processor2dtools.hxx b/include/drawinglayer/processor2d/processor2dtools.hxx new file mode 100644 index 000000000..95c1c6793 --- /dev/null +++ b/include/drawinglayer/processor2d/processor2dtools.hxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_PROCESSOR2DTOOLS_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_PROCESSOR2DTOOLS_HXX + +#include <drawinglayer/drawinglayerdllapi.h> +#include <memory> + +namespace drawinglayer::geometry { class ViewInformation2D; } +namespace drawinglayer::processor2d { class BaseProcessor2D; } + +class OutputDevice; + +namespace drawinglayer +{ + namespace processor2d + { + /** create the best available pixel based BaseProcessor2D + (which may be system-dependent) + + @param rTargetOutDev + The target OutputDevice + + @param rViewInformation2D + The ViewInformation to use + + @return + the created BaseProcessor2D (ownership change) or null if + something went wrong + */ + DRAWINGLAYER_DLLPUBLIC std::unique_ptr<BaseProcessor2D> createPixelProcessor2DFromOutputDevice( + OutputDevice& rTargetOutDev, + const drawinglayer::geometry::ViewInformation2D& rViewInformation2D); + + /** create a BaseProcessor2D dependent on some states of the + given OutputDevice. If metafile is recorded, the needed + VclMetafileProcessor2D will be created. If a pixel renderer + is requested, the best one is incarnated + + @param rTargetOutDev + The target OutputDevice + + @param rViewInformation2D + The ViewInformation to use + + @return + the created BaseProcessor2D (ownership change) or null if + something went wrong + */ + DRAWINGLAYER_DLLPUBLIC std::unique_ptr<BaseProcessor2D> createProcessor2DFromOutputDevice( + OutputDevice& rTargetOutDev, + const drawinglayer::geometry::ViewInformation2D& rViewInformation2D); + + } // end of namespace processor2d +} // end of namespace drawinglayer + +#endif //INCLUDED_DRAWINGLAYER_PROCESSOR2D_PROCESSOR2DTOOLS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/processor2d/processorfromoutputdevice.hxx b/include/drawinglayer/processor2d/processorfromoutputdevice.hxx new file mode 100644 index 000000000..f15a98e34 --- /dev/null +++ b/include/drawinglayer/processor2d/processorfromoutputdevice.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_PROCESSORFROMOUTPUTDEVICE_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_PROCESSORFROMOUTPUTDEVICE_HXX + +#include <drawinglayer/drawinglayerdllapi.h> +#include <memory> + +class OutputDevice; + +namespace drawinglayer::processor2d { + class BaseProcessor2D; +} + +namespace drawinglayer::geometry { class ViewInformation2D; } + +namespace drawinglayer +{ + namespace processor2d + { + // create a mating VCL-Processor for given OutputDevice. This includes + // looking for MetaFile-recording. The returned renderer changes owner, + // deletion is duty of the caller + DRAWINGLAYER_DLLPUBLIC std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> createBaseProcessor2DFromOutputDevice( + OutputDevice& rTargetOutDev, + const drawinglayer::geometry::ViewInformation2D& rViewInformation2D); + + } // end of namespace processor2d +} // end of namespace drawinglayer + +#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_PROCESSORFROMOUTPUTDEVICE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/processor2d/textaspolygonextractor2d.hxx b/include/drawinglayer/processor2d/textaspolygonextractor2d.hxx new file mode 100644 index 000000000..e973a372a --- /dev/null +++ b/include/drawinglayer/processor2d/textaspolygonextractor2d.hxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_TEXTASPOLYGONEXTRACTOR2D_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_TEXTASPOLYGONEXTRACTOR2D_HXX + +#include <drawinglayer/drawinglayerdllapi.h> + +#include <drawinglayer/processor2d/baseprocessor2d.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/color/bcolor.hxx> +#include <basegfx/color/bcolormodifier.hxx> +#include <vector> + + +namespace drawinglayer +{ + namespace processor2d + { + /// helper data structure for returning the result + struct DRAWINGLAYER_DLLPUBLIC TextAsPolygonDataNode + { + private: + basegfx::B2DPolyPolygon maB2DPolyPolygon; + basegfx::BColor maBColor; + bool mbIsFilled; + + public: + TextAsPolygonDataNode( + const basegfx::B2DPolyPolygon& rB2DPolyPolygon, + const basegfx::BColor& rBColor, + bool bIsFilled) + : maB2DPolyPolygon(rB2DPolyPolygon), + maBColor(rBColor), + mbIsFilled(bIsFilled) + { + } + + // data read access + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maB2DPolyPolygon; } + const basegfx::BColor& getBColor() const { return maBColor; } + bool getIsFilled() const { return mbIsFilled; } + }; + + /// typedef for a vector of that helper data + typedef ::std::vector< TextAsPolygonDataNode > TextAsPolygonDataNodeVector; + + /** TextAsPolygonExtractor2D class + + This processor extracts text in the fed primitives to filled polygons + */ + class DRAWINGLAYER_DLLPUBLIC TextAsPolygonExtractor2D final : public BaseProcessor2D + { + private: + // extraction target + TextAsPolygonDataNodeVector maTarget; + + // the modifiedColorPrimitive stack + basegfx::BColorModifierStack maBColorModifierStack; + + // flag if we are in a decomposed text + sal_uInt32 mnInText; + + // tooling methods + void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) override; + + public: + explicit TextAsPolygonExtractor2D(const geometry::ViewInformation2D& rViewInformation); + virtual ~TextAsPolygonExtractor2D() override; + + // data read access + const TextAsPolygonDataNodeVector& getTarget() const { return maTarget; } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + + +#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_TEXTASPOLYGONEXTRACTOR2D_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |