xref: /AOO41X/main/drawinglayer/source/processor2d/vclprocessor2d.cxx (revision 035a2f44eca4e31ced924464e6584eacbf3e9114)
1464702f4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3464702f4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4464702f4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5464702f4SAndrew Rist  * distributed with this work for additional information
6464702f4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7464702f4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8464702f4SAndrew Rist  * "License"); you may not use this file except in compliance
9464702f4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11464702f4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13464702f4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14464702f4SAndrew Rist  * software distributed under the License is distributed on an
15464702f4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16464702f4SAndrew Rist  * KIND, either express or implied.  See the License for the
17464702f4SAndrew Rist  * specific language governing permissions and limitations
18464702f4SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20464702f4SAndrew Rist  *************************************************************/
21464702f4SAndrew Rist 
22464702f4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <drawinglayer/processor2d/vclprocessor2d.hxx>
28cdf0e10cSrcweir #include <drawinglayer/primitive2d/textprimitive2d.hxx>
29cdf0e10cSrcweir #include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx>
30cdf0e10cSrcweir #include <tools/debug.hxx>
31cdf0e10cSrcweir #include <vcl/outdev.hxx>
32cdf0e10cSrcweir #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
33cdf0e10cSrcweir #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
34cdf0e10cSrcweir #include <vclhelperbitmaptransform.hxx>
35cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
36cdf0e10cSrcweir #include <vclhelperbitmaprender.hxx>
37*035a2f44SArmin Le Grand #include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
38*035a2f44SArmin Le Grand #include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx>
39cdf0e10cSrcweir #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
40cdf0e10cSrcweir #include <vclhelpergradient.hxx>
41cdf0e10cSrcweir #include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
42cdf0e10cSrcweir #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
43cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
44cdf0e10cSrcweir #include <vclhelperbufferdevice.hxx>
45cdf0e10cSrcweir #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
46cdf0e10cSrcweir #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
47cdf0e10cSrcweir #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
48cdf0e10cSrcweir #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
49cdf0e10cSrcweir #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
50cdf0e10cSrcweir #include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx>
51cdf0e10cSrcweir #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx>
52cdf0e10cSrcweir #include <svl/ctloptions.hxx>
53cdf0e10cSrcweir #include <vcl/svapp.hxx>
54cdf0e10cSrcweir #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx>
55cdf0e10cSrcweir #include <tools/diagnose_ex.h>
56cdf0e10cSrcweir #include <vcl/metric.hxx>
57cdf0e10cSrcweir #include <drawinglayer/primitive2d/textenumsprimitive2d.hxx>
58cdf0e10cSrcweir #include <drawinglayer/primitive2d/epsprimitive2d.hxx>
5939551d71SArmin Le Grand #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
6039551d71SArmin Le Grand #include <basegfx/color/bcolor.hxx>
6139551d71SArmin Le Grand #include <basegfx/matrix/b2dhommatrixtools.hxx>
62*035a2f44SArmin Le Grand #include <vcl/graph.hxx>
63cdf0e10cSrcweir 
64cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
65cdf0e10cSrcweir // control support
66cdf0e10cSrcweir 
67cdf0e10cSrcweir #include <com/sun/star/awt/XWindow2.hpp>
68cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
69cdf0e10cSrcweir #include <com/sun/star/awt/XView.hpp>
70cdf0e10cSrcweir #include <drawinglayer/primitive2d/controlprimitive2d.hxx>
71cdf0e10cSrcweir #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
72cdf0e10cSrcweir 
73cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
74cdf0e10cSrcweir // for test, can be removed again
75cdf0e10cSrcweir 
76cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygonclipper.hxx>
77cdf0e10cSrcweir #include <basegfx/polygon/b2dtrapezoid.hxx>
78cdf0e10cSrcweir 
79cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
80cdf0e10cSrcweir 
81cdf0e10cSrcweir using namespace com::sun::star;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
84cdf0e10cSrcweir 
8539551d71SArmin Le Grand namespace
8639551d71SArmin Le Grand {
8739551d71SArmin Le Grand     sal_uInt32 calculateStepsForSvgGradient(const basegfx::BColor& rColorA, const basegfx::BColor& rColorB, double fDelta, double fDiscreteUnit)
8839551d71SArmin Le Grand     {
8939551d71SArmin Le Grand         // use color distance, assume to do every color step
9039551d71SArmin Le Grand         sal_uInt32 nSteps(basegfx::fround(rColorA.getDistance(rColorB) * 255.0));
9139551d71SArmin Le Grand 
9239551d71SArmin Le Grand         if(nSteps)
9339551d71SArmin Le Grand         {
9439551d71SArmin Le Grand             // calc discrete length to change color each disctete unit (pixel)
9539551d71SArmin Le Grand             const sal_uInt32 nDistSteps(basegfx::fround(fDelta / fDiscreteUnit));
9639551d71SArmin Le Grand 
9739551d71SArmin Le Grand             nSteps = std::min(nSteps, nDistSteps);
9839551d71SArmin Le Grand         }
9939551d71SArmin Le Grand 
10039551d71SArmin Le Grand         // reduce quality to 3 discrete units or every 3rd color step for rendering
10139551d71SArmin Le Grand         nSteps /= 2;
10239551d71SArmin Le Grand 
10339551d71SArmin Le Grand         // roughly cut when too big or too small (not full quality, reduce complexity)
10439551d71SArmin Le Grand         nSteps = std::min(nSteps, sal_uInt32(255));
10539551d71SArmin Le Grand         nSteps = std::max(nSteps, sal_uInt32(1));
10639551d71SArmin Le Grand 
10739551d71SArmin Le Grand         return nSteps;
10839551d71SArmin Le Grand     }
10939551d71SArmin Le Grand } // end of anonymous namespace
11039551d71SArmin Le Grand 
11139551d71SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
11239551d71SArmin Le Grand 
113cdf0e10cSrcweir namespace drawinglayer
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	namespace processor2d
116cdf0e10cSrcweir 	{
117cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////////////
118cdf0e10cSrcweir 		// UNO class usages
119cdf0e10cSrcweir 		using ::com::sun::star::uno::Reference;
120cdf0e10cSrcweir 		using ::com::sun::star::uno::UNO_QUERY;
121cdf0e10cSrcweir 	    using ::com::sun::star::uno::UNO_QUERY_THROW;
122cdf0e10cSrcweir         using ::com::sun::star::uno::Exception;
123cdf0e10cSrcweir 		using ::com::sun::star::awt::XView;
124cdf0e10cSrcweir 		using ::com::sun::star::awt::XGraphics;
125cdf0e10cSrcweir 	    using ::com::sun::star::awt::XWindow;
126cdf0e10cSrcweir 	    using ::com::sun::star::awt::PosSize::POSSIZE;
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////////////
129cdf0e10cSrcweir 		// rendering support
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 		// directdraw of text simple portion or decorated portion primitive. When decorated, all the extra
132cdf0e10cSrcweir 		// information is translated to VCL parameters and set at the font.
133cdf0e10cSrcweir 		// Acceptance is restricted to no shearing and positive scaling in X and Y (no font mirroring
134cdf0e10cSrcweir 		// for VCL)
135cdf0e10cSrcweir 		void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate)
136cdf0e10cSrcweir 		{
137cdf0e10cSrcweir             // decompose matrix to have position and size of text
138cdf0e10cSrcweir 			basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rTextCandidate.getTextTransform());
139cdf0e10cSrcweir 			basegfx::B2DVector aFontScaling, aTranslate;
140cdf0e10cSrcweir 			double fRotate, fShearX;
141cdf0e10cSrcweir 			aLocalTransform.decompose(aFontScaling, aTranslate, fRotate, fShearX);
142cdf0e10cSrcweir 			bool bPrimitiveAccepted(false);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 			if(basegfx::fTools::equalZero(fShearX))
145cdf0e10cSrcweir 			{
146cdf0e10cSrcweir 				if(basegfx::fTools::less(aFontScaling.getX(), 0.0) && basegfx::fTools::less(aFontScaling.getY(), 0.0))
147cdf0e10cSrcweir 				{
148cdf0e10cSrcweir 					// handle special case: If scale is negative in (x,y) (3rd quadrant), it can
149cdf0e10cSrcweir 					// be expressed as rotation by PI. Use this since the Font rendering will not
150cdf0e10cSrcweir                     // apply the negative scales in any form
151cdf0e10cSrcweir 					aFontScaling = basegfx::absolute(aFontScaling);
152cdf0e10cSrcweir 					fRotate += F_PI;
153cdf0e10cSrcweir 				}
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 				if(basegfx::fTools::more(aFontScaling.getX(), 0.0) && basegfx::fTools::more(aFontScaling.getY(), 0.0))
156cdf0e10cSrcweir 				{
157cdf0e10cSrcweir                     // Get the VCL font (use FontHeight as FontWidth)
158cdf0e10cSrcweir                     Font aFont(primitive2d::getVclFontFromFontAttribute(
159cdf0e10cSrcweir                         rTextCandidate.getFontAttribute(),
160cdf0e10cSrcweir                         aFontScaling.getX(),
161cdf0e10cSrcweir                         aFontScaling.getY(),
162cdf0e10cSrcweir                         fRotate,
163cdf0e10cSrcweir                         rTextCandidate.getLocale()));
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 					// handle additional font attributes
166cdf0e10cSrcweir 					const primitive2d::TextDecoratedPortionPrimitive2D* pTCPP =
167cdf0e10cSrcweir 						dynamic_cast<const primitive2d::TextDecoratedPortionPrimitive2D*>( &rTextCandidate );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 					if( pTCPP != NULL )
170cdf0e10cSrcweir 					{
171cdf0e10cSrcweir 
172cdf0e10cSrcweir                         // set the color of text decorations
173cdf0e10cSrcweir                         const basegfx::BColor aTextlineColor = maBColorModifierStack.getModifiedColor(pTCPP->getTextlineColor());
174cdf0e10cSrcweir                         mpOutputDevice->SetTextLineColor( Color(aTextlineColor) );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir                         // set Overline attribute
177cdf0e10cSrcweir                         const FontUnderline eFontOverline(primitive2d::mapTextLineToFontUnderline( pTCPP->getFontOverline() ));
178cdf0e10cSrcweir                         if( eFontOverline != UNDERLINE_NONE )
179cdf0e10cSrcweir                         {
180cdf0e10cSrcweir                             aFont.SetOverline( eFontOverline );
181cdf0e10cSrcweir                             const basegfx::BColor aOverlineColor = maBColorModifierStack.getModifiedColor(pTCPP->getOverlineColor());
182cdf0e10cSrcweir                             mpOutputDevice->SetOverlineColor( Color(aOverlineColor) );
183cdf0e10cSrcweir                             if( pTCPP->getWordLineMode() )
184cdf0e10cSrcweir                                 aFont.SetWordLineMode( true );
185cdf0e10cSrcweir                         }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir                         // set Underline attribute
188cdf0e10cSrcweir                         const FontUnderline eFontUnderline(primitive2d::mapTextLineToFontUnderline( pTCPP->getFontUnderline() ));
189cdf0e10cSrcweir                         if( eFontUnderline != UNDERLINE_NONE )
190cdf0e10cSrcweir 						{
191cdf0e10cSrcweir 							aFont.SetUnderline( eFontUnderline );
192cdf0e10cSrcweir 							if( pTCPP->getWordLineMode() )
193cdf0e10cSrcweir 								aFont.SetWordLineMode( true );
194cdf0e10cSrcweir //TODO: ???					if( pTCPP->getUnderlineAbove() )
195cdf0e10cSrcweir //								aFont.SetUnderlineAbove( true );
196cdf0e10cSrcweir 						}
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 						// set Strikeout attribute
199cdf0e10cSrcweir 						const FontStrikeout eFontStrikeout(primitive2d::mapTextStrikeoutToFontStrikeout(pTCPP->getTextStrikeout()));
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 						if( eFontStrikeout != STRIKEOUT_NONE )
202cdf0e10cSrcweir 							aFont.SetStrikeout( eFontStrikeout );
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 						// set EmphasisMark attribute
205cdf0e10cSrcweir 						FontEmphasisMark eFontEmphasisMark = EMPHASISMARK_NONE;
206cdf0e10cSrcweir 						switch( pTCPP->getTextEmphasisMark() )
207cdf0e10cSrcweir 						{
208cdf0e10cSrcweir 							default:
209cdf0e10cSrcweir 								DBG_WARNING1( "DrawingLayer: Unknown EmphasisMark style (%d)!", pTCPP->getTextEmphasisMark() );
210cdf0e10cSrcweir 								// fall through
211cdf0e10cSrcweir 							case primitive2d::TEXT_EMPHASISMARK_NONE:	eFontEmphasisMark = EMPHASISMARK_NONE; break;
212cdf0e10cSrcweir 							case primitive2d::TEXT_EMPHASISMARK_DOT:	eFontEmphasisMark = EMPHASISMARK_DOT; break;
213cdf0e10cSrcweir 							case primitive2d::TEXT_EMPHASISMARK_CIRCLE:	eFontEmphasisMark = EMPHASISMARK_CIRCLE; break;
214cdf0e10cSrcweir 							case primitive2d::TEXT_EMPHASISMARK_DISC:	eFontEmphasisMark = EMPHASISMARK_DISC; break;
215cdf0e10cSrcweir 							case primitive2d::TEXT_EMPHASISMARK_ACCENT:	eFontEmphasisMark = EMPHASISMARK_ACCENT; break;
216cdf0e10cSrcweir 						}
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 						if( eFontEmphasisMark != EMPHASISMARK_NONE )
219cdf0e10cSrcweir 						{
220cdf0e10cSrcweir 							DBG_ASSERT( (pTCPP->getEmphasisMarkAbove() != pTCPP->getEmphasisMarkBelow()),
221cdf0e10cSrcweir 								"DrawingLayer: Bad EmphasisMark position!" );
222cdf0e10cSrcweir 							if( pTCPP->getEmphasisMarkAbove() )
223cdf0e10cSrcweir 								eFontEmphasisMark |= EMPHASISMARK_POS_ABOVE;
224cdf0e10cSrcweir 							else
225cdf0e10cSrcweir 								eFontEmphasisMark |= EMPHASISMARK_POS_BELOW;
226cdf0e10cSrcweir 							aFont.SetEmphasisMark( eFontEmphasisMark );
227cdf0e10cSrcweir 						}
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 						// set Relief attribute
230cdf0e10cSrcweir 						FontRelief eFontRelief = RELIEF_NONE;
231cdf0e10cSrcweir 						switch( pTCPP->getTextRelief() )
232cdf0e10cSrcweir 						{
233cdf0e10cSrcweir 							default:
234cdf0e10cSrcweir 								DBG_WARNING1( "DrawingLayer: Unknown Relief style (%d)!", pTCPP->getTextRelief() );
235cdf0e10cSrcweir 								// fall through
236cdf0e10cSrcweir 							case primitive2d::TEXT_RELIEF_NONE:		eFontRelief = RELIEF_NONE; break;
237cdf0e10cSrcweir 							case primitive2d::TEXT_RELIEF_EMBOSSED:	eFontRelief = RELIEF_EMBOSSED; break;
238cdf0e10cSrcweir 							case primitive2d::TEXT_RELIEF_ENGRAVED:	eFontRelief = RELIEF_ENGRAVED; break;
239cdf0e10cSrcweir 						}
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 						if( eFontRelief != RELIEF_NONE )
242cdf0e10cSrcweir 							aFont.SetRelief( eFontRelief );
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 						// set Shadow attribute
245cdf0e10cSrcweir 						if( pTCPP->getShadow() )
246cdf0e10cSrcweir 							aFont.SetShadow( true );
247cdf0e10cSrcweir 					}
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 					// create transformed integer DXArray in view coordinate system
250cdf0e10cSrcweir 					::std::vector< sal_Int32 > aTransformedDXArray;
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 					if(rTextCandidate.getDXArray().size())
253cdf0e10cSrcweir 					{
254cdf0e10cSrcweir 						aTransformedDXArray.reserve(rTextCandidate.getDXArray().size());
255cdf0e10cSrcweir 						const basegfx::B2DVector aPixelVector(maCurrentTransformation * basegfx::B2DVector(1.0, 0.0));
256cdf0e10cSrcweir 						const double fPixelVectorFactor(aPixelVector.getLength());
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 						for(::std::vector< double >::const_iterator aStart(rTextCandidate.getDXArray().begin());
259cdf0e10cSrcweir                             aStart != rTextCandidate.getDXArray().end(); aStart++)
260cdf0e10cSrcweir 						{
261cdf0e10cSrcweir 							aTransformedDXArray.push_back(basegfx::fround((*aStart) * fPixelVectorFactor));
262cdf0e10cSrcweir 						}
263cdf0e10cSrcweir 					}
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 					// set parameters and paint text snippet
266cdf0e10cSrcweir 					const basegfx::BColor aRGBFontColor(maBColorModifierStack.getModifiedColor(rTextCandidate.getFontColor()));
267cdf0e10cSrcweir 					const basegfx::B2DPoint aPoint(aLocalTransform * basegfx::B2DPoint(0.0, 0.0));
268cdf0e10cSrcweir 					const Point aStartPoint(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()));
269cdf0e10cSrcweir                     const sal_uInt32 nOldLayoutMode(mpOutputDevice->GetLayoutMode());
270cdf0e10cSrcweir 
271cdf0e10cSrcweir                     if(rTextCandidate.getFontAttribute().getRTL())
272cdf0e10cSrcweir                     {
273cdf0e10cSrcweir                         sal_uInt32 nRTLLayoutMode(nOldLayoutMode & ~(TEXT_LAYOUT_COMPLEX_DISABLED|TEXT_LAYOUT_BIDI_STRONG));
274cdf0e10cSrcweir                         nRTLLayoutMode |= TEXT_LAYOUT_BIDI_RTL|TEXT_LAYOUT_TEXTORIGIN_LEFT;
275cdf0e10cSrcweir                         mpOutputDevice->SetLayoutMode(nRTLLayoutMode);
276cdf0e10cSrcweir                     }
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 					mpOutputDevice->SetFont(aFont);
279cdf0e10cSrcweir 					mpOutputDevice->SetTextColor(Color(aRGBFontColor));
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 					if(aTransformedDXArray.size())
282cdf0e10cSrcweir 					{
283cdf0e10cSrcweir 						mpOutputDevice->DrawTextArray(
284cdf0e10cSrcweir 							aStartPoint,
285cdf0e10cSrcweir 							rTextCandidate.getText(),
286cdf0e10cSrcweir 							&(aTransformedDXArray[0]),
287cdf0e10cSrcweir 							rTextCandidate.getTextPosition(),
288cdf0e10cSrcweir 							rTextCandidate.getTextLength());
289cdf0e10cSrcweir 					}
290cdf0e10cSrcweir 					else
291cdf0e10cSrcweir 					{
292cdf0e10cSrcweir 						mpOutputDevice->DrawText(
293cdf0e10cSrcweir 							aStartPoint,
294cdf0e10cSrcweir 							rTextCandidate.getText(),
295cdf0e10cSrcweir 							rTextCandidate.getTextPosition(),
296cdf0e10cSrcweir 							rTextCandidate.getTextLength());
297cdf0e10cSrcweir 					}
298cdf0e10cSrcweir 
299cdf0e10cSrcweir                     if(rTextCandidate.getFontAttribute().getRTL())
300cdf0e10cSrcweir                     {
301cdf0e10cSrcweir                         mpOutputDevice->SetLayoutMode(nOldLayoutMode);
302cdf0e10cSrcweir                     }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 					bPrimitiveAccepted = true;
305cdf0e10cSrcweir 				}
306cdf0e10cSrcweir 			}
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 			if(!bPrimitiveAccepted)
309cdf0e10cSrcweir 			{
310cdf0e10cSrcweir 				// let break down
311cdf0e10cSrcweir 				process(rTextCandidate.get2DDecomposition(getViewInformation2D()));
312cdf0e10cSrcweir 			}
313cdf0e10cSrcweir 		}
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 		// direct draw of hairline
316cdf0e10cSrcweir 		void VclProcessor2D::RenderPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate, bool bPixelBased)
317cdf0e10cSrcweir 		{
318cdf0e10cSrcweir             const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor()));
319cdf0e10cSrcweir 			mpOutputDevice->SetLineColor(Color(aHairlineColor));
320cdf0e10cSrcweir 			mpOutputDevice->SetFillColor();
321cdf0e10cSrcweir 
322cdf0e10cSrcweir 			basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon());
323cdf0e10cSrcweir 			aLocalPolygon.transform(maCurrentTransformation);
324cdf0e10cSrcweir 
325cdf0e10cSrcweir             static bool bCheckTrapezoidDecomposition(false);
326cdf0e10cSrcweir             static bool bShowOutlinesThere(false);
327cdf0e10cSrcweir             if(bCheckTrapezoidDecomposition)
328cdf0e10cSrcweir             {
329cdf0e10cSrcweir                 // clip against discrete ViewPort
330cdf0e10cSrcweir                 const basegfx::B2DRange& rDiscreteViewport = getViewInformation2D().getDiscreteViewport();
331cdf0e10cSrcweir                 basegfx::B2DPolyPolygon aLocalPolyPolygon(basegfx::tools::clipPolygonOnRange(
332cdf0e10cSrcweir                     aLocalPolygon, rDiscreteViewport, true, false));
333cdf0e10cSrcweir 
334cdf0e10cSrcweir                 if(aLocalPolyPolygon.count())
335cdf0e10cSrcweir                 {
336cdf0e10cSrcweir                     // subdivide
337cdf0e10cSrcweir                     aLocalPolyPolygon = basegfx::tools::adaptiveSubdivideByDistance(
338cdf0e10cSrcweir                         aLocalPolyPolygon, 0.5);
339cdf0e10cSrcweir 
340cdf0e10cSrcweir                     // trapezoidize
341cdf0e10cSrcweir                     static double fLineWidth(2.0);
342cdf0e10cSrcweir                     basegfx::B2DTrapezoidVector aB2DTrapezoidVector;
343cdf0e10cSrcweir                     basegfx::tools::createLineTrapezoidFromB2DPolyPolygon(aB2DTrapezoidVector, aLocalPolyPolygon, fLineWidth);
344cdf0e10cSrcweir 
345cdf0e10cSrcweir                     const sal_uInt32 nCount(aB2DTrapezoidVector.size());
346cdf0e10cSrcweir 
347cdf0e10cSrcweir                     if(nCount)
348cdf0e10cSrcweir                     {
349cdf0e10cSrcweir                         basegfx::BColor aInvPolygonColor(aHairlineColor);
350cdf0e10cSrcweir                         aInvPolygonColor.invert();
351cdf0e10cSrcweir 
352cdf0e10cSrcweir                         for(sal_uInt32 a(0); a < nCount; a++)
353cdf0e10cSrcweir                         {
354cdf0e10cSrcweir                             const basegfx::B2DPolygon aTempPolygon(aB2DTrapezoidVector[a].getB2DPolygon());
355cdf0e10cSrcweir 
356cdf0e10cSrcweir                             if(bShowOutlinesThere)
357cdf0e10cSrcweir                             {
358cdf0e10cSrcweir                                 mpOutputDevice->SetFillColor(Color(aHairlineColor));
359cdf0e10cSrcweir 			                    mpOutputDevice->SetLineColor();
360cdf0e10cSrcweir                             }
361cdf0e10cSrcweir 
362cdf0e10cSrcweir                             mpOutputDevice->DrawPolygon(aTempPolygon);
363cdf0e10cSrcweir 
364cdf0e10cSrcweir                             if(bShowOutlinesThere)
365cdf0e10cSrcweir                             {
366cdf0e10cSrcweir                                 mpOutputDevice->SetFillColor();
367cdf0e10cSrcweir         		                mpOutputDevice->SetLineColor(Color(aInvPolygonColor));
368cdf0e10cSrcweir     	    		            mpOutputDevice->DrawPolyLine(aTempPolygon, 0.0);
369cdf0e10cSrcweir                             }
370cdf0e10cSrcweir                         }
371cdf0e10cSrcweir                     }
372cdf0e10cSrcweir                 }
373cdf0e10cSrcweir             }
374cdf0e10cSrcweir             else
375cdf0e10cSrcweir             {
376cdf0e10cSrcweir 			    if(bPixelBased && getOptionsDrawinglayer().IsAntiAliasing() && getOptionsDrawinglayer().IsSnapHorVerLinesToDiscrete())
377cdf0e10cSrcweir 			    {
378cdf0e10cSrcweir 				    // #i98289#
379cdf0e10cSrcweir 				    // when a Hairline is painted and AntiAliasing is on the option SnapHorVerLinesToDiscrete
380cdf0e10cSrcweir 				    // allows to suppress AntiAliasing for pure horizontal or vertical lines. This is done since
381cdf0e10cSrcweir 				    // not-AntiAliased such lines look more pleasing to the eye (e.g. 2D chart content). This
382cdf0e10cSrcweir 				    // NEEDS to be done in discrete coordinates, so only useful for pixel based rendering.
383cdf0e10cSrcweir 				    aLocalPolygon = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aLocalPolygon);
384cdf0e10cSrcweir 			    }
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 			    mpOutputDevice->DrawPolyLine(aLocalPolygon, 0.0);
387cdf0e10cSrcweir             }
388cdf0e10cSrcweir 		}
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 		// direct draw of transformed BitmapEx primitive
391cdf0e10cSrcweir 		void VclProcessor2D::RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate)
392cdf0e10cSrcweir 		{
393cdf0e10cSrcweir             // create local transform
394cdf0e10cSrcweir 			basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rBitmapCandidate.getTransform());
395cdf0e10cSrcweir 			BitmapEx aBitmapEx(rBitmapCandidate.getBitmapEx());
396cdf0e10cSrcweir 			bool bPainted(false);
397cdf0e10cSrcweir 
398cdf0e10cSrcweir 			if(maBColorModifierStack.count())
399cdf0e10cSrcweir 			{
400cdf0e10cSrcweir 				aBitmapEx = impModifyBitmapEx(maBColorModifierStack, aBitmapEx);
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 				if(aBitmapEx.IsEmpty())
403cdf0e10cSrcweir 				{
404cdf0e10cSrcweir 					// color gets completely replaced, get it
405cdf0e10cSrcweir 					const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor()));
406cdf0e10cSrcweir 					basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
407cdf0e10cSrcweir 					aPolygon.transform(aLocalTransform);
408cdf0e10cSrcweir 
409cdf0e10cSrcweir 					mpOutputDevice->SetFillColor(Color(aModifiedColor));
410cdf0e10cSrcweir 					mpOutputDevice->SetLineColor();
411cdf0e10cSrcweir 					mpOutputDevice->DrawPolygon(aPolygon);
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 					bPainted = true;
414cdf0e10cSrcweir 				}
415cdf0e10cSrcweir 			}
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 			if(!bPainted)
418cdf0e10cSrcweir 			{
419cdf0e10cSrcweir 				static bool bForceUseOfOwnTransformer(false);
420cdf0e10cSrcweir 				static bool bUseGraphicManager(true);
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 				// decompose matrix to check for shear, rotate and mirroring
423cdf0e10cSrcweir 				basegfx::B2DVector aScale, aTranslate;
424cdf0e10cSrcweir 				double fRotate, fShearX;
425cdf0e10cSrcweir 				aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 				if(!bForceUseOfOwnTransformer && basegfx::fTools::equalZero(fShearX))
428cdf0e10cSrcweir 				{
429cdf0e10cSrcweir 					if(!bUseGraphicManager && basegfx::fTools::equalZero(fRotate))
430cdf0e10cSrcweir 					{
431cdf0e10cSrcweir 						RenderBitmapPrimitive2D_BitmapEx(*mpOutputDevice, aBitmapEx, aLocalTransform);
432cdf0e10cSrcweir 					}
433cdf0e10cSrcweir 					else
434cdf0e10cSrcweir 					{
435cdf0e10cSrcweir 						RenderBitmapPrimitive2D_GraphicManager(*mpOutputDevice, aBitmapEx, aLocalTransform);
436cdf0e10cSrcweir 					}
437cdf0e10cSrcweir 				}
438cdf0e10cSrcweir 				else
439cdf0e10cSrcweir 				{
440cdf0e10cSrcweir 					if(!aBitmapEx.IsTransparent() && (!basegfx::fTools::equalZero(fShearX) || !basegfx::fTools::equalZero(fRotate)))
441cdf0e10cSrcweir 					{
442cdf0e10cSrcweir 						// parts will be uncovered, extend aBitmapEx with a mask bitmap
443cdf0e10cSrcweir 						const Bitmap aContent(aBitmapEx.GetBitmap());
444cdf0e10cSrcweir 						aBitmapEx = BitmapEx(aContent, Bitmap(aContent.GetSizePixel(), 1));
445cdf0e10cSrcweir 					}
446cdf0e10cSrcweir 
447cdf0e10cSrcweir 					RenderBitmapPrimitive2D_self(*mpOutputDevice, aBitmapEx, aLocalTransform);
448cdf0e10cSrcweir 				}
449cdf0e10cSrcweir 			}
450cdf0e10cSrcweir 		}
451cdf0e10cSrcweir 
452*035a2f44SArmin Le Grand 		void VclProcessor2D::RenderFillGraphicPrimitive2D(const primitive2d::FillGraphicPrimitive2D& rFillBitmapCandidate)
453cdf0e10cSrcweir 		{
454*035a2f44SArmin Le Grand 			const attribute::FillGraphicAttribute& rFillGraphicAttribute(rFillBitmapCandidate.getFillGraphic());
455cdf0e10cSrcweir 			bool bPrimitiveAccepted(false);
456*035a2f44SArmin Le Grand             static bool bTryTilingDirect = true;
457cdf0e10cSrcweir 
458*035a2f44SArmin Le Grand             // #121194# when tiling is used and content is bitmap-based, do direct tiling in the
459*035a2f44SArmin Le Grand             // renderer on pixel base to ensure tight fitting. Do not do this when
460*035a2f44SArmin Le Grand             // the fill is rotated or sheared.
461*035a2f44SArmin Le Grand 
462*035a2f44SArmin Le Grand             // ovveride static bool (for debug) and tiling is active
463*035a2f44SArmin Le Grand 			if(bTryTilingDirect && rFillGraphicAttribute.getTiling())
464*035a2f44SArmin Le Grand 			{
465*035a2f44SArmin Le Grand                 // content is bitmap(ex)
466*035a2f44SArmin Le Grand                 //
467*035a2f44SArmin Le Grand                 // for SVG support, force decomposition when SVG is present. This will lead to use
468*035a2f44SArmin Le Grand                 // the primitive representation of the svg directly.
469*035a2f44SArmin Le Grand                 //
470*035a2f44SArmin Le Grand                 // when graphic is animated, force decomposition to use the correct graphic, else
471*035a2f44SArmin Le Grand                 // fill style will not be animated
472*035a2f44SArmin Le Grand                 if(GRAPHIC_BITMAP == rFillGraphicAttribute.getGraphic().GetType()
473*035a2f44SArmin Le Grand                     && !rFillGraphicAttribute.getGraphic().getSvgData().get()
474*035a2f44SArmin Le Grand                     && !rFillGraphicAttribute.getGraphic().IsAnimated())
475cdf0e10cSrcweir                 {
476cdf0e10cSrcweir 				    // decompose matrix to check for shear, rotate and mirroring
477cdf0e10cSrcweir 				    basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rFillBitmapCandidate.getTransformation());
478cdf0e10cSrcweir 				    basegfx::B2DVector aScale, aTranslate;
479cdf0e10cSrcweir 				    double fRotate, fShearX;
480cdf0e10cSrcweir 				    aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
481cdf0e10cSrcweir 
482*035a2f44SArmin Le Grand                     // when nopt rotated/sheared
483cdf0e10cSrcweir 				    if(basegfx::fTools::equalZero(fRotate) && basegfx::fTools::equalZero(fShearX))
484cdf0e10cSrcweir 				    {
485cdf0e10cSrcweir 					    // no shear or rotate, draw direct in pixel coordinates
486cdf0e10cSrcweir 					    bPrimitiveAccepted = true;
487*035a2f44SArmin Le Grand 
488*035a2f44SArmin Le Grand                         // transform object range to device coordinates (pixels). Use
489*035a2f44SArmin Le Grand                         // the device transformation for better accuracy
490*035a2f44SArmin Le Grand                         basegfx::B2DRange aObjectRange(aTranslate, aTranslate + aScale);
491*035a2f44SArmin Le Grand                         aObjectRange.transform(mpOutputDevice->GetViewTransformation());
492*035a2f44SArmin Le Grand 
493*035a2f44SArmin Le Grand                         // extract discrete size of object
494*035a2f44SArmin Le Grand                         const sal_Int32 nOWidth(basegfx::fround(aObjectRange.getWidth()));
495*035a2f44SArmin Le Grand                         const sal_Int32 nOHeight(basegfx::fround(aObjectRange.getHeight()));
496*035a2f44SArmin Le Grand 
497*035a2f44SArmin Le Grand                         // only do something when object has a size in discrete units
498*035a2f44SArmin Le Grand 						if(nOWidth > 0 && nOHeight > 0)
499*035a2f44SArmin Le Grand 						{
500*035a2f44SArmin Le Grand                             // transform graphic range to device coordinates (pixels). Use
501*035a2f44SArmin Le Grand                             // the device transformation for better accuracy
502*035a2f44SArmin Le Grand                             basegfx::B2DRange aGraphicRange(rFillGraphicAttribute.getGraphicRange());
503*035a2f44SArmin Le Grand                             aGraphicRange.transform(mpOutputDevice->GetViewTransformation() * aLocalTransform);
504*035a2f44SArmin Le Grand 
505*035a2f44SArmin Le Grand                             // extract discrete size of graphic
506*035a2f44SArmin Le Grand                             const sal_Int32 nBWidth(basegfx::fround(aGraphicRange.getWidth()));
507*035a2f44SArmin Le Grand                             const sal_Int32 nBHeight(basegfx::fround(aGraphicRange.getHeight()));
508*035a2f44SArmin Le Grand 
509*035a2f44SArmin Le Grand                             // only do something when bitmap fill has a size in discrete units
510*035a2f44SArmin Le Grand 						    if(nBWidth > 0 && nBHeight > 0)
511*035a2f44SArmin Le Grand 						    {
512*035a2f44SArmin Le Grand 						        // nBWidth, nBHeight is the pixel size of the neede bitmap. To not need to scale it
513*035a2f44SArmin Le Grand 						        // in vcl many times, create a size-optimized version
514*035a2f44SArmin Le Grand 						        const Size aNeededBitmapSizePixel(nBWidth, nBHeight);
515*035a2f44SArmin Le Grand                                 BitmapEx aBitmapEx(rFillGraphicAttribute.getGraphic().GetBitmapEx(
516*035a2f44SArmin Le Grand                                     GraphicConversionParameters(
517*035a2f44SArmin Le Grand                                         aNeededBitmapSizePixel, // get the correct size immediately
518*035a2f44SArmin Le Grand                                         false, // no unlimited size
519*035a2f44SArmin Le Grand                                         false, // Use AntiAliasing
520*035a2f44SArmin Le Grand                                         false, //SnapHorVerLines
521*035a2f44SArmin Le Grand                                         true // ScaleHighQuality
522*035a2f44SArmin Le Grand                                         )));
523cdf0e10cSrcweir 					            bool bPainted(false);
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 					            if(maBColorModifierStack.count())
526cdf0e10cSrcweir 					            {
527*035a2f44SArmin Le Grand                                     // when color modifier, apply to bitmap
528cdf0e10cSrcweir 						            aBitmapEx = impModifyBitmapEx(maBColorModifierStack, aBitmapEx);
529cdf0e10cSrcweir 
530*035a2f44SArmin Le Grand                                     // impModifyBitmapEx uses empty bitmap as sign to return that
531*035a2f44SArmin Le Grand                                     // the content will be completely replaced to mono color, use shortcut
532cdf0e10cSrcweir 						            if(aBitmapEx.IsEmpty())
533cdf0e10cSrcweir 						            {
534cdf0e10cSrcweir 							            // color gets completely replaced, get it
535cdf0e10cSrcweir 							            const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor()));
536cdf0e10cSrcweir 							            basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
537cdf0e10cSrcweir 							            aPolygon.transform(aLocalTransform);
538cdf0e10cSrcweir 
539cdf0e10cSrcweir 							            mpOutputDevice->SetFillColor(Color(aModifiedColor));
540cdf0e10cSrcweir 							            mpOutputDevice->SetLineColor();
541cdf0e10cSrcweir 							            mpOutputDevice->DrawPolygon(aPolygon);
542cdf0e10cSrcweir 
543cdf0e10cSrcweir 							            bPainted = true;
544cdf0e10cSrcweir 						            }
545cdf0e10cSrcweir 					            }
546cdf0e10cSrcweir 
547cdf0e10cSrcweir 					            if(!bPainted)
548cdf0e10cSrcweir 					            {
549*035a2f44SArmin Le Grand                                     sal_Int32 nBLeft(basegfx::fround(aGraphicRange.getMinX()));
550*035a2f44SArmin Le Grand                                     sal_Int32 nBTop(basegfx::fround(aGraphicRange.getMinY()));
551*035a2f44SArmin Le Grand                                     const sal_Int32 nOLeft(basegfx::fround(aObjectRange.getMinX()));
552*035a2f44SArmin Le Grand                                     const sal_Int32 nOTop(basegfx::fround(aObjectRange.getMinY()));
553*035a2f44SArmin Le Grand                                     sal_Int32 nPosX(0);
554*035a2f44SArmin Le Grand                                     sal_Int32 nPosY(0);
555cdf0e10cSrcweir 
556*035a2f44SArmin Le Grand 						            if(nBLeft > nOLeft)
557cdf0e10cSrcweir 						            {
558*035a2f44SArmin Le Grand                                         const sal_Int32 nDiff((nBLeft / nBWidth) + 1);
559cdf0e10cSrcweir 
560*035a2f44SArmin Le Grand                                         nPosX -= nDiff;
561*035a2f44SArmin Le Grand 							            nBLeft -= nDiff * nBWidth;
562cdf0e10cSrcweir 						            }
563cdf0e10cSrcweir 
564*035a2f44SArmin Le Grand 						            if(nBLeft + nBWidth <= nOLeft)
565cdf0e10cSrcweir 						            {
566*035a2f44SArmin Le Grand                                         const sal_Int32 nDiff(-nBLeft / nBWidth);
567*035a2f44SArmin Le Grand 
568*035a2f44SArmin Le Grand                                         nPosX += nDiff;
569*035a2f44SArmin Le Grand 							            nBLeft += nDiff * nBWidth;
570cdf0e10cSrcweir 						            }
571cdf0e10cSrcweir 
572*035a2f44SArmin Le Grand 						            if(nBTop > nOTop)
573cdf0e10cSrcweir 						            {
574*035a2f44SArmin Le Grand                                         const sal_Int32 nDiff((nBTop / nBHeight) + 1);
575*035a2f44SArmin Le Grand 
576*035a2f44SArmin Le Grand                                         nPosY -= nDiff;
577*035a2f44SArmin Le Grand 							            nBTop -= nDiff * nBHeight;
578cdf0e10cSrcweir 						            }
579cdf0e10cSrcweir 
580*035a2f44SArmin Le Grand 						            if(nBTop + nBHeight <= nOTop)
581cdf0e10cSrcweir 						            {
582*035a2f44SArmin Le Grand                                         const sal_Int32 nDiff(-nBTop / nBHeight);
583cdf0e10cSrcweir 
584*035a2f44SArmin Le Grand                                         nPosY += nDiff;
585*035a2f44SArmin Le Grand 							            nBTop += nDiff * nBHeight;
586cdf0e10cSrcweir 						            }
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 						            // prepare OutDev
589cdf0e10cSrcweir 						            const Point aEmptyPoint(0, 0);
590cdf0e10cSrcweir 						            const Rectangle aVisiblePixel(aEmptyPoint, mpOutputDevice->GetOutputSizePixel());
591cdf0e10cSrcweir 						            const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled());
592cdf0e10cSrcweir 						            mpOutputDevice->EnableMapMode(false);
593cdf0e10cSrcweir 
594*035a2f44SArmin Le Grand                                     // check if offset is used
595*035a2f44SArmin Le Grand                                     const sal_Int32 nOffsetX(basegfx::fround(rFillGraphicAttribute.getOffsetX() * nBWidth));
596*035a2f44SArmin Le Grand 
597*035a2f44SArmin Le Grand                                     if(nOffsetX)
598cdf0e10cSrcweir                                     {
599*035a2f44SArmin Le Grand                                         // offset in X, so iterate over Y first and draw lines
600*035a2f44SArmin Le Grand                                         for(sal_Int32 nYPos(nBTop); nYPos < nOTop + nOHeight; nYPos += nBHeight, nPosY++)
601*035a2f44SArmin Le Grand                                         {
602*035a2f44SArmin Le Grand                                             for(sal_Int32 nXPos(nPosY % 2 ? nBLeft - nBWidth + nOffsetX : nBLeft);
603*035a2f44SArmin Le Grand                                                 nXPos < nOLeft + nOWidth; nXPos += nBWidth)
604cdf0e10cSrcweir                                             {
605cdf0e10cSrcweir                                                 const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel);
606cdf0e10cSrcweir 
607cdf0e10cSrcweir                                                 if(aOutRectPixel.IsOver(aVisiblePixel))
608cdf0e10cSrcweir                                                 {
609cdf0e10cSrcweir                                                     mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aBitmapEx);
610cdf0e10cSrcweir                                                 }
611cdf0e10cSrcweir                                             }
612cdf0e10cSrcweir                                         }
613*035a2f44SArmin Le Grand                                     }
614*035a2f44SArmin Le Grand                                     else
615*035a2f44SArmin Le Grand                                     {
616*035a2f44SArmin Le Grand                                         // check if offset is used
617*035a2f44SArmin Le Grand                                         const sal_Int32 nOffsetY(basegfx::fround(rFillGraphicAttribute.getOffsetY() * nBHeight));
618*035a2f44SArmin Le Grand 
619*035a2f44SArmin Le Grand                                         // possible offset in Y, so iterate over X first and draw columns
620*035a2f44SArmin Le Grand                                         for(sal_Int32 nXPos(nBLeft); nXPos < nOLeft + nOWidth; nXPos += nBWidth, nPosX++)
621*035a2f44SArmin Le Grand                                         {
622*035a2f44SArmin Le Grand                                             for(sal_Int32 nYPos(nPosX % 2 ? nBTop - nBHeight + nOffsetY : nBTop);
623*035a2f44SArmin Le Grand                                                 nYPos < nOTop + nOHeight; nYPos += nBHeight)
624*035a2f44SArmin Le Grand                                             {
625*035a2f44SArmin Le Grand                                                 const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel);
626*035a2f44SArmin Le Grand 
627*035a2f44SArmin Le Grand                                                 if(aOutRectPixel.IsOver(aVisiblePixel))
628*035a2f44SArmin Le Grand                                                 {
629*035a2f44SArmin Le Grand                                                     mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aBitmapEx);
630*035a2f44SArmin Le Grand                                                 }
631*035a2f44SArmin Le Grand                                             }
632*035a2f44SArmin Le Grand                                         }
633*035a2f44SArmin Le Grand                                     }
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 						            // restore OutDev
636cdf0e10cSrcweir 						            mpOutputDevice->EnableMapMode(bWasEnabled);
637cdf0e10cSrcweir                                 }
638cdf0e10cSrcweir                             }
639cdf0e10cSrcweir                         }
640cdf0e10cSrcweir 				    }
641cdf0e10cSrcweir 			    }
642*035a2f44SArmin Le Grand             }
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 			if(!bPrimitiveAccepted)
645cdf0e10cSrcweir 			{
646cdf0e10cSrcweir 				// do not accept, use decomposition
647cdf0e10cSrcweir 				process(rFillBitmapCandidate.get2DDecomposition(getViewInformation2D()));
648cdf0e10cSrcweir 			}
649cdf0e10cSrcweir 		}
650cdf0e10cSrcweir 
651cdf0e10cSrcweir 		// direct draw of gradient
652cdf0e10cSrcweir 		void VclProcessor2D::RenderPolyPolygonGradientPrimitive2D(const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate)
653cdf0e10cSrcweir 		{
654cdf0e10cSrcweir 			const attribute::FillGradientAttribute& rGradient(rPolygonCandidate.getFillGradient());
655cdf0e10cSrcweir 			basegfx::BColor aStartColor(maBColorModifierStack.getModifiedColor(rGradient.getStartColor()));
656cdf0e10cSrcweir 			basegfx::BColor aEndColor(maBColorModifierStack.getModifiedColor(rGradient.getEndColor()));
657cdf0e10cSrcweir 			basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
658cdf0e10cSrcweir 
659cdf0e10cSrcweir 			if(aLocalPolyPolygon.count())
660cdf0e10cSrcweir 			{
661cdf0e10cSrcweir 				aLocalPolyPolygon.transform(maCurrentTransformation);
662cdf0e10cSrcweir 
663cdf0e10cSrcweir 				if(aStartColor == aEndColor)
664cdf0e10cSrcweir 				{
665cdf0e10cSrcweir 					// no gradient at all, draw as polygon in AA and non-AA case
666cdf0e10cSrcweir 					mpOutputDevice->SetLineColor();
667cdf0e10cSrcweir 					mpOutputDevice->SetFillColor(Color(aStartColor));
668cdf0e10cSrcweir 					mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
669cdf0e10cSrcweir 				}
670cdf0e10cSrcweir 				else if(getOptionsDrawinglayer().IsAntiAliasing())
671cdf0e10cSrcweir 				{
672cdf0e10cSrcweir 					// For AA, direct render has to be avoided since it uses XOR maskings which will not
673cdf0e10cSrcweir 					// work with AA. Instead, the decompose which uses MaskPrimitive2D with fillings is
674cdf0e10cSrcweir 					// used
675cdf0e10cSrcweir 					process(rPolygonCandidate.get2DDecomposition(getViewInformation2D()));
676cdf0e10cSrcweir 				}
677cdf0e10cSrcweir 				else
678cdf0e10cSrcweir 				{
67996fc4b33SArmin Le Grand                     static bool bSimple = false; // allow testing simple paint in debugger
68096fc4b33SArmin Le Grand 
681cdf0e10cSrcweir                     impDrawGradientToOutDev(
682cdf0e10cSrcweir 						*mpOutputDevice, aLocalPolyPolygon, rGradient.getStyle(), rGradient.getSteps(),
683cdf0e10cSrcweir 						aStartColor, aEndColor, rGradient.getBorder(),
68496fc4b33SArmin Le Grand 						rGradient.getAngle(), rGradient.getOffsetX(), rGradient.getOffsetY(), bSimple);
685cdf0e10cSrcweir 				}
686cdf0e10cSrcweir 			}
687cdf0e10cSrcweir 		}
688cdf0e10cSrcweir 
689*035a2f44SArmin Le Grand 		// direct draw of Graphic
690*035a2f44SArmin Le Grand 		void VclProcessor2D::RenderPolyPolygonGraphicPrimitive2D(const primitive2d::PolyPolygonGraphicPrimitive2D& rPolygonCandidate)
691cdf0e10cSrcweir 		{
692cdf0e10cSrcweir             bool bDone(false);
693cdf0e10cSrcweir             const basegfx::B2DPolyPolygon& rPolyPolygon = rPolygonCandidate.getB2DPolyPolygon();
694cdf0e10cSrcweir 
695*035a2f44SArmin Le Grand             // #121194# Todo: check if this works
696*035a2f44SArmin Le Grand             if(!rPolyPolygon.count())
697cdf0e10cSrcweir             {
698*035a2f44SArmin Le Grand                 // empty polyPolygon, done
699cdf0e10cSrcweir                 bDone = true;
700cdf0e10cSrcweir             }
701cdf0e10cSrcweir             else
702cdf0e10cSrcweir             {
703*035a2f44SArmin Le Grand                 const attribute::FillGraphicAttribute& rFillGraphicAttribute = rPolygonCandidate.getFillGraphic();
704*035a2f44SArmin Le Grand 
705*035a2f44SArmin Le Grand                 // try to catch cases where the graphic will be color-modified to a single
706*035a2f44SArmin Le Grand                 // color (e.g. shadow)
707*035a2f44SArmin Le Grand                 switch(rFillGraphicAttribute.getGraphic().GetType())
708*035a2f44SArmin Le Grand                 {
709*035a2f44SArmin Le Grand                     case GRAPHIC_GDIMETAFILE:
710*035a2f44SArmin Le Grand                     {
711*035a2f44SArmin Le Grand                         // metafiles are potentially transparent, cannot optimize�, not done
712*035a2f44SArmin Le Grand                         break;
713*035a2f44SArmin Le Grand                     }
714*035a2f44SArmin Le Grand                     case GRAPHIC_BITMAP:
715*035a2f44SArmin Le Grand                     {
716*035a2f44SArmin Le Grand                         if(!rFillGraphicAttribute.getGraphic().IsTransparent() && !rFillGraphicAttribute.getGraphic().IsAlpha())
717*035a2f44SArmin Le Grand                         {
718*035a2f44SArmin Le Grand                             // bitmap is not transparent and has no alpha
719cdf0e10cSrcweir                             const sal_uInt32 nBColorModifierStackCount(maBColorModifierStack.count());
720cdf0e10cSrcweir 
721cdf0e10cSrcweir                             if(nBColorModifierStackCount)
722cdf0e10cSrcweir                             {
723cdf0e10cSrcweir                                 const basegfx::BColorModifier& rTopmostModifier = maBColorModifierStack.getBColorModifier(nBColorModifierStackCount - 1);
724cdf0e10cSrcweir 
725cdf0e10cSrcweir                                 if(basegfx::BCOLORMODIFYMODE_REPLACE == rTopmostModifier.getMode())
726cdf0e10cSrcweir                                 {
727cdf0e10cSrcweir                                     // the bitmap fill is in unified color, so we can replace it with
728cdf0e10cSrcweir                                     // a single polygon fill. The form of the fill depends on tiling
729*035a2f44SArmin Le Grand                                     if(rFillGraphicAttribute.getTiling())
730cdf0e10cSrcweir                                     {
731cdf0e10cSrcweir                                         // with tiling, fill the whole PolyPolygon with the modifier color
732cdf0e10cSrcweir                                         basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolyPolygon);
733cdf0e10cSrcweir 
734cdf0e10cSrcweir                                         aLocalPolyPolygon.transform(maCurrentTransformation);
735cdf0e10cSrcweir                                         mpOutputDevice->SetLineColor();
736cdf0e10cSrcweir                                         mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor()));
737cdf0e10cSrcweir                                         mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
738cdf0e10cSrcweir                                     }
739cdf0e10cSrcweir                                     else
740cdf0e10cSrcweir                                     {
741cdf0e10cSrcweir                                         // without tiling, only the area common to the bitmap tile and the
742cdf0e10cSrcweir                                         // PolyPolygon is filled. Create the bitmap tile area in object
743cdf0e10cSrcweir                                         // coordinates. For this, the object transformation needs to be created
744cdf0e10cSrcweir                                         // from the already scaled PolyPolygon. The tile area in object
745cdf0e10cSrcweir                                         // coordinates wil always be non-rotated, so it's not necessary to
746cdf0e10cSrcweir                                         // work with a polygon here
747*035a2f44SArmin Le Grand                                         basegfx::B2DRange aTileRange(rFillGraphicAttribute.getGraphicRange());
748cdf0e10cSrcweir                                         const basegfx::B2DRange aPolyPolygonRange(rPolyPolygon.getB2DRange());
749*035a2f44SArmin Le Grand                                         const basegfx::B2DHomMatrix aNewObjectTransform(
750*035a2f44SArmin Le Grand                                             basegfx::tools::createScaleTranslateB2DHomMatrix(
751*035a2f44SArmin Le Grand                                                 aPolyPolygonRange.getRange(),
752*035a2f44SArmin Le Grand                                                 aPolyPolygonRange.getMinimum()));
753cdf0e10cSrcweir 
754cdf0e10cSrcweir                                         aTileRange.transform(aNewObjectTransform);
755cdf0e10cSrcweir 
756cdf0e10cSrcweir                                         // now clip the object polyPolygon against the tile range
757*035a2f44SArmin Le Grand                                         // to get the common area
758*035a2f44SArmin Le Grand                                         basegfx::B2DPolyPolygon aTarget = basegfx::tools::clipPolyPolygonOnRange(
759*035a2f44SArmin Le Grand                                             rPolyPolygon,
760*035a2f44SArmin Le Grand                                             aTileRange,
761*035a2f44SArmin Le Grand                                             true,
762*035a2f44SArmin Le Grand                                             false);
763cdf0e10cSrcweir 
764cdf0e10cSrcweir                                         if(aTarget.count())
765cdf0e10cSrcweir                                         {
766cdf0e10cSrcweir                                             aTarget.transform(maCurrentTransformation);
767cdf0e10cSrcweir                                             mpOutputDevice->SetLineColor();
768cdf0e10cSrcweir                                             mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor()));
769cdf0e10cSrcweir                                             mpOutputDevice->DrawPolyPolygon(aTarget);
770cdf0e10cSrcweir                                         }
771cdf0e10cSrcweir                                     }
772cdf0e10cSrcweir 
773*035a2f44SArmin Le Grand                                     // simplified output executed, we are done
774cdf0e10cSrcweir                                     bDone = true;
775cdf0e10cSrcweir                                 }
776cdf0e10cSrcweir                             }
777cdf0e10cSrcweir                         }
778*035a2f44SArmin Le Grand                         break;
779cdf0e10cSrcweir                     }
780*035a2f44SArmin Le Grand                     default: //GRAPHIC_NONE, GRAPHIC_DEFAULT
781cdf0e10cSrcweir                     {
782*035a2f44SArmin Le Grand                         // empty graphic, we are done
783cdf0e10cSrcweir                         bDone = true;
784*035a2f44SArmin Le Grand                         break;
785*035a2f44SArmin Le Grand                     }
786*035a2f44SArmin Le Grand                 }
787cdf0e10cSrcweir             }
788cdf0e10cSrcweir 
789cdf0e10cSrcweir             if(!bDone)
790cdf0e10cSrcweir             {
791cdf0e10cSrcweir                 // use default decomposition
792cdf0e10cSrcweir                 process(rPolygonCandidate.get2DDecomposition(getViewInformation2D()));
793cdf0e10cSrcweir             }
794cdf0e10cSrcweir         }
795cdf0e10cSrcweir 
796cdf0e10cSrcweir 		// direct draw of PolyPolygon with color
797cdf0e10cSrcweir 		void VclProcessor2D::RenderPolyPolygonColorPrimitive2D(const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate)
798cdf0e10cSrcweir 		{
799cdf0e10cSrcweir 			const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor()));
800cdf0e10cSrcweir 			mpOutputDevice->SetFillColor(Color(aPolygonColor));
801cdf0e10cSrcweir 			mpOutputDevice->SetLineColor();
802cdf0e10cSrcweir 
803cdf0e10cSrcweir 			basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
804cdf0e10cSrcweir 			aLocalPolyPolygon.transform(maCurrentTransformation);
805cdf0e10cSrcweir 
806cdf0e10cSrcweir             static bool bCheckTrapezoidDecomposition(false);
807cdf0e10cSrcweir             static bool bShowOutlinesThere(false);
808cdf0e10cSrcweir             if(bCheckTrapezoidDecomposition)
809cdf0e10cSrcweir             {
810cdf0e10cSrcweir                 // clip against discrete ViewPort
811cdf0e10cSrcweir                 const basegfx::B2DRange& rDiscreteViewport = getViewInformation2D().getDiscreteViewport();
812cdf0e10cSrcweir                 aLocalPolyPolygon = basegfx::tools::clipPolyPolygonOnRange(
813cdf0e10cSrcweir                     aLocalPolyPolygon, rDiscreteViewport, true, false);
814cdf0e10cSrcweir 
815cdf0e10cSrcweir                 if(aLocalPolyPolygon.count())
816cdf0e10cSrcweir                 {
817cdf0e10cSrcweir                     // subdivide
818cdf0e10cSrcweir                     aLocalPolyPolygon = basegfx::tools::adaptiveSubdivideByDistance(
819cdf0e10cSrcweir                         aLocalPolyPolygon, 0.5);
820cdf0e10cSrcweir 
821cdf0e10cSrcweir                     // trapezoidize
822cdf0e10cSrcweir                     basegfx::B2DTrapezoidVector aB2DTrapezoidVector;
823cdf0e10cSrcweir                     basegfx::tools::trapezoidSubdivide(aB2DTrapezoidVector, aLocalPolyPolygon);
824cdf0e10cSrcweir 
825cdf0e10cSrcweir                     const sal_uInt32 nCount(aB2DTrapezoidVector.size());
826cdf0e10cSrcweir 
827cdf0e10cSrcweir                     if(nCount)
828cdf0e10cSrcweir                     {
829cdf0e10cSrcweir                         basegfx::BColor aInvPolygonColor(aPolygonColor);
830cdf0e10cSrcweir                         aInvPolygonColor.invert();
831cdf0e10cSrcweir 
832cdf0e10cSrcweir                         for(sal_uInt32 a(0); a < nCount; a++)
833cdf0e10cSrcweir                         {
834cdf0e10cSrcweir                             const basegfx::B2DPolygon aTempPolygon(aB2DTrapezoidVector[a].getB2DPolygon());
835cdf0e10cSrcweir 
836cdf0e10cSrcweir                             if(bShowOutlinesThere)
837cdf0e10cSrcweir                             {
838cdf0e10cSrcweir                                 mpOutputDevice->SetFillColor(Color(aPolygonColor));
839cdf0e10cSrcweir 			                    mpOutputDevice->SetLineColor();
840cdf0e10cSrcweir                             }
841cdf0e10cSrcweir 
842cdf0e10cSrcweir                             mpOutputDevice->DrawPolygon(aTempPolygon);
843cdf0e10cSrcweir 
844cdf0e10cSrcweir                             if(bShowOutlinesThere)
845cdf0e10cSrcweir                             {
846cdf0e10cSrcweir                                 mpOutputDevice->SetFillColor();
847cdf0e10cSrcweir         		                mpOutputDevice->SetLineColor(Color(aInvPolygonColor));
848cdf0e10cSrcweir     	    		            mpOutputDevice->DrawPolyLine(aTempPolygon, 0.0);
849cdf0e10cSrcweir                             }
850cdf0e10cSrcweir                         }
851cdf0e10cSrcweir                     }
852cdf0e10cSrcweir                 }
853cdf0e10cSrcweir             }
854cdf0e10cSrcweir             else
855cdf0e10cSrcweir             {
856cdf0e10cSrcweir 			    mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
857cdf0e10cSrcweir 
858cdf0e10cSrcweir                 if(mnPolygonStrokePrimitive2D
859cdf0e10cSrcweir                     && getOptionsDrawinglayer().IsAntiAliasing()
860cdf0e10cSrcweir                     && (mpOutputDevice->GetAntialiasing() & ANTIALIASING_ENABLE_B2DDRAW))
861cdf0e10cSrcweir                 {
862cdf0e10cSrcweir                     // when AA is on and this filled polygons are the result of stroked line geometry,
863cdf0e10cSrcweir                     // draw the geometry once extra as lines to avoid AA 'gaps' between partial polygons
864cdf0e10cSrcweir 			        mpOutputDevice->SetFillColor();
865cdf0e10cSrcweir 			        mpOutputDevice->SetLineColor(Color(aPolygonColor));
866cdf0e10cSrcweir                     const sal_uInt32 nCount(aLocalPolyPolygon.count());
867cdf0e10cSrcweir 
868cdf0e10cSrcweir                     for(sal_uInt32 a(0); a < nCount; a++)
869cdf0e10cSrcweir                     {
870cdf0e10cSrcweir                         mpOutputDevice->DrawPolyLine(aLocalPolyPolygon.getB2DPolygon(a), 0.0);
871cdf0e10cSrcweir                     }
872cdf0e10cSrcweir                 }
873cdf0e10cSrcweir             }
874cdf0e10cSrcweir 		}
875cdf0e10cSrcweir 
876cdf0e10cSrcweir 		// direct draw of MetaFile
877cdf0e10cSrcweir 		void VclProcessor2D::RenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rMetaCandidate)
878cdf0e10cSrcweir 		{
879cdf0e10cSrcweir 			// decompose matrix to check for shear, rotate and mirroring
880cdf0e10cSrcweir 			basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rMetaCandidate.getTransform());
881cdf0e10cSrcweir 			basegfx::B2DVector aScale, aTranslate;
882cdf0e10cSrcweir 			double fRotate, fShearX;
883cdf0e10cSrcweir 			aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
884cdf0e10cSrcweir 
885cdf0e10cSrcweir 			if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
886cdf0e10cSrcweir 			{
887cdf0e10cSrcweir 				// #i102175# handle special case: If scale is negative in (x,y) (3rd quadrant), it can
888cdf0e10cSrcweir 				// be expressed as rotation by PI. This needs to be done for Metafiles since
889cdf0e10cSrcweir                 // these can be rotated, but not really mirrored
890cdf0e10cSrcweir 				aScale = basegfx::absolute(aScale);
891cdf0e10cSrcweir 				fRotate += F_PI;
892cdf0e10cSrcweir 			}
893cdf0e10cSrcweir 
894cdf0e10cSrcweir             // get BoundRect
895cdf0e10cSrcweir 			basegfx::B2DRange aOutlineRange(rMetaCandidate.getB2DRange(getViewInformation2D()));
896cdf0e10cSrcweir 			aOutlineRange.transform(maCurrentTransformation);
897cdf0e10cSrcweir 
898cdf0e10cSrcweir 			// Due to the integer MapModes used from VCL aind inside MetaFiles errors of up to three
899cdf0e10cSrcweir 			// pixels in size may happen. As long as there is no better way (e.g. convert the MetaFile
900cdf0e10cSrcweir 			// to primitives) it is necessary to reduce maximum pixel size by 1 in X and Y and to use
901cdf0e10cSrcweir 			// the inner pixel bounds accordingly (ceil resp. floor). This will also be done for logic
902cdf0e10cSrcweir 			// units e.g. when creating a new MetaFile, but since much huger value ranges are used
903cdf0e10cSrcweir 			// there typically will be okay for this compromize.
904cdf0e10cSrcweir 			Rectangle aDestRectView(
905cdf0e10cSrcweir                 // !!CAUTION!! Here, ceil and floor are exchanged BY PURPOSE, do NOT copy when
906cdf0e10cSrcweir                 // looking for a standard conversion to rectangle (!)
907cdf0e10cSrcweir 				(sal_Int32)ceil(aOutlineRange.getMinX()), (sal_Int32)ceil(aOutlineRange.getMinY()),
908cdf0e10cSrcweir 				(sal_Int32)floor(aOutlineRange.getMaxX()), (sal_Int32)floor(aOutlineRange.getMaxY()));
909cdf0e10cSrcweir 
910cdf0e10cSrcweir 			// get metafile (copy it)
911cdf0e10cSrcweir 			GDIMetaFile aMetaFile;
912cdf0e10cSrcweir 
913cdf0e10cSrcweir 			if(maBColorModifierStack.count())
914cdf0e10cSrcweir 			{
915cdf0e10cSrcweir 				const basegfx::BColor aRGBBaseColor(0, 0, 0);
916cdf0e10cSrcweir 				const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(aRGBBaseColor));
917cdf0e10cSrcweir 				aMetaFile = rMetaCandidate.getMetaFile().GetMonochromeMtf(Color(aRGBColor));
918cdf0e10cSrcweir 			}
919cdf0e10cSrcweir 			else
920cdf0e10cSrcweir 			{
921cdf0e10cSrcweir 				aMetaFile = rMetaCandidate.getMetaFile();
922cdf0e10cSrcweir 			}
923cdf0e10cSrcweir 
924cdf0e10cSrcweir 			// rotation
925cdf0e10cSrcweir 			if(!basegfx::fTools::equalZero(fRotate))
926cdf0e10cSrcweir 			{
927cdf0e10cSrcweir                 // #i103530#
928cdf0e10cSrcweir                 // MetaFile::Rotate has no input parameter check, so the parameter needs to be
929cdf0e10cSrcweir                 // well-aligned to the old range [0..3600] 10th degrees with inverse orientation
930cdf0e10cSrcweir 				sal_Int16 nRotation((sal_Int16)((fRotate / F_PI180) * -10.0));
931cdf0e10cSrcweir 
932cdf0e10cSrcweir                 while(nRotation < 0)
933cdf0e10cSrcweir                     nRotation += 3600;
934cdf0e10cSrcweir 
935cdf0e10cSrcweir                 while(nRotation >= 3600)
936cdf0e10cSrcweir                     nRotation -= 3600;
937cdf0e10cSrcweir 
938cdf0e10cSrcweir 				aMetaFile.Rotate(nRotation);
939cdf0e10cSrcweir 			}
940cdf0e10cSrcweir 
941cdf0e10cSrcweir 			// Prepare target output size
942cdf0e10cSrcweir 			Size aDestSize(aDestRectView.GetSize());
943cdf0e10cSrcweir 
944cdf0e10cSrcweir 			if(aDestSize.getWidth() && aDestSize.getHeight())
945cdf0e10cSrcweir 			{
946cdf0e10cSrcweir 				// Get preferred Metafile output size. When it's very equal to the output size, it's probably
947cdf0e10cSrcweir 				// a rounding error somewhere, so correct it to get a 1:1 output without single pixel scalings
948cdf0e10cSrcweir 				// of the Metafile (esp. for contaned Bitmaps, e.g 3D charts)
949cdf0e10cSrcweir 				const Size aPrefSize(mpOutputDevice->LogicToPixel(aMetaFile.GetPrefSize(), aMetaFile.GetPrefMapMode()));
950cdf0e10cSrcweir 
951cdf0e10cSrcweir 				if(aPrefSize.getWidth() && (aPrefSize.getWidth() - 1 == aDestSize.getWidth() || aPrefSize.getWidth() + 1 == aDestSize.getWidth()))
952cdf0e10cSrcweir 				{
953cdf0e10cSrcweir 					aDestSize.setWidth(aPrefSize.getWidth());
954cdf0e10cSrcweir 				}
955cdf0e10cSrcweir 
956cdf0e10cSrcweir 				if(aPrefSize.getHeight() && (aPrefSize.getHeight() - 1 == aDestSize.getHeight() || aPrefSize.getHeight() + 1 == aDestSize.getHeight()))
957cdf0e10cSrcweir 				{
958cdf0e10cSrcweir 					aDestSize.setHeight(aPrefSize.getHeight());
959cdf0e10cSrcweir 				}
960cdf0e10cSrcweir 
961cdf0e10cSrcweir 				// paint it
962cdf0e10cSrcweir 				aMetaFile.WindStart();
963cdf0e10cSrcweir 				aMetaFile.Play(mpOutputDevice, aDestRectView.TopLeft(), aDestSize);
964cdf0e10cSrcweir 			}
965cdf0e10cSrcweir 		}
966cdf0e10cSrcweir 
967cdf0e10cSrcweir 		// mask group. Force output to VDev and create mask from given mask
968cdf0e10cSrcweir 		void VclProcessor2D::RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate)
969cdf0e10cSrcweir 		{
970cdf0e10cSrcweir 			if(rMaskCandidate.getChildren().hasElements())
971cdf0e10cSrcweir 			{
972cdf0e10cSrcweir 				basegfx::B2DPolyPolygon aMask(rMaskCandidate.getMask());
973cdf0e10cSrcweir 
974cdf0e10cSrcweir 				if(aMask.count())
975cdf0e10cSrcweir 				{
976cdf0e10cSrcweir 					aMask.transform(maCurrentTransformation);
977cdf0e10cSrcweir 					const basegfx::B2DRange aRange(basegfx::tools::getRange(aMask));
978cdf0e10cSrcweir 					impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
979cdf0e10cSrcweir 
980cdf0e10cSrcweir 					if(aBufferDevice.isVisible())
981cdf0e10cSrcweir 					{
982cdf0e10cSrcweir 						// remember last OutDev and set to content
983cdf0e10cSrcweir 						OutputDevice* pLastOutputDevice = mpOutputDevice;
984cdf0e10cSrcweir 						mpOutputDevice = &aBufferDevice.getContent();
985cdf0e10cSrcweir 
986cdf0e10cSrcweir 						// paint to it
987cdf0e10cSrcweir 						process(rMaskCandidate.getChildren());
988cdf0e10cSrcweir 
989cdf0e10cSrcweir 						// back to old OutDev
990cdf0e10cSrcweir 						mpOutputDevice = pLastOutputDevice;
991cdf0e10cSrcweir 
992cdf0e10cSrcweir 					    // draw mask
993cdf0e10cSrcweir                         if(getOptionsDrawinglayer().IsAntiAliasing())
994cdf0e10cSrcweir                         {
995cdf0e10cSrcweir                             // with AA, use 8bit AlphaMask to get nice borders
996cdf0e10cSrcweir 						    VirtualDevice& rTransparence = aBufferDevice.getTransparence();
997cdf0e10cSrcweir 						    rTransparence.SetLineColor();
998cdf0e10cSrcweir 						    rTransparence.SetFillColor(COL_BLACK);
999cdf0e10cSrcweir 						    rTransparence.DrawPolyPolygon(aMask);
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir 						    // dump buffer to outdev
1002cdf0e10cSrcweir 						    aBufferDevice.paint();
1003cdf0e10cSrcweir                         }
1004cdf0e10cSrcweir                         else
1005cdf0e10cSrcweir                         {
1006cdf0e10cSrcweir                             // No AA, use 1bit mask
1007cdf0e10cSrcweir 						    VirtualDevice& rMask = aBufferDevice.getMask();
1008cdf0e10cSrcweir 						    rMask.SetLineColor();
1009cdf0e10cSrcweir 						    rMask.SetFillColor(COL_BLACK);
1010cdf0e10cSrcweir 						    rMask.DrawPolyPolygon(aMask);
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir 						    // dump buffer to outdev
1013cdf0e10cSrcweir 						    aBufferDevice.paint();
1014cdf0e10cSrcweir                         }
1015cdf0e10cSrcweir 					}
1016cdf0e10cSrcweir 				}
1017cdf0e10cSrcweir 			}
1018cdf0e10cSrcweir 		}
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir 		// modified color group. Force output to unified color.
1021cdf0e10cSrcweir 		void VclProcessor2D::RenderModifiedColorPrimitive2D(const primitive2d::ModifiedColorPrimitive2D& rModifiedCandidate)
1022cdf0e10cSrcweir 		{
1023cdf0e10cSrcweir 			if(rModifiedCandidate.getChildren().hasElements())
1024cdf0e10cSrcweir 			{
1025cdf0e10cSrcweir 				maBColorModifierStack.push(rModifiedCandidate.getColorModifier());
1026cdf0e10cSrcweir 				process(rModifiedCandidate.getChildren());
1027cdf0e10cSrcweir 				maBColorModifierStack.pop();
1028cdf0e10cSrcweir 			}
1029cdf0e10cSrcweir 		}
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir 		// unified sub-transparence. Draw to VDev first.
1032cdf0e10cSrcweir 		void VclProcessor2D::RenderUnifiedTransparencePrimitive2D(const primitive2d::UnifiedTransparencePrimitive2D& rTransCandidate)
1033cdf0e10cSrcweir 		{
1034cdf0e10cSrcweir             static bool bForceToDecomposition(false);
1035cdf0e10cSrcweir 
1036cdf0e10cSrcweir             if(rTransCandidate.getChildren().hasElements())
1037cdf0e10cSrcweir             {
1038cdf0e10cSrcweir                 if(bForceToDecomposition)
1039cdf0e10cSrcweir                 {
1040cdf0e10cSrcweir     			    // use decomposition
1041cdf0e10cSrcweir 	    		    process(rTransCandidate.get2DDecomposition(getViewInformation2D()));
1042cdf0e10cSrcweir                 }
1043cdf0e10cSrcweir                 else
1044cdf0e10cSrcweir                 {
1045cdf0e10cSrcweir 			        if(0.0 == rTransCandidate.getTransparence())
1046cdf0e10cSrcweir 			        {
1047cdf0e10cSrcweir 				        // no transparence used, so just use the content
1048cdf0e10cSrcweir     	    		    process(rTransCandidate.getChildren());
1049cdf0e10cSrcweir 			        }
1050cdf0e10cSrcweir 			        else if(rTransCandidate.getTransparence() > 0.0 && rTransCandidate.getTransparence() < 1.0)
1051cdf0e10cSrcweir 			        {
1052cdf0e10cSrcweir                         // transparence is in visible range
1053cdf0e10cSrcweir 				        basegfx::B2DRange aRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rTransCandidate.getChildren(), getViewInformation2D()));
1054cdf0e10cSrcweir 				        aRange.transform(maCurrentTransformation);
1055cdf0e10cSrcweir 				        impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 				        if(aBufferDevice.isVisible())
1058cdf0e10cSrcweir 				        {
1059cdf0e10cSrcweir 					        // remember last OutDev and set to content
1060cdf0e10cSrcweir 					        OutputDevice* pLastOutputDevice = mpOutputDevice;
1061cdf0e10cSrcweir 					        mpOutputDevice = &aBufferDevice.getContent();
1062cdf0e10cSrcweir 
1063cdf0e10cSrcweir 					        // paint content to it
1064cdf0e10cSrcweir 					        process(rTransCandidate.getChildren());
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir 					        // back to old OutDev
1067cdf0e10cSrcweir 					        mpOutputDevice = pLastOutputDevice;
1068cdf0e10cSrcweir 
1069cdf0e10cSrcweir 					        // dump buffer to outdev using given transparence
1070cdf0e10cSrcweir 					        aBufferDevice.paint(rTransCandidate.getTransparence());
1071cdf0e10cSrcweir 				        }
1072cdf0e10cSrcweir 			        }
1073cdf0e10cSrcweir                 }
1074cdf0e10cSrcweir             }
1075cdf0e10cSrcweir 		}
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir 		// sub-transparence group. Draw to VDev first.
1078cdf0e10cSrcweir 		void VclProcessor2D::RenderTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransCandidate)
1079cdf0e10cSrcweir 		{
1080cdf0e10cSrcweir 			if(rTransCandidate.getChildren().hasElements())
1081cdf0e10cSrcweir 			{
1082cdf0e10cSrcweir 				basegfx::B2DRange aRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rTransCandidate.getChildren(), getViewInformation2D()));
1083cdf0e10cSrcweir 				aRange.transform(maCurrentTransformation);
1084cdf0e10cSrcweir 				impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir 				if(aBufferDevice.isVisible())
1087cdf0e10cSrcweir 				{
1088cdf0e10cSrcweir 					// remember last OutDev and set to content
1089cdf0e10cSrcweir 					OutputDevice* pLastOutputDevice = mpOutputDevice;
1090cdf0e10cSrcweir 					mpOutputDevice = &aBufferDevice.getContent();
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir 					// paint content to it
1093cdf0e10cSrcweir 					process(rTransCandidate.getChildren());
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir 					// set to mask
1096cdf0e10cSrcweir 					mpOutputDevice = &aBufferDevice.getTransparence();
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir 					// when painting transparence masks, reset the color stack
1099cdf0e10cSrcweir 					basegfx::BColorModifierStack aLastBColorModifierStack(maBColorModifierStack);
1100cdf0e10cSrcweir 					maBColorModifierStack = basegfx::BColorModifierStack();
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir 					// paint mask to it (always with transparence intensities, evtl. with AA)
1103cdf0e10cSrcweir 					process(rTransCandidate.getTransparence());
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir 					// back to old color stack
1106cdf0e10cSrcweir 					maBColorModifierStack = aLastBColorModifierStack;
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir 					// back to old OutDev
1109cdf0e10cSrcweir 					mpOutputDevice = pLastOutputDevice;
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir 					// dump buffer to outdev
1112cdf0e10cSrcweir 					aBufferDevice.paint();
1113cdf0e10cSrcweir 				}
1114cdf0e10cSrcweir 			}
1115cdf0e10cSrcweir 		}
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir 		// transform group.
1118cdf0e10cSrcweir 		void VclProcessor2D::RenderTransformPrimitive2D(const primitive2d::TransformPrimitive2D& rTransformCandidate)
1119cdf0e10cSrcweir 		{
1120cdf0e10cSrcweir 			// remember current transformation and ViewInformation
1121cdf0e10cSrcweir 			const basegfx::B2DHomMatrix aLastCurrentTransformation(maCurrentTransformation);
1122cdf0e10cSrcweir             const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir 			// create new transformations for CurrentTransformation
1125cdf0e10cSrcweir             // and for local ViewInformation2D
1126cdf0e10cSrcweir 			maCurrentTransformation = maCurrentTransformation * rTransformCandidate.getTransformation();
1127cdf0e10cSrcweir             const geometry::ViewInformation2D aViewInformation2D(
1128cdf0e10cSrcweir                 getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(),
1129cdf0e10cSrcweir                 getViewInformation2D().getViewTransformation(),
1130cdf0e10cSrcweir                 getViewInformation2D().getViewport(),
1131cdf0e10cSrcweir 				getViewInformation2D().getVisualizedPage(),
1132cdf0e10cSrcweir                 getViewInformation2D().getViewTime(),
1133cdf0e10cSrcweir 				getViewInformation2D().getExtendedInformationSequence());
1134cdf0e10cSrcweir 			updateViewInformation(aViewInformation2D);
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir 			// proccess content
1137cdf0e10cSrcweir 			process(rTransformCandidate.getChildren());
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir 			// restore transformations
1140cdf0e10cSrcweir 			maCurrentTransformation = aLastCurrentTransformation;
1141cdf0e10cSrcweir             updateViewInformation(aLastViewInformation2D);
1142cdf0e10cSrcweir 		}
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir 		// new XDrawPage for ViewInformation2D
1145cdf0e10cSrcweir 		void VclProcessor2D::RenderPagePreviewPrimitive2D(const primitive2d::PagePreviewPrimitive2D& rPagePreviewCandidate)
1146cdf0e10cSrcweir 		{
1147cdf0e10cSrcweir 			// remember current transformation and ViewInformation
1148cdf0e10cSrcweir             const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir 			// create new local ViewInformation2D
1151cdf0e10cSrcweir             const geometry::ViewInformation2D aViewInformation2D(
1152cdf0e10cSrcweir                 getViewInformation2D().getObjectTransformation(),
1153cdf0e10cSrcweir                 getViewInformation2D().getViewTransformation(),
1154cdf0e10cSrcweir                 getViewInformation2D().getViewport(),
1155cdf0e10cSrcweir 				rPagePreviewCandidate.getXDrawPage(),
1156cdf0e10cSrcweir                 getViewInformation2D().getViewTime(),
1157cdf0e10cSrcweir 				getViewInformation2D().getExtendedInformationSequence());
1158cdf0e10cSrcweir 			updateViewInformation(aViewInformation2D);
1159cdf0e10cSrcweir 
1160cdf0e10cSrcweir 			// proccess decomposed content
1161cdf0e10cSrcweir 			process(rPagePreviewCandidate.get2DDecomposition(getViewInformation2D()));
1162cdf0e10cSrcweir 
1163cdf0e10cSrcweir 			// restore transformations
1164cdf0e10cSrcweir             updateViewInformation(aLastViewInformation2D);
1165cdf0e10cSrcweir 		}
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir 		// marker
1168cdf0e10cSrcweir 		void VclProcessor2D::RenderMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkArrayCandidate)
1169cdf0e10cSrcweir 		{
1170cdf0e10cSrcweir             static bool bCheckCompleteMarkerDecompose(false);
1171cdf0e10cSrcweir             if(bCheckCompleteMarkerDecompose)
1172cdf0e10cSrcweir             {
1173cdf0e10cSrcweir 			    process(rMarkArrayCandidate.get2DDecomposition(getViewInformation2D()));
1174cdf0e10cSrcweir                 return;
1175cdf0e10cSrcweir             }
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir 			// get data
1178cdf0e10cSrcweir 	        const std::vector< basegfx::B2DPoint >& rPositions = rMarkArrayCandidate.getPositions();
1179cdf0e10cSrcweir 			const sal_uInt32 nCount(rPositions.size());
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir 			if(nCount && !rMarkArrayCandidate.getMarker().IsEmpty())
1182cdf0e10cSrcweir 			{
1183cdf0e10cSrcweir 				// get pixel size
1184cdf0e10cSrcweir 				const BitmapEx& rMarker(rMarkArrayCandidate.getMarker());
1185cdf0e10cSrcweir 				const Size aBitmapSize(rMarker.GetSizePixel());
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir 				if(aBitmapSize.Width() && aBitmapSize.Height())
1188cdf0e10cSrcweir 				{
1189cdf0e10cSrcweir 					// get discrete half size
1190cdf0e10cSrcweir 					const basegfx::B2DVector aDiscreteHalfSize(
1191cdf0e10cSrcweir                         (aBitmapSize.getWidth() - 1.0) * 0.5,
1192cdf0e10cSrcweir                         (aBitmapSize.getHeight() - 1.0) * 0.5);
1193cdf0e10cSrcweir 			        const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled());
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir                     // do not forget evtl. moved origin in target device MapMode when
1196cdf0e10cSrcweir                     // switching it off; it would be missing and lead to wrong positions.
1197cdf0e10cSrcweir                     // All his could be done using logic sizes and coordinates, too, but
1198cdf0e10cSrcweir                     // we want a 1:1 bitmap rendering here, so it's more safe and faster
1199cdf0e10cSrcweir                     // to work with switching off MapMode usage completely.
1200cdf0e10cSrcweir                     const Point aOrigin(mpOutputDevice->GetMapMode().GetOrigin());
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir                     mpOutputDevice->EnableMapMode(false);
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir 					for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); aIter++)
1205cdf0e10cSrcweir 				    {
1206cdf0e10cSrcweir 					    const basegfx::B2DPoint aDiscreteTopLeft((maCurrentTransformation * (*aIter)) - aDiscreteHalfSize);
1207cdf0e10cSrcweir                         const Point aDiscretePoint(basegfx::fround(aDiscreteTopLeft.getX()), basegfx::fround(aDiscreteTopLeft.getY()));
1208cdf0e10cSrcweir 
1209cdf0e10cSrcweir 						mpOutputDevice->DrawBitmapEx(aDiscretePoint + aOrigin, rMarker);
1210cdf0e10cSrcweir 					}
1211cdf0e10cSrcweir 
1212cdf0e10cSrcweir 			        mpOutputDevice->EnableMapMode(bWasEnabled);
1213cdf0e10cSrcweir 				}
1214cdf0e10cSrcweir 			}
1215cdf0e10cSrcweir 		}
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir 		// point
1218cdf0e10cSrcweir 		void VclProcessor2D::RenderPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate)
1219cdf0e10cSrcweir 		{
1220cdf0e10cSrcweir 			const std::vector< basegfx::B2DPoint >& rPositions = rPointArrayCandidate.getPositions();
1221cdf0e10cSrcweir 			const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(rPointArrayCandidate.getRGBColor()));
1222cdf0e10cSrcweir 			const Color aVCLColor(aRGBColor);
1223cdf0e10cSrcweir 
1224cdf0e10cSrcweir 			for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); aIter++)
1225cdf0e10cSrcweir 			{
1226cdf0e10cSrcweir 				const basegfx::B2DPoint aViewPosition(maCurrentTransformation * (*aIter));
1227cdf0e10cSrcweir 				const Point aPos(basegfx::fround(aViewPosition.getX()), basegfx::fround(aViewPosition.getY()));
1228cdf0e10cSrcweir 
1229cdf0e10cSrcweir 				mpOutputDevice->DrawPixel(aPos, aVCLColor);
1230cdf0e10cSrcweir 			}
1231cdf0e10cSrcweir 		}
1232cdf0e10cSrcweir 
1233cdf0e10cSrcweir 		void VclProcessor2D::RenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate)
1234cdf0e10cSrcweir 		{
1235cdf0e10cSrcweir             // #i101491# method restructured to clearly use the DrawPolyLine
1236cdf0e10cSrcweir             // calls starting from a deined line width
1237cdf0e10cSrcweir 			const attribute::LineAttribute& rLineAttribute = rPolygonStrokeCandidate.getLineAttribute();
1238cdf0e10cSrcweir 			const double fLineWidth(rLineAttribute.getWidth());
1239cdf0e10cSrcweir 			bool bDone(false);
1240cdf0e10cSrcweir 
1241cdf0e10cSrcweir 			if(basegfx::fTools::more(fLineWidth, 0.0))
1242cdf0e10cSrcweir 			{
1243cdf0e10cSrcweir 				const basegfx::B2DVector aDiscreteUnit(maCurrentTransformation * basegfx::B2DVector(fLineWidth, 0.0));
1244cdf0e10cSrcweir 				const double fDiscreteLineWidth(aDiscreteUnit.getLength());
1245cdf0e10cSrcweir 				const attribute::StrokeAttribute& rStrokeAttribute = rPolygonStrokeCandidate.getStrokeAttribute();
1246cdf0e10cSrcweir 				const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rLineAttribute.getColor()));
1247cdf0e10cSrcweir 				basegfx::B2DPolyPolygon aHairlinePolyPolygon;
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir 				mpOutputDevice->SetLineColor(Color(aHairlineColor));
1250cdf0e10cSrcweir 				mpOutputDevice->SetFillColor();
1251cdf0e10cSrcweir 
1252cdf0e10cSrcweir 				if(0.0 == rStrokeAttribute.getFullDotDashLen())
1253cdf0e10cSrcweir 				{
1254cdf0e10cSrcweir 					// no line dashing, just copy
1255cdf0e10cSrcweir 					aHairlinePolyPolygon.append(rPolygonStrokeCandidate.getB2DPolygon());
1256cdf0e10cSrcweir 				}
1257cdf0e10cSrcweir 				else
1258cdf0e10cSrcweir 				{
1259cdf0e10cSrcweir 					// else apply LineStyle
1260cdf0e10cSrcweir 					basegfx::tools::applyLineDashing(rPolygonStrokeCandidate.getB2DPolygon(),
1261cdf0e10cSrcweir 						rStrokeAttribute.getDotDashArray(),
1262cdf0e10cSrcweir 						&aHairlinePolyPolygon, 0, rStrokeAttribute.getFullDotDashLen());
1263cdf0e10cSrcweir 				}
1264cdf0e10cSrcweir 
1265cdf0e10cSrcweir 				const sal_uInt32 nCount(aHairlinePolyPolygon.count());
1266cdf0e10cSrcweir 
1267cdf0e10cSrcweir 				if(nCount)
1268cdf0e10cSrcweir 				{
1269cdf0e10cSrcweir                     const bool bAntiAliased(getOptionsDrawinglayer().IsAntiAliasing());
1270cdf0e10cSrcweir                     aHairlinePolyPolygon.transform(maCurrentTransformation);
1271cdf0e10cSrcweir 
1272cdf0e10cSrcweir                     if(bAntiAliased)
1273cdf0e10cSrcweir                     {
1274cdf0e10cSrcweir                         if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 1.0))
1275cdf0e10cSrcweir                         {
1276cdf0e10cSrcweir                             // line in range ]0.0 .. 1.0[
1277cdf0e10cSrcweir                             // paint as simple hairline
12787be6ee6dSArmin Le Grand                             for(sal_uInt32 a(0); a < nCount; a++)
12797be6ee6dSArmin Le Grand                             {
12807be6ee6dSArmin Le Grand                                 mpOutputDevice->DrawPolyLine(aHairlinePolyPolygon.getB2DPolygon(a), 0.0);
12817be6ee6dSArmin Le Grand                             }
12827be6ee6dSArmin Le Grand 
1283cdf0e10cSrcweir                             bDone = true;
1284cdf0e10cSrcweir                         }
1285cdf0e10cSrcweir                         else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 2.0))
1286cdf0e10cSrcweir                         {
1287cdf0e10cSrcweir                             // line in range [1.0 .. 2.0[
1288cdf0e10cSrcweir                             // paint as 2x2 with dynamic line distance
1289cdf0e10cSrcweir                             basegfx::B2DHomMatrix aMat;
1290cdf0e10cSrcweir                             const double fDistance(fDiscreteLineWidth - 1.0);
1291cdf0e10cSrcweir                             const double fHalfDistance(fDistance * 0.5);
1292cdf0e10cSrcweir 
12937be6ee6dSArmin Le Grand                             for(sal_uInt32 a(0); a < nCount; a++)
12947be6ee6dSArmin Le Grand                             {
12957be6ee6dSArmin Le Grand                                 basegfx::B2DPolygon aCandidate(aHairlinePolyPolygon.getB2DPolygon(a));
12967be6ee6dSArmin Le Grand 
1297cdf0e10cSrcweir                                 aMat.set(0, 2, -fHalfDistance);
1298cdf0e10cSrcweir                                 aMat.set(1, 2, -fHalfDistance);
1299cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1300cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1301cdf0e10cSrcweir 
1302cdf0e10cSrcweir                                 aMat.set(0, 2, fDistance);
1303cdf0e10cSrcweir                                 aMat.set(1, 2, 0.0);
1304cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1305cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1306cdf0e10cSrcweir 
1307cdf0e10cSrcweir                                 aMat.set(0, 2, 0.0);
1308cdf0e10cSrcweir                                 aMat.set(1, 2, fDistance);
1309cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1310cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1311cdf0e10cSrcweir 
1312cdf0e10cSrcweir                                 aMat.set(0, 2, -fDistance);
1313cdf0e10cSrcweir                                 aMat.set(1, 2, 0.0);
1314cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1315cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
13167be6ee6dSArmin Le Grand                             }
13177be6ee6dSArmin Le Grand 
1318cdf0e10cSrcweir                             bDone = true;
1319cdf0e10cSrcweir                         }
1320cdf0e10cSrcweir                         else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 3.0))
1321cdf0e10cSrcweir                         {
1322cdf0e10cSrcweir                             // line in range [2.0 .. 3.0]
1323cdf0e10cSrcweir                             // paint as cross in a 3x3  with dynamic line distance
1324cdf0e10cSrcweir                             basegfx::B2DHomMatrix aMat;
1325cdf0e10cSrcweir                             const double fDistance((fDiscreteLineWidth - 1.0) * 0.5);
1326cdf0e10cSrcweir 
13277be6ee6dSArmin Le Grand                             for(sal_uInt32 a(0); a < nCount; a++)
13287be6ee6dSArmin Le Grand                             {
13297be6ee6dSArmin Le Grand                                 basegfx::B2DPolygon aCandidate(aHairlinePolyPolygon.getB2DPolygon(a));
13307be6ee6dSArmin Le Grand 
1331cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1332cdf0e10cSrcweir 
1333cdf0e10cSrcweir                                 aMat.set(0, 2, -fDistance);
1334cdf0e10cSrcweir                                 aMat.set(1, 2, 0.0);
1335cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1336cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1337cdf0e10cSrcweir 
1338cdf0e10cSrcweir                                 aMat.set(0, 2, fDistance);
1339cdf0e10cSrcweir                                 aMat.set(1, 2, -fDistance);
1340cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1341cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1342cdf0e10cSrcweir 
1343cdf0e10cSrcweir                                 aMat.set(0, 2, fDistance);
1344cdf0e10cSrcweir                                 aMat.set(1, 2, fDistance);
1345cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1346cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1347cdf0e10cSrcweir 
1348cdf0e10cSrcweir                                 aMat.set(0, 2, -fDistance);
1349cdf0e10cSrcweir                                 aMat.set(1, 2, fDistance);
1350cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1351cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
13527be6ee6dSArmin Le Grand                             }
13537be6ee6dSArmin Le Grand 
1354cdf0e10cSrcweir                             bDone = true;
1355cdf0e10cSrcweir                         }
1356cdf0e10cSrcweir                         else
1357cdf0e10cSrcweir                         {
1358cdf0e10cSrcweir                             // #i101491# line width above 3.0
1359cdf0e10cSrcweir                         }
1360cdf0e10cSrcweir                     }
1361cdf0e10cSrcweir                     else
1362cdf0e10cSrcweir                     {
1363cdf0e10cSrcweir                         if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 1.5))
1364cdf0e10cSrcweir                         {
1365cdf0e10cSrcweir                             // line width below 1.5, draw the basic hairline polygon
13667be6ee6dSArmin Le Grand                             for(sal_uInt32 a(0); a < nCount; a++)
13677be6ee6dSArmin Le Grand                             {
13687be6ee6dSArmin Le Grand                                 mpOutputDevice->DrawPolyLine(aHairlinePolyPolygon.getB2DPolygon(a), 0.0);
13697be6ee6dSArmin Le Grand                             }
13707be6ee6dSArmin Le Grand 
1371cdf0e10cSrcweir                             bDone = true;
1372cdf0e10cSrcweir                         }
1373cdf0e10cSrcweir                         else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 2.5))
1374cdf0e10cSrcweir                         {
1375cdf0e10cSrcweir                             // line width is in range ]1.5 .. 2.5], use four hairlines
1376cdf0e10cSrcweir                             // drawn in a square
13777be6ee6dSArmin Le Grand                             for(sal_uInt32 a(0); a < nCount; a++)
13787be6ee6dSArmin Le Grand                             {
13797be6ee6dSArmin Le Grand                                 basegfx::B2DPolygon aCandidate(aHairlinePolyPolygon.getB2DPolygon(a));
1380cdf0e10cSrcweir                                 basegfx::B2DHomMatrix aMat;
13817be6ee6dSArmin Le Grand 
1382cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1383cdf0e10cSrcweir 
1384cdf0e10cSrcweir                                 aMat.set(0, 2, 1.0);
1385cdf0e10cSrcweir                                 aMat.set(1, 2, 0.0);
1386cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1387cdf0e10cSrcweir 
1388cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir                                 aMat.set(0, 2, 0.0);
1391cdf0e10cSrcweir                                 aMat.set(1, 2, 1.0);
1392cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1393cdf0e10cSrcweir 
1394cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1395cdf0e10cSrcweir 
1396cdf0e10cSrcweir                                 aMat.set(0, 2, -1.0);
1397cdf0e10cSrcweir                                 aMat.set(1, 2, 0.0);
1398cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1399cdf0e10cSrcweir 
1400cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
14017be6ee6dSArmin Le Grand                             }
14027be6ee6dSArmin Le Grand 
1403cdf0e10cSrcweir                             bDone = true;
1404cdf0e10cSrcweir                         }
1405cdf0e10cSrcweir                         else
1406cdf0e10cSrcweir                         {
1407cdf0e10cSrcweir                             // #i101491# line width is above 2.5
1408cdf0e10cSrcweir                         }
1409cdf0e10cSrcweir                     }
1410cdf0e10cSrcweir 
1411cdf0e10cSrcweir                     if(!bDone && rPolygonStrokeCandidate.getB2DPolygon().count() > 1000)
1412cdf0e10cSrcweir                     {
1413cdf0e10cSrcweir                         // #i101491# If the polygon complexity uses more than a given amount, do
1414cdf0e10cSrcweir                         // use OuputDevice::DrawPolyLine directly; this will avoid buffering all
1415cdf0e10cSrcweir                         // decompositions in primtives (memory) and fallback to old line painting
1416cdf0e10cSrcweir                         // for very complex polygons, too
14177be6ee6dSArmin Le Grand                         for(sal_uInt32 a(0); a < nCount; a++)
14187be6ee6dSArmin Le Grand                         {
14197be6ee6dSArmin Le Grand                             mpOutputDevice->DrawPolyLine(
14207be6ee6dSArmin Le Grand                                 aHairlinePolyPolygon.getB2DPolygon(a),
14217be6ee6dSArmin Le Grand                                 fDiscreteLineWidth,
14227be6ee6dSArmin Le Grand                                 rLineAttribute.getLineJoin(),
14237be6ee6dSArmin Le Grand                                 rLineAttribute.getLineCap());
1424cdf0e10cSrcweir                         }
14257be6ee6dSArmin Le Grand 
14267be6ee6dSArmin Le Grand                         bDone = true;
1427cdf0e10cSrcweir                     }
1428cdf0e10cSrcweir                 }
1429cdf0e10cSrcweir             }
1430cdf0e10cSrcweir 
1431cdf0e10cSrcweir 			if(!bDone)
1432cdf0e10cSrcweir             {
1433cdf0e10cSrcweir                 // remeber that we enter a PolygonStrokePrimitive2D decomposition,
1434cdf0e10cSrcweir                 // used for AA thick line drawing
1435cdf0e10cSrcweir                 mnPolygonStrokePrimitive2D++;
1436cdf0e10cSrcweir 
1437cdf0e10cSrcweir                 // line width is big enough for standard filled polygon visualisation or zero
1438cdf0e10cSrcweir 				process(rPolygonStrokeCandidate.get2DDecomposition(getViewInformation2D()));
1439cdf0e10cSrcweir 
1440cdf0e10cSrcweir                 // leave PolygonStrokePrimitive2D
1441cdf0e10cSrcweir                 mnPolygonStrokePrimitive2D--;
1442cdf0e10cSrcweir             }
1443cdf0e10cSrcweir 		}
1444cdf0e10cSrcweir 
1445cdf0e10cSrcweir         void VclProcessor2D::RenderEpsPrimitive2D(const primitive2d::EpsPrimitive2D& rEpsPrimitive2D)
1446cdf0e10cSrcweir         {
1447cdf0e10cSrcweir             // The new decomposition of Metafiles made it necessary to add an Eps
1448cdf0e10cSrcweir             // primitive to handle embedded Eps data. On some devices, this can be
1449cdf0e10cSrcweir             // painted directly (mac, printer).
1450cdf0e10cSrcweir             // To be able to handle the replacement correctly, i need to handle it myself
1451cdf0e10cSrcweir             // since DrawEPS will not be able e.g. to rotate the replacement. To be able
1452cdf0e10cSrcweir             // to do that, i added a boolean return to OutputDevice::DrawEPS(..)
1453cdf0e10cSrcweir             // to know when EPS was handled directly already.
1454cdf0e10cSrcweir 			basegfx::B2DRange aRange(0.0, 0.0, 1.0, 1.0);
1455cdf0e10cSrcweir             aRange.transform(maCurrentTransformation * rEpsPrimitive2D.getEpsTransform());
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir             if(!aRange.isEmpty())
1458cdf0e10cSrcweir             {
1459cdf0e10cSrcweir                 const Rectangle aRectangle(
1460cdf0e10cSrcweir 				    (sal_Int32)floor(aRange.getMinX()), (sal_Int32)floor(aRange.getMinY()),
1461cdf0e10cSrcweir 				    (sal_Int32)ceil(aRange.getMaxX()), (sal_Int32)ceil(aRange.getMaxY()));
1462cdf0e10cSrcweir 
1463cdf0e10cSrcweir                 if(!aRectangle.IsEmpty())
1464cdf0e10cSrcweir                 {
1465cdf0e10cSrcweir                     // try to paint EPS directly without fallback visualisation
1466cdf0e10cSrcweir                     const bool bEPSPaintedDirectly(mpOutputDevice->DrawEPS(
1467cdf0e10cSrcweir                         aRectangle.TopLeft(),
1468cdf0e10cSrcweir                         aRectangle.GetSize(),
1469cdf0e10cSrcweir                         rEpsPrimitive2D.getGfxLink(),
1470cdf0e10cSrcweir                         0));
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir                     if(!bEPSPaintedDirectly)
1473cdf0e10cSrcweir                     {
1474cdf0e10cSrcweir                         // use the decomposition which will correctly handle the
1475cdf0e10cSrcweir                         // fallback visualisation using full transformation (e.g. rotation)
1476cdf0e10cSrcweir         				process(rEpsPrimitive2D.get2DDecomposition(getViewInformation2D()));
1477cdf0e10cSrcweir                     }
1478cdf0e10cSrcweir                 }
1479cdf0e10cSrcweir             }
1480cdf0e10cSrcweir         }
1481cdf0e10cSrcweir 
148239551d71SArmin Le Grand         void VclProcessor2D::RenderSvgLinearAtomPrimitive2D(const primitive2d::SvgLinearAtomPrimitive2D& rCandidate)
148339551d71SArmin Le Grand         {
148439551d71SArmin Le Grand             const double fDelta(rCandidate.getOffsetB() - rCandidate.getOffsetA());
148539551d71SArmin Le Grand 
148639551d71SArmin Le Grand             if(basegfx::fTools::more(fDelta, 0.0))
148739551d71SArmin Le Grand             {
148839551d71SArmin Le Grand                 const basegfx::BColor aColorA(maBColorModifierStack.getModifiedColor(rCandidate.getColorA()));
148939551d71SArmin Le Grand                 const basegfx::BColor aColorB(maBColorModifierStack.getModifiedColor(rCandidate.getColorB()));
149039551d71SArmin Le Grand                 const double fDiscreteUnit((getViewInformation2D().getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength());
149139551d71SArmin Le Grand 
149239551d71SArmin Le Grand                 // use color distance and discrete lengths to calculate step count
149339551d71SArmin Le Grand                 const sal_uInt32 nSteps(calculateStepsForSvgGradient(aColorA, aColorB, fDelta, fDiscreteUnit));
149439551d71SArmin Le Grand 
1495025b0597SArmin Le Grand                 // switch off line painting
1496025b0597SArmin Le Grand                 mpOutputDevice->SetLineColor();
1497025b0597SArmin Le Grand 
1498025b0597SArmin Le Grand                 // prepare polygon in needed width at start position (with discrete overlap)
149939551d71SArmin Le Grand                 const basegfx::B2DPolygon aPolygon(
150039551d71SArmin Le Grand                     basegfx::tools::createPolygonFromRect(
150139551d71SArmin Le Grand                         basegfx::B2DRange(
150239551d71SArmin Le Grand                             rCandidate.getOffsetA() - fDiscreteUnit,
150339551d71SArmin Le Grand                             0.0,
1504025b0597SArmin Le Grand                             rCandidate.getOffsetA() + (fDelta / nSteps) + fDiscreteUnit,
150539551d71SArmin Le Grand                             1.0)));
150639551d71SArmin Le Grand 
1507025b0597SArmin Le Grand 
1508025b0597SArmin Le Grand                 // prepare loop ([0.0 .. 1.0[)
1509025b0597SArmin Le Grand                 double fUnitScale(0.0);
1510025b0597SArmin Le Grand                 const double fUnitStep(1.0 / nSteps);
151139551d71SArmin Le Grand 
151239551d71SArmin Le Grand                 // loop and paint
1513025b0597SArmin Le Grand                 for(sal_uInt32 a(0); a < nSteps; a++, fUnitScale += fUnitStep)
151439551d71SArmin Le Grand                 {
151539551d71SArmin Le Grand                     basegfx::B2DPolygon aNew(aPolygon);
151639551d71SArmin Le Grand 
1517025b0597SArmin Le Grand                     aNew.transform(maCurrentTransformation * basegfx::tools::createTranslateB2DHomMatrix(fDelta * fUnitScale, 0.0));
1518025b0597SArmin Le Grand                     mpOutputDevice->SetFillColor(Color(basegfx::interpolate(aColorA, aColorB, fUnitScale)));
151939551d71SArmin Le Grand                     mpOutputDevice->DrawPolyPolygon(basegfx::B2DPolyPolygon(aNew));
152039551d71SArmin Le Grand                 }
152139551d71SArmin Le Grand             }
152239551d71SArmin Le Grand         }
152339551d71SArmin Le Grand 
152439551d71SArmin Le Grand         void VclProcessor2D::RenderSvgRadialAtomPrimitive2D(const primitive2d::SvgRadialAtomPrimitive2D& rCandidate)
152539551d71SArmin Le Grand         {
152639551d71SArmin Le Grand             const double fDeltaScale(rCandidate.getScaleB() - rCandidate.getScaleA());
152739551d71SArmin Le Grand 
152839551d71SArmin Le Grand             if(basegfx::fTools::more(fDeltaScale, 0.0))
152939551d71SArmin Le Grand             {
153039551d71SArmin Le Grand                 const basegfx::BColor aColorA(maBColorModifierStack.getModifiedColor(rCandidate.getColorA()));
153139551d71SArmin Le Grand                 const basegfx::BColor aColorB(maBColorModifierStack.getModifiedColor(rCandidate.getColorB()));
153239551d71SArmin Le Grand                 const double fDiscreteUnit((getViewInformation2D().getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength());
153339551d71SArmin Le Grand 
153439551d71SArmin Le Grand                 // use color distance and discrete lengths to calculate step count
153539551d71SArmin Le Grand                 const sal_uInt32 nSteps(calculateStepsForSvgGradient(aColorA, aColorB, fDeltaScale, fDiscreteUnit));
153639551d71SArmin Le Grand 
153739551d71SArmin Le Grand                 // switch off line painting
153839551d71SArmin Le Grand                 mpOutputDevice->SetLineColor();
153939551d71SArmin Le Grand 
1540025b0597SArmin Le Grand                 // prepare loop ([0.0 .. 1.0[, full polygons, no polypolygons with holes)
1541025b0597SArmin Le Grand                 double fUnitScale(0.0);
1542025b0597SArmin Le Grand                 const double fUnitStep(1.0 / nSteps);
154339551d71SArmin Le Grand 
1544025b0597SArmin Le Grand                 for(sal_uInt32 a(0); a < nSteps; a++, fUnitScale += fUnitStep)
154539551d71SArmin Le Grand                 {
154639551d71SArmin Le Grand                     basegfx::B2DHomMatrix aTransform;
1547025b0597SArmin Le Grand                     const double fEndScale(rCandidate.getScaleB() - (fDeltaScale * fUnitScale));
154839551d71SArmin Le Grand 
154939551d71SArmin Le Grand                     if(rCandidate.isTranslateSet())
155039551d71SArmin Le Grand                     {
155139551d71SArmin Le Grand                         const basegfx::B2DVector aTranslate(
155239551d71SArmin Le Grand                             basegfx::interpolate(
155339551d71SArmin Le Grand                                 rCandidate.getTranslateB(),
1554025b0597SArmin Le Grand                                 rCandidate.getTranslateA(),
155539551d71SArmin Le Grand                                 fUnitScale));
155639551d71SArmin Le Grand 
155739551d71SArmin Le Grand                         aTransform = basegfx::tools::createScaleTranslateB2DHomMatrix(
155839551d71SArmin Le Grand                             fEndScale,
155939551d71SArmin Le Grand                             fEndScale,
156039551d71SArmin Le Grand                             aTranslate.getX(),
156139551d71SArmin Le Grand                             aTranslate.getY());
156239551d71SArmin Le Grand                     }
156339551d71SArmin Le Grand                     else
156439551d71SArmin Le Grand                     {
156539551d71SArmin Le Grand                         aTransform = basegfx::tools::createScaleB2DHomMatrix(
156639551d71SArmin Le Grand                             fEndScale,
156739551d71SArmin Le Grand                             fEndScale);
156839551d71SArmin Le Grand                     }
156939551d71SArmin Le Grand 
157039551d71SArmin Le Grand                     basegfx::B2DPolygon aNew(basegfx::tools::createPolygonFromUnitCircle());
157139551d71SArmin Le Grand 
157239551d71SArmin Le Grand                     aNew.transform(maCurrentTransformation * aTransform);
1573025b0597SArmin Le Grand                     mpOutputDevice->SetFillColor(Color(basegfx::interpolate(aColorB, aColorA, fUnitScale)));
157439551d71SArmin Le Grand                     mpOutputDevice->DrawPolyPolygon(basegfx::B2DPolyPolygon(aNew));
157539551d71SArmin Le Grand                 }
157639551d71SArmin Le Grand             }
157739551d71SArmin Le Grand         }
157839551d71SArmin Le Grand 
1579cdf0e10cSrcweir 		void VclProcessor2D::adaptLineToFillDrawMode() const
1580cdf0e10cSrcweir 		{
1581cdf0e10cSrcweir 			const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
1582cdf0e10cSrcweir 
1583cdf0e10cSrcweir 			if(nOriginalDrawMode & (DRAWMODE_BLACKLINE|DRAWMODE_GRAYLINE|DRAWMODE_GHOSTEDLINE|DRAWMODE_WHITELINE|DRAWMODE_SETTINGSLINE))
1584cdf0e10cSrcweir 			{
1585cdf0e10cSrcweir 				sal_uInt32 nAdaptedDrawMode(nOriginalDrawMode);
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_BLACKLINE)
1588cdf0e10cSrcweir 				{
1589cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_BLACKFILL;
1590cdf0e10cSrcweir 				}
1591cdf0e10cSrcweir 				else
1592cdf0e10cSrcweir 				{
1593cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_BLACKFILL;
1594cdf0e10cSrcweir 				}
1595cdf0e10cSrcweir 
1596cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_GRAYLINE)
1597cdf0e10cSrcweir 				{
1598cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_GRAYFILL;
1599cdf0e10cSrcweir 				}
1600cdf0e10cSrcweir 				else
1601cdf0e10cSrcweir 				{
1602cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_GRAYFILL;
1603cdf0e10cSrcweir 				}
1604cdf0e10cSrcweir 
1605cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_GHOSTEDLINE)
1606cdf0e10cSrcweir 				{
1607cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_GHOSTEDFILL;
1608cdf0e10cSrcweir 				}
1609cdf0e10cSrcweir 				else
1610cdf0e10cSrcweir 				{
1611cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_GHOSTEDFILL;
1612cdf0e10cSrcweir 				}
1613cdf0e10cSrcweir 
1614cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_WHITELINE)
1615cdf0e10cSrcweir 				{
1616cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_WHITEFILL;
1617cdf0e10cSrcweir 				}
1618cdf0e10cSrcweir 				else
1619cdf0e10cSrcweir 				{
1620cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_WHITEFILL;
1621cdf0e10cSrcweir 				}
1622cdf0e10cSrcweir 
1623cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_SETTINGSLINE)
1624cdf0e10cSrcweir 				{
1625cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_SETTINGSFILL;
1626cdf0e10cSrcweir 				}
1627cdf0e10cSrcweir 				else
1628cdf0e10cSrcweir 				{
1629cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_SETTINGSFILL;
1630cdf0e10cSrcweir 				}
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir 				mpOutputDevice->SetDrawMode(nAdaptedDrawMode);
1633cdf0e10cSrcweir 			}
1634cdf0e10cSrcweir 		}
1635cdf0e10cSrcweir 
1636cdf0e10cSrcweir 		void VclProcessor2D::adaptTextToFillDrawMode() const
1637cdf0e10cSrcweir 		{
1638cdf0e10cSrcweir 			const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
1639cdf0e10cSrcweir 			if(nOriginalDrawMode & (DRAWMODE_BLACKTEXT|DRAWMODE_GRAYTEXT|DRAWMODE_GHOSTEDTEXT|DRAWMODE_WHITETEXT|DRAWMODE_SETTINGSTEXT))
1640cdf0e10cSrcweir 			{
1641cdf0e10cSrcweir 				sal_uInt32 nAdaptedDrawMode(nOriginalDrawMode);
1642cdf0e10cSrcweir 
1643cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_BLACKTEXT)
1644cdf0e10cSrcweir 				{
1645cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_BLACKFILL;
1646cdf0e10cSrcweir 				}
1647cdf0e10cSrcweir 				else
1648cdf0e10cSrcweir 				{
1649cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_BLACKFILL;
1650cdf0e10cSrcweir 				}
1651cdf0e10cSrcweir 
1652cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_GRAYTEXT)
1653cdf0e10cSrcweir 				{
1654cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_GRAYFILL;
1655cdf0e10cSrcweir 				}
1656cdf0e10cSrcweir 				else
1657cdf0e10cSrcweir 				{
1658cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_GRAYFILL;
1659cdf0e10cSrcweir 				}
1660cdf0e10cSrcweir 
1661cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_GHOSTEDTEXT)
1662cdf0e10cSrcweir 				{
1663cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_GHOSTEDFILL;
1664cdf0e10cSrcweir 				}
1665cdf0e10cSrcweir 				else
1666cdf0e10cSrcweir 				{
1667cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_GHOSTEDFILL;
1668cdf0e10cSrcweir 				}
1669cdf0e10cSrcweir 
1670cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_WHITETEXT)
1671cdf0e10cSrcweir 				{
1672cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_WHITEFILL;
1673cdf0e10cSrcweir 				}
1674cdf0e10cSrcweir 				else
1675cdf0e10cSrcweir 				{
1676cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_WHITEFILL;
1677cdf0e10cSrcweir 				}
1678cdf0e10cSrcweir 
1679cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_SETTINGSTEXT)
1680cdf0e10cSrcweir 				{
1681cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_SETTINGSFILL;
1682cdf0e10cSrcweir 				}
1683cdf0e10cSrcweir 				else
1684cdf0e10cSrcweir 				{
1685cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_SETTINGSFILL;
1686cdf0e10cSrcweir 				}
1687cdf0e10cSrcweir 
1688cdf0e10cSrcweir 				mpOutputDevice->SetDrawMode(nAdaptedDrawMode);
1689cdf0e10cSrcweir 			}
1690cdf0e10cSrcweir 		}
1691cdf0e10cSrcweir 
1692cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////////////
1693cdf0e10cSrcweir 		// process support
1694cdf0e10cSrcweir 
1695cdf0e10cSrcweir 		VclProcessor2D::VclProcessor2D(
1696cdf0e10cSrcweir 			const geometry::ViewInformation2D& rViewInformation,
1697cdf0e10cSrcweir 			OutputDevice& rOutDev)
1698cdf0e10cSrcweir 		:	BaseProcessor2D(rViewInformation),
1699cdf0e10cSrcweir 			mpOutputDevice(&rOutDev),
1700cdf0e10cSrcweir 			maBColorModifierStack(),
1701cdf0e10cSrcweir 			maCurrentTransformation(),
1702cdf0e10cSrcweir 			maDrawinglayerOpt(),
1703cdf0e10cSrcweir             mnPolygonStrokePrimitive2D(0)
1704cdf0e10cSrcweir 		{
1705cdf0e10cSrcweir             // set digit language, derived from SvtCTLOptions to have the correct
1706cdf0e10cSrcweir             // number display for arabic/hindi numerals
1707cdf0e10cSrcweir             const SvtCTLOptions aSvtCTLOptions;
1708cdf0e10cSrcweir             LanguageType eLang(LANGUAGE_SYSTEM);
1709cdf0e10cSrcweir 
1710cdf0e10cSrcweir             if(SvtCTLOptions::NUMERALS_HINDI == aSvtCTLOptions.GetCTLTextNumerals())
1711cdf0e10cSrcweir             {
1712cdf0e10cSrcweir                 eLang = LANGUAGE_ARABIC_SAUDI_ARABIA;
1713cdf0e10cSrcweir             }
1714cdf0e10cSrcweir             else if(SvtCTLOptions::NUMERALS_ARABIC == aSvtCTLOptions.GetCTLTextNumerals())
1715cdf0e10cSrcweir             {
1716cdf0e10cSrcweir                 eLang = LANGUAGE_ENGLISH;
1717cdf0e10cSrcweir             }
1718cdf0e10cSrcweir             else
1719cdf0e10cSrcweir             {
1720cdf0e10cSrcweir                 eLang = (LanguageType)Application::GetSettings().GetLanguage();
1721cdf0e10cSrcweir             }
1722cdf0e10cSrcweir 
1723cdf0e10cSrcweir             rOutDev.SetDigitLanguage(eLang);
1724cdf0e10cSrcweir 		}
1725cdf0e10cSrcweir 
1726cdf0e10cSrcweir 		VclProcessor2D::~VclProcessor2D()
1727cdf0e10cSrcweir 		{
1728cdf0e10cSrcweir 		}
1729cdf0e10cSrcweir 	} // end of namespace processor2d
1730cdf0e10cSrcweir } // end of namespace drawinglayer
1731cdf0e10cSrcweir 
1732cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1733cdf0e10cSrcweir // eof
1734