xref: /trunk/main/drawinglayer/source/processor2d/vclprocessor2d.cxx (revision 96fc4b33382e706b7361f08aba6c96207eedf10a)
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                     static bool bSimple = false; // allow testing simple paint in debugger
609 
610                     impDrawGradientToOutDev(
611                         *mpOutputDevice, aLocalPolyPolygon, rGradient.getStyle(), rGradient.getSteps(),
612                         aStartColor, aEndColor, rGradient.getBorder(),
613                         rGradient.getAngle(), rGradient.getOffsetX(), rGradient.getOffsetY(), bSimple);
614                 }
615             }
616         }
617 
618         // direct draw of bitmap
619         void VclProcessor2D::RenderPolyPolygonBitmapPrimitive2D(const primitive2d::PolyPolygonBitmapPrimitive2D& rPolygonCandidate)
620         {
621             bool bDone(false);
622             const basegfx::B2DPolyPolygon& rPolyPolygon = rPolygonCandidate.getB2DPolyPolygon();
623 
624             if(rPolyPolygon.count())
625             {
626                 const attribute::FillBitmapAttribute& rFillBitmapAttribute = rPolygonCandidate.getFillBitmap();
627                 const BitmapEx& rBitmapEx = rFillBitmapAttribute.getBitmapEx();
628 
629                 if(rBitmapEx.IsEmpty())
630                 {
631                     // empty bitmap, done
632                     bDone = true;
633                 }
634                 else
635                 {
636                     // try to catch cases where the bitmap will be color-modified to a single
637                     // color (e.g. shadow). This would NOT be optimizable with an transparence channel
638                     // at the Bitmap which we do not have here. When this should change, this
639                     // optimization has to be reworked accordingly.
640                     const sal_uInt32 nBColorModifierStackCount(maBColorModifierStack.count());
641 
642                     if(nBColorModifierStackCount)
643                     {
644                         const basegfx::BColorModifier& rTopmostModifier = maBColorModifierStack.getBColorModifier(nBColorModifierStackCount - 1);
645 
646                         if(basegfx::BCOLORMODIFYMODE_REPLACE == rTopmostModifier.getMode())
647                         {
648                             // the bitmap fill is in unified color, so we can replace it with
649                             // a single polygon fill. The form of the fill depends on tiling
650                             if(rFillBitmapAttribute.getTiling())
651                             {
652                                 // with tiling, fill the whole PolyPolygon with the modifier color
653                                 basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolyPolygon);
654 
655                                 aLocalPolyPolygon.transform(maCurrentTransformation);
656                                 mpOutputDevice->SetLineColor();
657                                 mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor()));
658                                 mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
659                             }
660                             else
661                             {
662                                 // without tiling, only the area common to the bitmap tile and the
663                                 // PolyPolygon is filled. Create the bitmap tile area in object
664                                 // coordinates. For this, the object transformation needs to be created
665                                 // from the already scaled PolyPolygon. The tile area in object
666                                 // coordinates wil always be non-rotated, so it's not necessary to
667                                 // work with a polygon here
668                                 basegfx::B2DRange aTileRange(rFillBitmapAttribute.getTopLeft(),
669                                     rFillBitmapAttribute.getTopLeft() + rFillBitmapAttribute.getSize());
670                                 const basegfx::B2DRange aPolyPolygonRange(rPolyPolygon.getB2DRange());
671                                 basegfx::B2DHomMatrix aNewObjectTransform;
672 
673                                 aNewObjectTransform.set(0, 0, aPolyPolygonRange.getWidth());
674                                 aNewObjectTransform.set(1, 1, aPolyPolygonRange.getHeight());
675                                 aNewObjectTransform.set(0, 2, aPolyPolygonRange.getMinX());
676                                 aNewObjectTransform.set(1, 2, aPolyPolygonRange.getMinY());
677                                 aTileRange.transform(aNewObjectTransform);
678 
679                                 // now clip the object polyPolygon against the tile range
680                                 // to get the common area (OR)
681                                 basegfx::B2DPolyPolygon aTarget = basegfx::tools::clipPolyPolygonOnRange(rPolyPolygon, aTileRange, true, false);
682 
683                                 if(aTarget.count())
684                                 {
685                                     aTarget.transform(maCurrentTransformation);
686                                     mpOutputDevice->SetLineColor();
687                                     mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor()));
688                                     mpOutputDevice->DrawPolyPolygon(aTarget);
689                                 }
690                             }
691 
692                             bDone = true;
693                         }
694                     }
695                 }
696             }
697             else
698             {
699                 // empty polyPolygon, done
700                 bDone = true;
701             }
702 
703             if(!bDone)
704             {
705                 // use default decomposition
706                 process(rPolygonCandidate.get2DDecomposition(getViewInformation2D()));
707             }
708         }
709 
710         // direct draw of PolyPolygon with color
711         void VclProcessor2D::RenderPolyPolygonColorPrimitive2D(const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate)
712         {
713             const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor()));
714             mpOutputDevice->SetFillColor(Color(aPolygonColor));
715             mpOutputDevice->SetLineColor();
716 
717             basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
718             aLocalPolyPolygon.transform(maCurrentTransformation);
719 
720             static bool bCheckTrapezoidDecomposition(false);
721             static bool bShowOutlinesThere(false);
722             if(bCheckTrapezoidDecomposition)
723             {
724                 // clip against discrete ViewPort
725                 const basegfx::B2DRange& rDiscreteViewport = getViewInformation2D().getDiscreteViewport();
726                 aLocalPolyPolygon = basegfx::tools::clipPolyPolygonOnRange(
727                     aLocalPolyPolygon, rDiscreteViewport, true, false);
728 
729                 if(aLocalPolyPolygon.count())
730                 {
731                     // subdivide
732                     aLocalPolyPolygon = basegfx::tools::adaptiveSubdivideByDistance(
733                         aLocalPolyPolygon, 0.5);
734 
735                     // trapezoidize
736                     basegfx::B2DTrapezoidVector aB2DTrapezoidVector;
737                     basegfx::tools::trapezoidSubdivide(aB2DTrapezoidVector, aLocalPolyPolygon);
738 
739                     const sal_uInt32 nCount(aB2DTrapezoidVector.size());
740 
741                     if(nCount)
742                     {
743                         basegfx::BColor aInvPolygonColor(aPolygonColor);
744                         aInvPolygonColor.invert();
745 
746                         for(sal_uInt32 a(0); a < nCount; a++)
747                         {
748                             const basegfx::B2DPolygon aTempPolygon(aB2DTrapezoidVector[a].getB2DPolygon());
749 
750                             if(bShowOutlinesThere)
751                             {
752                                 mpOutputDevice->SetFillColor(Color(aPolygonColor));
753                                 mpOutputDevice->SetLineColor();
754                             }
755 
756                             mpOutputDevice->DrawPolygon(aTempPolygon);
757 
758                             if(bShowOutlinesThere)
759                             {
760                                 mpOutputDevice->SetFillColor();
761                                 mpOutputDevice->SetLineColor(Color(aInvPolygonColor));
762                                 mpOutputDevice->DrawPolyLine(aTempPolygon, 0.0);
763                             }
764                         }
765                     }
766                 }
767             }
768             else
769             {
770                 mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
771 
772                 if(mnPolygonStrokePrimitive2D
773                     && getOptionsDrawinglayer().IsAntiAliasing()
774                     && (mpOutputDevice->GetAntialiasing() & ANTIALIASING_ENABLE_B2DDRAW))
775                 {
776                     // when AA is on and this filled polygons are the result of stroked line geometry,
777                     // draw the geometry once extra as lines to avoid AA 'gaps' between partial polygons
778                     mpOutputDevice->SetFillColor();
779                     mpOutputDevice->SetLineColor(Color(aPolygonColor));
780                     const sal_uInt32 nCount(aLocalPolyPolygon.count());
781 
782                     for(sal_uInt32 a(0); a < nCount; a++)
783                     {
784                         mpOutputDevice->DrawPolyLine(aLocalPolyPolygon.getB2DPolygon(a), 0.0);
785                     }
786                 }
787             }
788         }
789 
790         // direct draw of MetaFile
791         void VclProcessor2D::RenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rMetaCandidate)
792         {
793             // decompose matrix to check for shear, rotate and mirroring
794             basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rMetaCandidate.getTransform());
795             basegfx::B2DVector aScale, aTranslate;
796             double fRotate, fShearX;
797             aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
798 
799             if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
800             {
801                 // #i102175# handle special case: If scale is negative in (x,y) (3rd quadrant), it can
802                 // be expressed as rotation by PI. This needs to be done for Metafiles since
803                 // these can be rotated, but not really mirrored
804                 aScale = basegfx::absolute(aScale);
805                 fRotate += F_PI;
806             }
807 
808             // get BoundRect
809             basegfx::B2DRange aOutlineRange(rMetaCandidate.getB2DRange(getViewInformation2D()));
810             aOutlineRange.transform(maCurrentTransformation);
811 
812             // Due to the integer MapModes used from VCL aind inside MetaFiles errors of up to three
813             // pixels in size may happen. As long as there is no better way (e.g. convert the MetaFile
814             // to primitives) it is necessary to reduce maximum pixel size by 1 in X and Y and to use
815             // the inner pixel bounds accordingly (ceil resp. floor). This will also be done for logic
816             // units e.g. when creating a new MetaFile, but since much huger value ranges are used
817             // there typically will be okay for this compromize.
818             Rectangle aDestRectView(
819                 // !!CAUTION!! Here, ceil and floor are exchanged BY PURPOSE, do NOT copy when
820                 // looking for a standard conversion to rectangle (!)
821                 (sal_Int32)ceil(aOutlineRange.getMinX()), (sal_Int32)ceil(aOutlineRange.getMinY()),
822                 (sal_Int32)floor(aOutlineRange.getMaxX()), (sal_Int32)floor(aOutlineRange.getMaxY()));
823 
824             // get metafile (copy it)
825             GDIMetaFile aMetaFile;
826 
827             if(maBColorModifierStack.count())
828             {
829                 const basegfx::BColor aRGBBaseColor(0, 0, 0);
830                 const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(aRGBBaseColor));
831                 aMetaFile = rMetaCandidate.getMetaFile().GetMonochromeMtf(Color(aRGBColor));
832             }
833             else
834             {
835                 aMetaFile = rMetaCandidate.getMetaFile();
836             }
837 
838             // rotation
839             if(!basegfx::fTools::equalZero(fRotate))
840             {
841                 // #i103530#
842                 // MetaFile::Rotate has no input parameter check, so the parameter needs to be
843                 // well-aligned to the old range [0..3600] 10th degrees with inverse orientation
844                 sal_Int16 nRotation((sal_Int16)((fRotate / F_PI180) * -10.0));
845 
846                 while(nRotation < 0)
847                     nRotation += 3600;
848 
849                 while(nRotation >= 3600)
850                     nRotation -= 3600;
851 
852                 aMetaFile.Rotate(nRotation);
853             }
854 
855             // Prepare target output size
856             Size aDestSize(aDestRectView.GetSize());
857 
858             if(aDestSize.getWidth() && aDestSize.getHeight())
859             {
860                 // Get preferred Metafile output size. When it's very equal to the output size, it's probably
861                 // a rounding error somewhere, so correct it to get a 1:1 output without single pixel scalings
862                 // of the Metafile (esp. for contaned Bitmaps, e.g 3D charts)
863                 const Size aPrefSize(mpOutputDevice->LogicToPixel(aMetaFile.GetPrefSize(), aMetaFile.GetPrefMapMode()));
864 
865                 if(aPrefSize.getWidth() && (aPrefSize.getWidth() - 1 == aDestSize.getWidth() || aPrefSize.getWidth() + 1 == aDestSize.getWidth()))
866                 {
867                     aDestSize.setWidth(aPrefSize.getWidth());
868                 }
869 
870                 if(aPrefSize.getHeight() && (aPrefSize.getHeight() - 1 == aDestSize.getHeight() || aPrefSize.getHeight() + 1 == aDestSize.getHeight()))
871                 {
872                     aDestSize.setHeight(aPrefSize.getHeight());
873                 }
874 
875                 // paint it
876                 aMetaFile.WindStart();
877                 aMetaFile.Play(mpOutputDevice, aDestRectView.TopLeft(), aDestSize);
878             }
879         }
880 
881         // mask group. Force output to VDev and create mask from given mask
882         void VclProcessor2D::RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate)
883         {
884             if(rMaskCandidate.getChildren().hasElements())
885             {
886                 basegfx::B2DPolyPolygon aMask(rMaskCandidate.getMask());
887 
888                 if(aMask.count())
889                 {
890                     aMask.transform(maCurrentTransformation);
891                     const basegfx::B2DRange aRange(basegfx::tools::getRange(aMask));
892                     impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
893 
894                     if(aBufferDevice.isVisible())
895                     {
896                         // remember last OutDev and set to content
897                         OutputDevice* pLastOutputDevice = mpOutputDevice;
898                         mpOutputDevice = &aBufferDevice.getContent();
899 
900                         // paint to it
901                         process(rMaskCandidate.getChildren());
902 
903                         // back to old OutDev
904                         mpOutputDevice = pLastOutputDevice;
905 
906                         // draw mask
907                         if(getOptionsDrawinglayer().IsAntiAliasing())
908                         {
909                             // with AA, use 8bit AlphaMask to get nice borders
910                             VirtualDevice& rTransparence = aBufferDevice.getTransparence();
911                             rTransparence.SetLineColor();
912                             rTransparence.SetFillColor(COL_BLACK);
913                             rTransparence.DrawPolyPolygon(aMask);
914 
915                             // dump buffer to outdev
916                             aBufferDevice.paint();
917                         }
918                         else
919                         {
920                             // No AA, use 1bit mask
921                             VirtualDevice& rMask = aBufferDevice.getMask();
922                             rMask.SetLineColor();
923                             rMask.SetFillColor(COL_BLACK);
924                             rMask.DrawPolyPolygon(aMask);
925 
926                             // dump buffer to outdev
927                             aBufferDevice.paint();
928                         }
929                     }
930                 }
931             }
932         }
933 
934         // modified color group. Force output to unified color.
935         void VclProcessor2D::RenderModifiedColorPrimitive2D(const primitive2d::ModifiedColorPrimitive2D& rModifiedCandidate)
936         {
937             if(rModifiedCandidate.getChildren().hasElements())
938             {
939                 maBColorModifierStack.push(rModifiedCandidate.getColorModifier());
940                 process(rModifiedCandidate.getChildren());
941                 maBColorModifierStack.pop();
942             }
943         }
944 
945         // unified sub-transparence. Draw to VDev first.
946         void VclProcessor2D::RenderUnifiedTransparencePrimitive2D(const primitive2d::UnifiedTransparencePrimitive2D& rTransCandidate)
947         {
948             static bool bForceToDecomposition(false);
949 
950             if(rTransCandidate.getChildren().hasElements())
951             {
952                 if(bForceToDecomposition)
953                 {
954                     // use decomposition
955                     process(rTransCandidate.get2DDecomposition(getViewInformation2D()));
956                 }
957                 else
958                 {
959                     if(0.0 == rTransCandidate.getTransparence())
960                     {
961                         // no transparence used, so just use the content
962                         process(rTransCandidate.getChildren());
963                     }
964                     else if(rTransCandidate.getTransparence() > 0.0 && rTransCandidate.getTransparence() < 1.0)
965                     {
966                         // transparence is in visible range
967                         basegfx::B2DRange aRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rTransCandidate.getChildren(), getViewInformation2D()));
968                         aRange.transform(maCurrentTransformation);
969                         impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
970 
971                         if(aBufferDevice.isVisible())
972                         {
973                             // remember last OutDev and set to content
974                             OutputDevice* pLastOutputDevice = mpOutputDevice;
975                             mpOutputDevice = &aBufferDevice.getContent();
976 
977                             // paint content to it
978                             process(rTransCandidate.getChildren());
979 
980                             // back to old OutDev
981                             mpOutputDevice = pLastOutputDevice;
982 
983                             // dump buffer to outdev using given transparence
984                             aBufferDevice.paint(rTransCandidate.getTransparence());
985                         }
986                     }
987                 }
988             }
989         }
990 
991         // sub-transparence group. Draw to VDev first.
992         void VclProcessor2D::RenderTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransCandidate)
993         {
994             if(rTransCandidate.getChildren().hasElements())
995             {
996                 basegfx::B2DRange aRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rTransCandidate.getChildren(), getViewInformation2D()));
997                 aRange.transform(maCurrentTransformation);
998                 impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
999 
1000                 if(aBufferDevice.isVisible())
1001                 {
1002                     // remember last OutDev and set to content
1003                     OutputDevice* pLastOutputDevice = mpOutputDevice;
1004                     mpOutputDevice = &aBufferDevice.getContent();
1005 
1006                     // paint content to it
1007                     process(rTransCandidate.getChildren());
1008 
1009                     // set to mask
1010                     mpOutputDevice = &aBufferDevice.getTransparence();
1011 
1012                     // when painting transparence masks, reset the color stack
1013                     basegfx::BColorModifierStack aLastBColorModifierStack(maBColorModifierStack);
1014                     maBColorModifierStack = basegfx::BColorModifierStack();
1015 
1016                     // paint mask to it (always with transparence intensities, evtl. with AA)
1017                     process(rTransCandidate.getTransparence());
1018 
1019                     // back to old color stack
1020                     maBColorModifierStack = aLastBColorModifierStack;
1021 
1022                     // back to old OutDev
1023                     mpOutputDevice = pLastOutputDevice;
1024 
1025                     // dump buffer to outdev
1026                     aBufferDevice.paint();
1027                 }
1028             }
1029         }
1030 
1031         // transform group.
1032         void VclProcessor2D::RenderTransformPrimitive2D(const primitive2d::TransformPrimitive2D& rTransformCandidate)
1033         {
1034             // remember current transformation and ViewInformation
1035             const basegfx::B2DHomMatrix aLastCurrentTransformation(maCurrentTransformation);
1036             const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
1037 
1038             // create new transformations for CurrentTransformation
1039             // and for local ViewInformation2D
1040             maCurrentTransformation = maCurrentTransformation * rTransformCandidate.getTransformation();
1041             const geometry::ViewInformation2D aViewInformation2D(
1042                 getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(),
1043                 getViewInformation2D().getViewTransformation(),
1044                 getViewInformation2D().getViewport(),
1045                 getViewInformation2D().getVisualizedPage(),
1046                 getViewInformation2D().getViewTime(),
1047                 getViewInformation2D().getExtendedInformationSequence());
1048             updateViewInformation(aViewInformation2D);
1049 
1050             // proccess content
1051             process(rTransformCandidate.getChildren());
1052 
1053             // restore transformations
1054             maCurrentTransformation = aLastCurrentTransformation;
1055             updateViewInformation(aLastViewInformation2D);
1056         }
1057 
1058         // new XDrawPage for ViewInformation2D
1059         void VclProcessor2D::RenderPagePreviewPrimitive2D(const primitive2d::PagePreviewPrimitive2D& rPagePreviewCandidate)
1060         {
1061             // remember current transformation and ViewInformation
1062             const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
1063 
1064             // create new local ViewInformation2D
1065             const geometry::ViewInformation2D aViewInformation2D(
1066                 getViewInformation2D().getObjectTransformation(),
1067                 getViewInformation2D().getViewTransformation(),
1068                 getViewInformation2D().getViewport(),
1069                 rPagePreviewCandidate.getXDrawPage(),
1070                 getViewInformation2D().getViewTime(),
1071                 getViewInformation2D().getExtendedInformationSequence());
1072             updateViewInformation(aViewInformation2D);
1073 
1074             // proccess decomposed content
1075             process(rPagePreviewCandidate.get2DDecomposition(getViewInformation2D()));
1076 
1077             // restore transformations
1078             updateViewInformation(aLastViewInformation2D);
1079         }
1080 
1081         // marker
1082         void VclProcessor2D::RenderMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkArrayCandidate)
1083         {
1084             static bool bCheckCompleteMarkerDecompose(false);
1085             if(bCheckCompleteMarkerDecompose)
1086             {
1087                 process(rMarkArrayCandidate.get2DDecomposition(getViewInformation2D()));
1088                 return;
1089             }
1090 
1091             // get data
1092             const std::vector< basegfx::B2DPoint >& rPositions = rMarkArrayCandidate.getPositions();
1093             const sal_uInt32 nCount(rPositions.size());
1094 
1095             if(nCount && !rMarkArrayCandidate.getMarker().IsEmpty())
1096             {
1097                 // get pixel size
1098                 const BitmapEx& rMarker(rMarkArrayCandidate.getMarker());
1099                 const Size aBitmapSize(rMarker.GetSizePixel());
1100 
1101                 if(aBitmapSize.Width() && aBitmapSize.Height())
1102                 {
1103                     // get discrete half size
1104                     const basegfx::B2DVector aDiscreteHalfSize(
1105                         (aBitmapSize.getWidth() - 1.0) * 0.5,
1106                         (aBitmapSize.getHeight() - 1.0) * 0.5);
1107                     const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled());
1108 
1109                     // do not forget evtl. moved origin in target device MapMode when
1110                     // switching it off; it would be missing and lead to wrong positions.
1111                     // All his could be done using logic sizes and coordinates, too, but
1112                     // we want a 1:1 bitmap rendering here, so it's more safe and faster
1113                     // to work with switching off MapMode usage completely.
1114                     const Point aOrigin(mpOutputDevice->GetMapMode().GetOrigin());
1115 
1116                     mpOutputDevice->EnableMapMode(false);
1117 
1118                     for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); aIter++)
1119                     {
1120                         const basegfx::B2DPoint aDiscreteTopLeft((maCurrentTransformation * (*aIter)) - aDiscreteHalfSize);
1121                         const Point aDiscretePoint(basegfx::fround(aDiscreteTopLeft.getX()), basegfx::fround(aDiscreteTopLeft.getY()));
1122 
1123                         mpOutputDevice->DrawBitmapEx(aDiscretePoint + aOrigin, rMarker);
1124                     }
1125 
1126                     mpOutputDevice->EnableMapMode(bWasEnabled);
1127                 }
1128             }
1129         }
1130 
1131         // point
1132         void VclProcessor2D::RenderPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate)
1133         {
1134             const std::vector< basegfx::B2DPoint >& rPositions = rPointArrayCandidate.getPositions();
1135             const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(rPointArrayCandidate.getRGBColor()));
1136             const Color aVCLColor(aRGBColor);
1137 
1138             for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); aIter++)
1139             {
1140                 const basegfx::B2DPoint aViewPosition(maCurrentTransformation * (*aIter));
1141                 const Point aPos(basegfx::fround(aViewPosition.getX()), basegfx::fround(aViewPosition.getY()));
1142 
1143                 mpOutputDevice->DrawPixel(aPos, aVCLColor);
1144             }
1145         }
1146 
1147         void VclProcessor2D::RenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate)
1148         {
1149             // #i101491# method restructured to clearly use the DrawPolyLine
1150             // calls starting from a deined line width
1151             const attribute::LineAttribute& rLineAttribute = rPolygonStrokeCandidate.getLineAttribute();
1152             const double fLineWidth(rLineAttribute.getWidth());
1153             bool bDone(false);
1154 
1155             if(basegfx::fTools::more(fLineWidth, 0.0))
1156             {
1157                 const basegfx::B2DVector aDiscreteUnit(maCurrentTransformation * basegfx::B2DVector(fLineWidth, 0.0));
1158                 const double fDiscreteLineWidth(aDiscreteUnit.getLength());
1159                 const attribute::StrokeAttribute& rStrokeAttribute = rPolygonStrokeCandidate.getStrokeAttribute();
1160                 const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rLineAttribute.getColor()));
1161                 basegfx::B2DPolyPolygon aHairlinePolyPolygon;
1162 
1163                 mpOutputDevice->SetLineColor(Color(aHairlineColor));
1164                 mpOutputDevice->SetFillColor();
1165 
1166                 if(0.0 == rStrokeAttribute.getFullDotDashLen())
1167                 {
1168                     // no line dashing, just copy
1169                     aHairlinePolyPolygon.append(rPolygonStrokeCandidate.getB2DPolygon());
1170                 }
1171                 else
1172                 {
1173                     // else apply LineStyle
1174                     basegfx::tools::applyLineDashing(rPolygonStrokeCandidate.getB2DPolygon(),
1175                         rStrokeAttribute.getDotDashArray(),
1176                         &aHairlinePolyPolygon, 0, rStrokeAttribute.getFullDotDashLen());
1177                 }
1178 
1179                 const sal_uInt32 nCount(aHairlinePolyPolygon.count());
1180 
1181                 if(nCount)
1182                 {
1183                     const bool bAntiAliased(getOptionsDrawinglayer().IsAntiAliasing());
1184                     aHairlinePolyPolygon.transform(maCurrentTransformation);
1185 
1186                     if(bAntiAliased)
1187                     {
1188                         if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 1.0))
1189                         {
1190                             // line in range ]0.0 .. 1.0[
1191                             // paint as simple hairline
1192                             for(sal_uInt32 a(0); a < nCount; a++)
1193                             {
1194                                 mpOutputDevice->DrawPolyLine(aHairlinePolyPolygon.getB2DPolygon(a), 0.0);
1195                             }
1196 
1197                             bDone = true;
1198                         }
1199                         else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 2.0))
1200                         {
1201                             // line in range [1.0 .. 2.0[
1202                             // paint as 2x2 with dynamic line distance
1203                             basegfx::B2DHomMatrix aMat;
1204                             const double fDistance(fDiscreteLineWidth - 1.0);
1205                             const double fHalfDistance(fDistance * 0.5);
1206 
1207                             for(sal_uInt32 a(0); a < nCount; a++)
1208                             {
1209                                 basegfx::B2DPolygon aCandidate(aHairlinePolyPolygon.getB2DPolygon(a));
1210 
1211                                 aMat.set(0, 2, -fHalfDistance);
1212                                 aMat.set(1, 2, -fHalfDistance);
1213                                 aCandidate.transform(aMat);
1214                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1215 
1216                                 aMat.set(0, 2, fDistance);
1217                                 aMat.set(1, 2, 0.0);
1218                                 aCandidate.transform(aMat);
1219                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1220 
1221                                 aMat.set(0, 2, 0.0);
1222                                 aMat.set(1, 2, fDistance);
1223                                 aCandidate.transform(aMat);
1224                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1225 
1226                                 aMat.set(0, 2, -fDistance);
1227                                 aMat.set(1, 2, 0.0);
1228                                 aCandidate.transform(aMat);
1229                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1230                             }
1231 
1232                             bDone = true;
1233                         }
1234                         else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 3.0))
1235                         {
1236                             // line in range [2.0 .. 3.0]
1237                             // paint as cross in a 3x3  with dynamic line distance
1238                             basegfx::B2DHomMatrix aMat;
1239                             const double fDistance((fDiscreteLineWidth - 1.0) * 0.5);
1240 
1241                             for(sal_uInt32 a(0); a < nCount; a++)
1242                             {
1243                                 basegfx::B2DPolygon aCandidate(aHairlinePolyPolygon.getB2DPolygon(a));
1244 
1245                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1246 
1247                                 aMat.set(0, 2, -fDistance);
1248                                 aMat.set(1, 2, 0.0);
1249                                 aCandidate.transform(aMat);
1250                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1251 
1252                                 aMat.set(0, 2, fDistance);
1253                                 aMat.set(1, 2, -fDistance);
1254                                 aCandidate.transform(aMat);
1255                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1256 
1257                                 aMat.set(0, 2, fDistance);
1258                                 aMat.set(1, 2, fDistance);
1259                                 aCandidate.transform(aMat);
1260                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1261 
1262                                 aMat.set(0, 2, -fDistance);
1263                                 aMat.set(1, 2, fDistance);
1264                                 aCandidate.transform(aMat);
1265                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1266                             }
1267 
1268                             bDone = true;
1269                         }
1270                         else
1271                         {
1272                             // #i101491# line width above 3.0
1273                         }
1274                     }
1275                     else
1276                     {
1277                         if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 1.5))
1278                         {
1279                             // line width below 1.5, draw the basic hairline polygon
1280                             for(sal_uInt32 a(0); a < nCount; a++)
1281                             {
1282                                 mpOutputDevice->DrawPolyLine(aHairlinePolyPolygon.getB2DPolygon(a), 0.0);
1283                             }
1284 
1285                             bDone = true;
1286                         }
1287                         else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 2.5))
1288                         {
1289                             // line width is in range ]1.5 .. 2.5], use four hairlines
1290                             // drawn in a square
1291                             for(sal_uInt32 a(0); a < nCount; a++)
1292                             {
1293                                 basegfx::B2DPolygon aCandidate(aHairlinePolyPolygon.getB2DPolygon(a));
1294                                 basegfx::B2DHomMatrix aMat;
1295 
1296                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1297 
1298                                 aMat.set(0, 2, 1.0);
1299                                 aMat.set(1, 2, 0.0);
1300                                 aCandidate.transform(aMat);
1301 
1302                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1303 
1304                                 aMat.set(0, 2, 0.0);
1305                                 aMat.set(1, 2, 1.0);
1306                                 aCandidate.transform(aMat);
1307 
1308                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1309 
1310                                 aMat.set(0, 2, -1.0);
1311                                 aMat.set(1, 2, 0.0);
1312                                 aCandidate.transform(aMat);
1313 
1314                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1315                             }
1316 
1317                             bDone = true;
1318                         }
1319                         else
1320                         {
1321                             // #i101491# line width is above 2.5
1322                         }
1323                     }
1324 
1325                     if(!bDone && rPolygonStrokeCandidate.getB2DPolygon().count() > 1000)
1326                     {
1327                         // #i101491# If the polygon complexity uses more than a given amount, do
1328                         // use OuputDevice::DrawPolyLine directly; this will avoid buffering all
1329                         // decompositions in primtives (memory) and fallback to old line painting
1330                         // for very complex polygons, too
1331                         for(sal_uInt32 a(0); a < nCount; a++)
1332                         {
1333                             mpOutputDevice->DrawPolyLine(
1334                                 aHairlinePolyPolygon.getB2DPolygon(a),
1335                                 fDiscreteLineWidth,
1336                                 rLineAttribute.getLineJoin(),
1337                                 rLineAttribute.getLineCap());
1338                         }
1339 
1340                         bDone = true;
1341                     }
1342                 }
1343             }
1344 
1345             if(!bDone)
1346             {
1347                 // remeber that we enter a PolygonStrokePrimitive2D decomposition,
1348                 // used for AA thick line drawing
1349                 mnPolygonStrokePrimitive2D++;
1350 
1351                 // line width is big enough for standard filled polygon visualisation or zero
1352                 process(rPolygonStrokeCandidate.get2DDecomposition(getViewInformation2D()));
1353 
1354                 // leave PolygonStrokePrimitive2D
1355                 mnPolygonStrokePrimitive2D--;
1356             }
1357         }
1358 
1359         void VclProcessor2D::RenderEpsPrimitive2D(const primitive2d::EpsPrimitive2D& rEpsPrimitive2D)
1360         {
1361             // The new decomposition of Metafiles made it necessary to add an Eps
1362             // primitive to handle embedded Eps data. On some devices, this can be
1363             // painted directly (mac, printer).
1364             // To be able to handle the replacement correctly, i need to handle it myself
1365             // since DrawEPS will not be able e.g. to rotate the replacement. To be able
1366             // to do that, i added a boolean return to OutputDevice::DrawEPS(..)
1367             // to know when EPS was handled directly already.
1368             basegfx::B2DRange aRange(0.0, 0.0, 1.0, 1.0);
1369             aRange.transform(maCurrentTransformation * rEpsPrimitive2D.getEpsTransform());
1370 
1371             if(!aRange.isEmpty())
1372             {
1373                 const Rectangle aRectangle(
1374                     (sal_Int32)floor(aRange.getMinX()), (sal_Int32)floor(aRange.getMinY()),
1375                     (sal_Int32)ceil(aRange.getMaxX()), (sal_Int32)ceil(aRange.getMaxY()));
1376 
1377                 if(!aRectangle.IsEmpty())
1378                 {
1379                     // try to paint EPS directly without fallback visualisation
1380                     const bool bEPSPaintedDirectly(mpOutputDevice->DrawEPS(
1381                         aRectangle.TopLeft(),
1382                         aRectangle.GetSize(),
1383                         rEpsPrimitive2D.getGfxLink(),
1384                         0));
1385 
1386                     if(!bEPSPaintedDirectly)
1387                     {
1388                         // use the decomposition which will correctly handle the
1389                         // fallback visualisation using full transformation (e.g. rotation)
1390                         process(rEpsPrimitive2D.get2DDecomposition(getViewInformation2D()));
1391                     }
1392                 }
1393             }
1394         }
1395 
1396         void VclProcessor2D::RenderSvgLinearAtomPrimitive2D(const primitive2d::SvgLinearAtomPrimitive2D& rCandidate)
1397         {
1398             const double fDelta(rCandidate.getOffsetB() - rCandidate.getOffsetA());
1399 
1400             if(basegfx::fTools::more(fDelta, 0.0))
1401             {
1402                 const basegfx::BColor aColorA(maBColorModifierStack.getModifiedColor(rCandidate.getColorA()));
1403                 const basegfx::BColor aColorB(maBColorModifierStack.getModifiedColor(rCandidate.getColorB()));
1404                 const double fDiscreteUnit((getViewInformation2D().getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength());
1405 
1406                 // use color distance and discrete lengths to calculate step count
1407                 const sal_uInt32 nSteps(calculateStepsForSvgGradient(aColorA, aColorB, fDelta, fDiscreteUnit));
1408 
1409                 // switch off line painting
1410                 mpOutputDevice->SetLineColor();
1411 
1412                 // prepare polygon in needed width at start position (with discrete overlap)
1413                 const basegfx::B2DPolygon aPolygon(
1414                     basegfx::tools::createPolygonFromRect(
1415                         basegfx::B2DRange(
1416                             rCandidate.getOffsetA() - fDiscreteUnit,
1417                             0.0,
1418                             rCandidate.getOffsetA() + (fDelta / nSteps) + fDiscreteUnit,
1419                             1.0)));
1420 
1421 
1422                 // prepare loop ([0.0 .. 1.0[)
1423                 double fUnitScale(0.0);
1424                 const double fUnitStep(1.0 / nSteps);
1425 
1426                 // loop and paint
1427                 for(sal_uInt32 a(0); a < nSteps; a++, fUnitScale += fUnitStep)
1428                 {
1429                     basegfx::B2DPolygon aNew(aPolygon);
1430 
1431                     aNew.transform(maCurrentTransformation * basegfx::tools::createTranslateB2DHomMatrix(fDelta * fUnitScale, 0.0));
1432                     mpOutputDevice->SetFillColor(Color(basegfx::interpolate(aColorA, aColorB, fUnitScale)));
1433                     mpOutputDevice->DrawPolyPolygon(basegfx::B2DPolyPolygon(aNew));
1434                 }
1435             }
1436         }
1437 
1438         void VclProcessor2D::RenderSvgRadialAtomPrimitive2D(const primitive2d::SvgRadialAtomPrimitive2D& rCandidate)
1439         {
1440             const double fDeltaScale(rCandidate.getScaleB() - rCandidate.getScaleA());
1441 
1442             if(basegfx::fTools::more(fDeltaScale, 0.0))
1443             {
1444                 const basegfx::BColor aColorA(maBColorModifierStack.getModifiedColor(rCandidate.getColorA()));
1445                 const basegfx::BColor aColorB(maBColorModifierStack.getModifiedColor(rCandidate.getColorB()));
1446                 const double fDiscreteUnit((getViewInformation2D().getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength());
1447 
1448                 // use color distance and discrete lengths to calculate step count
1449                 const sal_uInt32 nSteps(calculateStepsForSvgGradient(aColorA, aColorB, fDeltaScale, fDiscreteUnit));
1450 
1451                 // switch off line painting
1452                 mpOutputDevice->SetLineColor();
1453 
1454                 // prepare loop ([0.0 .. 1.0[, full polygons, no polypolygons with holes)
1455                 double fUnitScale(0.0);
1456                 const double fUnitStep(1.0 / nSteps);
1457 
1458                 for(sal_uInt32 a(0); a < nSteps; a++, fUnitScale += fUnitStep)
1459                 {
1460                     basegfx::B2DHomMatrix aTransform;
1461                     const double fEndScale(rCandidate.getScaleB() - (fDeltaScale * fUnitScale));
1462 
1463                     if(rCandidate.isTranslateSet())
1464                     {
1465                         const basegfx::B2DVector aTranslate(
1466                             basegfx::interpolate(
1467                                 rCandidate.getTranslateB(),
1468                                 rCandidate.getTranslateA(),
1469                                 fUnitScale));
1470 
1471                         aTransform = basegfx::tools::createScaleTranslateB2DHomMatrix(
1472                             fEndScale,
1473                             fEndScale,
1474                             aTranslate.getX(),
1475                             aTranslate.getY());
1476                     }
1477                     else
1478                     {
1479                         aTransform = basegfx::tools::createScaleB2DHomMatrix(
1480                             fEndScale,
1481                             fEndScale);
1482                     }
1483 
1484                     basegfx::B2DPolygon aNew(basegfx::tools::createPolygonFromUnitCircle());
1485 
1486                     aNew.transform(maCurrentTransformation * aTransform);
1487                     mpOutputDevice->SetFillColor(Color(basegfx::interpolate(aColorB, aColorA, fUnitScale)));
1488                     mpOutputDevice->DrawPolyPolygon(basegfx::B2DPolyPolygon(aNew));
1489                 }
1490             }
1491         }
1492 
1493         void VclProcessor2D::adaptLineToFillDrawMode() const
1494         {
1495             const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
1496 
1497             if(nOriginalDrawMode & (DRAWMODE_BLACKLINE|DRAWMODE_GRAYLINE|DRAWMODE_GHOSTEDLINE|DRAWMODE_WHITELINE|DRAWMODE_SETTINGSLINE))
1498             {
1499                 sal_uInt32 nAdaptedDrawMode(nOriginalDrawMode);
1500 
1501                 if(nOriginalDrawMode & DRAWMODE_BLACKLINE)
1502                 {
1503                     nAdaptedDrawMode |= DRAWMODE_BLACKFILL;
1504                 }
1505                 else
1506                 {
1507                     nAdaptedDrawMode &= ~DRAWMODE_BLACKFILL;
1508                 }
1509 
1510                 if(nOriginalDrawMode & DRAWMODE_GRAYLINE)
1511                 {
1512                     nAdaptedDrawMode |= DRAWMODE_GRAYFILL;
1513                 }
1514                 else
1515                 {
1516                     nAdaptedDrawMode &= ~DRAWMODE_GRAYFILL;
1517                 }
1518 
1519                 if(nOriginalDrawMode & DRAWMODE_GHOSTEDLINE)
1520                 {
1521                     nAdaptedDrawMode |= DRAWMODE_GHOSTEDFILL;
1522                 }
1523                 else
1524                 {
1525                     nAdaptedDrawMode &= ~DRAWMODE_GHOSTEDFILL;
1526                 }
1527 
1528                 if(nOriginalDrawMode & DRAWMODE_WHITELINE)
1529                 {
1530                     nAdaptedDrawMode |= DRAWMODE_WHITEFILL;
1531                 }
1532                 else
1533                 {
1534                     nAdaptedDrawMode &= ~DRAWMODE_WHITEFILL;
1535                 }
1536 
1537                 if(nOriginalDrawMode & DRAWMODE_SETTINGSLINE)
1538                 {
1539                     nAdaptedDrawMode |= DRAWMODE_SETTINGSFILL;
1540                 }
1541                 else
1542                 {
1543                     nAdaptedDrawMode &= ~DRAWMODE_SETTINGSFILL;
1544                 }
1545 
1546                 mpOutputDevice->SetDrawMode(nAdaptedDrawMode);
1547             }
1548         }
1549 
1550         void VclProcessor2D::adaptTextToFillDrawMode() const
1551         {
1552             const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
1553             if(nOriginalDrawMode & (DRAWMODE_BLACKTEXT|DRAWMODE_GRAYTEXT|DRAWMODE_GHOSTEDTEXT|DRAWMODE_WHITETEXT|DRAWMODE_SETTINGSTEXT))
1554             {
1555                 sal_uInt32 nAdaptedDrawMode(nOriginalDrawMode);
1556 
1557                 if(nOriginalDrawMode & DRAWMODE_BLACKTEXT)
1558                 {
1559                     nAdaptedDrawMode |= DRAWMODE_BLACKFILL;
1560                 }
1561                 else
1562                 {
1563                     nAdaptedDrawMode &= ~DRAWMODE_BLACKFILL;
1564                 }
1565 
1566                 if(nOriginalDrawMode & DRAWMODE_GRAYTEXT)
1567                 {
1568                     nAdaptedDrawMode |= DRAWMODE_GRAYFILL;
1569                 }
1570                 else
1571                 {
1572                     nAdaptedDrawMode &= ~DRAWMODE_GRAYFILL;
1573                 }
1574 
1575                 if(nOriginalDrawMode & DRAWMODE_GHOSTEDTEXT)
1576                 {
1577                     nAdaptedDrawMode |= DRAWMODE_GHOSTEDFILL;
1578                 }
1579                 else
1580                 {
1581                     nAdaptedDrawMode &= ~DRAWMODE_GHOSTEDFILL;
1582                 }
1583 
1584                 if(nOriginalDrawMode & DRAWMODE_WHITETEXT)
1585                 {
1586                     nAdaptedDrawMode |= DRAWMODE_WHITEFILL;
1587                 }
1588                 else
1589                 {
1590                     nAdaptedDrawMode &= ~DRAWMODE_WHITEFILL;
1591                 }
1592 
1593                 if(nOriginalDrawMode & DRAWMODE_SETTINGSTEXT)
1594                 {
1595                     nAdaptedDrawMode |= DRAWMODE_SETTINGSFILL;
1596                 }
1597                 else
1598                 {
1599                     nAdaptedDrawMode &= ~DRAWMODE_SETTINGSFILL;
1600                 }
1601 
1602                 mpOutputDevice->SetDrawMode(nAdaptedDrawMode);
1603             }
1604         }
1605 
1606         //////////////////////////////////////////////////////////////////////////////
1607         // process support
1608 
1609         VclProcessor2D::VclProcessor2D(
1610             const geometry::ViewInformation2D& rViewInformation,
1611             OutputDevice& rOutDev)
1612         :   BaseProcessor2D(rViewInformation),
1613             mpOutputDevice(&rOutDev),
1614             maBColorModifierStack(),
1615             maCurrentTransformation(),
1616             maDrawinglayerOpt(),
1617             mnPolygonStrokePrimitive2D(0)
1618         {
1619             // set digit language, derived from SvtCTLOptions to have the correct
1620             // number display for arabic/hindi numerals
1621             const SvtCTLOptions aSvtCTLOptions;
1622             LanguageType eLang(LANGUAGE_SYSTEM);
1623 
1624             if(SvtCTLOptions::NUMERALS_HINDI == aSvtCTLOptions.GetCTLTextNumerals())
1625             {
1626                 eLang = LANGUAGE_ARABIC_SAUDI_ARABIA;
1627             }
1628             else if(SvtCTLOptions::NUMERALS_ARABIC == aSvtCTLOptions.GetCTLTextNumerals())
1629             {
1630                 eLang = LANGUAGE_ENGLISH;
1631             }
1632             else
1633             {
1634                 eLang = (LanguageType)Application::GetSettings().GetLanguage();
1635             }
1636 
1637             rOutDev.SetDigitLanguage(eLang);
1638         }
1639 
1640         VclProcessor2D::~VclProcessor2D()
1641         {
1642         }
1643     } // end of namespace processor2d
1644 } // end of namespace drawinglayer
1645 
1646 //////////////////////////////////////////////////////////////////////////////
1647 // eof
1648