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