xref: /AOO41X/main/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx (revision 707fc0d4d52eb4f69d89a98ffec6918ca5de6326)
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/vclpixelprocessor2d.hxx>
28 #include <vcl/outdev.hxx>
29 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
30 #include <drawinglayer/primitive2d/textprimitive2d.hxx>
31 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
32 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
33 #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
34 #include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
35 #include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
36 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
37 #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
38 #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
39 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
40 #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
41 #include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx>
42 #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx>
43 #include <drawinglayer/primitive2d/controlprimitive2d.hxx>
44 #include <com/sun/star/awt/XWindow2.hpp>
45 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
46 #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx>
47 #include <helperwrongspellrenderer.hxx>
48 #include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx>
49 #include <basegfx/polygon/b2dpolygontools.hxx>
50 #include <vcl/hatch.hxx>
51 #include <tools/diagnose_ex.h>
52 #include <com/sun/star/awt/PosSize.hpp>
53 #include <drawinglayer/primitive2d/invertprimitive2d.hxx>
54 #include <cstdio>
55 #include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx>
56 #include <basegfx/matrix/b2dhommatrixtools.hxx>
57 #include <drawinglayer/primitive2d/epsprimitive2d.hxx>
58 #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
59 #include <toolkit/helper/vclunohelper.hxx>
60 #include <vcl/window.hxx>
61 
62 //////////////////////////////////////////////////////////////////////////////
63 
64 using namespace com::sun::star;
65 
66 //////////////////////////////////////////////////////////////////////////////
67 
68 namespace drawinglayer
69 {
70     namespace processor2d
71     {
72         VclPixelProcessor2D::VclPixelProcessor2D(const geometry::ViewInformation2D& rViewInformation, OutputDevice& rOutDev)
73         :   VclProcessor2D(rViewInformation, rOutDev)
74         {
75             // prepare maCurrentTransformation matrix with viewTransformation to target directly to pixels
76             maCurrentTransformation = rViewInformation.getObjectToViewTransformation();
77 
78             // prepare output directly to pixels
79             mpOutputDevice->Push(PUSH_MAPMODE);
80             mpOutputDevice->SetMapMode();
81 
82             // react on AntiAliasing settings
83             if(getOptionsDrawinglayer().IsAntiAliasing())
84             {
85                 mpOutputDevice->SetAntialiasing(mpOutputDevice->GetAntialiasing() | ANTIALIASING_ENABLE_B2DDRAW);
86             }
87             else
88             {
89                 mpOutputDevice->SetAntialiasing(mpOutputDevice->GetAntialiasing() & ~ANTIALIASING_ENABLE_B2DDRAW);
90             }
91         }
92 
93         VclPixelProcessor2D::~VclPixelProcessor2D()
94         {
95             // restore MapMode
96             mpOutputDevice->Pop();
97 
98             // restore AntiAliasing
99             mpOutputDevice->SetAntialiasing(mpOutputDevice->GetAntialiasing() & ~ANTIALIASING_ENABLE_B2DDRAW);
100         }
101 
102         void VclPixelProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
103         {
104             switch(rCandidate.getPrimitive2DID())
105             {
106                 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D :
107                 {
108                     // directdraw of wrong spell primitive; added test possibility to check wrong spell decompose
109                     static bool bHandleWrongSpellDirectly(true);
110 
111                     if(bHandleWrongSpellDirectly)
112                     {
113                         const primitive2d::WrongSpellPrimitive2D& rWrongSpellPrimitive = static_cast< const primitive2d::WrongSpellPrimitive2D& >(rCandidate);
114 
115                         if(!renderWrongSpellPrimitive2D(
116                             rWrongSpellPrimitive,
117                             *mpOutputDevice,
118                             maCurrentTransformation,
119                             maBColorModifierStack))
120                         {
121                             // fallback to decomposition (MetaFile)
122                             process(rWrongSpellPrimitive.get2DDecomposition(getViewInformation2D()));
123                         }
124                     }
125                     else
126                     {
127                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
128                     }
129                     break;
130                 }
131                 case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D :
132                 {
133                     // directdraw of text simple portion; added test possibility to check text decompose
134                     static bool bForceSimpleTextDecomposition(false);
135 
136                     // Adapt evtl. used special DrawMode
137                     const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
138                     adaptTextToFillDrawMode();
139 
140                     if(!bForceSimpleTextDecomposition && getOptionsDrawinglayer().IsRenderSimpleTextDirect())
141                     {
142                         RenderTextSimpleOrDecoratedPortionPrimitive2D(static_cast< const primitive2d::TextSimplePortionPrimitive2D& >(rCandidate));
143                     }
144                     else
145                     {
146                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
147                     }
148 
149                     // restore DrawMode
150                     mpOutputDevice->SetDrawMode(nOriginalDrawMode);
151 
152                     break;
153                 }
154                 case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D :
155                 {
156                     // directdraw of text simple portion; added test possibility to check text decompose
157                     static bool bForceComplexTextDecomposition(false);
158 
159                     // Adapt evtl. used special DrawMode
160                     const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
161                     adaptTextToFillDrawMode();
162 
163                     if(!bForceComplexTextDecomposition && getOptionsDrawinglayer().IsRenderDecoratedTextDirect())
164                     {
165                         RenderTextSimpleOrDecoratedPortionPrimitive2D(static_cast< const primitive2d::TextSimplePortionPrimitive2D& >(rCandidate));
166                     }
167                     else
168                     {
169                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
170                     }
171 
172                     // restore DrawMode
173                     mpOutputDevice->SetDrawMode(nOriginalDrawMode);
174 
175                     break;
176                 }
177                 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D :
178                 {
179                     // direct draw of hairline
180                     RenderPolygonHairlinePrimitive2D(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate), true);
181                     break;
182                 }
183                 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D :
184                 {
185                     // direct draw of transformed BitmapEx primitive
186                     RenderBitmapPrimitive2D(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate));
187                     break;
188                 }
189                 case PRIMITIVE2D_ID_FILLBITMAPPRIMITIVE2D :
190                 {
191                     // direct draw of fillBitmapPrimitive
192                     RenderFillBitmapPrimitive2D(static_cast< const primitive2d::FillBitmapPrimitive2D& >(rCandidate));
193                     break;
194                 }
195                 case PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D :
196                 {
197                     // direct draw of gradient
198                     RenderPolyPolygonGradientPrimitive2D(static_cast< const primitive2d::PolyPolygonGradientPrimitive2D& >(rCandidate));
199                     break;
200                 }
201                 case PRIMITIVE2D_ID_POLYPOLYGONBITMAPPRIMITIVE2D :
202                 {
203                     // direct draw of bitmap
204                     RenderPolyPolygonBitmapPrimitive2D(static_cast< const primitive2d::PolyPolygonBitmapPrimitive2D& >(rCandidate));
205                     break;
206                 }
207                 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D :
208                 {
209                     // direct draw of PolyPolygon with color
210                     RenderPolyPolygonColorPrimitive2D(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate));
211                     break;
212                 }
213                 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D :
214                 {
215                     // #i98289#
216                     const bool bForceLineSnap(getOptionsDrawinglayer().IsAntiAliasing() && getOptionsDrawinglayer().IsSnapHorVerLinesToDiscrete());
217                     const sal_uInt16 nOldAntiAliase(mpOutputDevice->GetAntialiasing());
218 
219                     if(bForceLineSnap)
220                     {
221                         mpOutputDevice->SetAntialiasing(nOldAntiAliase | ANTIALIASING_PIXELSNAPHAIRLINE);
222                     }
223 
224                     static bool bTestMetaFilePrimitiveDecomposition(true);
225                     if(bTestMetaFilePrimitiveDecomposition)
226                     {
227                         // use new Metafile decomposition
228                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
229                     }
230                     else
231                     {
232                         // direct draw of MetaFile
233                         RenderMetafilePrimitive2D(static_cast< const primitive2d::MetafilePrimitive2D& >(rCandidate));
234                     }
235 
236                     if(bForceLineSnap)
237                     {
238                         mpOutputDevice->SetAntialiasing(nOldAntiAliase);
239                     }
240 
241                     break;
242                 }
243                 case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
244                 {
245                     // mask group.
246                     RenderMaskPrimitive2DPixel(static_cast< const primitive2d::MaskPrimitive2D& >(rCandidate));
247                     break;
248                 }
249                 case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D :
250                 {
251                     // modified color group. Force output to unified color.
252                     RenderModifiedColorPrimitive2D(static_cast< const primitive2d::ModifiedColorPrimitive2D& >(rCandidate));
253                     break;
254                 }
255                 case PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D :
256                 {
257                     // Detect if a single PolyPolygonColorPrimitive2D is contained; in that case,
258                     // use the faster OutputDevice::DrawTransparent method
259                     const primitive2d::UnifiedTransparencePrimitive2D& rUniTransparenceCandidate = static_cast< const primitive2d::UnifiedTransparencePrimitive2D& >(rCandidate);
260                     const primitive2d::Primitive2DSequence rContent = rUniTransparenceCandidate.getChildren();
261 
262                     if(rContent.hasElements())
263                     {
264                         if(0.0 == rUniTransparenceCandidate.getTransparence())
265                         {
266                             // not transparent at all, use content
267                             process(rUniTransparenceCandidate.getChildren());
268                         }
269                         else if(rUniTransparenceCandidate.getTransparence() > 0.0 && rUniTransparenceCandidate.getTransparence() < 1.0)
270                         {
271                             bool bDrawTransparentUsed(false);
272 
273                             // since DEV300 m33 DrawTransparent is supported in VCL (for some targets
274                             // natively), so i am now enabling this shortcut
275                             static bool bAllowUsingDrawTransparent(true);
276 
277                             if(bAllowUsingDrawTransparent && 1 == rContent.getLength())
278                             {
279                                 const primitive2d::Primitive2DReference xReference(rContent[0]);
280                                 const primitive2d::BasePrimitive2D* pBasePrimitive = dynamic_cast< const primitive2d::BasePrimitive2D* >(xReference.get());
281 
282                                 if(pBasePrimitive)
283                                 {
284                                     switch(pBasePrimitive->getPrimitive2DID())
285                                     {
286                                         case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D:
287                                         {
288                                             // single transparent PolyPolygon identified, use directly
289                                             const primitive2d::PolyPolygonColorPrimitive2D* pPoPoColor = static_cast< const primitive2d::PolyPolygonColorPrimitive2D* >(pBasePrimitive);
290                                             OSL_ENSURE(pPoPoColor, "OOps, PrimitiveID and PrimitiveType do not match (!)");
291                                             const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(pPoPoColor->getBColor()));
292                                             mpOutputDevice->SetFillColor(Color(aPolygonColor));
293                                             mpOutputDevice->SetLineColor();
294 
295                                             basegfx::B2DPolyPolygon aLocalPolyPolygon(pPoPoColor->getB2DPolyPolygon());
296                                             aLocalPolyPolygon.transform(maCurrentTransformation);
297 
298                                             mpOutputDevice->DrawTransparent(aLocalPolyPolygon, rUniTransparenceCandidate.getTransparence());
299                                             bDrawTransparentUsed = true;
300                                             break;
301                                         }
302                                         // #i# need to wait for #i101378# which is in CWS vcl112 to directly paint transparent hairlines
303                                         //case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D:
304                                         //{
305                                         //  // single transparent PolygonHairlinePrimitive2D identified, use directly
306                                         //  const primitive2d::PolygonHairlinePrimitive2D* pPoHair = static_cast< const primitive2d::PolygonHairlinePrimitive2D* >(pBasePrimitive);
307                                         //  OSL_ENSURE(pPoHair, "OOps, PrimitiveID and PrimitiveType do not match (!)");
308                                         //  break;
309                                         //}
310                                     }
311                                 }
312                             }
313 
314                             if(!bDrawTransparentUsed)
315                             {
316                                 // unified sub-transparence. Draw to VDev first.
317                                 RenderUnifiedTransparencePrimitive2D(rUniTransparenceCandidate);
318                             }
319                         }
320                     }
321 
322                     break;
323                 }
324                 case PRIMITIVE2D_ID_TRANSPARENCEPRIMITIVE2D :
325                 {
326                     // sub-transparence group. Draw to VDev first.
327                     RenderTransparencePrimitive2D(static_cast< const primitive2d::TransparencePrimitive2D& >(rCandidate));
328                     break;
329                 }
330                 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D :
331                 {
332                     // transform group.
333                     RenderTransformPrimitive2D(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate));
334                     break;
335                 }
336                 case PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D :
337                 {
338                     // new XDrawPage for ViewInformation2D
339                     RenderPagePreviewPrimitive2D(static_cast< const primitive2d::PagePreviewPrimitive2D& >(rCandidate));
340                     break;
341                 }
342                 case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D :
343                 {
344                     // marker array
345                     RenderMarkerArrayPrimitive2D(static_cast< const primitive2d::MarkerArrayPrimitive2D& >(rCandidate));
346                     break;
347                 }
348                 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D :
349                 {
350                     // point array
351                     RenderPointArrayPrimitive2D(static_cast< const primitive2d::PointArrayPrimitive2D& >(rCandidate));
352                     break;
353                 }
354                 case PRIMITIVE2D_ID_CONTROLPRIMITIVE2D :
355                 {
356                     // control primitive
357                     const primitive2d::ControlPrimitive2D& rControlPrimitive = static_cast< const primitive2d::ControlPrimitive2D& >(rCandidate);
358                     const uno::Reference< awt::XControl >& rXControl(rControlPrimitive.getXControl());
359 
360                     try
361                     {
362                         // remember old graphics and create new
363                         uno::Reference< awt::XView > xControlView(rXControl, uno::UNO_QUERY_THROW);
364                         const uno::Reference< awt::XGraphics > xOriginalGraphics(xControlView->getGraphics());
365                         const uno::Reference< awt::XGraphics > xNewGraphics(mpOutputDevice->CreateUnoGraphics());
366 
367                         if(xNewGraphics.is())
368                         {
369                             // link graphics and view
370                             xControlView->setGraphics(xNewGraphics);
371 
372                             // get position
373                             const basegfx::B2DHomMatrix aObjectToPixel(maCurrentTransformation * rControlPrimitive.getTransform());
374                             const basegfx::B2DPoint aTopLeftPixel(aObjectToPixel * basegfx::B2DPoint(0.0, 0.0));
375 
376                             // find out if the control is already visualized as a VCL-ChildWindow. If yes,
377                             // it does not need to be painted at all.
378                             uno::Reference< awt::XWindow2 > xControlWindow(rXControl, uno::UNO_QUERY_THROW);
379                             const bool bControlIsVisibleAsChildWindow(rXControl->getPeer().is() && xControlWindow->isVisible());
380 
381                             if(!bControlIsVisibleAsChildWindow)
382                             {
383                                 // draw it. Do not forget to use the evtl. offsetted origin of the target device,
384                                 // e.g. when used with mask/transparence buffer device
385                                 const Point aOrigin(mpOutputDevice->GetMapMode().GetOrigin());
386                                 xControlView->draw(
387                                     aOrigin.X() + basegfx::fround(aTopLeftPixel.getX()),
388                                     aOrigin.Y() + basegfx::fround(aTopLeftPixel.getY()));
389                             }
390 
391                             // restore original graphics
392                             xControlView->setGraphics(xOriginalGraphics);
393                         }
394                     }
395                     catch(const uno::Exception&)
396                     {
397                         // #i116763# removing since there is a good alternative when the xControlView
398                         // is not found and it is allowed to happen
399                         // DBG_UNHANDLED_EXCEPTION();
400 
401                         // process recursively and use the decomposition as Bitmap
402                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
403                     }
404 
405                     break;
406                 }
407                 case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D:
408                 {
409                     // the stroke primitive may be decomposed to filled polygons. To keep
410                     // evtl. set DrawModes aka DRAWMODE_BLACKLINE, DRAWMODE_GRAYLINE,
411                     // DRAWMODE_GHOSTEDLINE, DRAWMODE_WHITELINE or DRAWMODE_SETTINGSLINE
412                     // working, these need to be copied to the corresponding fill modes
413                     const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
414                     adaptLineToFillDrawMode();
415 
416                     // polygon stroke primitive
417                     static bool bSuppressFatToHairlineCorrection(false);
418 
419                     if(bSuppressFatToHairlineCorrection)
420                     {
421                         // remeber that we enter a PolygonStrokePrimitive2D decomposition,
422                         // used for AA thick line drawing
423                         mnPolygonStrokePrimitive2D++;
424 
425                         // with AA there is no need to handle thin lines special
426                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
427 
428                         // leave PolygonStrokePrimitive2D
429                         mnPolygonStrokePrimitive2D--;
430                     }
431                     else
432                     {
433                         // Lines with 1 and 2 pixel width without AA need special treatment since their vsiualisation
434                         // as filled polygons is geometrically corret but looks wrong since polygon filling avoids
435                         // the right and bottom pixels. The used method evaluates that and takes the correct action,
436                         // including calling recursively with decomposition if line is wide enough
437                         const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokePrimitive = static_cast< const primitive2d::PolygonStrokePrimitive2D& >(rCandidate);
438 
439                         RenderPolygonStrokePrimitive2D(rPolygonStrokePrimitive);
440                     }
441 
442                     // restore DrawMode
443                     mpOutputDevice->SetDrawMode(nOriginalDrawMode);
444 
445                     break;
446                 }
447                 case PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D :
448                 {
449                     static bool bForceIgnoreHatchSmoothing(false);
450 
451                     if(bForceIgnoreHatchSmoothing || getOptionsDrawinglayer().IsAntiAliasing())
452                     {
453                         // if AA is used (or ignore smoothing is on), there is no need to smooth
454                         // hatch painting, use decomposition
455                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
456                     }
457                     else
458                     {
459                         // without AA, use VCL to draw the hatch. It snaps hatch distances to the next pixel
460                         // and forces hatch distance to be >= 3 pixels to make the hatch display look smoother.
461                         // This is wrong in principle, but looks nicer. This could also be done here directly
462                         // without VCL usage if needed
463                         const primitive2d::FillHatchPrimitive2D& rFillHatchPrimitive = static_cast< const primitive2d::FillHatchPrimitive2D& >(rCandidate);
464                         const attribute::FillHatchAttribute& rFillHatchAttributes = rFillHatchPrimitive.getFillHatch();
465 
466                         // create hatch polygon in range size and discrete coordinates
467                         basegfx::B2DRange aHatchRange(rFillHatchPrimitive.getObjectRange());
468                         aHatchRange.transform(maCurrentTransformation);
469                         const basegfx::B2DPolygon aHatchPolygon(basegfx::tools::createPolygonFromRect(aHatchRange));
470 
471                         if(rFillHatchAttributes.isFillBackground())
472                         {
473                             // #i111846# background fill is active; draw fill polygon
474                             const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rFillHatchPrimitive.getBColor()));
475 
476                             mpOutputDevice->SetFillColor(Color(aPolygonColor));
477                             mpOutputDevice->SetLineColor();
478                             mpOutputDevice->DrawPolygon(aHatchPolygon);
479                         }
480 
481                         // set hatch line color
482                         const basegfx::BColor aHatchColor(maBColorModifierStack.getModifiedColor(rFillHatchPrimitive.getBColor()));
483                         mpOutputDevice->SetFillColor();
484                         mpOutputDevice->SetLineColor(Color(aHatchColor));
485 
486                         // get hatch style
487                         HatchStyle eHatchStyle(HATCH_SINGLE);
488 
489                         switch(rFillHatchAttributes.getStyle())
490                         {
491                             default : // HATCHSTYLE_SINGLE
492                             {
493                                 break;
494                             }
495                             case attribute::HATCHSTYLE_DOUBLE :
496                             {
497                                 eHatchStyle = HATCH_DOUBLE;
498                                 break;
499                             }
500                             case attribute::HATCHSTYLE_TRIPLE :
501                             {
502                                 eHatchStyle = HATCH_TRIPLE;
503                                 break;
504                             }
505                         }
506 
507                         // create hatch
508                         const basegfx::B2DVector aDiscreteDistance(maCurrentTransformation * basegfx::B2DVector(rFillHatchAttributes.getDistance(), 0.0));
509                         const sal_uInt32 nDistance(basegfx::fround(aDiscreteDistance.getLength()));
510                         const sal_uInt16 nAngle10((sal_uInt16)basegfx::fround(rFillHatchAttributes.getAngle() / F_PI1800));
511                         ::Hatch aVCLHatch(eHatchStyle, Color(rFillHatchAttributes.getColor()), nDistance, nAngle10);
512 
513                         // draw hatch using VCL
514                         mpOutputDevice->DrawHatch(PolyPolygon(Polygon(aHatchPolygon)), aVCLHatch);
515                     }
516                     break;
517                 }
518                 case PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D :
519                 {
520                     // #i98404# Handle directly, especially when AA is active
521                     const primitive2d::BackgroundColorPrimitive2D& rPrimitive = static_cast< const primitive2d::BackgroundColorPrimitive2D& >(rCandidate);
522                     const sal_uInt16 nOriginalAA(mpOutputDevice->GetAntialiasing());
523 
524                     // switch AA off in all cases
525                     mpOutputDevice->SetAntialiasing(mpOutputDevice->GetAntialiasing() & ~ANTIALIASING_ENABLE_B2DDRAW);
526 
527                     // create color for fill
528                     const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPrimitive.getBColor()));
529                     mpOutputDevice->SetFillColor(Color(aPolygonColor));
530                     mpOutputDevice->SetLineColor();
531 
532                     // create rectangle for fill
533                     const basegfx::B2DRange& aViewport(getViewInformation2D().getDiscreteViewport());
534                     const Rectangle aRectangle(
535                         (sal_Int32)floor(aViewport.getMinX()), (sal_Int32)floor(aViewport.getMinY()),
536                         (sal_Int32)ceil(aViewport.getMaxX()), (sal_Int32)ceil(aViewport.getMaxY()));
537                     mpOutputDevice->DrawRect(aRectangle);
538 
539                     // restore AA setting
540                     mpOutputDevice->SetAntialiasing(nOriginalAA);
541                     break;
542                 }
543                 case PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D :
544                 {
545                     // #i97628#
546                     // This primitive means that the content is derived from an active text edit,
547                     // not from model data itself. Some renderers need to suppress this content, e.g.
548                     // the pixel renderer used for displaying the edit view (like this one). It's
549                     // not to be suppressed by the MetaFile renderers, so that the edited text is
550                     // part of the MetaFile, e.g. needed for presentation previews.
551                     // Action: Ignore here, do nothing.
552                     break;
553                 }
554                 case PRIMITIVE2D_ID_INVERTPRIMITIVE2D :
555                 {
556                     // invert primitive (currently only used for HighContrast fallback for selection in SW and SC).
557                     // Set OutDev to XOR and switch AA off (XOR does not work with AA)
558                     mpOutputDevice->Push();
559                     mpOutputDevice->SetRasterOp( ROP_XOR );
560                     const sal_uInt16 nAntiAliasing(mpOutputDevice->GetAntialiasing());
561                     mpOutputDevice->SetAntialiasing(nAntiAliasing & ~ANTIALIASING_ENABLE_B2DDRAW);
562 
563                     // process content recursively
564                     process(rCandidate.get2DDecomposition(getViewInformation2D()));
565 
566                     // restore OutDev
567                     mpOutputDevice->Pop();
568                     mpOutputDevice->SetAntialiasing(nAntiAliasing);
569                     break;
570                 }
571                 case PRIMITIVE2D_ID_EPSPRIMITIVE2D :
572                 {
573                     RenderEpsPrimitive2D(static_cast< const primitive2d::EpsPrimitive2D& >(rCandidate));
574                     break;
575                 }
576                 case PRIMITIVE2D_ID_SVGLINEARATOMPRIMITIVE2D:
577                 {
578                     RenderSvgLinearAtomPrimitive2D(static_cast< const primitive2d::SvgLinearAtomPrimitive2D& >(rCandidate));
579                     break;
580                 }
581                 case PRIMITIVE2D_ID_SVGRADIALATOMPRIMITIVE2D:
582                 {
583                     RenderSvgRadialAtomPrimitive2D(static_cast< const primitive2d::SvgRadialAtomPrimitive2D& >(rCandidate));
584                     break;
585                 }
586                 default :
587                 {
588                     // process recursively
589                     process(rCandidate.get2DDecomposition(getViewInformation2D()));
590                     break;
591                 }
592             }
593         }
594     } // end of namespace processor2d
595 } // end of namespace drawinglayer
596 
597 //////////////////////////////////////////////////////////////////////////////
598 // eof
599