1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_VCLMETAFILEPROCESSOR2D_HXX
25 #define INCLUDED_DRAWINGLAYER_PROCESSOR2D_VCLMETAFILEPROCESSOR2D_HXX
26 
27 #include <drawinglayer/drawinglayerdllapi.h>
28 #include <drawinglayer/processor2d/vclprocessor2d.hxx>
29 #include <com/sun/star/i18n/XBreakIterator.hpp>
30 #include <basegfx/polygon/b2dpolypolygon.hxx>
31 
32 //////////////////////////////////////////////////////////////////////////////
33 // vcl::PDFExtOutDevData support
34 
35 #include <vcl/pdfextoutdevdata.hxx>
36 
37 //////////////////////////////////////////////////////////////////////////////
38 // predefines
39 
40 class GDIMetaFile;
41 class Rectangle;
42 class Gradient;
43 class SvtGraphicFill;
44 class SvtGraphicStroke;
45 
46 namespace drawinglayer { namespace attribute {
47     class FillGradientAttribute;
48 	class LineAttribute;
49 	class StrokeAttribute;
50 	class LineStartEndAttribute;
51 }}
52 
53 namespace basegfx {
54 	class BColor;
55 }
56 
57 //////////////////////////////////////////////////////////////////////////////
58 
59 namespace drawinglayer
60 {
61 	namespace processor2d
62 	{
63         /** VclMetafileProcessor2D class
64 
65             This processor derived from VclProcessor2D is the base class for rendering
66             all feeded primitives to a classical VCL-Metafile, including all over the
67             time grown extra data in comments and PDF exception data creations. Also
68             printing needs some exception stuff.
69 
70             All in all it is needed to emulate the old ::paint output from the old
71             Drawinglayer as long as exporters and/or filters still use the Metafile
72             and the extra-data added to it (which can be seen mostly as 'extensions'
73             or simply as 'hacks').
74          */
75 		class VclMetafileProcessor2D : public VclProcessor2D
76 		{
77         private:
78             /// local helper(s)
79             Rectangle impDumpToMetaFile(
80 				const primitive2d::Primitive2DSequence& rContent,
81 				GDIMetaFile& o_rContentMetafile);
82             void impConvertFillGradientAttributeToVCLGradient(
83 				Gradient& o_rVCLGradient,
84 				const attribute::FillGradientAttribute& rFiGrAtt,
85 				bool bIsTransparenceGradient);
86 			void impStartSvtGraphicFill(SvtGraphicFill* pSvtGraphicFill);
87 			void impEndSvtGraphicFill(SvtGraphicFill* pSvtGraphicFill);
88 			SvtGraphicStroke* impTryToCreateSvtGraphicStroke(
89 				const basegfx::B2DPolygon& rB2DPolygon,
90 				const basegfx::BColor* pColor,
91 				const attribute::LineAttribute* pLineAttribute,
92 				const attribute::StrokeAttribute* pStrokeAttribute,
93 				const attribute::LineStartEndAttribute* pStart,
94 				const attribute::LineStartEndAttribute* pEnd);
95 			void impStartSvtGraphicStroke(SvtGraphicStroke* pSvtGraphicStroke);
96 			void impEndSvtGraphicStroke(SvtGraphicStroke* pSvtGraphicStroke);
97 
98             /// the current clipping PolyPolygon from MaskPrimitive2D
99             basegfx::B2DPolyPolygon             maClipPolyPolygon;
100 
101 			/// the target MetaFile
102 			GDIMetaFile*					    mpMetaFile;
103 
104 			/*  do not allow embedding SvtGraphicFills into each other,
105 			    use a counter to prevent that
106              */
107 			sal_uInt32						    mnSvtGraphicFillCount;
108 
109 			/// same for SvtGraphicStroke
110 			sal_uInt32						    mnSvtGraphicStrokeCount;
111 
112 			/*  hold the last unified transparence value to have it handy
113 			    on SvtGraphicStroke creation
114              */
115 			double							    mfCurrentUnifiedTransparence;
116 
117             /*  break iterator support
118                 made static so it only needs to be fetched once, even with many single
119                 constructed VclMetafileProcessor2D. It's still incarnated on demand,
120                 but exists for OOo runtime now by purpose.
121              */
122             static ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >   mxBreakIterator;
123 
124 			/*  vcl::PDFExtOutDevData support
125 			    For the first step, some extra actions at vcl::PDFExtOutDevData need to
126 			    be emulated with the VclMetafileProcessor2D. These are potentially temporarily
127 			    since PDF export may use PrimitiveSequences one day directly.
128              */
129 			vcl::PDFExtOutDevData*				mpPDFExtOutDevData;
130 
131 		protected:
132 			/*  the local processor for BasePrinitive2D-Implementation based primitives,
133 			    called from the common process()-implementation
134              */
135 			virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate);
136 
137 		public:
138 			/// constructor/destructor
139 			VclMetafileProcessor2D(
140 				const geometry::ViewInformation2D& rViewInformation,
141 				OutputDevice& rOutDev);
142 			virtual ~VclMetafileProcessor2D();
143 		};
144 	} // end of namespace processor2d
145 } // end of namespace drawinglayer
146 
147 //////////////////////////////////////////////////////////////////////////////
148 
149 #endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_VCLMETAFILEPROCESSOR2D_HXX
150 
151 // eof
152