diff options
author | Armin Le Grand <Armin.Le.Grand@Sun.COM> | 2010-01-27 11:51:56 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@Sun.COM> | 2010-01-27 11:51:56 +0100 |
commit | ffe5c97056ab181367e49691d487eb6f6f375200 (patch) | |
tree | 552e2d32015f11e023004a4104e15cce886312e0 /drawinglayer/inc/drawinglayer/processor2d | |
parent | de7c998fe9ba5be956bf8a155455ad17985c4f88 (diff) |
aw079: #i99147# attribute rework and others
Diffstat (limited to 'drawinglayer/inc/drawinglayer/processor2d')
9 files changed, 283 insertions, 62 deletions
diff --git a/drawinglayer/inc/drawinglayer/processor2d/baseprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/baseprocessor2d.hxx index fceae8dbeb31..58b5601f6242 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/baseprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/baseprocessor2d.hxx @@ -45,30 +45,159 @@ 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 + /* 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 + /// the central processing method virtual void process(const primitive2d::Primitive2DSequence& rSource); - // data access + /// data read access const geometry::ViewInformation2D& getViewInformation2D() const { return maViewInformation2D; } }; } // end of namespace processor2d @@ -76,6 +205,44 @@ 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 index 0c356e731169..13f1d540c239 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/canvasprocessor.hxx @@ -64,10 +64,10 @@ namespace drawinglayer { namespace primitive2d { class MetafilePrimitive2D; class TextSimplePortionPrimitive2D; class BitmapPrimitive2D; - class AlphaPrimitive2D; + class TransparencePrimitive2D; class PolygonStrokePrimitive2D; class FillBitmapPrimitive2D; - class UnifiedAlphaPrimitive2D; + class UnifiedTransparencePrimitive2D; }} ////////////////////////////////////////////////////////////////////////////// @@ -76,6 +76,11 @@ 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: @@ -111,10 +116,10 @@ namespace drawinglayer void impRenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rMetaCandidate); void impRenderTextSimplePortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate); void impRenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate); - void impRenderAlphaPrimitive2D(const primitive2d::AlphaPrimitive2D& rAlphaCandidate); + void impRenderTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransparenceCandidate); void impRenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokePrimitive); void impRenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapPrimitive2D); - void impRenderUnifiedAlphaPrimitive2D(const primitive2d::UnifiedAlphaPrimitive2D& rUniAlphaCandidate); + void impRenderUnifiedTransparencePrimitive2D(const primitive2d::UnifiedTransparencePrimitive2D& rUniTransparenceCandidate); public: canvasProcessor2D( diff --git a/drawinglayer/inc/drawinglayer/processor2d/contourextractor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/contourextractor2d.hxx index dbe85fab07c5..9d4dd48f8dff 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/contourextractor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/contourextractor2d.hxx @@ -46,13 +46,18 @@ 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 + /// the extracted contour std::vector< basegfx::B2DPolyPolygon > maExtractedContour; - // tooling methods + /// tooling methods void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); public: diff --git a/drawinglayer/inc/drawinglayer/processor2d/hittestprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/hittestprocessor2d.hxx index c0ab33052883..640ec11260c3 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/hittestprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/hittestprocessor2d.hxx @@ -51,29 +51,36 @@ 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 + /// discrete HitTest position basegfx::B2DPoint maDiscreteHitPosition; - // discrete HitTolerance + /// discrete HitTolerance double mfDiscreteHitTolerance; - // bitfield + /// bitfield unsigned mbHit : 1; unsigned mbHitToleranceUsed : 1; - // this flag decides if primitives of type HitTestPrimitive2D - // 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 mbUseHitTestPrimitiveContent : 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 + /// flag to concentraze on text hits only unsigned mbHitTextOnly : 1; - // tooling methods + /// tooling methods void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); bool checkHairlineHitWithTolerance( const basegfx::B2DPolygon& rPolygon, @@ -91,18 +98,18 @@ namespace drawinglayer bool bHitTextOnly); virtual ~HitTestProcessor2D(); - // data write access - void setUseHitTestPrimitiveContent(bool bNew) + /// data write access + void setUseInvisiblePrimitiveContent(bool bNew) { - if((bool)mbUseHitTestPrimitiveContent != bNew) mbUseHitTestPrimitiveContent = bNew; + if((bool)mbUseInvisiblePrimitiveContent != bNew) mbUseInvisiblePrimitiveContent = bNew; } - // data read access + /// 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 getUseHitTestPrimitiveContent() const { return mbUseHitTestPrimitiveContent;} + bool getUseInvisiblePrimitiveContent() const { return mbUseInvisiblePrimitiveContent;} bool getHitTextOnly() const { return mbHitTextOnly; } }; } // end of namespace processor2d diff --git a/drawinglayer/inc/drawinglayer/processor2d/linegeometryextractor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/linegeometryextractor2d.hxx index b2697abece66..8162bb0934f4 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/linegeometryextractor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/linegeometryextractor2d.hxx @@ -45,16 +45,21 @@ 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 + /// bitfield unsigned mbInLineGeometry : 1; - // tooling methods + /// tooling methods void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); public: diff --git a/drawinglayer/inc/drawinglayer/processor2d/textaspolygonextractor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/textaspolygonextractor2d.hxx index 88d9416b612a..77fa9432539d 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/textaspolygonextractor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/textaspolygonextractor2d.hxx @@ -48,7 +48,7 @@ namespace drawinglayer { namespace processor2d { - // helper data structure for returning the result + /// helper data structure for returning the result struct TextAsPolygonDataNode { private: @@ -73,9 +73,13 @@ namespace drawinglayer bool getIsFilled() const { return mbIsFilled; } }; - // typedef for a vector of that helper data + /// 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: diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclmetafileprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclmetafileprocessor2d.hxx index 38e7e5143b8a..66af45a7c6ce 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/vclmetafileprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/vclmetafileprocessor2d.hxx @@ -47,6 +47,7 @@ ////////////////////////////////////////////////////////////////////////////// // predefines + class GDIMetaFile; class Rectangle; class Gradient; @@ -70,10 +71,22 @@ 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) + /// local helper(s) Rectangle impDumpToMetaFile( const primitive2d::Primitive2DSequence& rContent, GDIMetaFile& o_rContentMetafile); @@ -93,42 +106,47 @@ namespace drawinglayer void impStartSvtGraphicStroke(SvtGraphicStroke* pSvtGraphicStroke); void impEndSvtGraphicStroke(SvtGraphicStroke* pSvtGraphicStroke); - // the current clipping PolyPolygon from MaskPrimitive2D + /// the current clipping PolyPolygon from MaskPrimitive2D basegfx::B2DPolyPolygon maClipPolyPolygon; - // the target MetaFile + /// the target MetaFile GDIMetaFile* mpMetaFile; - // do not allow embedding SvtGraphicFills into each other, - // use a counter to prevent that + /* do not allow embedding SvtGraphicFills into each other, + use a counter to prevent that + */ sal_uInt32 mnSvtGraphicFillCount; - // same for SvtGraphicStroke + /// same for SvtGraphicStroke sal_uInt32 mnSvtGraphicStrokeCount; - // hold the last unified transparence value to have it handy - // on SvtGraphicStroke creation + /* 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. + /* 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 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 + /* the local processor for BasePrinitive2D-Implementation based primitives, + called from the common process()-implementation + */ virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); public: - // constructor/destructor + /// constructor/destructor VclMetafileProcessor2D( const geometry::ViewInformation2D& rViewInformation, OutputDevice& rOutDev); diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclpixelprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclpixelprocessor2d.hxx index 836a097ae4d9..0d277325129b 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/vclpixelprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/vclpixelprocessor2d.hxx @@ -40,34 +40,39 @@ #include <vcl/outdev.hxx> ////////////////////////////////////////////////////////////////////////////// -// predefines - -////////////////////////////////////////////////////////////////////////////// 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 + /* 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 + /* the local processor for BasePrinitive2D-Implementation based primitives, + called from the common process()-implementation + */ virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate); public: - // constructor/destructor + /// constructor/destructor VclPixelProcessor2D( const geometry::ViewInformation2D& rViewInformation, OutputDevice& rOutDev); virtual ~VclPixelProcessor2D(); - // data access + /// data read access const MapMode& getOriginalMapMode() const { return maOriginalMapMode; } }; } // end of namespace processor2d diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx index ff77cc3fd5d0..0cef3da7a8ee 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx @@ -55,8 +55,8 @@ namespace drawinglayer { namespace primitive2d { class PolyPolygonColorPrimitive2D; class MetafilePrimitive2D; class MaskPrimitive2D; - class UnifiedAlphaPrimitive2D; - class AlphaPrimitive2D; + class UnifiedTransparencePrimitive2D; + class TransparencePrimitive2D; class TransformPrimitive2D; class MarkerArrayPrimitive2D; class PointArrayPrimitive2D; @@ -73,6 +73,11 @@ 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: @@ -107,8 +112,8 @@ namespace drawinglayer void RenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rPolygonCandidate); void RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate); void RenderModifiedColorPrimitive2D(const primitive2d::ModifiedColorPrimitive2D& rModifiedCandidate); - void RenderUnifiedAlphaPrimitive2D(const primitive2d::UnifiedAlphaPrimitive2D& rTransCandidate); - void RenderAlphaPrimitive2D(const primitive2d::AlphaPrimitive2D& rTransCandidate); + 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); |