xref: /AOO41X/main/drawinglayer/source/processor2d/vclprocessor2d.cxx (revision 3d84454909bcca03068c53de92a669b109af1583)
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 <basegfx/polygon/b2dpolygontools.hxx>
35035a2f44SArmin Le Grand #include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
36035a2f44SArmin Le Grand #include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx>
37cdf0e10cSrcweir #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
38cdf0e10cSrcweir #include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
39cdf0e10cSrcweir #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
40cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
41cdf0e10cSrcweir #include <vclhelperbufferdevice.hxx>
42cdf0e10cSrcweir #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
43cdf0e10cSrcweir #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
44cdf0e10cSrcweir #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
45cdf0e10cSrcweir #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
46cdf0e10cSrcweir #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
47cdf0e10cSrcweir #include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx>
48cdf0e10cSrcweir #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx>
49cdf0e10cSrcweir #include <svl/ctloptions.hxx>
50cdf0e10cSrcweir #include <vcl/svapp.hxx>
51cdf0e10cSrcweir #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx>
52cdf0e10cSrcweir #include <tools/diagnose_ex.h>
53cdf0e10cSrcweir #include <vcl/metric.hxx>
54cdf0e10cSrcweir #include <drawinglayer/primitive2d/textenumsprimitive2d.hxx>
55cdf0e10cSrcweir #include <drawinglayer/primitive2d/epsprimitive2d.hxx>
5639551d71SArmin Le Grand #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
5739551d71SArmin Le Grand #include <basegfx/color/bcolor.hxx>
5839551d71SArmin Le Grand #include <basegfx/matrix/b2dhommatrixtools.hxx>
59035a2f44SArmin Le Grand #include <vcl/graph.hxx>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
62cdf0e10cSrcweir // control support
63cdf0e10cSrcweir 
64cdf0e10cSrcweir #include <com/sun/star/awt/XWindow2.hpp>
65cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp>
66cdf0e10cSrcweir #include <com/sun/star/awt/XView.hpp>
67cdf0e10cSrcweir #include <drawinglayer/primitive2d/controlprimitive2d.hxx>
68cdf0e10cSrcweir #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
69cdf0e10cSrcweir 
70cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
71cdf0e10cSrcweir // for test, can be removed again
72cdf0e10cSrcweir 
73cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygonclipper.hxx>
74cdf0e10cSrcweir #include <basegfx/polygon/b2dtrapezoid.hxx>
75cdf0e10cSrcweir 
76cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
77cdf0e10cSrcweir 
78cdf0e10cSrcweir using namespace com::sun::star;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
81cdf0e10cSrcweir 
8239551d71SArmin Le Grand namespace
8339551d71SArmin Le Grand {
8439551d71SArmin Le Grand     sal_uInt32 calculateStepsForSvgGradient(const basegfx::BColor& rColorA, const basegfx::BColor& rColorB, double fDelta, double fDiscreteUnit)
8539551d71SArmin Le Grand     {
8639551d71SArmin Le Grand         // use color distance, assume to do every color step
8739551d71SArmin Le Grand         sal_uInt32 nSteps(basegfx::fround(rColorA.getDistance(rColorB) * 255.0));
8839551d71SArmin Le Grand 
8939551d71SArmin Le Grand         if(nSteps)
9039551d71SArmin Le Grand         {
9139551d71SArmin Le Grand             // calc discrete length to change color each disctete unit (pixel)
9239551d71SArmin Le Grand             const sal_uInt32 nDistSteps(basegfx::fround(fDelta / fDiscreteUnit));
9339551d71SArmin Le Grand 
9439551d71SArmin Le Grand             nSteps = std::min(nSteps, nDistSteps);
9539551d71SArmin Le Grand         }
9639551d71SArmin Le Grand 
9739551d71SArmin Le Grand         // reduce quality to 3 discrete units or every 3rd color step for rendering
9839551d71SArmin Le Grand         nSteps /= 2;
9939551d71SArmin Le Grand 
10039551d71SArmin Le Grand         // roughly cut when too big or too small (not full quality, reduce complexity)
10139551d71SArmin Le Grand         nSteps = std::min(nSteps, sal_uInt32(255));
10239551d71SArmin Le Grand         nSteps = std::max(nSteps, sal_uInt32(1));
10339551d71SArmin Le Grand 
10439551d71SArmin Le Grand         return nSteps;
10539551d71SArmin Le Grand     }
10639551d71SArmin Le Grand } // end of anonymous namespace
10739551d71SArmin Le Grand 
10839551d71SArmin Le Grand //////////////////////////////////////////////////////////////////////////////
10939551d71SArmin Le Grand 
110cdf0e10cSrcweir namespace drawinglayer
111cdf0e10cSrcweir {
112cdf0e10cSrcweir 	namespace processor2d
113cdf0e10cSrcweir 	{
114cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////////////
115cdf0e10cSrcweir 		// UNO class usages
116cdf0e10cSrcweir 		using ::com::sun::star::uno::Reference;
117cdf0e10cSrcweir 		using ::com::sun::star::uno::UNO_QUERY;
118cdf0e10cSrcweir 	    using ::com::sun::star::uno::UNO_QUERY_THROW;
119cdf0e10cSrcweir         using ::com::sun::star::uno::Exception;
120cdf0e10cSrcweir 		using ::com::sun::star::awt::XView;
121cdf0e10cSrcweir 		using ::com::sun::star::awt::XGraphics;
122cdf0e10cSrcweir 	    using ::com::sun::star::awt::XWindow;
123cdf0e10cSrcweir 	    using ::com::sun::star::awt::PosSize::POSSIZE;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////////////
126cdf0e10cSrcweir 		// rendering support
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 		// directdraw of text simple portion or decorated portion primitive. When decorated, all the extra
129cdf0e10cSrcweir 		// information is translated to VCL parameters and set at the font.
130cdf0e10cSrcweir 		// Acceptance is restricted to no shearing and positive scaling in X and Y (no font mirroring
131cdf0e10cSrcweir 		// for VCL)
132cdf0e10cSrcweir 		void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate)
133cdf0e10cSrcweir 		{
134cdf0e10cSrcweir             // decompose matrix to have position and size of text
135cdf0e10cSrcweir 			basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rTextCandidate.getTextTransform());
136cdf0e10cSrcweir 			basegfx::B2DVector aFontScaling, aTranslate;
137cdf0e10cSrcweir 			double fRotate, fShearX;
138cdf0e10cSrcweir 			aLocalTransform.decompose(aFontScaling, aTranslate, fRotate, fShearX);
139cdf0e10cSrcweir 			bool bPrimitiveAccepted(false);
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 			if(basegfx::fTools::equalZero(fShearX))
142cdf0e10cSrcweir 			{
143cdf0e10cSrcweir 				if(basegfx::fTools::less(aFontScaling.getX(), 0.0) && basegfx::fTools::less(aFontScaling.getY(), 0.0))
144cdf0e10cSrcweir 				{
145cdf0e10cSrcweir 					// handle special case: If scale is negative in (x,y) (3rd quadrant), it can
146cdf0e10cSrcweir 					// be expressed as rotation by PI. Use this since the Font rendering will not
147cdf0e10cSrcweir                     // apply the negative scales in any form
148cdf0e10cSrcweir 					aFontScaling = basegfx::absolute(aFontScaling);
149cdf0e10cSrcweir 					fRotate += F_PI;
150cdf0e10cSrcweir 				}
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 				if(basegfx::fTools::more(aFontScaling.getX(), 0.0) && basegfx::fTools::more(aFontScaling.getY(), 0.0))
153cdf0e10cSrcweir 				{
154cdf0e10cSrcweir                     // Get the VCL font (use FontHeight as FontWidth)
155cdf0e10cSrcweir                     Font aFont(primitive2d::getVclFontFromFontAttribute(
156cdf0e10cSrcweir                         rTextCandidate.getFontAttribute(),
157cdf0e10cSrcweir                         aFontScaling.getX(),
158cdf0e10cSrcweir                         aFontScaling.getY(),
159cdf0e10cSrcweir                         fRotate,
160cdf0e10cSrcweir                         rTextCandidate.getLocale()));
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 					// handle additional font attributes
163cdf0e10cSrcweir 					const primitive2d::TextDecoratedPortionPrimitive2D* pTCPP =
164cdf0e10cSrcweir 						dynamic_cast<const primitive2d::TextDecoratedPortionPrimitive2D*>( &rTextCandidate );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 					if( pTCPP != NULL )
167cdf0e10cSrcweir 					{
168cdf0e10cSrcweir 
169cdf0e10cSrcweir                         // set the color of text decorations
170cdf0e10cSrcweir                         const basegfx::BColor aTextlineColor = maBColorModifierStack.getModifiedColor(pTCPP->getTextlineColor());
171cdf0e10cSrcweir                         mpOutputDevice->SetTextLineColor( Color(aTextlineColor) );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir                         // set Overline attribute
174cdf0e10cSrcweir                         const FontUnderline eFontOverline(primitive2d::mapTextLineToFontUnderline( pTCPP->getFontOverline() ));
175cdf0e10cSrcweir                         if( eFontOverline != UNDERLINE_NONE )
176cdf0e10cSrcweir                         {
177cdf0e10cSrcweir                             aFont.SetOverline( eFontOverline );
178cdf0e10cSrcweir                             const basegfx::BColor aOverlineColor = maBColorModifierStack.getModifiedColor(pTCPP->getOverlineColor());
179cdf0e10cSrcweir                             mpOutputDevice->SetOverlineColor( Color(aOverlineColor) );
180cdf0e10cSrcweir                             if( pTCPP->getWordLineMode() )
181cdf0e10cSrcweir                                 aFont.SetWordLineMode( true );
182cdf0e10cSrcweir                         }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir                         // set Underline attribute
185cdf0e10cSrcweir                         const FontUnderline eFontUnderline(primitive2d::mapTextLineToFontUnderline( pTCPP->getFontUnderline() ));
186cdf0e10cSrcweir                         if( eFontUnderline != UNDERLINE_NONE )
187cdf0e10cSrcweir 						{
188cdf0e10cSrcweir 							aFont.SetUnderline( eFontUnderline );
189cdf0e10cSrcweir 							if( pTCPP->getWordLineMode() )
190cdf0e10cSrcweir 								aFont.SetWordLineMode( true );
191cdf0e10cSrcweir //TODO: ???					if( pTCPP->getUnderlineAbove() )
192cdf0e10cSrcweir //								aFont.SetUnderlineAbove( true );
193cdf0e10cSrcweir 						}
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 						// set Strikeout attribute
196cdf0e10cSrcweir 						const FontStrikeout eFontStrikeout(primitive2d::mapTextStrikeoutToFontStrikeout(pTCPP->getTextStrikeout()));
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 						if( eFontStrikeout != STRIKEOUT_NONE )
199cdf0e10cSrcweir 							aFont.SetStrikeout( eFontStrikeout );
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 						// set EmphasisMark attribute
202cdf0e10cSrcweir 						FontEmphasisMark eFontEmphasisMark = EMPHASISMARK_NONE;
203cdf0e10cSrcweir 						switch( pTCPP->getTextEmphasisMark() )
204cdf0e10cSrcweir 						{
205cdf0e10cSrcweir 							default:
206cdf0e10cSrcweir 								DBG_WARNING1( "DrawingLayer: Unknown EmphasisMark style (%d)!", pTCPP->getTextEmphasisMark() );
207cdf0e10cSrcweir 								// fall through
208cdf0e10cSrcweir 							case primitive2d::TEXT_EMPHASISMARK_NONE:	eFontEmphasisMark = EMPHASISMARK_NONE; break;
209cdf0e10cSrcweir 							case primitive2d::TEXT_EMPHASISMARK_DOT:	eFontEmphasisMark = EMPHASISMARK_DOT; break;
210cdf0e10cSrcweir 							case primitive2d::TEXT_EMPHASISMARK_CIRCLE:	eFontEmphasisMark = EMPHASISMARK_CIRCLE; break;
211cdf0e10cSrcweir 							case primitive2d::TEXT_EMPHASISMARK_DISC:	eFontEmphasisMark = EMPHASISMARK_DISC; break;
212cdf0e10cSrcweir 							case primitive2d::TEXT_EMPHASISMARK_ACCENT:	eFontEmphasisMark = EMPHASISMARK_ACCENT; break;
213cdf0e10cSrcweir 						}
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 						if( eFontEmphasisMark != EMPHASISMARK_NONE )
216cdf0e10cSrcweir 						{
217cdf0e10cSrcweir 							DBG_ASSERT( (pTCPP->getEmphasisMarkAbove() != pTCPP->getEmphasisMarkBelow()),
218cdf0e10cSrcweir 								"DrawingLayer: Bad EmphasisMark position!" );
219cdf0e10cSrcweir 							if( pTCPP->getEmphasisMarkAbove() )
220cdf0e10cSrcweir 								eFontEmphasisMark |= EMPHASISMARK_POS_ABOVE;
221cdf0e10cSrcweir 							else
222cdf0e10cSrcweir 								eFontEmphasisMark |= EMPHASISMARK_POS_BELOW;
223cdf0e10cSrcweir 							aFont.SetEmphasisMark( eFontEmphasisMark );
224cdf0e10cSrcweir 						}
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 						// set Relief attribute
227cdf0e10cSrcweir 						FontRelief eFontRelief = RELIEF_NONE;
228cdf0e10cSrcweir 						switch( pTCPP->getTextRelief() )
229cdf0e10cSrcweir 						{
230cdf0e10cSrcweir 							default:
231cdf0e10cSrcweir 								DBG_WARNING1( "DrawingLayer: Unknown Relief style (%d)!", pTCPP->getTextRelief() );
232cdf0e10cSrcweir 								// fall through
233cdf0e10cSrcweir 							case primitive2d::TEXT_RELIEF_NONE:		eFontRelief = RELIEF_NONE; break;
234cdf0e10cSrcweir 							case primitive2d::TEXT_RELIEF_EMBOSSED:	eFontRelief = RELIEF_EMBOSSED; break;
235cdf0e10cSrcweir 							case primitive2d::TEXT_RELIEF_ENGRAVED:	eFontRelief = RELIEF_ENGRAVED; break;
236cdf0e10cSrcweir 						}
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 						if( eFontRelief != RELIEF_NONE )
239cdf0e10cSrcweir 							aFont.SetRelief( eFontRelief );
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 						// set Shadow attribute
242cdf0e10cSrcweir 						if( pTCPP->getShadow() )
243cdf0e10cSrcweir 							aFont.SetShadow( true );
244cdf0e10cSrcweir 					}
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 					// create transformed integer DXArray in view coordinate system
247cdf0e10cSrcweir 					::std::vector< sal_Int32 > aTransformedDXArray;
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 					if(rTextCandidate.getDXArray().size())
250cdf0e10cSrcweir 					{
251cdf0e10cSrcweir 						aTransformedDXArray.reserve(rTextCandidate.getDXArray().size());
252cdf0e10cSrcweir 						const basegfx::B2DVector aPixelVector(maCurrentTransformation * basegfx::B2DVector(1.0, 0.0));
253cdf0e10cSrcweir 						const double fPixelVectorFactor(aPixelVector.getLength());
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 						for(::std::vector< double >::const_iterator aStart(rTextCandidate.getDXArray().begin());
256cdf0e10cSrcweir                             aStart != rTextCandidate.getDXArray().end(); aStart++)
257cdf0e10cSrcweir 						{
258cdf0e10cSrcweir 							aTransformedDXArray.push_back(basegfx::fround((*aStart) * fPixelVectorFactor));
259cdf0e10cSrcweir 						}
260cdf0e10cSrcweir 					}
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 					// set parameters and paint text snippet
263cdf0e10cSrcweir 					const basegfx::BColor aRGBFontColor(maBColorModifierStack.getModifiedColor(rTextCandidate.getFontColor()));
264cdf0e10cSrcweir 					const basegfx::B2DPoint aPoint(aLocalTransform * basegfx::B2DPoint(0.0, 0.0));
265cdf0e10cSrcweir 					const Point aStartPoint(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()));
266cdf0e10cSrcweir                     const sal_uInt32 nOldLayoutMode(mpOutputDevice->GetLayoutMode());
267cdf0e10cSrcweir 
268cdf0e10cSrcweir                     if(rTextCandidate.getFontAttribute().getRTL())
269cdf0e10cSrcweir                     {
270cdf0e10cSrcweir                         sal_uInt32 nRTLLayoutMode(nOldLayoutMode & ~(TEXT_LAYOUT_COMPLEX_DISABLED|TEXT_LAYOUT_BIDI_STRONG));
271cdf0e10cSrcweir                         nRTLLayoutMode |= TEXT_LAYOUT_BIDI_RTL|TEXT_LAYOUT_TEXTORIGIN_LEFT;
272cdf0e10cSrcweir                         mpOutputDevice->SetLayoutMode(nRTLLayoutMode);
273cdf0e10cSrcweir                     }
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 					mpOutputDevice->SetFont(aFont);
276cdf0e10cSrcweir 					mpOutputDevice->SetTextColor(Color(aRGBFontColor));
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 					if(aTransformedDXArray.size())
279cdf0e10cSrcweir 					{
280cdf0e10cSrcweir 						mpOutputDevice->DrawTextArray(
281cdf0e10cSrcweir 							aStartPoint,
282cdf0e10cSrcweir 							rTextCandidate.getText(),
283cdf0e10cSrcweir 							&(aTransformedDXArray[0]),
284cdf0e10cSrcweir 							rTextCandidate.getTextPosition(),
285cdf0e10cSrcweir 							rTextCandidate.getTextLength());
286cdf0e10cSrcweir 					}
287cdf0e10cSrcweir 					else
288cdf0e10cSrcweir 					{
289cdf0e10cSrcweir 						mpOutputDevice->DrawText(
290cdf0e10cSrcweir 							aStartPoint,
291cdf0e10cSrcweir 							rTextCandidate.getText(),
292cdf0e10cSrcweir 							rTextCandidate.getTextPosition(),
293cdf0e10cSrcweir 							rTextCandidate.getTextLength());
294cdf0e10cSrcweir 					}
295cdf0e10cSrcweir 
296cdf0e10cSrcweir                     if(rTextCandidate.getFontAttribute().getRTL())
297cdf0e10cSrcweir                     {
298cdf0e10cSrcweir                         mpOutputDevice->SetLayoutMode(nOldLayoutMode);
299cdf0e10cSrcweir                     }
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 					bPrimitiveAccepted = true;
302cdf0e10cSrcweir 				}
303cdf0e10cSrcweir 			}
304cdf0e10cSrcweir 
305cdf0e10cSrcweir 			if(!bPrimitiveAccepted)
306cdf0e10cSrcweir 			{
307cdf0e10cSrcweir 				// let break down
308cdf0e10cSrcweir 				process(rTextCandidate.get2DDecomposition(getViewInformation2D()));
309cdf0e10cSrcweir 			}
310cdf0e10cSrcweir 		}
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 		// direct draw of hairline
313cdf0e10cSrcweir 		void VclProcessor2D::RenderPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate, bool bPixelBased)
314cdf0e10cSrcweir 		{
315cdf0e10cSrcweir             const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor()));
316cdf0e10cSrcweir 			mpOutputDevice->SetLineColor(Color(aHairlineColor));
317cdf0e10cSrcweir 			mpOutputDevice->SetFillColor();
318cdf0e10cSrcweir 
319cdf0e10cSrcweir 			basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon());
320cdf0e10cSrcweir 			aLocalPolygon.transform(maCurrentTransformation);
321cdf0e10cSrcweir 
322cdf0e10cSrcweir             static bool bCheckTrapezoidDecomposition(false);
323cdf0e10cSrcweir             static bool bShowOutlinesThere(false);
324cdf0e10cSrcweir             if(bCheckTrapezoidDecomposition)
325cdf0e10cSrcweir             {
326cdf0e10cSrcweir                 // clip against discrete ViewPort
327cdf0e10cSrcweir                 const basegfx::B2DRange& rDiscreteViewport = getViewInformation2D().getDiscreteViewport();
328cdf0e10cSrcweir                 basegfx::B2DPolyPolygon aLocalPolyPolygon(basegfx::tools::clipPolygonOnRange(
329cdf0e10cSrcweir                     aLocalPolygon, rDiscreteViewport, true, false));
330cdf0e10cSrcweir 
331cdf0e10cSrcweir                 if(aLocalPolyPolygon.count())
332cdf0e10cSrcweir                 {
333cdf0e10cSrcweir                     // subdivide
334cdf0e10cSrcweir                     aLocalPolyPolygon = basegfx::tools::adaptiveSubdivideByDistance(
335cdf0e10cSrcweir                         aLocalPolyPolygon, 0.5);
336cdf0e10cSrcweir 
337cdf0e10cSrcweir                     // trapezoidize
338cdf0e10cSrcweir                     static double fLineWidth(2.0);
339cdf0e10cSrcweir                     basegfx::B2DTrapezoidVector aB2DTrapezoidVector;
340cdf0e10cSrcweir                     basegfx::tools::createLineTrapezoidFromB2DPolyPolygon(aB2DTrapezoidVector, aLocalPolyPolygon, fLineWidth);
341cdf0e10cSrcweir 
342cdf0e10cSrcweir                     const sal_uInt32 nCount(aB2DTrapezoidVector.size());
343cdf0e10cSrcweir 
344cdf0e10cSrcweir                     if(nCount)
345cdf0e10cSrcweir                     {
346cdf0e10cSrcweir                         basegfx::BColor aInvPolygonColor(aHairlineColor);
347cdf0e10cSrcweir                         aInvPolygonColor.invert();
348cdf0e10cSrcweir 
349cdf0e10cSrcweir                         for(sal_uInt32 a(0); a < nCount; a++)
350cdf0e10cSrcweir                         {
351cdf0e10cSrcweir                             const basegfx::B2DPolygon aTempPolygon(aB2DTrapezoidVector[a].getB2DPolygon());
352cdf0e10cSrcweir 
353cdf0e10cSrcweir                             if(bShowOutlinesThere)
354cdf0e10cSrcweir                             {
355cdf0e10cSrcweir                                 mpOutputDevice->SetFillColor(Color(aHairlineColor));
356cdf0e10cSrcweir 			                    mpOutputDevice->SetLineColor();
357cdf0e10cSrcweir                             }
358cdf0e10cSrcweir 
359cdf0e10cSrcweir                             mpOutputDevice->DrawPolygon(aTempPolygon);
360cdf0e10cSrcweir 
361cdf0e10cSrcweir                             if(bShowOutlinesThere)
362cdf0e10cSrcweir                             {
363cdf0e10cSrcweir                                 mpOutputDevice->SetFillColor();
364cdf0e10cSrcweir         		                mpOutputDevice->SetLineColor(Color(aInvPolygonColor));
365cdf0e10cSrcweir     	    		            mpOutputDevice->DrawPolyLine(aTempPolygon, 0.0);
366cdf0e10cSrcweir                             }
367cdf0e10cSrcweir                         }
368cdf0e10cSrcweir                     }
369cdf0e10cSrcweir                 }
370cdf0e10cSrcweir             }
371cdf0e10cSrcweir             else
372cdf0e10cSrcweir             {
373cdf0e10cSrcweir 			    if(bPixelBased && getOptionsDrawinglayer().IsAntiAliasing() && getOptionsDrawinglayer().IsSnapHorVerLinesToDiscrete())
374cdf0e10cSrcweir 			    {
375cdf0e10cSrcweir 				    // #i98289#
376cdf0e10cSrcweir 				    // when a Hairline is painted and AntiAliasing is on the option SnapHorVerLinesToDiscrete
377cdf0e10cSrcweir 				    // allows to suppress AntiAliasing for pure horizontal or vertical lines. This is done since
378cdf0e10cSrcweir 				    // not-AntiAliased such lines look more pleasing to the eye (e.g. 2D chart content). This
379cdf0e10cSrcweir 				    // NEEDS to be done in discrete coordinates, so only useful for pixel based rendering.
380cdf0e10cSrcweir 				    aLocalPolygon = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aLocalPolygon);
381cdf0e10cSrcweir 			    }
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 			    mpOutputDevice->DrawPolyLine(aLocalPolygon, 0.0);
384cdf0e10cSrcweir             }
385cdf0e10cSrcweir 		}
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 		// direct draw of transformed BitmapEx primitive
388cdf0e10cSrcweir 		void VclProcessor2D::RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate)
389cdf0e10cSrcweir 		{
390cdf0e10cSrcweir             BitmapEx aBitmapEx(rBitmapCandidate.getBitmapEx());
391cf95e506SArmin Le Grand             const basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rBitmapCandidate.getTransform());
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 			if(maBColorModifierStack.count())
394cdf0e10cSrcweir 			{
3955f27b83cSArmin Le Grand                 aBitmapEx = aBitmapEx.ModifyBitmapEx(maBColorModifierStack);
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 				if(aBitmapEx.IsEmpty())
398cdf0e10cSrcweir 				{
399cdf0e10cSrcweir 					// color gets completely replaced, get it
400cdf0e10cSrcweir 					const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor()));
401cdf0e10cSrcweir 					basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
402cdf0e10cSrcweir 					aPolygon.transform(aLocalTransform);
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 					mpOutputDevice->SetFillColor(Color(aModifiedColor));
405cdf0e10cSrcweir 					mpOutputDevice->SetLineColor();
406cdf0e10cSrcweir 					mpOutputDevice->DrawPolygon(aPolygon);
407cdf0e10cSrcweir 
408b0e53128SArmin Le Grand 					return;
409cdf0e10cSrcweir 				}
410cdf0e10cSrcweir 			}
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 			// decompose matrix to check for shear, rotate and mirroring
413cdf0e10cSrcweir 			basegfx::B2DVector aScale, aTranslate;
414cdf0e10cSrcweir 			double fRotate, fShearX;
4155f27b83cSArmin Le Grand 
416cdf0e10cSrcweir             aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
417cdf0e10cSrcweir 
418034900cbSArmin Le Grand             const bool bRotated(!basegfx::fTools::equalZero(fRotate));
419034900cbSArmin Le Grand             const bool bSheared(!basegfx::fTools::equalZero(fShearX));
420d935ed1bSArmin Le Grand 
421d935ed1bSArmin Le Grand 			if(!aBitmapEx.IsTransparent() && (bSheared || bRotated))
422cdf0e10cSrcweir 			{
423cdf0e10cSrcweir 				// parts will be uncovered, extend aBitmapEx with a mask bitmap
424cdf0e10cSrcweir 				const Bitmap aContent(aBitmapEx.GetBitmap());
425e4172a75SHerbert Dürr #if defined(MACOSX)
426e4172a75SHerbert Dürr 				const AlphaMask aMaskBmp( aContent.GetSizePixel());
427e4172a75SHerbert Dürr #else
428e4172a75SHerbert Dürr 				const Bitmap aMaskBmp( aContent.GetSizePixel(), 1);
429e4172a75SHerbert Dürr #endif
430e4172a75SHerbert Dürr 				aBitmapEx = BitmapEx(aContent, aMaskBmp);
431cdf0e10cSrcweir 			}
432cdf0e10cSrcweir 
4335f27b83cSArmin Le Grand             // draw using OutputDevice'sDrawTransformedBitmapEx
4345f27b83cSArmin Le Grand             mpOutputDevice->DrawTransformedBitmapEx(aLocalTransform, aBitmapEx);
435cdf0e10cSrcweir 		}
436cdf0e10cSrcweir 
437035a2f44SArmin Le Grand 		void VclProcessor2D::RenderFillGraphicPrimitive2D(const primitive2d::FillGraphicPrimitive2D& rFillBitmapCandidate)
438cdf0e10cSrcweir 		{
439035a2f44SArmin Le Grand 			const attribute::FillGraphicAttribute& rFillGraphicAttribute(rFillBitmapCandidate.getFillGraphic());
440cdf0e10cSrcweir 			bool bPrimitiveAccepted(false);
441035a2f44SArmin Le Grand             static bool bTryTilingDirect = true;
442cdf0e10cSrcweir 
443035a2f44SArmin Le Grand             // #121194# when tiling is used and content is bitmap-based, do direct tiling in the
444035a2f44SArmin Le Grand             // renderer on pixel base to ensure tight fitting. Do not do this when
445035a2f44SArmin Le Grand             // the fill is rotated or sheared.
446035a2f44SArmin Le Grand 
447035a2f44SArmin Le Grand             // ovveride static bool (for debug) and tiling is active
448035a2f44SArmin Le Grand 			if(bTryTilingDirect && rFillGraphicAttribute.getTiling())
449035a2f44SArmin Le Grand 			{
450035a2f44SArmin Le Grand                 // content is bitmap(ex)
451035a2f44SArmin Le Grand                 //
452035a2f44SArmin Le Grand                 // for SVG support, force decomposition when SVG is present. This will lead to use
453035a2f44SArmin Le Grand                 // the primitive representation of the svg directly.
454035a2f44SArmin Le Grand                 //
455035a2f44SArmin Le Grand                 // when graphic is animated, force decomposition to use the correct graphic, else
456035a2f44SArmin Le Grand                 // fill style will not be animated
457035a2f44SArmin Le Grand                 if(GRAPHIC_BITMAP == rFillGraphicAttribute.getGraphic().GetType()
458035a2f44SArmin Le Grand                     && !rFillGraphicAttribute.getGraphic().getSvgData().get()
459035a2f44SArmin Le Grand                     && !rFillGraphicAttribute.getGraphic().IsAnimated())
460cdf0e10cSrcweir                 {
461cdf0e10cSrcweir 				    // decompose matrix to check for shear, rotate and mirroring
462cdf0e10cSrcweir 				    basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rFillBitmapCandidate.getTransformation());
463cdf0e10cSrcweir 				    basegfx::B2DVector aScale, aTranslate;
464cdf0e10cSrcweir 				    double fRotate, fShearX;
465cdf0e10cSrcweir 				    aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
466cdf0e10cSrcweir 
467035a2f44SArmin Le Grand                     // when nopt rotated/sheared
468cdf0e10cSrcweir 				    if(basegfx::fTools::equalZero(fRotate) && basegfx::fTools::equalZero(fShearX))
469cdf0e10cSrcweir 				    {
470cdf0e10cSrcweir 					    // no shear or rotate, draw direct in pixel coordinates
471cdf0e10cSrcweir 					    bPrimitiveAccepted = true;
472035a2f44SArmin Le Grand 
473035a2f44SArmin Le Grand                         // transform object range to device coordinates (pixels). Use
474035a2f44SArmin Le Grand                         // the device transformation for better accuracy
475035a2f44SArmin Le Grand                         basegfx::B2DRange aObjectRange(aTranslate, aTranslate + aScale);
476035a2f44SArmin Le Grand                         aObjectRange.transform(mpOutputDevice->GetViewTransformation());
477035a2f44SArmin Le Grand 
478035a2f44SArmin Le Grand                         // extract discrete size of object
479035a2f44SArmin Le Grand                         const sal_Int32 nOWidth(basegfx::fround(aObjectRange.getWidth()));
480035a2f44SArmin Le Grand                         const sal_Int32 nOHeight(basegfx::fround(aObjectRange.getHeight()));
481035a2f44SArmin Le Grand 
482035a2f44SArmin Le Grand                         // only do something when object has a size in discrete units
483035a2f44SArmin Le Grand 						if(nOWidth > 0 && nOHeight > 0)
484035a2f44SArmin Le Grand 						{
485035a2f44SArmin Le Grand                             // transform graphic range to device coordinates (pixels). Use
486035a2f44SArmin Le Grand                             // the device transformation for better accuracy
487035a2f44SArmin Le Grand                             basegfx::B2DRange aGraphicRange(rFillGraphicAttribute.getGraphicRange());
488035a2f44SArmin Le Grand                             aGraphicRange.transform(mpOutputDevice->GetViewTransformation() * aLocalTransform);
489035a2f44SArmin Le Grand 
490035a2f44SArmin Le Grand                             // extract discrete size of graphic
491035a2f44SArmin Le Grand                             const sal_Int32 nBWidth(basegfx::fround(aGraphicRange.getWidth()));
492035a2f44SArmin Le Grand                             const sal_Int32 nBHeight(basegfx::fround(aGraphicRange.getHeight()));
493035a2f44SArmin Le Grand 
494035a2f44SArmin Le Grand                             // only do something when bitmap fill has a size in discrete units
495035a2f44SArmin Le Grand 						    if(nBWidth > 0 && nBHeight > 0)
496035a2f44SArmin Le Grand 						    {
497035a2f44SArmin Le Grand 						        // nBWidth, nBHeight is the pixel size of the neede bitmap. To not need to scale it
498035a2f44SArmin Le Grand 						        // in vcl many times, create a size-optimized version
499035a2f44SArmin Le Grand 						        const Size aNeededBitmapSizePixel(nBWidth, nBHeight);
5004665f8d3SArmin Le Grand                                 BitmapEx aBitmapEx(rFillGraphicAttribute.getGraphic().GetBitmapEx());
5014665f8d3SArmin Le Grand                                 static bool bEnablePreScaling(true);
5024665f8d3SArmin Le Grand                                 const bool bPreScaled(bEnablePreScaling && nBWidth * nBHeight < (250 * 250));
5034665f8d3SArmin Le Grand 
5044665f8d3SArmin Le Grand                                 if(bPreScaled)
5054665f8d3SArmin Le Grand                                 {
5064665f8d3SArmin Le Grand                                     // ... but only up to a maximum size, else it gets too expensive
5074665f8d3SArmin Le Grand                                     aBitmapEx.Scale(aNeededBitmapSizePixel, BMP_SCALE_INTERPOLATE);
5084665f8d3SArmin Le Grand                                 }
5094665f8d3SArmin Le Grand 
510cdf0e10cSrcweir 					            bool bPainted(false);
511cdf0e10cSrcweir 
512cdf0e10cSrcweir 					            if(maBColorModifierStack.count())
513cdf0e10cSrcweir 					            {
514035a2f44SArmin Le Grand                                     // when color modifier, apply to bitmap
5155f27b83cSArmin Le Grand 						            aBitmapEx = aBitmapEx.ModifyBitmapEx(maBColorModifierStack);
516cdf0e10cSrcweir 
517035a2f44SArmin Le Grand                                     // impModifyBitmapEx uses empty bitmap as sign to return that
518035a2f44SArmin Le Grand                                     // the content will be completely replaced to mono color, use shortcut
519cdf0e10cSrcweir 						            if(aBitmapEx.IsEmpty())
520cdf0e10cSrcweir 						            {
521cdf0e10cSrcweir 							            // color gets completely replaced, get it
522cdf0e10cSrcweir 							            const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor()));
523cdf0e10cSrcweir 							            basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
524cdf0e10cSrcweir 							            aPolygon.transform(aLocalTransform);
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 							            mpOutputDevice->SetFillColor(Color(aModifiedColor));
527cdf0e10cSrcweir 							            mpOutputDevice->SetLineColor();
528cdf0e10cSrcweir 							            mpOutputDevice->DrawPolygon(aPolygon);
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 							            bPainted = true;
531cdf0e10cSrcweir 						            }
532cdf0e10cSrcweir 					            }
533cdf0e10cSrcweir 
534cdf0e10cSrcweir 					            if(!bPainted)
535cdf0e10cSrcweir 					            {
536035a2f44SArmin Le Grand                                     sal_Int32 nBLeft(basegfx::fround(aGraphicRange.getMinX()));
537035a2f44SArmin Le Grand                                     sal_Int32 nBTop(basegfx::fround(aGraphicRange.getMinY()));
538035a2f44SArmin Le Grand                                     const sal_Int32 nOLeft(basegfx::fround(aObjectRange.getMinX()));
539035a2f44SArmin Le Grand                                     const sal_Int32 nOTop(basegfx::fround(aObjectRange.getMinY()));
540035a2f44SArmin Le Grand                                     sal_Int32 nPosX(0);
541035a2f44SArmin Le Grand                                     sal_Int32 nPosY(0);
542cdf0e10cSrcweir 
543035a2f44SArmin Le Grand 						            if(nBLeft > nOLeft)
544cdf0e10cSrcweir 						            {
545035a2f44SArmin Le Grand                                         const sal_Int32 nDiff((nBLeft / nBWidth) + 1);
546cdf0e10cSrcweir 
547035a2f44SArmin Le Grand                                         nPosX -= nDiff;
548035a2f44SArmin Le Grand 							            nBLeft -= nDiff * nBWidth;
549cdf0e10cSrcweir 						            }
550cdf0e10cSrcweir 
551035a2f44SArmin Le Grand 						            if(nBLeft + nBWidth <= nOLeft)
552cdf0e10cSrcweir 						            {
553035a2f44SArmin Le Grand                                         const sal_Int32 nDiff(-nBLeft / nBWidth);
554035a2f44SArmin Le Grand 
555035a2f44SArmin Le Grand                                         nPosX += nDiff;
556035a2f44SArmin Le Grand 							            nBLeft += nDiff * nBWidth;
557cdf0e10cSrcweir 						            }
558cdf0e10cSrcweir 
559035a2f44SArmin Le Grand 						            if(nBTop > nOTop)
560cdf0e10cSrcweir 						            {
561035a2f44SArmin Le Grand                                         const sal_Int32 nDiff((nBTop / nBHeight) + 1);
562035a2f44SArmin Le Grand 
563035a2f44SArmin Le Grand                                         nPosY -= nDiff;
564035a2f44SArmin Le Grand 							            nBTop -= nDiff * nBHeight;
565cdf0e10cSrcweir 						            }
566cdf0e10cSrcweir 
567035a2f44SArmin Le Grand 						            if(nBTop + nBHeight <= nOTop)
568cdf0e10cSrcweir 						            {
569035a2f44SArmin Le Grand                                         const sal_Int32 nDiff(-nBTop / nBHeight);
570cdf0e10cSrcweir 
571035a2f44SArmin Le Grand                                         nPosY += nDiff;
572035a2f44SArmin Le Grand 							            nBTop += nDiff * nBHeight;
573cdf0e10cSrcweir 						            }
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 						            // prepare OutDev
576cdf0e10cSrcweir 						            const Point aEmptyPoint(0, 0);
577cdf0e10cSrcweir 						            const Rectangle aVisiblePixel(aEmptyPoint, mpOutputDevice->GetOutputSizePixel());
578cdf0e10cSrcweir 						            const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled());
579cdf0e10cSrcweir 						            mpOutputDevice->EnableMapMode(false);
580cdf0e10cSrcweir 
581035a2f44SArmin Le Grand                                     // check if offset is used
582035a2f44SArmin Le Grand                                     const sal_Int32 nOffsetX(basegfx::fround(rFillGraphicAttribute.getOffsetX() * nBWidth));
583035a2f44SArmin Le Grand 
584035a2f44SArmin Le Grand                                     if(nOffsetX)
585cdf0e10cSrcweir                                     {
586035a2f44SArmin Le Grand                                         // offset in X, so iterate over Y first and draw lines
587035a2f44SArmin Le Grand                                         for(sal_Int32 nYPos(nBTop); nYPos < nOTop + nOHeight; nYPos += nBHeight, nPosY++)
588035a2f44SArmin Le Grand                                         {
589035a2f44SArmin Le Grand                                             for(sal_Int32 nXPos(nPosY % 2 ? nBLeft - nBWidth + nOffsetX : nBLeft);
590035a2f44SArmin Le Grand                                                 nXPos < nOLeft + nOWidth; nXPos += nBWidth)
591cdf0e10cSrcweir                                             {
592cdf0e10cSrcweir                                                 const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel);
593cdf0e10cSrcweir 
594cdf0e10cSrcweir                                                 if(aOutRectPixel.IsOver(aVisiblePixel))
595cdf0e10cSrcweir                                                 {
5964665f8d3SArmin Le Grand                                                     if(bPreScaled)
5974665f8d3SArmin Le Grand                                                     {
598cdf0e10cSrcweir                                                         mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aBitmapEx);
599cdf0e10cSrcweir                                                     }
6004665f8d3SArmin Le Grand                                                     else
6014665f8d3SArmin Le Grand                                                     {
6024665f8d3SArmin Le Grand                                                         mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aNeededBitmapSizePixel, aBitmapEx);
6034665f8d3SArmin Le Grand                                                     }
6044665f8d3SArmin Le Grand                                                 }
605cdf0e10cSrcweir                                             }
606cdf0e10cSrcweir                                         }
607035a2f44SArmin Le Grand                                     }
608035a2f44SArmin Le Grand                                     else
609035a2f44SArmin Le Grand                                     {
610035a2f44SArmin Le Grand                                         // check if offset is used
611035a2f44SArmin Le Grand                                         const sal_Int32 nOffsetY(basegfx::fround(rFillGraphicAttribute.getOffsetY() * nBHeight));
612035a2f44SArmin Le Grand 
613035a2f44SArmin Le Grand                                         // possible offset in Y, so iterate over X first and draw columns
614035a2f44SArmin Le Grand                                         for(sal_Int32 nXPos(nBLeft); nXPos < nOLeft + nOWidth; nXPos += nBWidth, nPosX++)
615035a2f44SArmin Le Grand                                         {
616035a2f44SArmin Le Grand                                             for(sal_Int32 nYPos(nPosX % 2 ? nBTop - nBHeight + nOffsetY : nBTop);
617035a2f44SArmin Le Grand                                                 nYPos < nOTop + nOHeight; nYPos += nBHeight)
618035a2f44SArmin Le Grand                                             {
619035a2f44SArmin Le Grand                                                 const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel);
620035a2f44SArmin Le Grand 
621035a2f44SArmin Le Grand                                                 if(aOutRectPixel.IsOver(aVisiblePixel))
622035a2f44SArmin Le Grand                                                 {
6234665f8d3SArmin Le Grand                                                     if(bPreScaled)
6244665f8d3SArmin Le Grand                                                     {
625035a2f44SArmin Le Grand                                                         mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aBitmapEx);
626035a2f44SArmin Le Grand                                                     }
6274665f8d3SArmin Le Grand                                                     else
6284665f8d3SArmin Le Grand                                                     {
6294665f8d3SArmin Le Grand                                                         mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aNeededBitmapSizePixel, aBitmapEx);
6304665f8d3SArmin Le Grand                                                     }
6314665f8d3SArmin Le Grand                                                 }
632035a2f44SArmin Le Grand                                             }
633035a2f44SArmin Le Grand                                         }
634035a2f44SArmin Le Grand                                     }
635cdf0e10cSrcweir 
636cdf0e10cSrcweir 						            // restore OutDev
637cdf0e10cSrcweir 						            mpOutputDevice->EnableMapMode(bWasEnabled);
638cdf0e10cSrcweir                                 }
639cdf0e10cSrcweir                             }
640cdf0e10cSrcweir                         }
641cdf0e10cSrcweir 				    }
642cdf0e10cSrcweir 			    }
643035a2f44SArmin Le Grand             }
644cdf0e10cSrcweir 
645cdf0e10cSrcweir 			if(!bPrimitiveAccepted)
646cdf0e10cSrcweir 			{
647cdf0e10cSrcweir 				// do not accept, use decomposition
648cdf0e10cSrcweir 				process(rFillBitmapCandidate.get2DDecomposition(getViewInformation2D()));
649cdf0e10cSrcweir 			}
650cdf0e10cSrcweir 		}
651cdf0e10cSrcweir 
652035a2f44SArmin Le Grand 		// direct draw of Graphic
653035a2f44SArmin Le Grand 		void VclProcessor2D::RenderPolyPolygonGraphicPrimitive2D(const primitive2d::PolyPolygonGraphicPrimitive2D& rPolygonCandidate)
654cdf0e10cSrcweir 		{
655cdf0e10cSrcweir             bool bDone(false);
656cdf0e10cSrcweir             const basegfx::B2DPolyPolygon& rPolyPolygon = rPolygonCandidate.getB2DPolyPolygon();
657cdf0e10cSrcweir 
658035a2f44SArmin Le Grand             // #121194# Todo: check if this works
659035a2f44SArmin Le Grand             if(!rPolyPolygon.count())
660cdf0e10cSrcweir             {
661035a2f44SArmin Le Grand                 // empty polyPolygon, done
662cdf0e10cSrcweir                 bDone = true;
663cdf0e10cSrcweir             }
664cdf0e10cSrcweir             else
665cdf0e10cSrcweir             {
666035a2f44SArmin Le Grand                 const attribute::FillGraphicAttribute& rFillGraphicAttribute = rPolygonCandidate.getFillGraphic();
667035a2f44SArmin Le Grand 
668035a2f44SArmin Le Grand                 // try to catch cases where the graphic will be color-modified to a single
669035a2f44SArmin Le Grand                 // color (e.g. shadow)
670035a2f44SArmin Le Grand                 switch(rFillGraphicAttribute.getGraphic().GetType())
671035a2f44SArmin Le Grand                 {
672035a2f44SArmin Le Grand                     case GRAPHIC_GDIMETAFILE:
673035a2f44SArmin Le Grand                     {
674035a2f44SArmin Le Grand                         // metafiles are potentially transparent, cannot optimize�, not done
675035a2f44SArmin Le Grand                         break;
676035a2f44SArmin Le Grand                     }
677035a2f44SArmin Le Grand                     case GRAPHIC_BITMAP:
678035a2f44SArmin Le Grand                     {
679035a2f44SArmin Le Grand                         if(!rFillGraphicAttribute.getGraphic().IsTransparent() && !rFillGraphicAttribute.getGraphic().IsAlpha())
680035a2f44SArmin Le Grand                         {
681035a2f44SArmin Le Grand                             // bitmap is not transparent and has no alpha
682cdf0e10cSrcweir                             const sal_uInt32 nBColorModifierStackCount(maBColorModifierStack.count());
683cdf0e10cSrcweir 
684cdf0e10cSrcweir                             if(nBColorModifierStackCount)
685cdf0e10cSrcweir                             {
686cdf0e10cSrcweir                                 const basegfx::BColorModifier& rTopmostModifier = maBColorModifierStack.getBColorModifier(nBColorModifierStackCount - 1);
687cdf0e10cSrcweir 
688cdf0e10cSrcweir                                 if(basegfx::BCOLORMODIFYMODE_REPLACE == rTopmostModifier.getMode())
689cdf0e10cSrcweir                                 {
690cdf0e10cSrcweir                                     // the bitmap fill is in unified color, so we can replace it with
691cdf0e10cSrcweir                                     // a single polygon fill. The form of the fill depends on tiling
692035a2f44SArmin Le Grand                                     if(rFillGraphicAttribute.getTiling())
693cdf0e10cSrcweir                                     {
694cdf0e10cSrcweir                                         // with tiling, fill the whole PolyPolygon with the modifier color
695cdf0e10cSrcweir                                         basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolyPolygon);
696cdf0e10cSrcweir 
697cdf0e10cSrcweir                                         aLocalPolyPolygon.transform(maCurrentTransformation);
698cdf0e10cSrcweir                                         mpOutputDevice->SetLineColor();
699cdf0e10cSrcweir                                         mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor()));
700cdf0e10cSrcweir                                         mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
701cdf0e10cSrcweir                                     }
702cdf0e10cSrcweir                                     else
703cdf0e10cSrcweir                                     {
704cdf0e10cSrcweir                                         // without tiling, only the area common to the bitmap tile and the
705cdf0e10cSrcweir                                         // PolyPolygon is filled. Create the bitmap tile area in object
706cdf0e10cSrcweir                                         // coordinates. For this, the object transformation needs to be created
707cdf0e10cSrcweir                                         // from the already scaled PolyPolygon. The tile area in object
708cdf0e10cSrcweir                                         // coordinates wil always be non-rotated, so it's not necessary to
709cdf0e10cSrcweir                                         // work with a polygon here
710035a2f44SArmin Le Grand                                         basegfx::B2DRange aTileRange(rFillGraphicAttribute.getGraphicRange());
711cdf0e10cSrcweir                                         const basegfx::B2DRange aPolyPolygonRange(rPolyPolygon.getB2DRange());
712035a2f44SArmin Le Grand                                         const basegfx::B2DHomMatrix aNewObjectTransform(
713035a2f44SArmin Le Grand                                             basegfx::tools::createScaleTranslateB2DHomMatrix(
714035a2f44SArmin Le Grand                                                 aPolyPolygonRange.getRange(),
715035a2f44SArmin Le Grand                                                 aPolyPolygonRange.getMinimum()));
716cdf0e10cSrcweir 
717cdf0e10cSrcweir                                         aTileRange.transform(aNewObjectTransform);
718cdf0e10cSrcweir 
719cdf0e10cSrcweir                                         // now clip the object polyPolygon against the tile range
720035a2f44SArmin Le Grand                                         // to get the common area
721035a2f44SArmin Le Grand                                         basegfx::B2DPolyPolygon aTarget = basegfx::tools::clipPolyPolygonOnRange(
722035a2f44SArmin Le Grand                                             rPolyPolygon,
723035a2f44SArmin Le Grand                                             aTileRange,
724035a2f44SArmin Le Grand                                             true,
725035a2f44SArmin Le Grand                                             false);
726cdf0e10cSrcweir 
727cdf0e10cSrcweir                                         if(aTarget.count())
728cdf0e10cSrcweir                                         {
729cdf0e10cSrcweir                                             aTarget.transform(maCurrentTransformation);
730cdf0e10cSrcweir                                             mpOutputDevice->SetLineColor();
731cdf0e10cSrcweir                                             mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor()));
732cdf0e10cSrcweir                                             mpOutputDevice->DrawPolyPolygon(aTarget);
733cdf0e10cSrcweir                                         }
734cdf0e10cSrcweir                                     }
735cdf0e10cSrcweir 
736035a2f44SArmin Le Grand                                     // simplified output executed, we are done
737cdf0e10cSrcweir                                     bDone = true;
738cdf0e10cSrcweir                                 }
739cdf0e10cSrcweir                             }
740cdf0e10cSrcweir                         }
741035a2f44SArmin Le Grand                         break;
742cdf0e10cSrcweir                     }
743035a2f44SArmin Le Grand                     default: //GRAPHIC_NONE, GRAPHIC_DEFAULT
744cdf0e10cSrcweir                     {
745035a2f44SArmin Le Grand                         // empty graphic, we are done
746cdf0e10cSrcweir                         bDone = true;
747035a2f44SArmin Le Grand                         break;
748035a2f44SArmin Le Grand                     }
749035a2f44SArmin Le Grand                 }
750cdf0e10cSrcweir             }
751cdf0e10cSrcweir 
752cdf0e10cSrcweir             if(!bDone)
753cdf0e10cSrcweir             {
754cdf0e10cSrcweir                 // use default decomposition
755cdf0e10cSrcweir                 process(rPolygonCandidate.get2DDecomposition(getViewInformation2D()));
756cdf0e10cSrcweir             }
757cdf0e10cSrcweir         }
758cdf0e10cSrcweir 
759cdf0e10cSrcweir 		// mask group. Force output to VDev and create mask from given mask
760cdf0e10cSrcweir 		void VclProcessor2D::RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate)
761cdf0e10cSrcweir 		{
762cdf0e10cSrcweir 			if(rMaskCandidate.getChildren().hasElements())
763cdf0e10cSrcweir 			{
764cdf0e10cSrcweir 				basegfx::B2DPolyPolygon aMask(rMaskCandidate.getMask());
765cdf0e10cSrcweir 
766cdf0e10cSrcweir 				if(aMask.count())
767cdf0e10cSrcweir 				{
768cdf0e10cSrcweir 					aMask.transform(maCurrentTransformation);
769cdf0e10cSrcweir 					const basegfx::B2DRange aRange(basegfx::tools::getRange(aMask));
770cdf0e10cSrcweir 					impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
771cdf0e10cSrcweir 
772cdf0e10cSrcweir 					if(aBufferDevice.isVisible())
773cdf0e10cSrcweir 					{
774cdf0e10cSrcweir 						// remember last OutDev and set to content
775cdf0e10cSrcweir 						OutputDevice* pLastOutputDevice = mpOutputDevice;
776cdf0e10cSrcweir 						mpOutputDevice = &aBufferDevice.getContent();
777cdf0e10cSrcweir 
778cdf0e10cSrcweir 						// paint to it
779cdf0e10cSrcweir 						process(rMaskCandidate.getChildren());
780cdf0e10cSrcweir 
781cdf0e10cSrcweir 						// back to old OutDev
782cdf0e10cSrcweir 						mpOutputDevice = pLastOutputDevice;
783cdf0e10cSrcweir 
784cdf0e10cSrcweir 					    // draw mask
785cdf0e10cSrcweir                         if(getOptionsDrawinglayer().IsAntiAliasing())
786cdf0e10cSrcweir                         {
787cdf0e10cSrcweir                             // with AA, use 8bit AlphaMask to get nice borders
788cdf0e10cSrcweir 						    VirtualDevice& rTransparence = aBufferDevice.getTransparence();
789cdf0e10cSrcweir 						    rTransparence.SetLineColor();
790cdf0e10cSrcweir 						    rTransparence.SetFillColor(COL_BLACK);
791cdf0e10cSrcweir 						    rTransparence.DrawPolyPolygon(aMask);
792cdf0e10cSrcweir 
793cdf0e10cSrcweir 						    // dump buffer to outdev
794cdf0e10cSrcweir 						    aBufferDevice.paint();
795cdf0e10cSrcweir                         }
796cdf0e10cSrcweir                         else
797cdf0e10cSrcweir                         {
798cdf0e10cSrcweir                             // No AA, use 1bit mask
799cdf0e10cSrcweir 						    VirtualDevice& rMask = aBufferDevice.getMask();
800cdf0e10cSrcweir 						    rMask.SetLineColor();
801cdf0e10cSrcweir 						    rMask.SetFillColor(COL_BLACK);
802cdf0e10cSrcweir 						    rMask.DrawPolyPolygon(aMask);
803cdf0e10cSrcweir 
804cdf0e10cSrcweir 						    // dump buffer to outdev
805cdf0e10cSrcweir 						    aBufferDevice.paint();
806cdf0e10cSrcweir                         }
807cdf0e10cSrcweir 					}
808cdf0e10cSrcweir 				}
809cdf0e10cSrcweir 			}
810cdf0e10cSrcweir 		}
811cdf0e10cSrcweir 
812cdf0e10cSrcweir 		// modified color group. Force output to unified color.
813cdf0e10cSrcweir 		void VclProcessor2D::RenderModifiedColorPrimitive2D(const primitive2d::ModifiedColorPrimitive2D& rModifiedCandidate)
814cdf0e10cSrcweir 		{
815cdf0e10cSrcweir 			if(rModifiedCandidate.getChildren().hasElements())
816cdf0e10cSrcweir 			{
817cdf0e10cSrcweir 				maBColorModifierStack.push(rModifiedCandidate.getColorModifier());
818cdf0e10cSrcweir 				process(rModifiedCandidate.getChildren());
819cdf0e10cSrcweir 				maBColorModifierStack.pop();
820cdf0e10cSrcweir 			}
821cdf0e10cSrcweir 		}
822cdf0e10cSrcweir 
823cdf0e10cSrcweir 		// unified sub-transparence. Draw to VDev first.
824cdf0e10cSrcweir 		void VclProcessor2D::RenderUnifiedTransparencePrimitive2D(const primitive2d::UnifiedTransparencePrimitive2D& rTransCandidate)
825cdf0e10cSrcweir 		{
826cdf0e10cSrcweir             static bool bForceToDecomposition(false);
827cdf0e10cSrcweir 
828cdf0e10cSrcweir             if(rTransCandidate.getChildren().hasElements())
829cdf0e10cSrcweir             {
830cdf0e10cSrcweir                 if(bForceToDecomposition)
831cdf0e10cSrcweir                 {
832cdf0e10cSrcweir     			    // use decomposition
833cdf0e10cSrcweir 	    		    process(rTransCandidate.get2DDecomposition(getViewInformation2D()));
834cdf0e10cSrcweir                 }
835cdf0e10cSrcweir                 else
836cdf0e10cSrcweir                 {
837cdf0e10cSrcweir 			        if(0.0 == rTransCandidate.getTransparence())
838cdf0e10cSrcweir 			        {
839cdf0e10cSrcweir 				        // no transparence used, so just use the content
840cdf0e10cSrcweir     	    		    process(rTransCandidate.getChildren());
841cdf0e10cSrcweir 			        }
842cdf0e10cSrcweir 			        else if(rTransCandidate.getTransparence() > 0.0 && rTransCandidate.getTransparence() < 1.0)
843cdf0e10cSrcweir 			        {
844cdf0e10cSrcweir                         // transparence is in visible range
845cdf0e10cSrcweir 				        basegfx::B2DRange aRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rTransCandidate.getChildren(), getViewInformation2D()));
846cdf0e10cSrcweir 				        aRange.transform(maCurrentTransformation);
847cdf0e10cSrcweir 				        impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
848cdf0e10cSrcweir 
849cdf0e10cSrcweir 				        if(aBufferDevice.isVisible())
850cdf0e10cSrcweir 				        {
851cdf0e10cSrcweir 					        // remember last OutDev and set to content
852cdf0e10cSrcweir 					        OutputDevice* pLastOutputDevice = mpOutputDevice;
853cdf0e10cSrcweir 					        mpOutputDevice = &aBufferDevice.getContent();
854cdf0e10cSrcweir 
855cdf0e10cSrcweir 					        // paint content to it
856cdf0e10cSrcweir 					        process(rTransCandidate.getChildren());
857cdf0e10cSrcweir 
858cdf0e10cSrcweir 					        // back to old OutDev
859cdf0e10cSrcweir 					        mpOutputDevice = pLastOutputDevice;
860cdf0e10cSrcweir 
861cdf0e10cSrcweir 					        // dump buffer to outdev using given transparence
862cdf0e10cSrcweir 					        aBufferDevice.paint(rTransCandidate.getTransparence());
863cdf0e10cSrcweir 				        }
864cdf0e10cSrcweir 			        }
865cdf0e10cSrcweir                 }
866cdf0e10cSrcweir             }
867cdf0e10cSrcweir 		}
868cdf0e10cSrcweir 
869cdf0e10cSrcweir 		// sub-transparence group. Draw to VDev first.
870cdf0e10cSrcweir 		void VclProcessor2D::RenderTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransCandidate)
871cdf0e10cSrcweir 		{
872cdf0e10cSrcweir 			if(rTransCandidate.getChildren().hasElements())
873cdf0e10cSrcweir 			{
874cdf0e10cSrcweir 				basegfx::B2DRange aRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rTransCandidate.getChildren(), getViewInformation2D()));
875cdf0e10cSrcweir 				aRange.transform(maCurrentTransformation);
876cdf0e10cSrcweir 				impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
877cdf0e10cSrcweir 
878cdf0e10cSrcweir 				if(aBufferDevice.isVisible())
879cdf0e10cSrcweir 				{
880cdf0e10cSrcweir 					// remember last OutDev and set to content
881cdf0e10cSrcweir 					OutputDevice* pLastOutputDevice = mpOutputDevice;
882cdf0e10cSrcweir 					mpOutputDevice = &aBufferDevice.getContent();
883cdf0e10cSrcweir 
884cdf0e10cSrcweir 					// paint content to it
885cdf0e10cSrcweir 					process(rTransCandidate.getChildren());
886cdf0e10cSrcweir 
887cdf0e10cSrcweir 					// set to mask
888cdf0e10cSrcweir 					mpOutputDevice = &aBufferDevice.getTransparence();
889cdf0e10cSrcweir 
890cdf0e10cSrcweir 					// when painting transparence masks, reset the color stack
891cdf0e10cSrcweir 					basegfx::BColorModifierStack aLastBColorModifierStack(maBColorModifierStack);
892cdf0e10cSrcweir 					maBColorModifierStack = basegfx::BColorModifierStack();
893cdf0e10cSrcweir 
894cdf0e10cSrcweir 					// paint mask to it (always with transparence intensities, evtl. with AA)
895cdf0e10cSrcweir 					process(rTransCandidate.getTransparence());
896cdf0e10cSrcweir 
897cdf0e10cSrcweir 					// back to old color stack
898cdf0e10cSrcweir 					maBColorModifierStack = aLastBColorModifierStack;
899cdf0e10cSrcweir 
900cdf0e10cSrcweir 					// back to old OutDev
901cdf0e10cSrcweir 					mpOutputDevice = pLastOutputDevice;
902cdf0e10cSrcweir 
903cdf0e10cSrcweir 					// dump buffer to outdev
904cdf0e10cSrcweir 					aBufferDevice.paint();
905cdf0e10cSrcweir 				}
906cdf0e10cSrcweir 			}
907cdf0e10cSrcweir 		}
908cdf0e10cSrcweir 
909cdf0e10cSrcweir 		// transform group.
910cdf0e10cSrcweir 		void VclProcessor2D::RenderTransformPrimitive2D(const primitive2d::TransformPrimitive2D& rTransformCandidate)
911cdf0e10cSrcweir 		{
912cdf0e10cSrcweir 			// remember current transformation and ViewInformation
913cdf0e10cSrcweir 			const basegfx::B2DHomMatrix aLastCurrentTransformation(maCurrentTransformation);
914cdf0e10cSrcweir             const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
915cdf0e10cSrcweir 
916cdf0e10cSrcweir 			// create new transformations for CurrentTransformation
917cdf0e10cSrcweir             // and for local ViewInformation2D
918cdf0e10cSrcweir 			maCurrentTransformation = maCurrentTransformation * rTransformCandidate.getTransformation();
919cdf0e10cSrcweir             const geometry::ViewInformation2D aViewInformation2D(
920cdf0e10cSrcweir                 getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(),
921cdf0e10cSrcweir                 getViewInformation2D().getViewTransformation(),
922cdf0e10cSrcweir                 getViewInformation2D().getViewport(),
923cdf0e10cSrcweir 				getViewInformation2D().getVisualizedPage(),
924cdf0e10cSrcweir                 getViewInformation2D().getViewTime(),
925cdf0e10cSrcweir 				getViewInformation2D().getExtendedInformationSequence());
926cdf0e10cSrcweir 			updateViewInformation(aViewInformation2D);
927cdf0e10cSrcweir 
928cdf0e10cSrcweir 			// proccess content
929cdf0e10cSrcweir 			process(rTransformCandidate.getChildren());
930cdf0e10cSrcweir 
931cdf0e10cSrcweir 			// restore transformations
932cdf0e10cSrcweir 			maCurrentTransformation = aLastCurrentTransformation;
933cdf0e10cSrcweir             updateViewInformation(aLastViewInformation2D);
934cdf0e10cSrcweir 		}
935cdf0e10cSrcweir 
936cdf0e10cSrcweir 		// new XDrawPage for ViewInformation2D
937cdf0e10cSrcweir 		void VclProcessor2D::RenderPagePreviewPrimitive2D(const primitive2d::PagePreviewPrimitive2D& rPagePreviewCandidate)
938cdf0e10cSrcweir 		{
939cdf0e10cSrcweir 			// remember current transformation and ViewInformation
940cdf0e10cSrcweir             const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
941cdf0e10cSrcweir 
942cdf0e10cSrcweir 			// create new local ViewInformation2D
943cdf0e10cSrcweir             const geometry::ViewInformation2D aViewInformation2D(
944cdf0e10cSrcweir                 getViewInformation2D().getObjectTransformation(),
945cdf0e10cSrcweir                 getViewInformation2D().getViewTransformation(),
946cdf0e10cSrcweir                 getViewInformation2D().getViewport(),
947cdf0e10cSrcweir 				rPagePreviewCandidate.getXDrawPage(),
948cdf0e10cSrcweir                 getViewInformation2D().getViewTime(),
949cdf0e10cSrcweir 				getViewInformation2D().getExtendedInformationSequence());
950cdf0e10cSrcweir 			updateViewInformation(aViewInformation2D);
951cdf0e10cSrcweir 
952cdf0e10cSrcweir 			// proccess decomposed content
953cdf0e10cSrcweir 			process(rPagePreviewCandidate.get2DDecomposition(getViewInformation2D()));
954cdf0e10cSrcweir 
955cdf0e10cSrcweir 			// restore transformations
956cdf0e10cSrcweir             updateViewInformation(aLastViewInformation2D);
957cdf0e10cSrcweir 		}
958cdf0e10cSrcweir 
959cdf0e10cSrcweir 		// marker
960cdf0e10cSrcweir 		void VclProcessor2D::RenderMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkArrayCandidate)
961cdf0e10cSrcweir 		{
962cdf0e10cSrcweir             static bool bCheckCompleteMarkerDecompose(false);
963cdf0e10cSrcweir             if(bCheckCompleteMarkerDecompose)
964cdf0e10cSrcweir             {
965cdf0e10cSrcweir 			    process(rMarkArrayCandidate.get2DDecomposition(getViewInformation2D()));
966cdf0e10cSrcweir                 return;
967cdf0e10cSrcweir             }
968cdf0e10cSrcweir 
969cdf0e10cSrcweir 			// get data
970cdf0e10cSrcweir 	        const std::vector< basegfx::B2DPoint >& rPositions = rMarkArrayCandidate.getPositions();
971cdf0e10cSrcweir 			const sal_uInt32 nCount(rPositions.size());
972cdf0e10cSrcweir 
973cdf0e10cSrcweir 			if(nCount && !rMarkArrayCandidate.getMarker().IsEmpty())
974cdf0e10cSrcweir 			{
975cdf0e10cSrcweir 				// get pixel size
976cdf0e10cSrcweir 				const BitmapEx& rMarker(rMarkArrayCandidate.getMarker());
977cdf0e10cSrcweir 				const Size aBitmapSize(rMarker.GetSizePixel());
978cdf0e10cSrcweir 
979cdf0e10cSrcweir 				if(aBitmapSize.Width() && aBitmapSize.Height())
980cdf0e10cSrcweir 				{
981cdf0e10cSrcweir 					// get discrete half size
982cdf0e10cSrcweir 					const basegfx::B2DVector aDiscreteHalfSize(
983cdf0e10cSrcweir                         (aBitmapSize.getWidth() - 1.0) * 0.5,
984cdf0e10cSrcweir                         (aBitmapSize.getHeight() - 1.0) * 0.5);
985cdf0e10cSrcweir 			        const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled());
986cdf0e10cSrcweir 
987cdf0e10cSrcweir                     // do not forget evtl. moved origin in target device MapMode when
988cdf0e10cSrcweir                     // switching it off; it would be missing and lead to wrong positions.
989cdf0e10cSrcweir                     // All his could be done using logic sizes and coordinates, too, but
990cdf0e10cSrcweir                     // we want a 1:1 bitmap rendering here, so it's more safe and faster
991cdf0e10cSrcweir                     // to work with switching off MapMode usage completely.
992cdf0e10cSrcweir                     const Point aOrigin(mpOutputDevice->GetMapMode().GetOrigin());
993cdf0e10cSrcweir 
994cdf0e10cSrcweir                     mpOutputDevice->EnableMapMode(false);
995cdf0e10cSrcweir 
996cdf0e10cSrcweir 					for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); aIter++)
997cdf0e10cSrcweir 				    {
998cdf0e10cSrcweir 					    const basegfx::B2DPoint aDiscreteTopLeft((maCurrentTransformation * (*aIter)) - aDiscreteHalfSize);
999cdf0e10cSrcweir                         const Point aDiscretePoint(basegfx::fround(aDiscreteTopLeft.getX()), basegfx::fround(aDiscreteTopLeft.getY()));
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir 						mpOutputDevice->DrawBitmapEx(aDiscretePoint + aOrigin, rMarker);
1002cdf0e10cSrcweir 					}
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir 			        mpOutputDevice->EnableMapMode(bWasEnabled);
1005cdf0e10cSrcweir 				}
1006cdf0e10cSrcweir 			}
1007cdf0e10cSrcweir 		}
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir 		// point
1010cdf0e10cSrcweir 		void VclProcessor2D::RenderPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate)
1011cdf0e10cSrcweir 		{
1012cdf0e10cSrcweir 			const std::vector< basegfx::B2DPoint >& rPositions = rPointArrayCandidate.getPositions();
1013cdf0e10cSrcweir 			const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(rPointArrayCandidate.getRGBColor()));
1014cdf0e10cSrcweir 			const Color aVCLColor(aRGBColor);
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir 			for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); aIter++)
1017cdf0e10cSrcweir 			{
1018cdf0e10cSrcweir 				const basegfx::B2DPoint aViewPosition(maCurrentTransformation * (*aIter));
1019cdf0e10cSrcweir 				const Point aPos(basegfx::fround(aViewPosition.getX()), basegfx::fround(aViewPosition.getY()));
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir 				mpOutputDevice->DrawPixel(aPos, aVCLColor);
1022cdf0e10cSrcweir 			}
1023cdf0e10cSrcweir 		}
1024cdf0e10cSrcweir 
1025cdf0e10cSrcweir 		void VclProcessor2D::RenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate)
1026cdf0e10cSrcweir 		{
1027cdf0e10cSrcweir             // #i101491# method restructured to clearly use the DrawPolyLine
1028cdf0e10cSrcweir             // calls starting from a deined line width
1029cdf0e10cSrcweir 			const attribute::LineAttribute& rLineAttribute = rPolygonStrokeCandidate.getLineAttribute();
1030cdf0e10cSrcweir 			const double fLineWidth(rLineAttribute.getWidth());
1031cdf0e10cSrcweir 			bool bDone(false);
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir 			if(basegfx::fTools::more(fLineWidth, 0.0))
1034cdf0e10cSrcweir 			{
1035cdf0e10cSrcweir 				const basegfx::B2DVector aDiscreteUnit(maCurrentTransformation * basegfx::B2DVector(fLineWidth, 0.0));
1036cdf0e10cSrcweir 				const double fDiscreteLineWidth(aDiscreteUnit.getLength());
1037cdf0e10cSrcweir 				const attribute::StrokeAttribute& rStrokeAttribute = rPolygonStrokeCandidate.getStrokeAttribute();
1038cdf0e10cSrcweir 				const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rLineAttribute.getColor()));
1039cdf0e10cSrcweir 				basegfx::B2DPolyPolygon aHairlinePolyPolygon;
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir 				mpOutputDevice->SetLineColor(Color(aHairlineColor));
1042cdf0e10cSrcweir 				mpOutputDevice->SetFillColor();
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir 				if(0.0 == rStrokeAttribute.getFullDotDashLen())
1045cdf0e10cSrcweir 				{
1046cdf0e10cSrcweir 					// no line dashing, just copy
1047cdf0e10cSrcweir 					aHairlinePolyPolygon.append(rPolygonStrokeCandidate.getB2DPolygon());
1048cdf0e10cSrcweir 				}
1049cdf0e10cSrcweir 				else
1050cdf0e10cSrcweir 				{
1051cdf0e10cSrcweir 					// else apply LineStyle
1052cdf0e10cSrcweir 					basegfx::tools::applyLineDashing(rPolygonStrokeCandidate.getB2DPolygon(),
1053cdf0e10cSrcweir 						rStrokeAttribute.getDotDashArray(),
1054cdf0e10cSrcweir 						&aHairlinePolyPolygon, 0, rStrokeAttribute.getFullDotDashLen());
1055cdf0e10cSrcweir 				}
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 				const sal_uInt32 nCount(aHairlinePolyPolygon.count());
1058cdf0e10cSrcweir 
1059cdf0e10cSrcweir 				if(nCount)
1060cdf0e10cSrcweir 				{
1061cdf0e10cSrcweir                     const bool bAntiAliased(getOptionsDrawinglayer().IsAntiAliasing());
1062cdf0e10cSrcweir                     aHairlinePolyPolygon.transform(maCurrentTransformation);
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir                     if(bAntiAliased)
1065cdf0e10cSrcweir                     {
1066cdf0e10cSrcweir                         if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 1.0))
1067cdf0e10cSrcweir                         {
1068cdf0e10cSrcweir                             // line in range ]0.0 .. 1.0[
1069cdf0e10cSrcweir                             // paint as simple hairline
10707be6ee6dSArmin Le Grand                             for(sal_uInt32 a(0); a < nCount; a++)
10717be6ee6dSArmin Le Grand                             {
10727be6ee6dSArmin Le Grand                                 mpOutputDevice->DrawPolyLine(aHairlinePolyPolygon.getB2DPolygon(a), 0.0);
10737be6ee6dSArmin Le Grand                             }
10747be6ee6dSArmin Le Grand 
1075cdf0e10cSrcweir                             bDone = true;
1076cdf0e10cSrcweir                         }
1077cdf0e10cSrcweir                         else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 2.0))
1078cdf0e10cSrcweir                         {
1079cdf0e10cSrcweir                             // line in range [1.0 .. 2.0[
1080cdf0e10cSrcweir                             // paint as 2x2 with dynamic line distance
1081cdf0e10cSrcweir                             basegfx::B2DHomMatrix aMat;
1082cdf0e10cSrcweir                             const double fDistance(fDiscreteLineWidth - 1.0);
1083cdf0e10cSrcweir                             const double fHalfDistance(fDistance * 0.5);
1084cdf0e10cSrcweir 
10857be6ee6dSArmin Le Grand                             for(sal_uInt32 a(0); a < nCount; a++)
10867be6ee6dSArmin Le Grand                             {
10877be6ee6dSArmin Le Grand                                 basegfx::B2DPolygon aCandidate(aHairlinePolyPolygon.getB2DPolygon(a));
10887be6ee6dSArmin Le Grand 
1089cdf0e10cSrcweir                                 aMat.set(0, 2, -fHalfDistance);
1090cdf0e10cSrcweir                                 aMat.set(1, 2, -fHalfDistance);
1091cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1092cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir                                 aMat.set(0, 2, fDistance);
1095cdf0e10cSrcweir                                 aMat.set(1, 2, 0.0);
1096cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1097cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir                                 aMat.set(0, 2, 0.0);
1100cdf0e10cSrcweir                                 aMat.set(1, 2, fDistance);
1101cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1102cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir                                 aMat.set(0, 2, -fDistance);
1105cdf0e10cSrcweir                                 aMat.set(1, 2, 0.0);
1106cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1107cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
11087be6ee6dSArmin Le Grand                             }
11097be6ee6dSArmin Le Grand 
1110cdf0e10cSrcweir                             bDone = true;
1111cdf0e10cSrcweir                         }
1112cdf0e10cSrcweir                         else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 3.0))
1113cdf0e10cSrcweir                         {
1114cdf0e10cSrcweir                             // line in range [2.0 .. 3.0]
1115cdf0e10cSrcweir                             // paint as cross in a 3x3  with dynamic line distance
1116cdf0e10cSrcweir                             basegfx::B2DHomMatrix aMat;
1117cdf0e10cSrcweir                             const double fDistance((fDiscreteLineWidth - 1.0) * 0.5);
1118cdf0e10cSrcweir 
11197be6ee6dSArmin Le Grand                             for(sal_uInt32 a(0); a < nCount; a++)
11207be6ee6dSArmin Le Grand                             {
11217be6ee6dSArmin Le Grand                                 basegfx::B2DPolygon aCandidate(aHairlinePolyPolygon.getB2DPolygon(a));
11227be6ee6dSArmin Le Grand 
1123cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1124cdf0e10cSrcweir 
1125cdf0e10cSrcweir                                 aMat.set(0, 2, -fDistance);
1126cdf0e10cSrcweir                                 aMat.set(1, 2, 0.0);
1127cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1128cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1129cdf0e10cSrcweir 
1130cdf0e10cSrcweir                                 aMat.set(0, 2, fDistance);
1131cdf0e10cSrcweir                                 aMat.set(1, 2, -fDistance);
1132cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1133cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir                                 aMat.set(0, 2, fDistance);
1136cdf0e10cSrcweir                                 aMat.set(1, 2, fDistance);
1137cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1138cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1139cdf0e10cSrcweir 
1140cdf0e10cSrcweir                                 aMat.set(0, 2, -fDistance);
1141cdf0e10cSrcweir                                 aMat.set(1, 2, fDistance);
1142cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1143cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
11447be6ee6dSArmin Le Grand                             }
11457be6ee6dSArmin Le Grand 
1146cdf0e10cSrcweir                             bDone = true;
1147cdf0e10cSrcweir                         }
1148cdf0e10cSrcweir                         else
1149cdf0e10cSrcweir                         {
1150cdf0e10cSrcweir                             // #i101491# line width above 3.0
1151cdf0e10cSrcweir                         }
1152cdf0e10cSrcweir                     }
1153cdf0e10cSrcweir                     else
1154cdf0e10cSrcweir                     {
1155cdf0e10cSrcweir                         if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 1.5))
1156cdf0e10cSrcweir                         {
1157cdf0e10cSrcweir                             // line width below 1.5, draw the basic hairline polygon
11587be6ee6dSArmin Le Grand                             for(sal_uInt32 a(0); a < nCount; a++)
11597be6ee6dSArmin Le Grand                             {
11607be6ee6dSArmin Le Grand                                 mpOutputDevice->DrawPolyLine(aHairlinePolyPolygon.getB2DPolygon(a), 0.0);
11617be6ee6dSArmin Le Grand                             }
11627be6ee6dSArmin Le Grand 
1163cdf0e10cSrcweir                             bDone = true;
1164cdf0e10cSrcweir                         }
1165cdf0e10cSrcweir                         else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 2.5))
1166cdf0e10cSrcweir                         {
1167cdf0e10cSrcweir                             // line width is in range ]1.5 .. 2.5], use four hairlines
1168cdf0e10cSrcweir                             // drawn in a square
11697be6ee6dSArmin Le Grand                             for(sal_uInt32 a(0); a < nCount; a++)
11707be6ee6dSArmin Le Grand                             {
11717be6ee6dSArmin Le Grand                                 basegfx::B2DPolygon aCandidate(aHairlinePolyPolygon.getB2DPolygon(a));
1172cdf0e10cSrcweir                                 basegfx::B2DHomMatrix aMat;
11737be6ee6dSArmin Le Grand 
1174cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1175cdf0e10cSrcweir 
1176cdf0e10cSrcweir                                 aMat.set(0, 2, 1.0);
1177cdf0e10cSrcweir                                 aMat.set(1, 2, 0.0);
1178cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1179cdf0e10cSrcweir 
1180cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1181cdf0e10cSrcweir 
1182cdf0e10cSrcweir                                 aMat.set(0, 2, 0.0);
1183cdf0e10cSrcweir                                 aMat.set(1, 2, 1.0);
1184cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir                                 aMat.set(0, 2, -1.0);
1189cdf0e10cSrcweir                                 aMat.set(1, 2, 0.0);
1190cdf0e10cSrcweir                                 aCandidate.transform(aMat);
1191cdf0e10cSrcweir 
1192cdf0e10cSrcweir                                 mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
11937be6ee6dSArmin Le Grand                             }
11947be6ee6dSArmin Le Grand 
1195cdf0e10cSrcweir                             bDone = true;
1196cdf0e10cSrcweir                         }
1197cdf0e10cSrcweir                         else
1198cdf0e10cSrcweir                         {
1199cdf0e10cSrcweir                             // #i101491# line width is above 2.5
1200cdf0e10cSrcweir                         }
1201cdf0e10cSrcweir                     }
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir                     if(!bDone && rPolygonStrokeCandidate.getB2DPolygon().count() > 1000)
1204cdf0e10cSrcweir                     {
1205cdf0e10cSrcweir                         // #i101491# If the polygon complexity uses more than a given amount, do
1206cdf0e10cSrcweir                         // use OuputDevice::DrawPolyLine directly; this will avoid buffering all
1207cdf0e10cSrcweir                         // decompositions in primtives (memory) and fallback to old line painting
1208cdf0e10cSrcweir                         // for very complex polygons, too
12097be6ee6dSArmin Le Grand                         for(sal_uInt32 a(0); a < nCount; a++)
12107be6ee6dSArmin Le Grand                         {
12117be6ee6dSArmin Le Grand                             mpOutputDevice->DrawPolyLine(
12127be6ee6dSArmin Le Grand                                 aHairlinePolyPolygon.getB2DPolygon(a),
12137be6ee6dSArmin Le Grand                                 fDiscreteLineWidth,
12147be6ee6dSArmin Le Grand                                 rLineAttribute.getLineJoin(),
12157be6ee6dSArmin Le Grand                                 rLineAttribute.getLineCap());
1216cdf0e10cSrcweir                         }
12177be6ee6dSArmin Le Grand 
12187be6ee6dSArmin Le Grand                         bDone = true;
1219cdf0e10cSrcweir                     }
1220cdf0e10cSrcweir                 }
1221cdf0e10cSrcweir             }
1222cdf0e10cSrcweir 
1223cdf0e10cSrcweir 			if(!bDone)
1224cdf0e10cSrcweir             {
1225cdf0e10cSrcweir                 // remeber that we enter a PolygonStrokePrimitive2D decomposition,
1226cdf0e10cSrcweir                 // used for AA thick line drawing
1227cdf0e10cSrcweir                 mnPolygonStrokePrimitive2D++;
1228cdf0e10cSrcweir 
1229cdf0e10cSrcweir                 // line width is big enough for standard filled polygon visualisation or zero
1230cdf0e10cSrcweir 				process(rPolygonStrokeCandidate.get2DDecomposition(getViewInformation2D()));
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir                 // leave PolygonStrokePrimitive2D
1233cdf0e10cSrcweir                 mnPolygonStrokePrimitive2D--;
1234cdf0e10cSrcweir             }
1235cdf0e10cSrcweir 		}
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir         void VclProcessor2D::RenderEpsPrimitive2D(const primitive2d::EpsPrimitive2D& rEpsPrimitive2D)
1238cdf0e10cSrcweir         {
1239cdf0e10cSrcweir             // The new decomposition of Metafiles made it necessary to add an Eps
1240cdf0e10cSrcweir             // primitive to handle embedded Eps data. On some devices, this can be
1241cdf0e10cSrcweir             // painted directly (mac, printer).
1242cdf0e10cSrcweir             // To be able to handle the replacement correctly, i need to handle it myself
1243cdf0e10cSrcweir             // since DrawEPS will not be able e.g. to rotate the replacement. To be able
1244cdf0e10cSrcweir             // to do that, i added a boolean return to OutputDevice::DrawEPS(..)
1245cdf0e10cSrcweir             // to know when EPS was handled directly already.
1246cdf0e10cSrcweir 			basegfx::B2DRange aRange(0.0, 0.0, 1.0, 1.0);
1247cdf0e10cSrcweir             aRange.transform(maCurrentTransformation * rEpsPrimitive2D.getEpsTransform());
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir             if(!aRange.isEmpty())
1250cdf0e10cSrcweir             {
1251cdf0e10cSrcweir                 const Rectangle aRectangle(
1252cdf0e10cSrcweir 				    (sal_Int32)floor(aRange.getMinX()), (sal_Int32)floor(aRange.getMinY()),
1253cdf0e10cSrcweir 				    (sal_Int32)ceil(aRange.getMaxX()), (sal_Int32)ceil(aRange.getMaxY()));
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir                 if(!aRectangle.IsEmpty())
1256cdf0e10cSrcweir                 {
1257cdf0e10cSrcweir                     // try to paint EPS directly without fallback visualisation
1258cdf0e10cSrcweir                     const bool bEPSPaintedDirectly(mpOutputDevice->DrawEPS(
1259cdf0e10cSrcweir                         aRectangle.TopLeft(),
1260cdf0e10cSrcweir                         aRectangle.GetSize(),
1261cdf0e10cSrcweir                         rEpsPrimitive2D.getGfxLink(),
1262cdf0e10cSrcweir                         0));
1263cdf0e10cSrcweir 
1264cdf0e10cSrcweir                     if(!bEPSPaintedDirectly)
1265cdf0e10cSrcweir                     {
1266cdf0e10cSrcweir                         // use the decomposition which will correctly handle the
1267cdf0e10cSrcweir                         // fallback visualisation using full transformation (e.g. rotation)
1268cdf0e10cSrcweir         				process(rEpsPrimitive2D.get2DDecomposition(getViewInformation2D()));
1269cdf0e10cSrcweir                     }
1270cdf0e10cSrcweir                 }
1271cdf0e10cSrcweir             }
1272cdf0e10cSrcweir         }
1273cdf0e10cSrcweir 
127439551d71SArmin Le Grand         void VclProcessor2D::RenderSvgLinearAtomPrimitive2D(const primitive2d::SvgLinearAtomPrimitive2D& rCandidate)
127539551d71SArmin Le Grand         {
127639551d71SArmin Le Grand             const double fDelta(rCandidate.getOffsetB() - rCandidate.getOffsetA());
127739551d71SArmin Le Grand 
127839551d71SArmin Le Grand             if(basegfx::fTools::more(fDelta, 0.0))
127939551d71SArmin Le Grand             {
128039551d71SArmin Le Grand                 const basegfx::BColor aColorA(maBColorModifierStack.getModifiedColor(rCandidate.getColorA()));
128139551d71SArmin Le Grand                 const basegfx::BColor aColorB(maBColorModifierStack.getModifiedColor(rCandidate.getColorB()));
1282*3d844549SArmin Le Grand                 const basegfx::B2DVector aDiscreteVector(getViewInformation2D().getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 1.0));
1283*3d844549SArmin Le Grand                 const double fDiscreteUnit(std::min(fabs(aDiscreteVector.getX()), fabs(aDiscreteVector.getY())));
128439551d71SArmin Le Grand 
128539551d71SArmin Le Grand                 // use color distance and discrete lengths to calculate step count
128639551d71SArmin Le Grand                 const sal_uInt32 nSteps(calculateStepsForSvgGradient(aColorA, aColorB, fDelta, fDiscreteUnit));
128739551d71SArmin Le Grand 
1288025b0597SArmin Le Grand                 // switch off line painting
1289025b0597SArmin Le Grand                 mpOutputDevice->SetLineColor();
1290025b0597SArmin Le Grand 
1291025b0597SArmin Le Grand                 // prepare polygon in needed width at start position (with discrete overlap)
129239551d71SArmin Le Grand                 const basegfx::B2DPolygon aPolygon(
129339551d71SArmin Le Grand                     basegfx::tools::createPolygonFromRect(
129439551d71SArmin Le Grand                         basegfx::B2DRange(
129539551d71SArmin Le Grand                             rCandidate.getOffsetA() - fDiscreteUnit,
129639551d71SArmin Le Grand                             0.0,
1297025b0597SArmin Le Grand                             rCandidate.getOffsetA() + (fDelta / nSteps) + fDiscreteUnit,
129839551d71SArmin Le Grand                             1.0)));
129939551d71SArmin Le Grand 
1300025b0597SArmin Le Grand 
1301025b0597SArmin Le Grand                 // prepare loop ([0.0 .. 1.0[)
1302025b0597SArmin Le Grand                 double fUnitScale(0.0);
1303025b0597SArmin Le Grand                 const double fUnitStep(1.0 / nSteps);
130439551d71SArmin Le Grand 
130539551d71SArmin Le Grand                 // loop and paint
1306025b0597SArmin Le Grand                 for(sal_uInt32 a(0); a < nSteps; a++, fUnitScale += fUnitStep)
130739551d71SArmin Le Grand                 {
130839551d71SArmin Le Grand                     basegfx::B2DPolygon aNew(aPolygon);
130939551d71SArmin Le Grand 
1310025b0597SArmin Le Grand                     aNew.transform(maCurrentTransformation * basegfx::tools::createTranslateB2DHomMatrix(fDelta * fUnitScale, 0.0));
1311025b0597SArmin Le Grand                     mpOutputDevice->SetFillColor(Color(basegfx::interpolate(aColorA, aColorB, fUnitScale)));
131239551d71SArmin Le Grand                     mpOutputDevice->DrawPolyPolygon(basegfx::B2DPolyPolygon(aNew));
131339551d71SArmin Le Grand                 }
131439551d71SArmin Le Grand             }
131539551d71SArmin Le Grand         }
131639551d71SArmin Le Grand 
131739551d71SArmin Le Grand         void VclProcessor2D::RenderSvgRadialAtomPrimitive2D(const primitive2d::SvgRadialAtomPrimitive2D& rCandidate)
131839551d71SArmin Le Grand         {
131939551d71SArmin Le Grand             const double fDeltaScale(rCandidate.getScaleB() - rCandidate.getScaleA());
132039551d71SArmin Le Grand 
132139551d71SArmin Le Grand             if(basegfx::fTools::more(fDeltaScale, 0.0))
132239551d71SArmin Le Grand             {
132339551d71SArmin Le Grand                 const basegfx::BColor aColorA(maBColorModifierStack.getModifiedColor(rCandidate.getColorA()));
132439551d71SArmin Le Grand                 const basegfx::BColor aColorB(maBColorModifierStack.getModifiedColor(rCandidate.getColorB()));
1325*3d844549SArmin Le Grand                 const basegfx::B2DVector aDiscreteVector(getViewInformation2D().getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 1.0));
1326*3d844549SArmin Le Grand                 const double fDiscreteUnit(std::min(fabs(aDiscreteVector.getX()), fabs(aDiscreteVector.getY())));
132739551d71SArmin Le Grand 
132839551d71SArmin Le Grand                 // use color distance and discrete lengths to calculate step count
132939551d71SArmin Le Grand                 const sal_uInt32 nSteps(calculateStepsForSvgGradient(aColorA, aColorB, fDeltaScale, fDiscreteUnit));
133039551d71SArmin Le Grand 
133139551d71SArmin Le Grand                 // switch off line painting
133239551d71SArmin Le Grand                 mpOutputDevice->SetLineColor();
133339551d71SArmin Le Grand 
1334025b0597SArmin Le Grand                 // prepare loop ([0.0 .. 1.0[, full polygons, no polypolygons with holes)
1335025b0597SArmin Le Grand                 double fUnitScale(0.0);
1336025b0597SArmin Le Grand                 const double fUnitStep(1.0 / nSteps);
133739551d71SArmin Le Grand 
1338025b0597SArmin Le Grand                 for(sal_uInt32 a(0); a < nSteps; a++, fUnitScale += fUnitStep)
133939551d71SArmin Le Grand                 {
134039551d71SArmin Le Grand                     basegfx::B2DHomMatrix aTransform;
1341025b0597SArmin Le Grand                     const double fEndScale(rCandidate.getScaleB() - (fDeltaScale * fUnitScale));
134239551d71SArmin Le Grand 
134339551d71SArmin Le Grand                     if(rCandidate.isTranslateSet())
134439551d71SArmin Le Grand                     {
134539551d71SArmin Le Grand                         const basegfx::B2DVector aTranslate(
134639551d71SArmin Le Grand                             basegfx::interpolate(
134739551d71SArmin Le Grand                                 rCandidate.getTranslateB(),
1348025b0597SArmin Le Grand                                 rCandidate.getTranslateA(),
134939551d71SArmin Le Grand                                 fUnitScale));
135039551d71SArmin Le Grand 
135139551d71SArmin Le Grand                         aTransform = basegfx::tools::createScaleTranslateB2DHomMatrix(
135239551d71SArmin Le Grand                             fEndScale,
135339551d71SArmin Le Grand                             fEndScale,
135439551d71SArmin Le Grand                             aTranslate.getX(),
135539551d71SArmin Le Grand                             aTranslate.getY());
135639551d71SArmin Le Grand                     }
135739551d71SArmin Le Grand                     else
135839551d71SArmin Le Grand                     {
135939551d71SArmin Le Grand                         aTransform = basegfx::tools::createScaleB2DHomMatrix(
136039551d71SArmin Le Grand                             fEndScale,
136139551d71SArmin Le Grand                             fEndScale);
136239551d71SArmin Le Grand                     }
136339551d71SArmin Le Grand 
136439551d71SArmin Le Grand                     basegfx::B2DPolygon aNew(basegfx::tools::createPolygonFromUnitCircle());
136539551d71SArmin Le Grand 
136639551d71SArmin Le Grand                     aNew.transform(maCurrentTransformation * aTransform);
1367025b0597SArmin Le Grand                     mpOutputDevice->SetFillColor(Color(basegfx::interpolate(aColorB, aColorA, fUnitScale)));
136839551d71SArmin Le Grand                     mpOutputDevice->DrawPolyPolygon(basegfx::B2DPolyPolygon(aNew));
136939551d71SArmin Le Grand                 }
137039551d71SArmin Le Grand             }
137139551d71SArmin Le Grand         }
137239551d71SArmin Le Grand 
1373cdf0e10cSrcweir 		void VclProcessor2D::adaptLineToFillDrawMode() const
1374cdf0e10cSrcweir 		{
1375cdf0e10cSrcweir 			const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir 			if(nOriginalDrawMode & (DRAWMODE_BLACKLINE|DRAWMODE_GRAYLINE|DRAWMODE_GHOSTEDLINE|DRAWMODE_WHITELINE|DRAWMODE_SETTINGSLINE))
1378cdf0e10cSrcweir 			{
1379cdf0e10cSrcweir 				sal_uInt32 nAdaptedDrawMode(nOriginalDrawMode);
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_BLACKLINE)
1382cdf0e10cSrcweir 				{
1383cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_BLACKFILL;
1384cdf0e10cSrcweir 				}
1385cdf0e10cSrcweir 				else
1386cdf0e10cSrcweir 				{
1387cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_BLACKFILL;
1388cdf0e10cSrcweir 				}
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_GRAYLINE)
1391cdf0e10cSrcweir 				{
1392cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_GRAYFILL;
1393cdf0e10cSrcweir 				}
1394cdf0e10cSrcweir 				else
1395cdf0e10cSrcweir 				{
1396cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_GRAYFILL;
1397cdf0e10cSrcweir 				}
1398cdf0e10cSrcweir 
1399cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_GHOSTEDLINE)
1400cdf0e10cSrcweir 				{
1401cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_GHOSTEDFILL;
1402cdf0e10cSrcweir 				}
1403cdf0e10cSrcweir 				else
1404cdf0e10cSrcweir 				{
1405cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_GHOSTEDFILL;
1406cdf0e10cSrcweir 				}
1407cdf0e10cSrcweir 
1408cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_WHITELINE)
1409cdf0e10cSrcweir 				{
1410cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_WHITEFILL;
1411cdf0e10cSrcweir 				}
1412cdf0e10cSrcweir 				else
1413cdf0e10cSrcweir 				{
1414cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_WHITEFILL;
1415cdf0e10cSrcweir 				}
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_SETTINGSLINE)
1418cdf0e10cSrcweir 				{
1419cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_SETTINGSFILL;
1420cdf0e10cSrcweir 				}
1421cdf0e10cSrcweir 				else
1422cdf0e10cSrcweir 				{
1423cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_SETTINGSFILL;
1424cdf0e10cSrcweir 				}
1425cdf0e10cSrcweir 
1426cdf0e10cSrcweir 				mpOutputDevice->SetDrawMode(nAdaptedDrawMode);
1427cdf0e10cSrcweir 			}
1428cdf0e10cSrcweir 		}
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir 		void VclProcessor2D::adaptTextToFillDrawMode() const
1431cdf0e10cSrcweir 		{
1432cdf0e10cSrcweir 			const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
1433cdf0e10cSrcweir 			if(nOriginalDrawMode & (DRAWMODE_BLACKTEXT|DRAWMODE_GRAYTEXT|DRAWMODE_GHOSTEDTEXT|DRAWMODE_WHITETEXT|DRAWMODE_SETTINGSTEXT))
1434cdf0e10cSrcweir 			{
1435cdf0e10cSrcweir 				sal_uInt32 nAdaptedDrawMode(nOriginalDrawMode);
1436cdf0e10cSrcweir 
1437cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_BLACKTEXT)
1438cdf0e10cSrcweir 				{
1439cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_BLACKFILL;
1440cdf0e10cSrcweir 				}
1441cdf0e10cSrcweir 				else
1442cdf0e10cSrcweir 				{
1443cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_BLACKFILL;
1444cdf0e10cSrcweir 				}
1445cdf0e10cSrcweir 
1446cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_GRAYTEXT)
1447cdf0e10cSrcweir 				{
1448cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_GRAYFILL;
1449cdf0e10cSrcweir 				}
1450cdf0e10cSrcweir 				else
1451cdf0e10cSrcweir 				{
1452cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_GRAYFILL;
1453cdf0e10cSrcweir 				}
1454cdf0e10cSrcweir 
1455cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_GHOSTEDTEXT)
1456cdf0e10cSrcweir 				{
1457cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_GHOSTEDFILL;
1458cdf0e10cSrcweir 				}
1459cdf0e10cSrcweir 				else
1460cdf0e10cSrcweir 				{
1461cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_GHOSTEDFILL;
1462cdf0e10cSrcweir 				}
1463cdf0e10cSrcweir 
1464cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_WHITETEXT)
1465cdf0e10cSrcweir 				{
1466cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_WHITEFILL;
1467cdf0e10cSrcweir 				}
1468cdf0e10cSrcweir 				else
1469cdf0e10cSrcweir 				{
1470cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_WHITEFILL;
1471cdf0e10cSrcweir 				}
1472cdf0e10cSrcweir 
1473cdf0e10cSrcweir 				if(nOriginalDrawMode & DRAWMODE_SETTINGSTEXT)
1474cdf0e10cSrcweir 				{
1475cdf0e10cSrcweir 					nAdaptedDrawMode |= DRAWMODE_SETTINGSFILL;
1476cdf0e10cSrcweir 				}
1477cdf0e10cSrcweir 				else
1478cdf0e10cSrcweir 				{
1479cdf0e10cSrcweir 					nAdaptedDrawMode &= ~DRAWMODE_SETTINGSFILL;
1480cdf0e10cSrcweir 				}
1481cdf0e10cSrcweir 
1482cdf0e10cSrcweir 				mpOutputDevice->SetDrawMode(nAdaptedDrawMode);
1483cdf0e10cSrcweir 			}
1484cdf0e10cSrcweir 		}
1485cdf0e10cSrcweir 
1486cdf0e10cSrcweir 		//////////////////////////////////////////////////////////////////////////////
1487cdf0e10cSrcweir 		// process support
1488cdf0e10cSrcweir 
1489cdf0e10cSrcweir 		VclProcessor2D::VclProcessor2D(
1490cdf0e10cSrcweir 			const geometry::ViewInformation2D& rViewInformation,
1491cdf0e10cSrcweir 			OutputDevice& rOutDev)
1492cdf0e10cSrcweir 		:	BaseProcessor2D(rViewInformation),
1493cdf0e10cSrcweir 			mpOutputDevice(&rOutDev),
1494cdf0e10cSrcweir 			maBColorModifierStack(),
1495cdf0e10cSrcweir 			maCurrentTransformation(),
1496cdf0e10cSrcweir 			maDrawinglayerOpt(),
1497cdf0e10cSrcweir             mnPolygonStrokePrimitive2D(0)
1498cdf0e10cSrcweir 		{
1499cdf0e10cSrcweir             // set digit language, derived from SvtCTLOptions to have the correct
1500cdf0e10cSrcweir             // number display for arabic/hindi numerals
1501cdf0e10cSrcweir             const SvtCTLOptions aSvtCTLOptions;
1502cdf0e10cSrcweir             LanguageType eLang(LANGUAGE_SYSTEM);
1503cdf0e10cSrcweir 
1504cdf0e10cSrcweir             if(SvtCTLOptions::NUMERALS_HINDI == aSvtCTLOptions.GetCTLTextNumerals())
1505cdf0e10cSrcweir             {
1506cdf0e10cSrcweir                 eLang = LANGUAGE_ARABIC_SAUDI_ARABIA;
1507cdf0e10cSrcweir             }
1508cdf0e10cSrcweir             else if(SvtCTLOptions::NUMERALS_ARABIC == aSvtCTLOptions.GetCTLTextNumerals())
1509cdf0e10cSrcweir             {
1510cdf0e10cSrcweir                 eLang = LANGUAGE_ENGLISH;
1511cdf0e10cSrcweir             }
1512cdf0e10cSrcweir             else
1513cdf0e10cSrcweir             {
1514cdf0e10cSrcweir                 eLang = (LanguageType)Application::GetSettings().GetLanguage();
1515cdf0e10cSrcweir             }
1516cdf0e10cSrcweir 
1517cdf0e10cSrcweir             rOutDev.SetDigitLanguage(eLang);
1518cdf0e10cSrcweir 		}
1519cdf0e10cSrcweir 
1520cdf0e10cSrcweir 		VclProcessor2D::~VclProcessor2D()
1521cdf0e10cSrcweir 		{
1522cdf0e10cSrcweir 		}
1523cdf0e10cSrcweir 	} // end of namespace processor2d
1524cdf0e10cSrcweir } // end of namespace drawinglayer
1525cdf0e10cSrcweir 
1526cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1527cdf0e10cSrcweir // eof
1528