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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_drawinglayer.hxx"
26 
27 #include <drawinglayer/processor2d/vclprocessor2d.hxx>
28 #include <drawinglayer/primitive2d/textprimitive2d.hxx>
29 #include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx>
30 #include <tools/debug.hxx>
31 #include <vcl/outdev.hxx>
32 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
33 #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
34 #include <vclhelperbitmaptransform.hxx>
35 #include <basegfx/polygon/b2dpolygontools.hxx>
36 #include <vclhelperbitmaprender.hxx>
37 #include <drawinglayer/attribute/sdrfillbitmapattribute.hxx>
38 #include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
39 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
40 #include <vclhelpergradient.hxx>
41 #include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
42 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
43 #include <basegfx/polygon/b2dpolypolygontools.hxx>
44 #include <vclhelperbufferdevice.hxx>
45 #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
46 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
47 #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
48 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
49 #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
50 #include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx>
51 #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx>
52 #include <svl/ctloptions.hxx>
53 #include <vcl/svapp.hxx>
54 #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx>
55 #include <tools/diagnose_ex.h>
56 #include <vcl/metric.hxx>
57 #include <drawinglayer/primitive2d/textenumsprimitive2d.hxx>
58 #include <drawinglayer/primitive2d/epsprimitive2d.hxx>
59 #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
60 #include <basegfx/color/bcolor.hxx>
61 #include <basegfx/matrix/b2dhommatrixtools.hxx>
62 
63 //////////////////////////////////////////////////////////////////////////////
64 // control support
65 
66 #include <com/sun/star/awt/XWindow2.hpp>
67 #include <com/sun/star/awt/PosSize.hpp>
68 #include <com/sun/star/awt/XView.hpp>
69 #include <drawinglayer/primitive2d/controlprimitive2d.hxx>
70 #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
71 
72 //////////////////////////////////////////////////////////////////////////////
73 // for test, can be removed again
74 
75 #include <basegfx/polygon/b2dpolygonclipper.hxx>
76 #include <basegfx/polygon/b2dtrapezoid.hxx>
77 
78 //////////////////////////////////////////////////////////////////////////////
79 
80 using namespace com::sun::star;
81 
82 //////////////////////////////////////////////////////////////////////////////
83 
84 namespace
85 {
86     sal_uInt32 calculateStepsForSvgGradient(const basegfx::BColor& rColorA, const basegfx::BColor& rColorB, double fDelta, double fDiscreteUnit)
87     {
88         // use color distance, assume to do every color step
89         sal_uInt32 nSteps(basegfx::fround(rColorA.getDistance(rColorB) * 255.0));
90 
91         if(nSteps)
92         {
93             // calc discrete length to change color each disctete unit (pixel)
94             const sal_uInt32 nDistSteps(basegfx::fround(fDelta / fDiscreteUnit));
95 
96             nSteps = std::min(nSteps, nDistSteps);
97         }
98 
99         // reduce quality to 3 discrete units or every 3rd color step for rendering
100         nSteps /= 2;
101 
102         // roughly cut when too big or too small (not full quality, reduce complexity)
103         nSteps = std::min(nSteps, sal_uInt32(255));
104         nSteps = std::max(nSteps, sal_uInt32(1));
105 
106         return nSteps;
107     }
108 } // end of anonymous namespace
109 
110 //////////////////////////////////////////////////////////////////////////////
111 
112 namespace drawinglayer
113 {
114 	namespace processor2d
115 	{
116 		//////////////////////////////////////////////////////////////////////////////
117 		// UNO class usages
118 		using ::com::sun::star::uno::Reference;
119 		using ::com::sun::star::uno::UNO_QUERY;
120 	    using ::com::sun::star::uno::UNO_QUERY_THROW;
121         using ::com::sun::star::uno::Exception;
122 		using ::com::sun::star::awt::XView;
123 		using ::com::sun::star::awt::XGraphics;
124 	    using ::com::sun::star::awt::XWindow;
125 	    using ::com::sun::star::awt::PosSize::POSSIZE;
126 
127 		//////////////////////////////////////////////////////////////////////////////
128 		// rendering support
129 
130 		// directdraw of text simple portion or decorated portion primitive. When decorated, all the extra
131 		// information is translated to VCL parameters and set at the font.
132 		// Acceptance is restricted to no shearing and positive scaling in X and Y (no font mirroring
133 		// for VCL)
134 		void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate)
135 		{
136             // decompose matrix to have position and size of text
137 			basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rTextCandidate.getTextTransform());
138 			basegfx::B2DVector aFontScaling, aTranslate;
139 			double fRotate, fShearX;
140 			aLocalTransform.decompose(aFontScaling, aTranslate, fRotate, fShearX);
141 			bool bPrimitiveAccepted(false);
142 
143 			if(basegfx::fTools::equalZero(fShearX))
144 			{
145 				if(basegfx::fTools::less(aFontScaling.getX(), 0.0) && basegfx::fTools::less(aFontScaling.getY(), 0.0))
146 				{
147 					// handle special case: If scale is negative in (x,y) (3rd quadrant), it can
148 					// be expressed as rotation by PI. Use this since the Font rendering will not
149                     // apply the negative scales in any form
150 					aFontScaling = basegfx::absolute(aFontScaling);
151 					fRotate += F_PI;
152 				}
153 
154 				if(basegfx::fTools::more(aFontScaling.getX(), 0.0) && basegfx::fTools::more(aFontScaling.getY(), 0.0))
155 				{
156                     // Get the VCL font (use FontHeight as FontWidth)
157                     Font aFont(primitive2d::getVclFontFromFontAttribute(
158                         rTextCandidate.getFontAttribute(),
159                         aFontScaling.getX(),
160                         aFontScaling.getY(),
161                         fRotate,
162                         rTextCandidate.getLocale()));
163 
164 					// handle additional font attributes
165 					const primitive2d::TextDecoratedPortionPrimitive2D* pTCPP =
166 						dynamic_cast<const primitive2d::TextDecoratedPortionPrimitive2D*>( &rTextCandidate );
167 
168 					if( pTCPP != NULL )
169 					{
170 
171                         // set the color of text decorations
172                         const basegfx::BColor aTextlineColor = maBColorModifierStack.getModifiedColor(pTCPP->getTextlineColor());
173                         mpOutputDevice->SetTextLineColor( Color(aTextlineColor) );
174 
175                         // set Overline attribute
176                         const FontUnderline eFontOverline(primitive2d::mapTextLineToFontUnderline( pTCPP->getFontOverline() ));
177                         if( eFontOverline != UNDERLINE_NONE )
178                         {
179                             aFont.SetOverline( eFontOverline );
180                             const basegfx::BColor aOverlineColor = maBColorModifierStack.getModifiedColor(pTCPP->getOverlineColor());
181                             mpOutputDevice->SetOverlineColor( Color(aOverlineColor) );
182                             if( pTCPP->getWordLineMode() )
183                                 aFont.SetWordLineMode( true );
184                         }
185 
186                         // set Underline attribute
187                         const FontUnderline eFontUnderline(primitive2d::mapTextLineToFontUnderline( pTCPP->getFontUnderline() ));
188                         if( eFontUnderline != UNDERLINE_NONE )
189 						{
190 							aFont.SetUnderline( eFontUnderline );
191 							if( pTCPP->getWordLineMode() )
192 								aFont.SetWordLineMode( true );
193 //TODO: ???					if( pTCPP->getUnderlineAbove() )
194 //								aFont.SetUnderlineAbove( true );
195 						}
196 
197 						// set Strikeout attribute
198 						const FontStrikeout eFontStrikeout(primitive2d::mapTextStrikeoutToFontStrikeout(pTCPP->getTextStrikeout()));
199 
200 						if( eFontStrikeout != STRIKEOUT_NONE )
201 							aFont.SetStrikeout( eFontStrikeout );
202 
203 						// set EmphasisMark attribute
204 						FontEmphasisMark eFontEmphasisMark = EMPHASISMARK_NONE;
205 						switch( pTCPP->getTextEmphasisMark() )
206 						{
207 							default:
208 								DBG_WARNING1( "DrawingLayer: Unknown EmphasisMark style (%d)!", pTCPP->getTextEmphasisMark() );
209 								// fall through
210 							case primitive2d::TEXT_EMPHASISMARK_NONE:	eFontEmphasisMark = EMPHASISMARK_NONE; break;
211 							case primitive2d::TEXT_EMPHASISMARK_DOT:	eFontEmphasisMark = EMPHASISMARK_DOT; break;
212 							case primitive2d::TEXT_EMPHASISMARK_CIRCLE:	eFontEmphasisMark = EMPHASISMARK_CIRCLE; break;
213 							case primitive2d::TEXT_EMPHASISMARK_DISC:	eFontEmphasisMark = EMPHASISMARK_DISC; break;
214 							case primitive2d::TEXT_EMPHASISMARK_ACCENT:	eFontEmphasisMark = EMPHASISMARK_ACCENT; break;
215 						}
216 
217 						if( eFontEmphasisMark != EMPHASISMARK_NONE )
218 						{
219 							DBG_ASSERT( (pTCPP->getEmphasisMarkAbove() != pTCPP->getEmphasisMarkBelow()),
220 								"DrawingLayer: Bad EmphasisMark position!" );
221 							if( pTCPP->getEmphasisMarkAbove() )
222 								eFontEmphasisMark |= EMPHASISMARK_POS_ABOVE;
223 							else
224 								eFontEmphasisMark |= EMPHASISMARK_POS_BELOW;
225 							aFont.SetEmphasisMark( eFontEmphasisMark );
226 						}
227 
228 						// set Relief attribute
229 						FontRelief eFontRelief = RELIEF_NONE;
230 						switch( pTCPP->getTextRelief() )
231 						{
232 							default:
233 								DBG_WARNING1( "DrawingLayer: Unknown Relief style (%d)!", pTCPP->getTextRelief() );
234 								// fall through
235 							case primitive2d::TEXT_RELIEF_NONE:		eFontRelief = RELIEF_NONE; break;
236 							case primitive2d::TEXT_RELIEF_EMBOSSED:	eFontRelief = RELIEF_EMBOSSED; break;
237 							case primitive2d::TEXT_RELIEF_ENGRAVED:	eFontRelief = RELIEF_ENGRAVED; break;
238 						}
239 
240 						if( eFontRelief != RELIEF_NONE )
241 							aFont.SetRelief( eFontRelief );
242 
243 						// set Shadow attribute
244 						if( pTCPP->getShadow() )
245 							aFont.SetShadow( true );
246 					}
247 
248 					// create transformed integer DXArray in view coordinate system
249 					::std::vector< sal_Int32 > aTransformedDXArray;
250 
251 					if(rTextCandidate.getDXArray().size())
252 					{
253 						aTransformedDXArray.reserve(rTextCandidate.getDXArray().size());
254 						const basegfx::B2DVector aPixelVector(maCurrentTransformation * basegfx::B2DVector(1.0, 0.0));
255 						const double fPixelVectorFactor(aPixelVector.getLength());
256 
257 						for(::std::vector< double >::const_iterator aStart(rTextCandidate.getDXArray().begin());
258                             aStart != rTextCandidate.getDXArray().end(); aStart++)
259 						{
260 							aTransformedDXArray.push_back(basegfx::fround((*aStart) * fPixelVectorFactor));
261 						}
262 					}
263 
264 					// set parameters and paint text snippet
265 					const basegfx::BColor aRGBFontColor(maBColorModifierStack.getModifiedColor(rTextCandidate.getFontColor()));
266 					const basegfx::B2DPoint aPoint(aLocalTransform * basegfx::B2DPoint(0.0, 0.0));
267 					const Point aStartPoint(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()));
268                     const sal_uInt32 nOldLayoutMode(mpOutputDevice->GetLayoutMode());
269 
270                     if(rTextCandidate.getFontAttribute().getRTL())
271                     {
272                         sal_uInt32 nRTLLayoutMode(nOldLayoutMode & ~(TEXT_LAYOUT_COMPLEX_DISABLED|TEXT_LAYOUT_BIDI_STRONG));
273                         nRTLLayoutMode |= TEXT_LAYOUT_BIDI_RTL|TEXT_LAYOUT_TEXTORIGIN_LEFT;
274                         mpOutputDevice->SetLayoutMode(nRTLLayoutMode);
275                     }
276 
277 					mpOutputDevice->SetFont(aFont);
278 					mpOutputDevice->SetTextColor(Color(aRGBFontColor));
279 
280 					if(aTransformedDXArray.size())
281 					{
282 						mpOutputDevice->DrawTextArray(
283 							aStartPoint,
284 							rTextCandidate.getText(),
285 							&(aTransformedDXArray[0]),
286 							rTextCandidate.getTextPosition(),
287 							rTextCandidate.getTextLength());
288 					}
289 					else
290 					{
291 						mpOutputDevice->DrawText(
292 							aStartPoint,
293 							rTextCandidate.getText(),
294 							rTextCandidate.getTextPosition(),
295 							rTextCandidate.getTextLength());
296 					}
297 
298                     if(rTextCandidate.getFontAttribute().getRTL())
299                     {
300                         mpOutputDevice->SetLayoutMode(nOldLayoutMode);
301                     }
302 
303 					bPrimitiveAccepted = true;
304 				}
305 			}
306 
307 			if(!bPrimitiveAccepted)
308 			{
309 				// let break down
310 				process(rTextCandidate.get2DDecomposition(getViewInformation2D()));
311 			}
312 		}
313 
314 		// direct draw of hairline
315 		void VclProcessor2D::RenderPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate, bool bPixelBased)
316 		{
317             const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor()));
318 			mpOutputDevice->SetLineColor(Color(aHairlineColor));
319 			mpOutputDevice->SetFillColor();
320 
321 			basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon());
322 			aLocalPolygon.transform(maCurrentTransformation);
323 
324             static bool bCheckTrapezoidDecomposition(false);
325             static bool bShowOutlinesThere(false);
326             if(bCheckTrapezoidDecomposition)
327             {
328                 // clip against discrete ViewPort
329                 const basegfx::B2DRange& rDiscreteViewport = getViewInformation2D().getDiscreteViewport();
330                 basegfx::B2DPolyPolygon aLocalPolyPolygon(basegfx::tools::clipPolygonOnRange(
331                     aLocalPolygon, rDiscreteViewport, true, false));
332 
333                 if(aLocalPolyPolygon.count())
334                 {
335                     // subdivide
336                     aLocalPolyPolygon = basegfx::tools::adaptiveSubdivideByDistance(
337                         aLocalPolyPolygon, 0.5);
338 
339                     // trapezoidize
340                     static double fLineWidth(2.0);
341                     basegfx::B2DTrapezoidVector aB2DTrapezoidVector;
342                     basegfx::tools::createLineTrapezoidFromB2DPolyPolygon(aB2DTrapezoidVector, aLocalPolyPolygon, fLineWidth);
343 
344                     const sal_uInt32 nCount(aB2DTrapezoidVector.size());
345 
346                     if(nCount)
347                     {
348                         basegfx::BColor aInvPolygonColor(aHairlineColor);
349                         aInvPolygonColor.invert();
350 
351                         for(sal_uInt32 a(0); a < nCount; a++)
352                         {
353                             const basegfx::B2DPolygon aTempPolygon(aB2DTrapezoidVector[a].getB2DPolygon());
354 
355                             if(bShowOutlinesThere)
356                             {
357                                 mpOutputDevice->SetFillColor(Color(aHairlineColor));
358 			                    mpOutputDevice->SetLineColor();
359                             }
360 
361                             mpOutputDevice->DrawPolygon(aTempPolygon);
362 
363                             if(bShowOutlinesThere)
364                             {
365                                 mpOutputDevice->SetFillColor();
366         		                mpOutputDevice->SetLineColor(Color(aInvPolygonColor));
367     	    		            mpOutputDevice->DrawPolyLine(aTempPolygon, 0.0);
368                             }
369                         }
370                     }
371                 }
372             }
373             else
374             {
375 			    if(bPixelBased && getOptionsDrawinglayer().IsAntiAliasing() && getOptionsDrawinglayer().IsSnapHorVerLinesToDiscrete())
376 			    {
377 				    // #i98289#
378 				    // when a Hairline is painted and AntiAliasing is on the option SnapHorVerLinesToDiscrete
379 				    // allows to suppress AntiAliasing for pure horizontal or vertical lines. This is done since
380 				    // not-AntiAliased such lines look more pleasing to the eye (e.g. 2D chart content). This
381 				    // NEEDS to be done in discrete coordinates, so only useful for pixel based rendering.
382 				    aLocalPolygon = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aLocalPolygon);
383 			    }
384 
385 			    mpOutputDevice->DrawPolyLine(aLocalPolygon, 0.0);
386             }
387 		}
388 
389 		// direct draw of transformed BitmapEx primitive
390 		void VclProcessor2D::RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate)
391 		{
392             // create local transform
393 			basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rBitmapCandidate.getTransform());
394 			BitmapEx aBitmapEx(rBitmapCandidate.getBitmapEx());
395 			bool bPainted(false);
396 
397 			if(maBColorModifierStack.count())
398 			{
399 				aBitmapEx = impModifyBitmapEx(maBColorModifierStack, aBitmapEx);
400 
401 				if(aBitmapEx.IsEmpty())
402 				{
403 					// color gets completely replaced, get it
404 					const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor()));
405 					basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
406 					aPolygon.transform(aLocalTransform);
407 
408 					mpOutputDevice->SetFillColor(Color(aModifiedColor));
409 					mpOutputDevice->SetLineColor();
410 					mpOutputDevice->DrawPolygon(aPolygon);
411 
412 					bPainted = true;
413 				}
414 			}
415 
416 			if(!bPainted)
417 			{
418 				static bool bForceUseOfOwnTransformer(false);
419 				static bool bUseGraphicManager(true);
420 
421 				// decompose matrix to check for shear, rotate and mirroring
422 				basegfx::B2DVector aScale, aTranslate;
423 				double fRotate, fShearX;
424 				aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
425 
426 				if(!bForceUseOfOwnTransformer && basegfx::fTools::equalZero(fShearX))
427 				{
428 					if(!bUseGraphicManager && basegfx::fTools::equalZero(fRotate))
429 					{
430 						RenderBitmapPrimitive2D_BitmapEx(*mpOutputDevice, aBitmapEx, aLocalTransform);
431 					}
432 					else
433 					{
434 						RenderBitmapPrimitive2D_GraphicManager(*mpOutputDevice, aBitmapEx, aLocalTransform);
435 					}
436 				}
437 				else
438 				{
439 					if(!aBitmapEx.IsTransparent() && (!basegfx::fTools::equalZero(fShearX) || !basegfx::fTools::equalZero(fRotate)))
440 					{
441 						// parts will be uncovered, extend aBitmapEx with a mask bitmap
442 						const Bitmap aContent(aBitmapEx.GetBitmap());
443 						aBitmapEx = BitmapEx(aContent, Bitmap(aContent.GetSizePixel(), 1));
444 					}
445 
446 					RenderBitmapPrimitive2D_self(*mpOutputDevice, aBitmapEx, aLocalTransform);
447 				}
448 			}
449 		}
450 
451 		void VclProcessor2D::RenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapCandidate)
452 		{
453 			const attribute::FillBitmapAttribute& rFillBitmapAttribute(rFillBitmapCandidate.getFillBitmap());
454 			bool bPrimitiveAccepted(false);
455 
456 			if(rFillBitmapAttribute.getTiling())
457 			{
458 				// decompose matrix to check for shear, rotate and mirroring
459 				basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rFillBitmapCandidate.getTransformation());
460 				basegfx::B2DVector aScale, aTranslate;
461 				double fRotate, fShearX;
462 				aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
463 
464 				if(basegfx::fTools::equalZero(fRotate) && basegfx::fTools::equalZero(fShearX))
465 				{
466 					// no shear or rotate, draw direct in pixel coordinates
467 					bPrimitiveAccepted = true;
468 					BitmapEx aBitmapEx(rFillBitmapAttribute.getBitmapEx());
469 					bool bPainted(false);
470 
471 					if(maBColorModifierStack.count())
472 					{
473 						aBitmapEx = impModifyBitmapEx(maBColorModifierStack, aBitmapEx);
474 
475 						if(aBitmapEx.IsEmpty())
476 						{
477 							// color gets completely replaced, get it
478 							const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor()));
479 							basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
480 							aPolygon.transform(aLocalTransform);
481 
482 							mpOutputDevice->SetFillColor(Color(aModifiedColor));
483 							mpOutputDevice->SetLineColor();
484 							mpOutputDevice->DrawPolygon(aPolygon);
485 
486 							bPainted = true;
487 						}
488 					}
489 
490 					if(!bPainted)
491 					{
492 						const basegfx::B2DPoint aObjTopLeft(aTranslate.getX(), aTranslate.getY());
493 						const basegfx::B2DPoint aObjBottomRight(aTranslate.getX() + aScale.getX(), aTranslate.getY() + aScale.getY());
494 						const Point aObjTL(mpOutputDevice->LogicToPixel(Point((sal_Int32)aObjTopLeft.getX(), (sal_Int32)aObjTopLeft.getY())));
495 						const Point aObjBR(mpOutputDevice->LogicToPixel(Point((sal_Int32)aObjBottomRight.getX(), (sal_Int32)aObjBottomRight.getY())));
496 
497 						const basegfx::B2DPoint aBmpTopLeft(aLocalTransform * rFillBitmapAttribute.getTopLeft());
498 						const basegfx::B2DPoint aBmpBottomRight(aLocalTransform * basegfx::B2DPoint(rFillBitmapAttribute.getTopLeft() + rFillBitmapAttribute.getSize()));
499 						const Point aBmpTL(mpOutputDevice->LogicToPixel(Point((sal_Int32)aBmpTopLeft.getX(), (sal_Int32)aBmpTopLeft.getY())));
500 						const Point aBmpBR(mpOutputDevice->LogicToPixel(Point((sal_Int32)aBmpBottomRight.getX(), (sal_Int32)aBmpBottomRight.getY())));
501 
502 						sal_Int32 nOWidth(aObjBR.X() - aObjTL.X());
503 						sal_Int32 nOHeight(aObjBR.Y() - aObjTL.Y());
504 
505                         // only do something when object has a size in discrete units
506 						if(nOWidth > 0 && nOHeight > 0)
507 						{
508 						    sal_Int32 nBWidth(aBmpBR.X() - aBmpTL.X());
509 						    sal_Int32 nBHeight(aBmpBR.Y() - aBmpTL.Y());
510 
511                             // only do something when bitmap fill has a size in discrete units
512 						    if(nBWidth > 0 && nBHeight > 0)
513 						    {
514 						        sal_Int32 nBLeft(aBmpTL.X());
515 						        sal_Int32 nBTop(aBmpTL.Y());
516 
517 						        if(nBLeft > aObjTL.X())
518 						        {
519 							        nBLeft -= ((nBLeft / nBWidth) + 1L) * nBWidth;
520 						        }
521 
522 						        if(nBLeft + nBWidth <= aObjTL.X())
523 						        {
524 							        nBLeft -= (nBLeft / nBWidth) * nBWidth;
525 						        }
526 
527 						        if(nBTop > aObjTL.Y())
528 						        {
529 							        nBTop -= ((nBTop / nBHeight) + 1L) * nBHeight;
530 						        }
531 
532 						        if(nBTop + nBHeight <= aObjTL.Y())
533 						        {
534 							        nBTop -= (nBTop / nBHeight) * nBHeight;
535 						        }
536 
537 						        // nBWidth, nBHeight is the pixel size of the neede bitmap. To not need to scale it
538 						        // in vcl many times, create a size-optimized version
539 						        const Size aNeededBitmapSizePixel(nBWidth, nBHeight);
540 
541 						        if(aNeededBitmapSizePixel != aBitmapEx.GetSizePixel())
542 						        {
543 							        aBitmapEx.Scale(aNeededBitmapSizePixel);
544 						        }
545 
546 						        // prepare OutDev
547 						        const Point aEmptyPoint(0, 0);
548 						        const Rectangle aVisiblePixel(aEmptyPoint, mpOutputDevice->GetOutputSizePixel());
549 						        const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled());
550 						        mpOutputDevice->EnableMapMode(false);
551 
552 						        for(sal_Int32 nXPos(nBLeft); nXPos < aObjTL.X() + nOWidth; nXPos += nBWidth)
553 						        {
554 							        for(sal_Int32 nYPos(nBTop); nYPos < aObjTL.Y() + nOHeight; nYPos += nBHeight)
555 							        {
556 								        const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel);
557 
558 								        if(aOutRectPixel.IsOver(aVisiblePixel))
559 								        {
560 									        mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aBitmapEx);
561 								        }
562 							        }
563 						        }
564 
565 						        // restore OutDev
566 						        mpOutputDevice->EnableMapMode(bWasEnabled);
567                             }
568                         }
569 					}
570 				}
571 			}
572 
573 			if(!bPrimitiveAccepted)
574 			{
575 				// do not accept, use decomposition
576 				process(rFillBitmapCandidate.get2DDecomposition(getViewInformation2D()));
577 			}
578 		}
579 
580 		// direct draw of gradient
581 		void VclProcessor2D::RenderPolyPolygonGradientPrimitive2D(const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate)
582 		{
583 			const attribute::FillGradientAttribute& rGradient(rPolygonCandidate.getFillGradient());
584 			basegfx::BColor aStartColor(maBColorModifierStack.getModifiedColor(rGradient.getStartColor()));
585 			basegfx::BColor aEndColor(maBColorModifierStack.getModifiedColor(rGradient.getEndColor()));
586 			basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
587 
588 			if(aLocalPolyPolygon.count())
589 			{
590 				aLocalPolyPolygon.transform(maCurrentTransformation);
591 
592 				if(aStartColor == aEndColor)
593 				{
594 					// no gradient at all, draw as polygon in AA and non-AA case
595 					mpOutputDevice->SetLineColor();
596 					mpOutputDevice->SetFillColor(Color(aStartColor));
597 					mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
598 				}
599 				else if(getOptionsDrawinglayer().IsAntiAliasing())
600 				{
601 					// For AA, direct render has to be avoided since it uses XOR maskings which will not
602 					// work with AA. Instead, the decompose which uses MaskPrimitive2D with fillings is
603 					// used
604 					process(rPolygonCandidate.get2DDecomposition(getViewInformation2D()));
605 				}
606 				else
607 				{
608 					impDrawGradientToOutDev(
609 						*mpOutputDevice, aLocalPolyPolygon, rGradient.getStyle(), rGradient.getSteps(),
610 						aStartColor, aEndColor, rGradient.getBorder(),
611 						rGradient.getAngle(), rGradient.getOffsetX(), rGradient.getOffsetY(), false);
612 				}
613 			}
614 		}
615 
616 		// direct draw of bitmap
617 		void VclProcessor2D::RenderPolyPolygonBitmapPrimitive2D(const primitive2d::PolyPolygonBitmapPrimitive2D& rPolygonCandidate)
618 		{
619 			bool bDone(false);
620 			const basegfx::B2DPolyPolygon& rPolyPolygon = rPolygonCandidate.getB2DPolyPolygon();
621 
622 			if(rPolyPolygon.count())
623 			{
624 				const attribute::FillBitmapAttribute& rFillBitmapAttribute = rPolygonCandidate.getFillBitmap();
625 				const BitmapEx& rBitmapEx = rFillBitmapAttribute.getBitmapEx();
626 
627 				if(rBitmapEx.IsEmpty())
628 				{
629 					// empty bitmap, done
630 					bDone = true;
631 				}
632 				else
633 				{
634 					// try to catch cases where the bitmap will be color-modified to a single
635 					// color (e.g. shadow). This would NOT be optimizable with an transparence channel
636 					// at the Bitmap which we do not have here. When this should change, this
637 					// optimization has to be reworked accordingly.
638 					const sal_uInt32 nBColorModifierStackCount(maBColorModifierStack.count());
639 
640 					if(nBColorModifierStackCount)
641 					{
642 						const basegfx::BColorModifier& rTopmostModifier = maBColorModifierStack.getBColorModifier(nBColorModifierStackCount - 1);
643 
644 						if(basegfx::BCOLORMODIFYMODE_REPLACE == rTopmostModifier.getMode())
645 						{
646 							// the bitmap fill is in unified color, so we can replace it with
647 							// a single polygon fill. The form of the fill depends on tiling
648 							if(rFillBitmapAttribute.getTiling())
649 							{
650 								// with tiling, fill the whole PolyPolygon with the modifier color
651 								basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolyPolygon);
652 
653 								aLocalPolyPolygon.transform(maCurrentTransformation);
654 								mpOutputDevice->SetLineColor();
655 								mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor()));
656 								mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
657 							}
658 							else
659 							{
660 								// without tiling, only the area common to the bitmap tile and the
661 								// PolyPolygon is filled. Create the bitmap tile area in object
662 								// coordinates. For this, the object transformation needs to be created
663 								// from the already scaled PolyPolygon. The tile area in object
664 								// coordinates wil always be non-rotated, so it's not necessary to
665 								// work with a polygon here
666 								basegfx::B2DRange aTileRange(rFillBitmapAttribute.getTopLeft(),
667 									rFillBitmapAttribute.getTopLeft() + rFillBitmapAttribute.getSize());
668 								const basegfx::B2DRange aPolyPolygonRange(rPolyPolygon.getB2DRange());
669 								basegfx::B2DHomMatrix aNewObjectTransform;
670 
671 								aNewObjectTransform.set(0, 0, aPolyPolygonRange.getWidth());
672 								aNewObjectTransform.set(1, 1, aPolyPolygonRange.getHeight());
673 								aNewObjectTransform.set(0, 2, aPolyPolygonRange.getMinX());
674 								aNewObjectTransform.set(1, 2, aPolyPolygonRange.getMinY());
675 								aTileRange.transform(aNewObjectTransform);
676 
677 								// now clip the object polyPolygon against the tile range
678 								// to get the common area (OR)
679 								basegfx::B2DPolyPolygon aTarget = basegfx::tools::clipPolyPolygonOnRange(rPolyPolygon, aTileRange, true, false);
680 
681 								if(aTarget.count())
682 								{
683 									aTarget.transform(maCurrentTransformation);
684 									mpOutputDevice->SetLineColor();
685 									mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor()));
686 									mpOutputDevice->DrawPolyPolygon(aTarget);
687 								}
688 							}
689 
690 							bDone = true;
691 						}
692 					}
693 				}
694 			}
695 			else
696 			{
697 				// empty polyPolygon, done
698 				bDone = true;
699 			}
700 
701 			if(!bDone)
702 			{
703 				// use default decomposition
704 				process(rPolygonCandidate.get2DDecomposition(getViewInformation2D()));
705 			}
706 		}
707 
708 		// direct draw of PolyPolygon with color
709 		void VclProcessor2D::RenderPolyPolygonColorPrimitive2D(const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate)
710 		{
711 			const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor()));
712 			mpOutputDevice->SetFillColor(Color(aPolygonColor));
713 			mpOutputDevice->SetLineColor();
714 
715 			basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
716 			aLocalPolyPolygon.transform(maCurrentTransformation);
717 
718             static bool bCheckTrapezoidDecomposition(false);
719             static bool bShowOutlinesThere(false);
720             if(bCheckTrapezoidDecomposition)
721             {
722                 // clip against discrete ViewPort
723                 const basegfx::B2DRange& rDiscreteViewport = getViewInformation2D().getDiscreteViewport();
724                 aLocalPolyPolygon = basegfx::tools::clipPolyPolygonOnRange(
725                     aLocalPolyPolygon, rDiscreteViewport, true, false);
726 
727                 if(aLocalPolyPolygon.count())
728                 {
729                     // subdivide
730                     aLocalPolyPolygon = basegfx::tools::adaptiveSubdivideByDistance(
731                         aLocalPolyPolygon, 0.5);
732 
733                     // trapezoidize
734                     basegfx::B2DTrapezoidVector aB2DTrapezoidVector;
735                     basegfx::tools::trapezoidSubdivide(aB2DTrapezoidVector, aLocalPolyPolygon);
736 
737                     const sal_uInt32 nCount(aB2DTrapezoidVector.size());
738 
739                     if(nCount)
740                     {
741                         basegfx::BColor aInvPolygonColor(aPolygonColor);
742                         aInvPolygonColor.invert();
743 
744                         for(sal_uInt32 a(0); a < nCount; a++)
745                         {
746                             const basegfx::B2DPolygon aTempPolygon(aB2DTrapezoidVector[a].getB2DPolygon());
747 
748                             if(bShowOutlinesThere)
749                             {
750                                 mpOutputDevice->SetFillColor(Color(aPolygonColor));
751 			                    mpOutputDevice->SetLineColor();
752                             }
753 
754                             mpOutputDevice->DrawPolygon(aTempPolygon);
755 
756                             if(bShowOutlinesThere)
757                             {
758                                 mpOutputDevice->SetFillColor();
759         		                mpOutputDevice->SetLineColor(Color(aInvPolygonColor));
760     	    		            mpOutputDevice->DrawPolyLine(aTempPolygon, 0.0);
761                             }
762                         }
763                     }
764                 }
765             }
766             else
767             {
768 			    mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
769 
770                 if(mnPolygonStrokePrimitive2D
771                     && getOptionsDrawinglayer().IsAntiAliasing()
772                     && (mpOutputDevice->GetAntialiasing() & ANTIALIASING_ENABLE_B2DDRAW))
773                 {
774                     // when AA is on and this filled polygons are the result of stroked line geometry,
775                     // draw the geometry once extra as lines to avoid AA 'gaps' between partial polygons
776 			        mpOutputDevice->SetFillColor();
777 			        mpOutputDevice->SetLineColor(Color(aPolygonColor));
778                     const sal_uInt32 nCount(aLocalPolyPolygon.count());
779 
780                     for(sal_uInt32 a(0); a < nCount; a++)
781                     {
782                         mpOutputDevice->DrawPolyLine(aLocalPolyPolygon.getB2DPolygon(a), 0.0);
783                     }
784                 }
785             }
786 		}
787 
788 		// direct draw of MetaFile
789 		void VclProcessor2D::RenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rMetaCandidate)
790 		{
791 			// decompose matrix to check for shear, rotate and mirroring
792 			basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rMetaCandidate.getTransform());
793 			basegfx::B2DVector aScale, aTranslate;
794 			double fRotate, fShearX;
795 			aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
796 
797 			if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
798 			{
799 				// #i102175# handle special case: If scale is negative in (x,y) (3rd quadrant), it can
800 				// be expressed as rotation by PI. This needs to be done for Metafiles since
801                 // these can be rotated, but not really mirrored
802 				aScale = basegfx::absolute(aScale);
803 				fRotate += F_PI;
804 			}
805 
806             // get BoundRect
807 			basegfx::B2DRange aOutlineRange(rMetaCandidate.getB2DRange(getViewInformation2D()));
808 			aOutlineRange.transform(maCurrentTransformation);
809 
810 			// Due to the integer MapModes used from VCL aind inside MetaFiles errors of up to three
811 			// pixels in size may happen. As long as there is no better way (e.g. convert the MetaFile
812 			// to primitives) it is necessary to reduce maximum pixel size by 1 in X and Y and to use
813 			// the inner pixel bounds accordingly (ceil resp. floor). This will also be done for logic
814 			// units e.g. when creating a new MetaFile, but since much huger value ranges are used
815 			// there typically will be okay for this compromize.
816 			Rectangle aDestRectView(
817                 // !!CAUTION!! Here, ceil and floor are exchanged BY PURPOSE, do NOT copy when
818                 // looking for a standard conversion to rectangle (!)
819 				(sal_Int32)ceil(aOutlineRange.getMinX()), (sal_Int32)ceil(aOutlineRange.getMinY()),
820 				(sal_Int32)floor(aOutlineRange.getMaxX()), (sal_Int32)floor(aOutlineRange.getMaxY()));
821 
822 			// get metafile (copy it)
823 			GDIMetaFile aMetaFile;
824 
825 			if(maBColorModifierStack.count())
826 			{
827 				const basegfx::BColor aRGBBaseColor(0, 0, 0);
828 				const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(aRGBBaseColor));
829 				aMetaFile = rMetaCandidate.getMetaFile().GetMonochromeMtf(Color(aRGBColor));
830 			}
831 			else
832 			{
833 				aMetaFile = rMetaCandidate.getMetaFile();
834 			}
835 
836 			// rotation
837 			if(!basegfx::fTools::equalZero(fRotate))
838 			{
839                 // #i103530#
840                 // MetaFile::Rotate has no input parameter check, so the parameter needs to be
841                 // well-aligned to the old range [0..3600] 10th degrees with inverse orientation
842 				sal_Int16 nRotation((sal_Int16)((fRotate / F_PI180) * -10.0));
843 
844                 while(nRotation < 0)
845                     nRotation += 3600;
846 
847                 while(nRotation >= 3600)
848                     nRotation -= 3600;
849 
850 				aMetaFile.Rotate(nRotation);
851 			}
852 
853 			// Prepare target output size
854 			Size aDestSize(aDestRectView.GetSize());
855 
856 			if(aDestSize.getWidth() && aDestSize.getHeight())
857 			{
858 				// Get preferred Metafile output size. When it's very equal to the output size, it's probably
859 				// a rounding error somewhere, so correct it to get a 1:1 output without single pixel scalings
860 				// of the Metafile (esp. for contaned Bitmaps, e.g 3D charts)
861 				const Size aPrefSize(mpOutputDevice->LogicToPixel(aMetaFile.GetPrefSize(), aMetaFile.GetPrefMapMode()));
862 
863 				if(aPrefSize.getWidth() && (aPrefSize.getWidth() - 1 == aDestSize.getWidth() || aPrefSize.getWidth() + 1 == aDestSize.getWidth()))
864 				{
865 					aDestSize.setWidth(aPrefSize.getWidth());
866 				}
867 
868 				if(aPrefSize.getHeight() && (aPrefSize.getHeight() - 1 == aDestSize.getHeight() || aPrefSize.getHeight() + 1 == aDestSize.getHeight()))
869 				{
870 					aDestSize.setHeight(aPrefSize.getHeight());
871 				}
872 
873 				// paint it
874 				aMetaFile.WindStart();
875 				aMetaFile.Play(mpOutputDevice, aDestRectView.TopLeft(), aDestSize);
876 			}
877 		}
878 
879 		// mask group. Force output to VDev and create mask from given mask
880 		void VclProcessor2D::RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate)
881 		{
882 			if(rMaskCandidate.getChildren().hasElements())
883 			{
884 				basegfx::B2DPolyPolygon aMask(rMaskCandidate.getMask());
885 
886 				if(aMask.count())
887 				{
888 					aMask.transform(maCurrentTransformation);
889 					const basegfx::B2DRange aRange(basegfx::tools::getRange(aMask));
890 					impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
891 
892 					if(aBufferDevice.isVisible())
893 					{
894 						// remember last OutDev and set to content
895 						OutputDevice* pLastOutputDevice = mpOutputDevice;
896 						mpOutputDevice = &aBufferDevice.getContent();
897 
898 						// paint to it
899 						process(rMaskCandidate.getChildren());
900 
901 						// back to old OutDev
902 						mpOutputDevice = pLastOutputDevice;
903 
904 					    // draw mask
905                         if(getOptionsDrawinglayer().IsAntiAliasing())
906                         {
907                             // with AA, use 8bit AlphaMask to get nice borders
908 						    VirtualDevice& rTransparence = aBufferDevice.getTransparence();
909 						    rTransparence.SetLineColor();
910 						    rTransparence.SetFillColor(COL_BLACK);
911 						    rTransparence.DrawPolyPolygon(aMask);
912 
913 						    // dump buffer to outdev
914 						    aBufferDevice.paint();
915                         }
916                         else
917                         {
918                             // No AA, use 1bit mask
919 						    VirtualDevice& rMask = aBufferDevice.getMask();
920 						    rMask.SetLineColor();
921 						    rMask.SetFillColor(COL_BLACK);
922 						    rMask.DrawPolyPolygon(aMask);
923 
924 						    // dump buffer to outdev
925 						    aBufferDevice.paint();
926                         }
927 					}
928 				}
929 			}
930 		}
931 
932 		// modified color group. Force output to unified color.
933 		void VclProcessor2D::RenderModifiedColorPrimitive2D(const primitive2d::ModifiedColorPrimitive2D& rModifiedCandidate)
934 		{
935 			if(rModifiedCandidate.getChildren().hasElements())
936 			{
937 				maBColorModifierStack.push(rModifiedCandidate.getColorModifier());
938 				process(rModifiedCandidate.getChildren());
939 				maBColorModifierStack.pop();
940 			}
941 		}
942 
943 		// unified sub-transparence. Draw to VDev first.
944 		void VclProcessor2D::RenderUnifiedTransparencePrimitive2D(const primitive2d::UnifiedTransparencePrimitive2D& rTransCandidate)
945 		{
946             static bool bForceToDecomposition(false);
947 
948             if(rTransCandidate.getChildren().hasElements())
949             {
950                 if(bForceToDecomposition)
951                 {
952     			    // use decomposition
953 	    		    process(rTransCandidate.get2DDecomposition(getViewInformation2D()));
954                 }
955                 else
956                 {
957 			        if(0.0 == rTransCandidate.getTransparence())
958 			        {
959 				        // no transparence used, so just use the content
960     	    		    process(rTransCandidate.getChildren());
961 			        }
962 			        else if(rTransCandidate.getTransparence() > 0.0 && rTransCandidate.getTransparence() < 1.0)
963 			        {
964                         // transparence is in visible range
965 				        basegfx::B2DRange aRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rTransCandidate.getChildren(), getViewInformation2D()));
966 				        aRange.transform(maCurrentTransformation);
967 				        impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
968 
969 				        if(aBufferDevice.isVisible())
970 				        {
971 					        // remember last OutDev and set to content
972 					        OutputDevice* pLastOutputDevice = mpOutputDevice;
973 					        mpOutputDevice = &aBufferDevice.getContent();
974 
975 					        // paint content to it
976 					        process(rTransCandidate.getChildren());
977 
978 					        // back to old OutDev
979 					        mpOutputDevice = pLastOutputDevice;
980 
981 					        // dump buffer to outdev using given transparence
982 					        aBufferDevice.paint(rTransCandidate.getTransparence());
983 				        }
984 			        }
985                 }
986             }
987 		}
988 
989 		// sub-transparence group. Draw to VDev first.
990 		void VclProcessor2D::RenderTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransCandidate)
991 		{
992 			if(rTransCandidate.getChildren().hasElements())
993 			{
994 				basegfx::B2DRange aRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rTransCandidate.getChildren(), getViewInformation2D()));
995 				aRange.transform(maCurrentTransformation);
996 				impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
997 
998 				if(aBufferDevice.isVisible())
999 				{
1000 					// remember last OutDev and set to content
1001 					OutputDevice* pLastOutputDevice = mpOutputDevice;
1002 					mpOutputDevice = &aBufferDevice.getContent();
1003 
1004 					// paint content to it
1005 					process(rTransCandidate.getChildren());
1006 
1007 					// set to mask
1008 					mpOutputDevice = &aBufferDevice.getTransparence();
1009 
1010 					// when painting transparence masks, reset the color stack
1011 					basegfx::BColorModifierStack aLastBColorModifierStack(maBColorModifierStack);
1012 					maBColorModifierStack = basegfx::BColorModifierStack();
1013 
1014 					// paint mask to it (always with transparence intensities, evtl. with AA)
1015 					process(rTransCandidate.getTransparence());
1016 
1017 					// back to old color stack
1018 					maBColorModifierStack = aLastBColorModifierStack;
1019 
1020 					// back to old OutDev
1021 					mpOutputDevice = pLastOutputDevice;
1022 
1023 					// dump buffer to outdev
1024 					aBufferDevice.paint();
1025 				}
1026 			}
1027 		}
1028 
1029 		// transform group.
1030 		void VclProcessor2D::RenderTransformPrimitive2D(const primitive2d::TransformPrimitive2D& rTransformCandidate)
1031 		{
1032 			// remember current transformation and ViewInformation
1033 			const basegfx::B2DHomMatrix aLastCurrentTransformation(maCurrentTransformation);
1034             const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
1035 
1036 			// create new transformations for CurrentTransformation
1037             // and for local ViewInformation2D
1038 			maCurrentTransformation = maCurrentTransformation * rTransformCandidate.getTransformation();
1039             const geometry::ViewInformation2D aViewInformation2D(
1040                 getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(),
1041                 getViewInformation2D().getViewTransformation(),
1042                 getViewInformation2D().getViewport(),
1043 				getViewInformation2D().getVisualizedPage(),
1044                 getViewInformation2D().getViewTime(),
1045 				getViewInformation2D().getExtendedInformationSequence());
1046 			updateViewInformation(aViewInformation2D);
1047 
1048 			// proccess content
1049 			process(rTransformCandidate.getChildren());
1050 
1051 			// restore transformations
1052 			maCurrentTransformation = aLastCurrentTransformation;
1053             updateViewInformation(aLastViewInformation2D);
1054 		}
1055 
1056 		// new XDrawPage for ViewInformation2D
1057 		void VclProcessor2D::RenderPagePreviewPrimitive2D(const primitive2d::PagePreviewPrimitive2D& rPagePreviewCandidate)
1058 		{
1059 			// remember current transformation and ViewInformation
1060             const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
1061 
1062 			// create new local ViewInformation2D
1063             const geometry::ViewInformation2D aViewInformation2D(
1064                 getViewInformation2D().getObjectTransformation(),
1065                 getViewInformation2D().getViewTransformation(),
1066                 getViewInformation2D().getViewport(),
1067 				rPagePreviewCandidate.getXDrawPage(),
1068                 getViewInformation2D().getViewTime(),
1069 				getViewInformation2D().getExtendedInformationSequence());
1070 			updateViewInformation(aViewInformation2D);
1071 
1072 			// proccess decomposed content
1073 			process(rPagePreviewCandidate.get2DDecomposition(getViewInformation2D()));
1074 
1075 			// restore transformations
1076             updateViewInformation(aLastViewInformation2D);
1077 		}
1078 
1079 		// marker
1080 		void VclProcessor2D::RenderMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkArrayCandidate)
1081 		{
1082             static bool bCheckCompleteMarkerDecompose(false);
1083             if(bCheckCompleteMarkerDecompose)
1084             {
1085 			    process(rMarkArrayCandidate.get2DDecomposition(getViewInformation2D()));
1086                 return;
1087             }
1088 
1089 			// get data
1090 	        const std::vector< basegfx::B2DPoint >& rPositions = rMarkArrayCandidate.getPositions();
1091 			const sal_uInt32 nCount(rPositions.size());
1092 
1093 			if(nCount && !rMarkArrayCandidate.getMarker().IsEmpty())
1094 			{
1095 				// get pixel size
1096 				const BitmapEx& rMarker(rMarkArrayCandidate.getMarker());
1097 				const Size aBitmapSize(rMarker.GetSizePixel());
1098 
1099 				if(aBitmapSize.Width() && aBitmapSize.Height())
1100 				{
1101 					// get discrete half size
1102 					const basegfx::B2DVector aDiscreteHalfSize(
1103                         (aBitmapSize.getWidth() - 1.0) * 0.5,
1104                         (aBitmapSize.getHeight() - 1.0) * 0.5);
1105 			        const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled());
1106 
1107                     // do not forget evtl. moved origin in target device MapMode when
1108                     // switching it off; it would be missing and lead to wrong positions.
1109                     // All his could be done using logic sizes and coordinates, too, but
1110                     // we want a 1:1 bitmap rendering here, so it's more safe and faster
1111                     // to work with switching off MapMode usage completely.
1112                     const Point aOrigin(mpOutputDevice->GetMapMode().GetOrigin());
1113 
1114                     mpOutputDevice->EnableMapMode(false);
1115 
1116 					for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); aIter++)
1117 				    {
1118 					    const basegfx::B2DPoint aDiscreteTopLeft((maCurrentTransformation * (*aIter)) - aDiscreteHalfSize);
1119                         const Point aDiscretePoint(basegfx::fround(aDiscreteTopLeft.getX()), basegfx::fround(aDiscreteTopLeft.getY()));
1120 
1121 						mpOutputDevice->DrawBitmapEx(aDiscretePoint + aOrigin, rMarker);
1122 					}
1123 
1124 			        mpOutputDevice->EnableMapMode(bWasEnabled);
1125 				}
1126 			}
1127 		}
1128 
1129 		// point
1130 		void VclProcessor2D::RenderPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate)
1131 		{
1132 			const std::vector< basegfx::B2DPoint >& rPositions = rPointArrayCandidate.getPositions();
1133 			const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(rPointArrayCandidate.getRGBColor()));
1134 			const Color aVCLColor(aRGBColor);
1135 
1136 			for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); aIter++)
1137 			{
1138 				const basegfx::B2DPoint aViewPosition(maCurrentTransformation * (*aIter));
1139 				const Point aPos(basegfx::fround(aViewPosition.getX()), basegfx::fround(aViewPosition.getY()));
1140 
1141 				mpOutputDevice->DrawPixel(aPos, aVCLColor);
1142 			}
1143 		}
1144 
1145 		void VclProcessor2D::RenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate)
1146 		{
1147             // #i101491# method restructured to clearly use the DrawPolyLine
1148             // calls starting from a deined line width
1149 			const attribute::LineAttribute& rLineAttribute = rPolygonStrokeCandidate.getLineAttribute();
1150 			const double fLineWidth(rLineAttribute.getWidth());
1151 			bool bDone(false);
1152 
1153 			if(basegfx::fTools::more(fLineWidth, 0.0))
1154 			{
1155 				const basegfx::B2DVector aDiscreteUnit(maCurrentTransformation * basegfx::B2DVector(fLineWidth, 0.0));
1156 				const double fDiscreteLineWidth(aDiscreteUnit.getLength());
1157 				const attribute::StrokeAttribute& rStrokeAttribute = rPolygonStrokeCandidate.getStrokeAttribute();
1158 				const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rLineAttribute.getColor()));
1159 				basegfx::B2DPolyPolygon aHairlinePolyPolygon;
1160 
1161 				mpOutputDevice->SetLineColor(Color(aHairlineColor));
1162 				mpOutputDevice->SetFillColor();
1163 
1164 				if(0.0 == rStrokeAttribute.getFullDotDashLen())
1165 				{
1166 					// no line dashing, just copy
1167 					aHairlinePolyPolygon.append(rPolygonStrokeCandidate.getB2DPolygon());
1168 				}
1169 				else
1170 				{
1171 					// else apply LineStyle
1172 					basegfx::tools::applyLineDashing(rPolygonStrokeCandidate.getB2DPolygon(),
1173 						rStrokeAttribute.getDotDashArray(),
1174 						&aHairlinePolyPolygon, 0, rStrokeAttribute.getFullDotDashLen());
1175 				}
1176 
1177 				const sal_uInt32 nCount(aHairlinePolyPolygon.count());
1178 
1179 				if(nCount)
1180 				{
1181                     const bool bAntiAliased(getOptionsDrawinglayer().IsAntiAliasing());
1182         			aHairlinePolyPolygon.transform(maCurrentTransformation);
1183 
1184                     for(sal_uInt32 a(0); a < nCount; a++)
1185 				    {
1186 					    basegfx::B2DPolygon aCandidate(aHairlinePolyPolygon.getB2DPolygon(a));
1187 
1188                         if(bAntiAliased)
1189                         {
1190 						    if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 1.0))
1191                             {
1192                                 // line in range ]0.0 .. 1.0[
1193                                 // paint as simple hairline
1194 							    mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1195 								bDone = true;
1196                             }
1197 						    else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 2.0))
1198                             {
1199                                 // line in range [1.0 .. 2.0[
1200                                 // paint as 2x2 with dynamic line distance
1201 							    basegfx::B2DHomMatrix aMat;
1202                                 const double fDistance(fDiscreteLineWidth - 1.0);
1203                                 const double fHalfDistance(fDistance * 0.5);
1204 
1205 			                    aMat.set(0, 2, -fHalfDistance);
1206 			                    aMat.set(1, 2, -fHalfDistance);
1207                                 aCandidate.transform(aMat);
1208 			                    mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1209 
1210 			                    aMat.set(0, 2, fDistance);
1211 			                    aMat.set(1, 2, 0.0);
1212                                 aCandidate.transform(aMat);
1213 			                    mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1214 
1215 			                    aMat.set(0, 2, 0.0);
1216 			                    aMat.set(1, 2, fDistance);
1217                                 aCandidate.transform(aMat);
1218 			                    mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1219 
1220 			                    aMat.set(0, 2, -fDistance);
1221 			                    aMat.set(1, 2, 0.0);
1222                                 aCandidate.transform(aMat);
1223 			                    mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1224 								bDone = true;
1225                             }
1226                             else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 3.0))
1227                             {
1228                                 // line in range [2.0 .. 3.0]
1229                                 // paint as cross in a 3x3  with dynamic line distance
1230 							    basegfx::B2DHomMatrix aMat;
1231                                 const double fDistance((fDiscreteLineWidth - 1.0) * 0.5);
1232 
1233                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1234 
1235                                 aMat.set(0, 2, -fDistance);
1236 			                    aMat.set(1, 2, 0.0);
1237                                 aCandidate.transform(aMat);
1238 			                    mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1239 
1240                                 aMat.set(0, 2, fDistance);
1241 			                    aMat.set(1, 2, -fDistance);
1242                                 aCandidate.transform(aMat);
1243 			                    mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1244 
1245                                 aMat.set(0, 2, fDistance);
1246 			                    aMat.set(1, 2, fDistance);
1247                                 aCandidate.transform(aMat);
1248 			                    mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1249 
1250                                 aMat.set(0, 2, -fDistance);
1251 			                    aMat.set(1, 2, fDistance);
1252                                 aCandidate.transform(aMat);
1253 			                    mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1254 								bDone = true;
1255                             }
1256                             else
1257                             {
1258                                 // #i101491# line width above 3.0
1259                             }
1260                         }
1261                         else
1262                         {
1263 						    if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 1.5))
1264                             {
1265 							    // line width below 1.5, draw the basic hairline polygon
1266 							    mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1267 								bDone = true;
1268                             }
1269                             else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 2.5))
1270                             {
1271 							    // line width is in range ]1.5 .. 2.5], use four hairlines
1272 							    // drawn in a square
1273 							    basegfx::B2DHomMatrix aMat;
1274 							    mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1275 
1276 							    aMat.set(0, 2, 1.0);
1277 							    aMat.set(1, 2, 0.0);
1278 							    aCandidate.transform(aMat);
1279 
1280 							    mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1281 
1282 							    aMat.set(0, 2, 0.0);
1283 							    aMat.set(1, 2, 1.0);
1284 							    aCandidate.transform(aMat);
1285 
1286 							    mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1287 
1288 							    aMat.set(0, 2, -1.0);
1289 							    aMat.set(1, 2, 0.0);
1290 							    aCandidate.transform(aMat);
1291 
1292 							    mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1293 								bDone = true;
1294                             }
1295                             else
1296                             {
1297                                 // #i101491# line width is above 2.5
1298                             }
1299                         }
1300 
1301 						if(!bDone && rPolygonStrokeCandidate.getB2DPolygon().count() > 1000)
1302 						{
1303                             // #i101491# If the polygon complexity uses more than a given amount, do
1304 							// use OuputDevice::DrawPolyLine directly; this will avoid buffering all
1305 							// decompositions in primtives (memory) and fallback to old line painting
1306 							// for very complex polygons, too
1307 		                    mpOutputDevice->DrawPolyLine(aCandidate, fDiscreteLineWidth, rLineAttribute.getLineJoin());
1308 							bDone = true;
1309 						}
1310                     }
1311                 }
1312             }
1313 
1314 			if(!bDone)
1315             {
1316                 // remeber that we enter a PolygonStrokePrimitive2D decomposition,
1317                 // used for AA thick line drawing
1318                 mnPolygonStrokePrimitive2D++;
1319 
1320                 // line width is big enough for standard filled polygon visualisation or zero
1321 				process(rPolygonStrokeCandidate.get2DDecomposition(getViewInformation2D()));
1322 
1323                 // leave PolygonStrokePrimitive2D
1324                 mnPolygonStrokePrimitive2D--;
1325             }
1326 		}
1327 
1328         void VclProcessor2D::RenderEpsPrimitive2D(const primitive2d::EpsPrimitive2D& rEpsPrimitive2D)
1329         {
1330             // The new decomposition of Metafiles made it necessary to add an Eps
1331             // primitive to handle embedded Eps data. On some devices, this can be
1332             // painted directly (mac, printer).
1333             // To be able to handle the replacement correctly, i need to handle it myself
1334             // since DrawEPS will not be able e.g. to rotate the replacement. To be able
1335             // to do that, i added a boolean return to OutputDevice::DrawEPS(..)
1336             // to know when EPS was handled directly already.
1337 			basegfx::B2DRange aRange(0.0, 0.0, 1.0, 1.0);
1338             aRange.transform(maCurrentTransformation * rEpsPrimitive2D.getEpsTransform());
1339 
1340             if(!aRange.isEmpty())
1341             {
1342                 const Rectangle aRectangle(
1343 				    (sal_Int32)floor(aRange.getMinX()), (sal_Int32)floor(aRange.getMinY()),
1344 				    (sal_Int32)ceil(aRange.getMaxX()), (sal_Int32)ceil(aRange.getMaxY()));
1345 
1346                 if(!aRectangle.IsEmpty())
1347                 {
1348                     // try to paint EPS directly without fallback visualisation
1349                     const bool bEPSPaintedDirectly(mpOutputDevice->DrawEPS(
1350                         aRectangle.TopLeft(),
1351                         aRectangle.GetSize(),
1352                         rEpsPrimitive2D.getGfxLink(),
1353                         0));
1354 
1355                     if(!bEPSPaintedDirectly)
1356                     {
1357                         // use the decomposition which will correctly handle the
1358                         // fallback visualisation using full transformation (e.g. rotation)
1359         				process(rEpsPrimitive2D.get2DDecomposition(getViewInformation2D()));
1360                     }
1361                 }
1362             }
1363         }
1364 
1365         void VclProcessor2D::RenderSvgLinearAtomPrimitive2D(const primitive2d::SvgLinearAtomPrimitive2D& rCandidate)
1366         {
1367             const double fDelta(rCandidate.getOffsetB() - rCandidate.getOffsetA());
1368 
1369             if(basegfx::fTools::more(fDelta, 0.0))
1370             {
1371                 const basegfx::BColor aColorA(maBColorModifierStack.getModifiedColor(rCandidate.getColorA()));
1372                 const basegfx::BColor aColorB(maBColorModifierStack.getModifiedColor(rCandidate.getColorB()));
1373                 const double fDiscreteUnit((getViewInformation2D().getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength());
1374 
1375                 // use color distance and discrete lengths to calculate step count
1376                 const sal_uInt32 nSteps(calculateStepsForSvgGradient(aColorA, aColorB, fDelta, fDiscreteUnit));
1377 
1378                 // prepare loop and polygon
1379                 double fStart(0.0);
1380                 double fStep(fDelta / nSteps);
1381                 const basegfx::B2DPolygon aPolygon(
1382                     basegfx::tools::createPolygonFromRect(
1383                         basegfx::B2DRange(
1384                             rCandidate.getOffsetA() - fDiscreteUnit,
1385                             0.0,
1386                             rCandidate.getOffsetA() + fStep + fDiscreteUnit,
1387                             1.0)));
1388 
1389                 // switch off line painting
1390                 mpOutputDevice->SetLineColor();
1391 
1392                 // loop and paint
1393                 for(sal_uInt32 a(0); a < nSteps; a++, fStart += fStep)
1394                 {
1395                     basegfx::B2DPolygon aNew(aPolygon);
1396 
1397                     aNew.transform(maCurrentTransformation * basegfx::tools::createTranslateB2DHomMatrix(fStart, 0.0));
1398                     mpOutputDevice->SetFillColor(Color(basegfx::interpolate(aColorA, aColorB, fStart/fDelta)));
1399                     mpOutputDevice->DrawPolyPolygon(basegfx::B2DPolyPolygon(aNew));
1400                 }
1401             }
1402         }
1403 
1404         void VclProcessor2D::RenderSvgRadialAtomPrimitive2D(const primitive2d::SvgRadialAtomPrimitive2D& rCandidate)
1405         {
1406             const double fDeltaScale(rCandidate.getScaleB() - rCandidate.getScaleA());
1407 
1408             if(basegfx::fTools::more(fDeltaScale, 0.0))
1409             {
1410                 const basegfx::BColor aColorA(maBColorModifierStack.getModifiedColor(rCandidate.getColorA()));
1411                 const basegfx::BColor aColorB(maBColorModifierStack.getModifiedColor(rCandidate.getColorB()));
1412                 const double fDiscreteUnit((getViewInformation2D().getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength());
1413 
1414                 // use color distance and discrete lengths to calculate step count
1415                 const sal_uInt32 nSteps(calculateStepsForSvgGradient(aColorA, aColorB, fDeltaScale, fDiscreteUnit));
1416 
1417                 // switch off line painting
1418                 mpOutputDevice->SetLineColor();
1419 
1420                 // prepare loop (outside to inside)
1421                 double fEndScale(rCandidate.getScaleB());
1422                 double fStepScale(fDeltaScale / nSteps);
1423 
1424                 for(sal_uInt32 a(0); a < nSteps; a++, fEndScale -= fStepScale)
1425                 {
1426                     const double fUnitScale(fEndScale/fDeltaScale);
1427                     basegfx::B2DHomMatrix aTransform;
1428 
1429                     if(rCandidate.isTranslateSet())
1430                     {
1431                         const basegfx::B2DVector aTranslate(
1432                             basegfx::interpolate(
1433                                 rCandidate.getTranslateA(),
1434                                 rCandidate.getTranslateB(),
1435                                 fUnitScale));
1436 
1437                         aTransform = basegfx::tools::createScaleTranslateB2DHomMatrix(
1438                             fEndScale,
1439                             fEndScale,
1440                             aTranslate.getX(),
1441                             aTranslate.getY());
1442                     }
1443                     else
1444                     {
1445                         aTransform = basegfx::tools::createScaleB2DHomMatrix(
1446                             fEndScale,
1447                             fEndScale);
1448                     }
1449 
1450                     basegfx::B2DPolygon aNew(basegfx::tools::createPolygonFromUnitCircle());
1451 
1452                     aNew.transform(maCurrentTransformation * aTransform);
1453                     mpOutputDevice->SetFillColor(Color(basegfx::interpolate(aColorA, aColorB, fUnitScale)));
1454                     mpOutputDevice->DrawPolyPolygon(basegfx::B2DPolyPolygon(aNew));
1455                 }
1456             }
1457         }
1458 
1459 		void VclProcessor2D::adaptLineToFillDrawMode() const
1460 		{
1461 			const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
1462 
1463 			if(nOriginalDrawMode & (DRAWMODE_BLACKLINE|DRAWMODE_GRAYLINE|DRAWMODE_GHOSTEDLINE|DRAWMODE_WHITELINE|DRAWMODE_SETTINGSLINE))
1464 			{
1465 				sal_uInt32 nAdaptedDrawMode(nOriginalDrawMode);
1466 
1467 				if(nOriginalDrawMode & DRAWMODE_BLACKLINE)
1468 				{
1469 					nAdaptedDrawMode |= DRAWMODE_BLACKFILL;
1470 				}
1471 				else
1472 				{
1473 					nAdaptedDrawMode &= ~DRAWMODE_BLACKFILL;
1474 				}
1475 
1476 				if(nOriginalDrawMode & DRAWMODE_GRAYLINE)
1477 				{
1478 					nAdaptedDrawMode |= DRAWMODE_GRAYFILL;
1479 				}
1480 				else
1481 				{
1482 					nAdaptedDrawMode &= ~DRAWMODE_GRAYFILL;
1483 				}
1484 
1485 				if(nOriginalDrawMode & DRAWMODE_GHOSTEDLINE)
1486 				{
1487 					nAdaptedDrawMode |= DRAWMODE_GHOSTEDFILL;
1488 				}
1489 				else
1490 				{
1491 					nAdaptedDrawMode &= ~DRAWMODE_GHOSTEDFILL;
1492 				}
1493 
1494 				if(nOriginalDrawMode & DRAWMODE_WHITELINE)
1495 				{
1496 					nAdaptedDrawMode |= DRAWMODE_WHITEFILL;
1497 				}
1498 				else
1499 				{
1500 					nAdaptedDrawMode &= ~DRAWMODE_WHITEFILL;
1501 				}
1502 
1503 				if(nOriginalDrawMode & DRAWMODE_SETTINGSLINE)
1504 				{
1505 					nAdaptedDrawMode |= DRAWMODE_SETTINGSFILL;
1506 				}
1507 				else
1508 				{
1509 					nAdaptedDrawMode &= ~DRAWMODE_SETTINGSFILL;
1510 				}
1511 
1512 				mpOutputDevice->SetDrawMode(nAdaptedDrawMode);
1513 			}
1514 		}
1515 
1516 		void VclProcessor2D::adaptTextToFillDrawMode() const
1517 		{
1518 			const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
1519 			if(nOriginalDrawMode & (DRAWMODE_BLACKTEXT|DRAWMODE_GRAYTEXT|DRAWMODE_GHOSTEDTEXT|DRAWMODE_WHITETEXT|DRAWMODE_SETTINGSTEXT))
1520 			{
1521 				sal_uInt32 nAdaptedDrawMode(nOriginalDrawMode);
1522 
1523 				if(nOriginalDrawMode & DRAWMODE_BLACKTEXT)
1524 				{
1525 					nAdaptedDrawMode |= DRAWMODE_BLACKFILL;
1526 				}
1527 				else
1528 				{
1529 					nAdaptedDrawMode &= ~DRAWMODE_BLACKFILL;
1530 				}
1531 
1532 				if(nOriginalDrawMode & DRAWMODE_GRAYTEXT)
1533 				{
1534 					nAdaptedDrawMode |= DRAWMODE_GRAYFILL;
1535 				}
1536 				else
1537 				{
1538 					nAdaptedDrawMode &= ~DRAWMODE_GRAYFILL;
1539 				}
1540 
1541 				if(nOriginalDrawMode & DRAWMODE_GHOSTEDTEXT)
1542 				{
1543 					nAdaptedDrawMode |= DRAWMODE_GHOSTEDFILL;
1544 				}
1545 				else
1546 				{
1547 					nAdaptedDrawMode &= ~DRAWMODE_GHOSTEDFILL;
1548 				}
1549 
1550 				if(nOriginalDrawMode & DRAWMODE_WHITETEXT)
1551 				{
1552 					nAdaptedDrawMode |= DRAWMODE_WHITEFILL;
1553 				}
1554 				else
1555 				{
1556 					nAdaptedDrawMode &= ~DRAWMODE_WHITEFILL;
1557 				}
1558 
1559 				if(nOriginalDrawMode & DRAWMODE_SETTINGSTEXT)
1560 				{
1561 					nAdaptedDrawMode |= DRAWMODE_SETTINGSFILL;
1562 				}
1563 				else
1564 				{
1565 					nAdaptedDrawMode &= ~DRAWMODE_SETTINGSFILL;
1566 				}
1567 
1568 				mpOutputDevice->SetDrawMode(nAdaptedDrawMode);
1569 			}
1570 		}
1571 
1572 		//////////////////////////////////////////////////////////////////////////////
1573 		// process support
1574 
1575 		VclProcessor2D::VclProcessor2D(
1576 			const geometry::ViewInformation2D& rViewInformation,
1577 			OutputDevice& rOutDev)
1578 		:	BaseProcessor2D(rViewInformation),
1579 			mpOutputDevice(&rOutDev),
1580 			maBColorModifierStack(),
1581 			maCurrentTransformation(),
1582 			maDrawinglayerOpt(),
1583             mnPolygonStrokePrimitive2D(0)
1584 		{
1585             // set digit language, derived from SvtCTLOptions to have the correct
1586             // number display for arabic/hindi numerals
1587             const SvtCTLOptions aSvtCTLOptions;
1588             LanguageType eLang(LANGUAGE_SYSTEM);
1589 
1590             if(SvtCTLOptions::NUMERALS_HINDI == aSvtCTLOptions.GetCTLTextNumerals())
1591             {
1592                 eLang = LANGUAGE_ARABIC_SAUDI_ARABIA;
1593             }
1594             else if(SvtCTLOptions::NUMERALS_ARABIC == aSvtCTLOptions.GetCTLTextNumerals())
1595             {
1596                 eLang = LANGUAGE_ENGLISH;
1597             }
1598             else
1599             {
1600                 eLang = (LanguageType)Application::GetSettings().GetLanguage();
1601             }
1602 
1603             rOutDev.SetDigitLanguage(eLang);
1604 		}
1605 
1606 		VclProcessor2D::~VclProcessor2D()
1607 		{
1608 		}
1609 	} // end of namespace processor2d
1610 } // end of namespace drawinglayer
1611 
1612 //////////////////////////////////////////////////////////////////////////////
1613 // eof
1614