diff options
Diffstat (limited to 'drawinglayer/inc/drawinglayer/processor2d')
9 files changed, 1098 insertions, 0 deletions
diff --git a/drawinglayer/inc/drawinglayer/processor2d/baseprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/baseprocessor2d.hxx new file mode 100644 index 000000000000..d93fb68c932c --- /dev/null +++ b/drawinglayer/inc/drawinglayer/processor2d/baseprocessor2d.hxx @@ -0,0 +1,240 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_BASEPROCESSOR2D_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_BASEPROCESSOR2D_HXX + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <drawinglayer/geometry/viewinformation2d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace processor2d + { + /** BaseProcessor2D class + + Baseclass 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 tis 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 (an 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 com::sun::star::graphic::XPrimitive2D interface in the future. + + So, to implement a basic processor, it is necessary to overload 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, evtl. with transparence) + - 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 prmitive (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 varibles, 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 it's 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 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); + + public: + /// constructor/destructor + BaseProcessor2D(const geometry::ViewInformation2D& rViewInformation); + virtual ~BaseProcessor2D(); + + /// the central processing method + virtual void process(const primitive2d::Primitive2DSequence& rSource); + + /// data read access + const geometry::ViewInformation2D& getViewInformation2D() const { return maViewInformation2D; } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace processor2d + { + /** CollectingProcessor2D class + + A processor which just collects all primitives given to it in + process(..) calls to maPrimitive2DSequence. This can e.g. be used to + hand around as instance over various methods where every called + method can add graphic content to it. + */ + class CollectingProcessor2D : public BaseProcessor2D + { + private: + primitive2d::Primitive2DSequence maPrimitive2DSequence; + + public: + CollectingProcessor2D(const geometry::ViewInformation2D& rViewInformation); + virtual ~CollectingProcessor2D(); + + /// the central processing method + virtual void process(const primitive2d::Primitive2DSequence& rSource); + + /// helpers for adding to local sequence + void appendPrimitive2DReference(const primitive2d::Primitive2DReference& rSource) + { + primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(maPrimitive2DSequence, rSource); + } + + /// data access and reset + const primitive2d::Primitive2DSequence& getPrimitive2DSequence() const { return maPrimitive2DSequence; } + void reset() { maPrimitive2DSequence = primitive2d::Primitive2DSequence(); } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PROCESSOR2D_BASEPROCESSOR2D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx b/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx new file mode 100644 index 000000000000..72ff97076a6c --- /dev/null +++ b/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DRAWINGLAYER_PROCESSOR_CANVASPROCESSOR_HXX +#define _DRAWINGLAYER_PROCESSOR_CANVASPROCESSOR_HXX + +#include <drawinglayer/processor2d/baseprocessor2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/color/bcolormodifier.hxx> +#include <svtools/optionsdrawinglayer.hxx> +#include <com/sun/star/rendering/ViewState.hpp> +#include <com/sun/star/rendering/RenderState.hpp> +#include <i18npool/lang.h> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <vcl/mapmod.hxx> + +////////////////////////////////////////////////////////////////////////////// +// forward declaration + +namespace basegfx { + class BColor; + class B2DPolygon; +} + +namespace com { namespace sun { namespace star { namespace rendering { + class XCanvas; + class XPolyPolygon2D; +}}}} + +namespace drawinglayer { namespace primitive2d { + class MaskPrimitive2D; + class MetafilePrimitive2D; + class TextSimplePortionPrimitive2D; + class BitmapPrimitive2D; + class TransparencePrimitive2D; + class PolygonStrokePrimitive2D; + class FillBitmapPrimitive2D; + class UnifiedTransparencePrimitive2D; +}} + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace processor2d + { + /** canvasProcessor2D class + + A basic implementation of a renderer for com::sun::star::rendering::XCanvas + as a target + */ + class canvasProcessor2D : public BaseProcessor2D + { + private: + // The Pixel renderer resets the original MapMode from the OutputDevice. + // For some situations it is necessary to get it again, so it is rescued here + MapMode maOriginalMapMode; + + // the (current) destination OutDev and canvas + OutputDevice* mpOutputDevice; + com::sun::star::uno::Reference< com::sun::star::rendering::XCanvas > mxCanvas; + com::sun::star::rendering::ViewState maViewState; + com::sun::star::rendering::RenderState maRenderState; + + // the modifiedColorPrimitive stack + basegfx::BColorModifierStack maBColorModifierStack; + + // SvtOptionsDrawinglayer incarnation to react on diverse settings + const SvtOptionsDrawinglayer maDrawinglayerOpt; + + // the current clipping PolyPolygon from MaskPrimitive2D, always in + // object coordinates + basegfx::B2DPolyPolygon maClipPolyPolygon; + + // determined LanguageType + LanguageType meLang; + + // as tooling, the process() implementation takes over API handling and calls this + // virtual render method when the primitive implementation is BasePrimitive2D-based. + virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); + + // direct primitive renderer support + void impRenderMaskPrimitive2D(const primitive2d::MaskPrimitive2D& rMaskCandidate); + void impRenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rMetaCandidate); + void impRenderTextSimplePortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate); + void impRenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate); + void impRenderTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransparenceCandidate); + void impRenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokePrimitive); + void impRenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapPrimitive2D); + void impRenderUnifiedTransparencePrimitive2D(const primitive2d::UnifiedTransparencePrimitive2D& rUniTransparenceCandidate); + + public: + canvasProcessor2D( + const geometry::ViewInformation2D& rViewInformation, + OutputDevice& rOutDev); + virtual ~canvasProcessor2D(); + + // access to Drawinglayer configuration options + const SvtOptionsDrawinglayer& getOptionsDrawinglayer() const { return maDrawinglayerOpt; } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //_DRAWINGLAYER_PROCESSOR_CANVASPROCESSOR_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/processor2d/contourextractor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/contourextractor2d.hxx new file mode 100644 index 000000000000..9ec44d324187 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/processor2d/contourextractor2d.hxx @@ -0,0 +1,68 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_CONTOUREXTRACTOR2D_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_CONTOUREXTRACTOR2D_HXX + +#include <drawinglayer/processor2d/baseprocessor2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace processor2d + { + /** ContourExtractor2D class + + A processor who extracts the contour of the primtives feeded to it + in the single local PolyPolygon + */ + class ContourExtractor2D : public BaseProcessor2D + { + private: + /// the extracted contour + std::vector< basegfx::B2DPolyPolygon > maExtractedContour; + + /// tooling methods + void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); + + public: + ContourExtractor2D(const geometry::ViewInformation2D& rViewInformation); + virtual ~ContourExtractor2D(); + + const std::vector< basegfx::B2DPolyPolygon >& getExtractedContour() const { return maExtractedContour; } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_CONTOUREXTRACTOR2D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/processor2d/hittestprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/hittestprocessor2d.hxx new file mode 100644 index 000000000000..be0b40ff2139 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/processor2d/hittestprocessor2d.hxx @@ -0,0 +1,114 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX + +#include <drawinglayer/processor2d/baseprocessor2d.hxx> + +////////////////////////////////////////////////////////////////////////////// +// predeclarations + +namespace basegfx { class B2DPolygon; } +namespace basegfx { class B2DPolyPolygon; } +namespace drawinglayer { namespace primitive2d { class ScenePrimitive2D; }} + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace processor2d + { + /** HitTestProcessor2D class + + This processor implements a HitTest with the feeded primitives, + given tolerance and extras + */ + class HitTestProcessor2D : public BaseProcessor2D + { + private: + /// discrete HitTest position + basegfx::B2DPoint maDiscreteHitPosition; + + /// discrete HitTolerance + double mfDiscreteHitTolerance; + + /// bitfield + unsigned mbHit : 1; + unsigned mbHitToleranceUsed : 1; + + /* this flag decides if primitives which are embedded to an + UnifiedTransparencePrimitive2D and are invisible will be taken into account for + HitTesting or not. Those primitives are created for objects which are else + completely invisible and normally their content exists of hairline + primitives describing the object's contour + */ + unsigned mbUseInvisiblePrimitiveContent : 1; + + /// flag to concentraze on text hits only + unsigned mbHitTextOnly : 1; + + /// tooling methods + void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); + bool checkHairlineHitWithTolerance( + const basegfx::B2DPolygon& rPolygon, + double fDiscreteHitTolerance); + bool checkFillHitWithTolerance( + const basegfx::B2DPolyPolygon& rPolyPolygon, + double fDiscreteHitTolerance); + void check3DHit(const primitive2d::ScenePrimitive2D& rCandidate); + + public: + HitTestProcessor2D( + const geometry::ViewInformation2D& rViewInformation, + const basegfx::B2DPoint& rLogicHitPosition, + double fLogicHitTolerance, + bool bHitTextOnly); + virtual ~HitTestProcessor2D(); + + /// data write access + void setUseInvisiblePrimitiveContent(bool bNew) + { + if((bool)mbUseInvisiblePrimitiveContent != bNew) mbUseInvisiblePrimitiveContent = bNew; + } + + /// data read access + const basegfx::B2DPoint& getDiscreteHitPosition() const { return maDiscreteHitPosition; } + double getDiscreteHitTolerance() const { return mfDiscreteHitTolerance; } + bool getHit() const { return mbHit; } + bool getHitToleranceUsed() const { return mbHitToleranceUsed; } + bool getUseInvisiblePrimitiveContent() const { return mbUseInvisiblePrimitiveContent;} + bool getHitTextOnly() const { return mbHitTextOnly; } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_HITTESTPROCESSOR2D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/processor2d/linegeometryextractor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/linegeometryextractor2d.hxx new file mode 100644 index 000000000000..9ea9313c8743 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/processor2d/linegeometryextractor2d.hxx @@ -0,0 +1,71 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_LINEGEOMETRYEXTRACTOR2D_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_LINEGEOMETRYEXTRACTOR2D_HXX + +#include <drawinglayer/processor2d/baseprocessor2d.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace processor2d + { + /** LineGeometryExtractor2D class + + This processor can extract the line geometry from feeded primpitives. The + hairlines and the fille geometry from fat lines are separated. + */ + class LineGeometryExtractor2D : public BaseProcessor2D + { + private: + std::vector< basegfx::B2DPolygon > maExtractedHairlines; + std::vector< basegfx::B2DPolyPolygon > maExtractedLineFills; + + /// bitfield + unsigned mbInLineGeometry : 1; + + /// tooling methods + void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); + + public: + LineGeometryExtractor2D(const geometry::ViewInformation2D& rViewInformation); + virtual ~LineGeometryExtractor2D(); + + const std::vector< basegfx::B2DPolygon >& getExtractedHairlines() const { return maExtractedHairlines; } + const std::vector< basegfx::B2DPolyPolygon >& getExtractedLineFills() const { return maExtractedLineFills; } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_LINEGEOMETRYEXTRACTOR2D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/processor2d/textaspolygonextractor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/textaspolygonextractor2d.hxx new file mode 100644 index 000000000000..2fa0bc47862c --- /dev/null +++ b/drawinglayer/inc/drawinglayer/processor2d/textaspolygonextractor2d.hxx @@ -0,0 +1,104 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_TEXTASPOLYGONEXTRACTOR2D_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_TEXTASPOLYGONEXTRACTOR2D_HXX + +#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 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 feeded primitives to filled polygons + */ + class TextAsPolygonExtractor2D : 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); + + public: + TextAsPolygonExtractor2D(const geometry::ViewInformation2D& rViewInformation); + virtual ~TextAsPolygonExtractor2D(); + + // data read access + const TextAsPolygonDataNodeVector& getTarget() const { return maTarget; } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_TEXTASPOLYGONEXTRACTOR2D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclmetafileprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclmetafileprocessor2d.hxx new file mode 100644 index 000000000000..db5a70e9b4d7 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/processor2d/vclmetafileprocessor2d.hxx @@ -0,0 +1,154 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_VCLMETAFILEPROCESSOR2D_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_VCLMETAFILEPROCESSOR2D_HXX + +#include <drawinglayer/processor2d/vclprocessor2d.hxx> +#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <basegfx/polygon/b2dpolypolygon.hxx> + +////////////////////////////////////////////////////////////////////////////// +// vcl::PDFExtOutDevData support + +#include <vcl/pdfextoutdevdata.hxx> + +////////////////////////////////////////////////////////////////////////////// +// predefines + +class GDIMetaFile; +class Rectangle; +class Gradient; +class SvtGraphicFill; +class SvtGraphicStroke; + +namespace drawinglayer { namespace attribute { + class FillGradientAttribute; + class LineAttribute; + class StrokeAttribute; + class LineStartEndAttribute; +}} + +namespace basegfx { + class BColor; +} + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace processor2d + { + /** VclMetafileProcessor2D class + + This processor derived from VclProcessor2D is the base class for rendering + all feeded primitives to a classical VCL-Metafile, including all over the + time grown extra data in comments and PDF exception data creations. Also + printing needs some exception stuff. + + All in all it is needed to emulate the old ::paint output from the old + Drawinglayer as long as exporters and/or filters still use the Metafile + and the extra-data added to it (which can be seen mostly as 'extensions' + or simply as 'hacks'). + */ + class VclMetafileProcessor2D : public VclProcessor2D + { + private: + /// local helper(s) + Rectangle impDumpToMetaFile( + const primitive2d::Primitive2DSequence& rContent, + GDIMetaFile& o_rContentMetafile); + void impConvertFillGradientAttributeToVCLGradient( + Gradient& o_rVCLGradient, + const attribute::FillGradientAttribute& rFiGrAtt, + bool bIsTransparenceGradient); + void impStartSvtGraphicFill(SvtGraphicFill* pSvtGraphicFill); + void impEndSvtGraphicFill(SvtGraphicFill* pSvtGraphicFill); + SvtGraphicStroke* impTryToCreateSvtGraphicStroke( + const basegfx::B2DPolygon& rB2DPolygon, + const basegfx::BColor* pColor, + const attribute::LineAttribute* pLineAttribute, + const attribute::StrokeAttribute* pStrokeAttribute, + const attribute::LineStartEndAttribute* pStart, + const attribute::LineStartEndAttribute* pEnd); + void impStartSvtGraphicStroke(SvtGraphicStroke* pSvtGraphicStroke); + void impEndSvtGraphicStroke(SvtGraphicStroke* pSvtGraphicStroke); + + /// the current clipping PolyPolygon from MaskPrimitive2D + basegfx::B2DPolyPolygon maClipPolyPolygon; + + /// the target MetaFile + GDIMetaFile* mpMetaFile; + + /* do not allow embedding SvtGraphicFills into each other, + use a counter to prevent that + */ + sal_uInt32 mnSvtGraphicFillCount; + + /// same for SvtGraphicStroke + sal_uInt32 mnSvtGraphicStrokeCount; + + /* hold the last unified transparence value to have it handy + on SvtGraphicStroke creation + */ + double mfCurrentUnifiedTransparence; + + /* break iterator support + made static so it only needs to be fetched once, even with many single + constructed VclMetafileProcessor2D. It's still incarnated on demand, + but exists for OOo runtime now by purpose. + */ + static ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > mxBreakIterator; + + /* vcl::PDFExtOutDevData support + For the first step, some extra actions at vcl::PDFExtOutDevData need to + be emulated with the VclMetafileProcessor2D. These are potentially temporarily + since PDF export may use PrimitiveSequences one day directly. + */ + vcl::PDFExtOutDevData* mpPDFExtOutDevData; + + protected: + /* the local processor for BasePrinitive2D-Implementation based primitives, + called from the common process()-implementation + */ + virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); + + public: + /// constructor/destructor + VclMetafileProcessor2D( + const geometry::ViewInformation2D& rViewInformation, + OutputDevice& rOutDev); + virtual ~VclMetafileProcessor2D(); + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_VCLMETAFILEPROCESSOR2D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclpixelprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclpixelprocessor2d.hxx new file mode 100644 index 000000000000..a237f5d289d7 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/processor2d/vclpixelprocessor2d.hxx @@ -0,0 +1,77 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_VCLPIXELPROCESSOR2D_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_VCLPIXELPROCESSOR2D_HXX + +#include <drawinglayer/processor2d/vclprocessor2d.hxx> +#include <vcl/outdev.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace processor2d + { + /** VclPixelProcessor2D class + + This processor derived from VclProcessor2D is the base class for rendering + all feeded primitives to a VCL Window. It is the currently used renderer + for all VCL editing output from the DrawingLayer. + */ + class VclPixelProcessor2D : public VclProcessor2D + { + private: + /* The Pixel renderer resets the original MapMode from the OutputDevice. + For some situations it is necessary to get it again, so it is rescued here + */ + MapMode maOriginalMapMode; + + protected: + /* the local processor for BasePrinitive2D-Implementation based primitives, + called from the common process()-implementation + */ + virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); + + public: + /// constructor/destructor + VclPixelProcessor2D( + const geometry::ViewInformation2D& rViewInformation, + OutputDevice& rOutDev); + virtual ~VclPixelProcessor2D(); + + /// data read access + const MapMode& getOriginalMapMode() const { return maOriginalMapMode; } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_VCLPIXELPROCESSOR2D_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx new file mode 100644 index 000000000000..9db84f3e7e0c --- /dev/null +++ b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_VCLPROCESSOR2D_HXX +#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_VCLPROCESSOR2D_HXX + +#include <drawinglayer/processor2d/baseprocessor2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/color/bcolormodifier.hxx> +#include <svtools/optionsdrawinglayer.hxx> + +////////////////////////////////////////////////////////////////////////////// +// predefines +class OutputDevice; + +namespace drawinglayer { namespace primitive2d { + class TextSimplePortionPrimitive2D; + class PolygonHairlinePrimitive2D; + class BitmapPrimitive2D; + class FillBitmapPrimitive2D; + class PolyPolygonGradientPrimitive2D; + class PolyPolygonBitmapPrimitive2D; + class PolyPolygonColorPrimitive2D; + class MetafilePrimitive2D; + class MaskPrimitive2D; + class UnifiedTransparencePrimitive2D; + class TransparencePrimitive2D; + class TransformPrimitive2D; + class MarkerArrayPrimitive2D; + class PointArrayPrimitive2D; + class ModifiedColorPrimitive2D; + class PolygonStrokePrimitive2D; + class ControlPrimitive2D; + class PagePreviewPrimitive2D; + class EpsPrimitive2D; +}} + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace processor2d + { + /** VclProcessor2D class + + This processor is the base class for VCL-Based processors. It has no + processBasePrimitive2D implementation and thus is not usable directly. + */ + class VclProcessor2D : public BaseProcessor2D + { + protected: + // the destination OutDev + OutputDevice* mpOutputDevice; + + // the modifiedColorPrimitive stack + basegfx::BColorModifierStack maBColorModifierStack; + + // the current transformation. Since VCL pixel renderer transforms to pixels + // and VCL MetaFile renderer to World (logic) coordinates, the local + // ViewInformation2D cannot directly be used, but needs to be kept up to date + basegfx::B2DHomMatrix maCurrentTransformation; + + // SvtOptionsDrawinglayer incarnation to react on diverse settings + const SvtOptionsDrawinglayer maDrawinglayerOpt; + + // stack value (increment and decrement) to count how deep we are in + // PolygonStrokePrimitive2D's decompositions (normally only one) + sal_uInt32 mnPolygonStrokePrimitive2D; + + ////////////////////////////////////////////////////////////////////////////// + // common VCL rendering support + + void RenderTextSimpleOrDecoratedPortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate); + void RenderPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate, bool bPixelBased); + void RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate); + void RenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapCandidate); + void RenderPolyPolygonGradientPrimitive2D(const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate); + void RenderPolyPolygonBitmapPrimitive2D(const primitive2d::PolyPolygonBitmapPrimitive2D& rPolygonCandidate); + void RenderPolyPolygonColorPrimitive2D(const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate); + void RenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rPolygonCandidate); + void RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate); + void RenderModifiedColorPrimitive2D(const primitive2d::ModifiedColorPrimitive2D& rModifiedCandidate); + void RenderUnifiedTransparencePrimitive2D(const primitive2d::UnifiedTransparencePrimitive2D& rTransCandidate); + void RenderTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransCandidate); + void RenderTransformPrimitive2D(const primitive2d::TransformPrimitive2D& rTransformCandidate); + void RenderPagePreviewPrimitive2D(const primitive2d::PagePreviewPrimitive2D& rPagePreviewCandidate); + void RenderMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkerArrayCandidate); + void RenderPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate); + void RenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate); + void RenderEpsPrimitive2D(const primitive2d::EpsPrimitive2D& rEpsPrimitive2D); + + ///////////////////////////////////////////////////////////////////////////// + // DrawMode adaption support + void adaptLineToFillDrawMode() const; + void adaptTextToFillDrawMode() const; + + public: + // constructor/destructor + VclProcessor2D( + const geometry::ViewInformation2D& rViewInformation, + OutputDevice& rOutDev); + virtual ~VclProcessor2D(); + + // access to Drawinglayer configuration options + const SvtOptionsDrawinglayer& getOptionsDrawinglayer() const { return maDrawinglayerOpt; } + }; + } // end of namespace processor2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_VCLPROCESSOR2D_HXX + +// eof |