Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <drawinglayer/processor2d/vclprocessor2d.hxx>
30 : : #include <drawinglayer/primitive2d/textprimitive2d.hxx>
31 : : #include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx>
32 : : #include <tools/debug.hxx>
33 : : #include <vcl/outdev.hxx>
34 : : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
35 : : #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
36 : : #include <drawinglayer/primitive2d/rendergraphicprimitive2d.hxx>
37 : : #include <vclhelperbitmaptransform.hxx>
38 : : #include <basegfx/polygon/b2dpolygontools.hxx>
39 : : #include <vclhelperbitmaprender.hxx>
40 : : #include <drawinglayer/attribute/sdrfillbitmapattribute.hxx>
41 : : #include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
42 : : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
43 : : #include <vclhelpergradient.hxx>
44 : : #include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
45 : : #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
46 : : #include <basegfx/polygon/b2dpolypolygontools.hxx>
47 : : #include <vclhelperbufferdevice.hxx>
48 : : #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
49 : : #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
50 : : #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
51 : : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
52 : : #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
53 : : #include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx>
54 : : #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx>
55 : : #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx>
56 : : #include <tools/diagnose_ex.h>
57 : : #include <vcl/metric.hxx>
58 : : #include <drawinglayer/primitive2d/textenumsprimitive2d.hxx>
59 : : #include <drawinglayer/primitive2d/epsprimitive2d.hxx>
60 : : #include <vcl/rendergraphicrasterizer.hxx>
61 : :
62 : : #include "getdigitlanguage.hxx"
63 : :
64 : : //////////////////////////////////////////////////////////////////////////////
65 : : // control support
66 : :
67 : : #include <com/sun/star/awt/XWindow2.hpp>
68 : : #include <com/sun/star/awt/PosSize.hpp>
69 : : #include <com/sun/star/awt/XView.hpp>
70 : : #include <drawinglayer/primitive2d/controlprimitive2d.hxx>
71 : : #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
72 : :
73 : : //////////////////////////////////////////////////////////////////////////////
74 : : // for test, can be removed again
75 : :
76 : : #include <basegfx/polygon/b2dpolygonclipper.hxx>
77 : : #include <basegfx/polygon/b2dtrapezoid.hxx>
78 : :
79 : : //////////////////////////////////////////////////////////////////////////////
80 : :
81 : : using namespace com::sun::star;
82 : :
83 : : //////////////////////////////////////////////////////////////////////////////
84 : :
85 : : namespace drawinglayer
86 : : {
87 : : namespace processor2d
88 : : {
89 : : //////////////////////////////////////////////////////////////////////////////
90 : : // UNO class usages
91 : : using ::com::sun::star::uno::Reference;
92 : : using ::com::sun::star::uno::UNO_QUERY;
93 : : using ::com::sun::star::uno::UNO_QUERY_THROW;
94 : : using ::com::sun::star::uno::Exception;
95 : : using ::com::sun::star::awt::XView;
96 : : using ::com::sun::star::awt::XGraphics;
97 : : using ::com::sun::star::awt::XWindow;
98 : : using ::com::sun::star::awt::PosSize::POSSIZE;
99 : :
100 : : //////////////////////////////////////////////////////////////////////////////
101 : : // rendering support
102 : :
103 : : // directdraw of text simple portion or decorated portion primitive. When decorated, all the extra
104 : : // information is translated to VCL parameters and set at the font.
105 : : // Acceptance is restricted to no shearing and positive scaling in X and Y (no font mirroring
106 : : // for VCL)
107 : 20018 : void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D(const primitive2d::TextSimplePortionPrimitive2D& rTextCandidate)
108 : : {
109 : : // decompose matrix to have position and size of text
110 [ + - ]: 20018 : basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rTextCandidate.getTextTransform());
111 : 20018 : basegfx::B2DVector aFontScaling, aTranslate;
112 : : double fRotate, fShearX;
113 [ + - ]: 20018 : aLocalTransform.decompose(aFontScaling, aTranslate, fRotate, fShearX);
114 : 20018 : bool bPrimitiveAccepted(false);
115 : :
116 [ + + ]: 20018 : if(basegfx::fTools::equalZero(fShearX))
117 : : {
118 [ - + ][ # # ]: 17559 : if(basegfx::fTools::less(aFontScaling.getX(), 0.0) && basegfx::fTools::less(aFontScaling.getY(), 0.0))
[ - + ][ - + ]
[ + - ][ + - ]
[ - + ]
119 : : {
120 : : // handle special case: If scale is negative in (x,y) (3rd quadrant), it can
121 : : // be expressed as rotation by PI. Use this since the Font rendering will not
122 : : // apply the negative scales in any form
123 [ # # ]: 0 : aFontScaling = basegfx::absolute(aFontScaling);
124 : 0 : fRotate += F_PI;
125 : : }
126 : :
127 [ + - ][ + - ]: 17559 : if(basegfx::fTools::more(aFontScaling.getX(), 0.0) && basegfx::fTools::more(aFontScaling.getY(), 0.0))
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
128 : : {
129 : : // Get the VCL font (use FontHeight as FontWidth)
130 : : Font aFont(primitive2d::getVclFontFromFontAttribute(
131 : 17559 : rTextCandidate.getFontAttribute(),
132 : : aFontScaling.getX(),
133 : : aFontScaling.getY(),
134 : : fRotate,
135 [ + - ]: 35118 : rTextCandidate.getLocale()));
136 : :
137 : : // handle additional font attributes
138 : : const primitive2d::TextDecoratedPortionPrimitive2D* pTCPP =
139 [ - + ]: 17559 : dynamic_cast<const primitive2d::TextDecoratedPortionPrimitive2D*>( &rTextCandidate );
140 : :
141 [ + + ]: 17559 : if( pTCPP != NULL )
142 : : {
143 : :
144 : : // set the color of text decorations
145 [ + - ]: 1777 : const basegfx::BColor aTextlineColor = maBColorModifierStack.getModifiedColor(pTCPP->getTextlineColor());
146 [ + - ]: 1777 : mpOutputDevice->SetTextLineColor( Color(aTextlineColor) );
147 : :
148 : : // set Overline attribute
149 [ + - ]: 1777 : const FontUnderline eFontOverline(primitive2d::mapTextLineToFontUnderline( pTCPP->getFontOverline() ));
150 [ + + ]: 1777 : if( eFontOverline != UNDERLINE_NONE )
151 : : {
152 [ + - ]: 1295 : aFont.SetOverline( eFontOverline );
153 [ + - ]: 1295 : const basegfx::BColor aOverlineColor = maBColorModifierStack.getModifiedColor(pTCPP->getOverlineColor());
154 [ + - ]: 1295 : mpOutputDevice->SetOverlineColor( Color(aOverlineColor) );
155 [ + + ]: 1295 : if( pTCPP->getWordLineMode() )
156 [ + - ]: 1295 : aFont.SetWordLineMode( true );
157 : : }
158 : :
159 : : // set Underline attribute
160 [ + - ]: 1777 : const FontUnderline eFontUnderline(primitive2d::mapTextLineToFontUnderline( pTCPP->getFontUnderline() ));
161 [ + + ]: 1777 : if( eFontUnderline != UNDERLINE_NONE )
162 : : {
163 [ + - ]: 1734 : aFont.SetUnderline( eFontUnderline );
164 [ + + ]: 1734 : if( pTCPP->getWordLineMode() )
165 [ + - ]: 732 : aFont.SetWordLineMode( true );
166 : : //TODO: ??? if( pTCPP->getUnderlineAbove() )
167 : : // aFont.SetUnderlineAbove( true );
168 : : }
169 : :
170 : : // set Strikeout attribute
171 [ + - ]: 1777 : const FontStrikeout eFontStrikeout(primitive2d::mapTextStrikeoutToFontStrikeout(pTCPP->getTextStrikeout()));
172 : :
173 [ + + ]: 1777 : if( eFontStrikeout != STRIKEOUT_NONE )
174 [ + - ]: 477 : aFont.SetStrikeout( eFontStrikeout );
175 : :
176 : : // set EmphasisMark attribute
177 : 1777 : FontEmphasisMark eFontEmphasisMark = EMPHASISMARK_NONE;
178 [ + + + + : 1777 : switch( pTCPP->getTextEmphasisMark() )
- ]
179 : : {
180 : : default:
181 : : DBG_WARNING1( "DrawingLayer: Unknown EmphasisMark style (%d)!", pTCPP->getTextEmphasisMark() );
182 : : // fall through
183 : 100 : case primitive2d::TEXT_EMPHASISMARK_NONE: eFontEmphasisMark = EMPHASISMARK_NONE; break;
184 : 413 : case primitive2d::TEXT_EMPHASISMARK_DOT: eFontEmphasisMark = EMPHASISMARK_DOT; break;
185 : 955 : case primitive2d::TEXT_EMPHASISMARK_CIRCLE: eFontEmphasisMark = EMPHASISMARK_CIRCLE; break;
186 : 309 : case primitive2d::TEXT_EMPHASISMARK_DISC: eFontEmphasisMark = EMPHASISMARK_DISC; break;
187 : 0 : case primitive2d::TEXT_EMPHASISMARK_ACCENT: eFontEmphasisMark = EMPHASISMARK_ACCENT; break;
188 : : }
189 : :
190 [ + + ]: 1777 : if( eFontEmphasisMark != EMPHASISMARK_NONE )
191 : : {
192 : : DBG_ASSERT( (pTCPP->getEmphasisMarkAbove() != pTCPP->getEmphasisMarkBelow()),
193 : : "DrawingLayer: Bad EmphasisMark position!" );
194 [ + - ]: 1677 : if( pTCPP->getEmphasisMarkAbove() )
195 : 1677 : eFontEmphasisMark |= EMPHASISMARK_POS_ABOVE;
196 : : else
197 : 0 : eFontEmphasisMark |= EMPHASISMARK_POS_BELOW;
198 [ + - ]: 1677 : aFont.SetEmphasisMark( eFontEmphasisMark );
199 : : }
200 : :
201 : : // set Relief attribute
202 : 1777 : FontRelief eFontRelief = RELIEF_NONE;
203 [ + + - ]: 1777 : switch( pTCPP->getTextRelief() )
204 : : {
205 : : default:
206 : : DBG_WARNING1( "DrawingLayer: Unknown Relief style (%d)!", pTCPP->getTextRelief() );
207 : : // fall through
208 : 455 : case primitive2d::TEXT_RELIEF_NONE: eFontRelief = RELIEF_NONE; break;
209 : 1322 : case primitive2d::TEXT_RELIEF_EMBOSSED: eFontRelief = RELIEF_EMBOSSED; break;
210 : 0 : case primitive2d::TEXT_RELIEF_ENGRAVED: eFontRelief = RELIEF_ENGRAVED; break;
211 : : }
212 : :
213 [ + + ]: 1777 : if( eFontRelief != RELIEF_NONE )
214 [ + - ]: 1322 : aFont.SetRelief( eFontRelief );
215 : :
216 : : // set Shadow attribute
217 [ + + ]: 1777 : if( pTCPP->getShadow() )
218 [ + - ]: 1777 : aFont.SetShadow( true );
219 : : }
220 : :
221 : : // create transformed integer DXArray in view coordinate system
222 [ + - ]: 17559 : ::std::vector< sal_Int32 > aTransformedDXArray;
223 : :
224 [ + - ]: 17559 : if(rTextCandidate.getDXArray().size())
225 : : {
226 [ + - ]: 17559 : aTransformedDXArray.reserve(rTextCandidate.getDXArray().size());
227 [ + - ]: 17559 : const basegfx::B2DVector aPixelVector(maCurrentTransformation * basegfx::B2DVector(1.0, 0.0));
228 [ + - ]: 17559 : const double fPixelVectorFactor(aPixelVector.getLength());
229 : :
230 [ + - + - ]: 249878 : for(::std::vector< double >::const_iterator aStart(rTextCandidate.getDXArray().begin());
[ + + ]
231 : 124939 : aStart != rTextCandidate.getDXArray().end(); ++aStart)
232 : : {
233 [ + - ][ + - ]: 107380 : aTransformedDXArray.push_back(basegfx::fround((*aStart) * fPixelVectorFactor));
234 : 17559 : }
235 : : }
236 : :
237 : : // set parameters and paint text snippet
238 [ + - ]: 17559 : const basegfx::BColor aRGBFontColor(maBColorModifierStack.getModifiedColor(rTextCandidate.getFontColor()));
239 [ + - ]: 17559 : const basegfx::B2DPoint aPoint(aLocalTransform * basegfx::B2DPoint(0.0, 0.0));
240 : 17559 : const Point aStartPoint(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()));
241 : 17559 : const sal_uInt32 nOldLayoutMode(mpOutputDevice->GetLayoutMode());
242 : :
243 [ - + ][ + - ]: 17559 : if(rTextCandidate.getFontAttribute().getRTL())
244 : : {
245 : 0 : sal_uInt32 nRTLLayoutMode(nOldLayoutMode & ~(TEXT_LAYOUT_COMPLEX_DISABLED|TEXT_LAYOUT_BIDI_STRONG));
246 : 0 : nRTLLayoutMode |= TEXT_LAYOUT_BIDI_RTL|TEXT_LAYOUT_TEXTORIGIN_LEFT;
247 [ # # ]: 0 : mpOutputDevice->SetLayoutMode(nRTLLayoutMode);
248 : : }
249 : :
250 [ + - ]: 17559 : mpOutputDevice->SetFont(aFont);
251 [ + - ]: 17559 : mpOutputDevice->SetTextColor(Color(aRGBFontColor));
252 : :
253 [ + - ]: 17559 : String aText( rTextCandidate.getText() );
254 : 17559 : xub_StrLen nPos = rTextCandidate.getTextPosition();
255 : 17559 : xub_StrLen nLen = rTextCandidate.getTextLength();
256 : :
257 [ + - ][ + - ]: 17559 : sal_Int32* pDXArray = aTransformedDXArray.size() ? &(aTransformedDXArray[0]) : NULL ;
258 : :
259 [ - + ]: 17559 : if ( rTextCandidate.isFilled() )
260 : : {
261 : 0 : basegfx::B2DVector aOldFontScaling, aOldTranslate;
262 : : double fOldRotate, fOldShearX;
263 [ # # ]: 0 : rTextCandidate.getTextTransform().decompose(aOldFontScaling, aOldTranslate, fOldRotate, fOldShearX);
264 : :
265 : 0 : long nWidthToFill = static_cast<long>(rTextCandidate.getWidthToFill( ) * aFontScaling.getX() / aOldFontScaling.getX());
266 : :
267 : : long nWidth = mpOutputDevice->GetTextArray(
268 [ # # ]: 0 : rTextCandidate.getText(), pDXArray, 0, 1 );
269 : 0 : long nChars = 2;
270 [ # # ]: 0 : if ( nWidth )
271 : 0 : nChars = nWidthToFill / nWidth;
272 : :
273 [ # # ]: 0 : String aFilled;
274 [ # # ]: 0 : aFilled.Fill( (sal_uInt16)nChars, aText.GetChar( 0 ) );
275 [ # # ]: 0 : aText = aFilled;
276 : 0 : nPos = 0;
277 [ # # ]: 0 : nLen = nChars;
278 : : }
279 : :
280 [ + - ]: 17559 : if(!aTransformedDXArray.empty())
281 : : {
282 : : mpOutputDevice->DrawTextArray(
283 : : aStartPoint,
284 : : aText,
285 : : pDXArray,
286 : : nPos,
287 [ + - ]: 17559 : nLen);
288 : : }
289 : : else
290 : : {
291 : : mpOutputDevice->DrawText(
292 : : aStartPoint,
293 : : aText,
294 : : nPos,
295 [ # # ]: 0 : nLen);
296 : : }
297 : :
298 [ + - ][ - + ]: 17559 : if(rTextCandidate.getFontAttribute().getRTL())
299 : : {
300 [ # # ]: 0 : mpOutputDevice->SetLayoutMode(nOldLayoutMode);
301 : : }
302 : :
303 [ + - ][ + - ]: 17559 : bPrimitiveAccepted = true;
304 : : }
305 : : }
306 : :
307 [ + + ]: 20018 : if(!bPrimitiveAccepted)
308 : : {
309 : : // let break down
310 [ + - ][ + - ]: 2459 : process(rTextCandidate.get2DDecomposition(getViewInformation2D()));
[ + - ]
311 [ + - ]: 20018 : }
312 : 20018 : }
313 : :
314 : : // direct draw of hairline
315 : 142651 : void VclProcessor2D::RenderPolygonHairlinePrimitive2D(const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate, bool bPixelBased)
316 : : {
317 [ + - ]: 142651 : const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor()));
318 [ + - ]: 142651 : mpOutputDevice->SetLineColor(Color(aHairlineColor));
319 [ + - ]: 142651 : mpOutputDevice->SetFillColor();
320 : :
321 [ + - ]: 142651 : basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon());
322 [ + - ]: 142651 : aLocalPolygon.transform(maCurrentTransformation);
323 : :
324 : : static bool bCheckTrapezoidDecomposition(false);
325 : : static bool bShowOutlinesThere(false);
326 [ - + ]: 142651 : if(bCheckTrapezoidDecomposition)
327 : : {
328 : : // clip against discrete ViewPort
329 [ # # ]: 0 : const basegfx::B2DRange& rDiscreteViewport = getViewInformation2D().getDiscreteViewport();
330 : : basegfx::B2DPolyPolygon aLocalPolyPolygon(basegfx::tools::clipPolygonOnRange(
331 [ # # ]: 0 : aLocalPolygon, rDiscreteViewport, true, false));
332 : :
333 [ # # ][ # # ]: 0 : if(aLocalPolyPolygon.count())
334 : : {
335 : : // subdivide
336 : : aLocalPolyPolygon = basegfx::tools::adaptiveSubdivideByDistance(
337 [ # # ][ # # ]: 0 : aLocalPolyPolygon, 0.5);
[ # # ]
338 : :
339 : : // trapezoidize
340 : : static double fLineWidth(2.0);
341 [ # # ]: 0 : basegfx::B2DTrapezoidVector aB2DTrapezoidVector;
342 [ # # ]: 0 : basegfx::tools::createLineTrapezoidFromB2DPolyPolygon(aB2DTrapezoidVector, aLocalPolyPolygon, fLineWidth);
343 : :
344 : 0 : const sal_uInt32 nCount(aB2DTrapezoidVector.size());
345 : :
346 [ # # ]: 0 : if(nCount)
347 : : {
348 : 0 : basegfx::BColor aInvPolygonColor(aHairlineColor);
349 : 0 : aInvPolygonColor.invert();
350 : :
351 [ # # ]: 0 : for(sal_uInt32 a(0); a < nCount; a++)
352 : : {
353 [ # # ][ # # ]: 0 : const basegfx::B2DPolygon aTempPolygon(aB2DTrapezoidVector[a].getB2DPolygon());
354 : :
355 [ # # ]: 0 : if(bShowOutlinesThere)
356 : : {
357 [ # # ]: 0 : mpOutputDevice->SetFillColor(Color(aHairlineColor));
358 [ # # ]: 0 : mpOutputDevice->SetLineColor();
359 : : }
360 : :
361 [ # # ]: 0 : mpOutputDevice->DrawPolygon(aTempPolygon);
362 : :
363 [ # # ]: 0 : if(bShowOutlinesThere)
364 : : {
365 [ # # ]: 0 : mpOutputDevice->SetFillColor();
366 [ # # ]: 0 : mpOutputDevice->SetLineColor(Color(aInvPolygonColor));
367 [ # # ]: 0 : mpOutputDevice->DrawPolyLine(aTempPolygon, 0.0);
368 : : }
369 [ # # ]: 0 : }
370 : 0 : }
371 [ # # ]: 0 : }
372 : : }
373 : : else
374 : : {
375 [ + + ][ + - ]: 142651 : if(bPixelBased && getOptionsDrawinglayer().IsAntiAliasing() && getOptionsDrawinglayer().IsSnapHorVerLinesToDiscrete())
[ - + ][ # # ]
[ # # ][ - + ]
376 : : {
377 : : // #i98289#
378 : : // when a Hairline is painted and AntiAliasing is on the option SnapHorVerLinesToDiscrete
379 : : // allows to suppress AntiAliasing for pure horizontal or vertical lines. This is done since
380 : : // not-AntiAliased such lines look more pleasing to the eye (e.g. 2D chart content). This
381 : : // NEEDS to be done in discrete coordinates, so only useful for pixel based rendering.
382 [ # # ][ # # ]: 0 : aLocalPolygon = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aLocalPolygon);
[ # # ]
383 : : }
384 : :
385 [ + - ]: 142651 : mpOutputDevice->DrawPolyLine(aLocalPolygon, 0.0);
386 [ + - ]: 142651 : }
387 : 142651 : }
388 : :
389 : : // direct draw of transformed BitmapEx primitive
390 : 17557 : void VclProcessor2D::RenderBitmapPrimitive2D(const primitive2d::BitmapPrimitive2D& rBitmapCandidate)
391 : : {
392 : : // create local transform
393 [ + - ]: 17557 : basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rBitmapCandidate.getTransform());
394 [ + - ]: 17557 : BitmapEx aBitmapEx(rBitmapCandidate.getBitmapEx());
395 : 17557 : bool bPainted(false);
396 : :
397 [ - + ]: 17557 : if(maBColorModifierStack.count())
398 : : {
399 [ # # ][ # # ]: 0 : aBitmapEx = impModifyBitmapEx(maBColorModifierStack, aBitmapEx);
[ # # ]
400 : :
401 [ # # ][ # # ]: 0 : if(aBitmapEx.IsEmpty())
402 : : {
403 : : // color gets completely replaced, get it
404 [ # # ]: 0 : const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor()));
405 [ # # ]: 0 : basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
406 [ # # ]: 0 : aPolygon.transform(aLocalTransform);
407 : :
408 [ # # ]: 0 : mpOutputDevice->SetFillColor(Color(aModifiedColor));
409 [ # # ]: 0 : mpOutputDevice->SetLineColor();
410 [ # # ]: 0 : mpOutputDevice->DrawPolygon(aPolygon);
411 : :
412 [ # # ]: 0 : bPainted = true;
413 : : }
414 : : }
415 : :
416 [ + - ]: 17557 : if(!bPainted)
417 : : {
418 : : static bool bForceUseOfOwnTransformer(false);
419 : : static bool bUseGraphicManager(true);
420 : :
421 : : // decompose matrix to check for shear, rotate and mirroring
422 : 17557 : basegfx::B2DVector aScale, aTranslate;
423 : : double fRotate, fShearX;
424 [ + - ]: 17557 : aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
425 : :
426 [ + - ][ + - ]: 17557 : if(!bForceUseOfOwnTransformer && basegfx::fTools::equalZero(fShearX))
[ + - ]
427 : : {
428 [ - + ][ # # ]: 17557 : if(!bUseGraphicManager && basegfx::fTools::equalZero(fRotate))
[ - + ]
429 : : {
430 [ # # ]: 0 : RenderBitmapPrimitive2D_BitmapEx(*mpOutputDevice, aBitmapEx, aLocalTransform);
431 : : }
432 : : else
433 : : {
434 [ + - ]: 17557 : RenderBitmapPrimitive2D_GraphicManager(*mpOutputDevice, aBitmapEx, aLocalTransform);
435 : : }
436 : : }
437 : : else
438 : : {
439 [ # # ][ # # ]: 0 : if(!aBitmapEx.IsTransparent() && (!basegfx::fTools::equalZero(fShearX) || !basegfx::fTools::equalZero(fRotate)))
[ # # ][ # # ]
[ # # ]
440 : : {
441 : : // parts will be uncovered, extend aBitmapEx with a mask bitmap
442 [ # # ]: 0 : const Bitmap aContent(aBitmapEx.GetBitmap());
443 [ # # ][ # # ]: 0 : aBitmapEx = BitmapEx(aContent, Bitmap(aContent.GetSizePixel(), 1));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
444 : : }
445 : :
446 [ # # ]: 0 : RenderBitmapPrimitive2D_self(*mpOutputDevice, aBitmapEx, aLocalTransform);
447 : 17557 : }
448 [ + - ][ + - ]: 17557 : }
449 : 17557 : }
450 : :
451 : 0 : void VclProcessor2D::RenderRenderGraphicPrimitive2D(const primitive2d::RenderGraphicPrimitive2D& rRenderGraphicCandidate)
452 : : {
453 : : // create local transform
454 [ # # ]: 0 : basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rRenderGraphicCandidate.getTransform());
455 [ # # ]: 0 : vcl::RenderGraphic aRenderGraphic(rRenderGraphicCandidate.getRenderGraphic());
456 : 0 : bool bPainted(false);
457 : :
458 [ # # ]: 0 : if(maBColorModifierStack.count())
459 : : {
460 : : // !!! TODO
461 : : // aRenderGraphic = impModifyRenderGraphic(maBColorModifierStack, aRenderGraphic);
462 : :
463 [ # # ][ # # ]: 0 : if(aRenderGraphic.IsEmpty())
464 : : {
465 : : // color gets completely replaced, get it
466 [ # # ]: 0 : const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor()));
467 [ # # ]: 0 : basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
468 [ # # ]: 0 : aPolygon.transform(aLocalTransform);
469 : :
470 [ # # ]: 0 : mpOutputDevice->SetFillColor(Color(aModifiedColor));
471 [ # # ]: 0 : mpOutputDevice->SetLineColor();
472 [ # # ]: 0 : mpOutputDevice->DrawPolygon(aPolygon);
473 : :
474 [ # # ]: 0 : bPainted = true;
475 : : }
476 : : }
477 : :
478 [ # # ]: 0 : if(!bPainted)
479 : : {
480 : : // decompose matrix to check for shear, rotate and mirroring
481 : 0 : basegfx::B2DVector aScale, aTranslate;
482 : : double fRotate, fShearX;
483 [ # # ]: 0 : aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
484 : :
485 [ # # ]: 0 : basegfx::B2DRange aOutlineRange(0.0, 0.0, 1.0, 1.0);
486 : :
487 [ # # ]: 0 : if( basegfx::fTools::equalZero( fRotate ) )
488 : : {
489 [ # # ]: 0 : aOutlineRange.transform( aLocalTransform );
490 : : }
491 : : else
492 : : {
493 : : // !!! TODO
494 : : // if rotated, create the unrotated output rectangle for the GraphicManager paint
495 : : /*
496 : : const basegfx::B2DHomMatrix aSimpleObjectMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix(
497 : : fabs(aScale.getX()), fabs(aScale.getY()),
498 : : aTranslate.getX(), aTranslate.getY()));
499 : :
500 : : aOutlineRange.transform(aSimpleObjectMatrix);
501 : : */
502 : : }
503 : :
504 : : // prepare dest coordinates
505 : : const Point aPoint( basegfx::fround(aOutlineRange.getMinX() ),
506 [ # # ][ # # ]: 0 : basegfx::fround(aOutlineRange.getMinY() ) );
507 : : const Size aSize( basegfx::fround(aOutlineRange.getWidth() ),
508 [ # # ][ # # ]: 0 : basegfx::fround(aOutlineRange.getHeight() ) );
509 [ # # ]: 0 : const Size aSizePixel( mpOutputDevice->LogicToPixel( aSize ) );
510 [ # # ]: 0 : const vcl::RenderGraphicRasterizer aRasterizer( aRenderGraphic );
511 [ # # ][ # # ]: 0 : const BitmapEx aBitmapEx( aRasterizer.Rasterize( aSizePixel, fRotate, fShearX ) );
512 : :
513 [ # # ][ # # ]: 0 : if( !aBitmapEx.IsEmpty() )
514 : : {
515 [ # # ]: 0 : mpOutputDevice->DrawBitmapEx( aPoint, aSize, aBitmapEx );
516 [ # # ][ # # ]: 0 : }
517 [ # # ][ # # ]: 0 : }
518 : 0 : }
519 : :
520 : 313 : void VclProcessor2D::RenderFillBitmapPrimitive2D(const primitive2d::FillBitmapPrimitive2D& rFillBitmapCandidate)
521 : : {
522 : 313 : const attribute::FillBitmapAttribute& rFillBitmapAttribute(rFillBitmapCandidate.getFillBitmap());
523 : 313 : bool bPrimitiveAccepted(false);
524 : :
525 [ + - ]: 313 : if(rFillBitmapAttribute.getTiling())
526 : : {
527 : : // decompose matrix to check for shear, rotate and mirroring
528 [ + - ]: 313 : basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rFillBitmapCandidate.getTransformation());
529 : 313 : basegfx::B2DVector aScale, aTranslate;
530 : : double fRotate, fShearX;
531 [ + - ]: 313 : aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
532 : :
533 [ + - ][ + - ]: 313 : if(basegfx::fTools::equalZero(fRotate) && basegfx::fTools::equalZero(fShearX))
[ + - ]
534 : : {
535 : : // no shear or rotate, draw direct in pixel coordinates
536 : 313 : bPrimitiveAccepted = true;
537 [ + - ][ + - ]: 313 : BitmapEx aBitmapEx(rFillBitmapAttribute.getBitmapEx());
538 : 313 : bool bPainted(false);
539 : :
540 [ - + ]: 313 : if(maBColorModifierStack.count())
541 : : {
542 [ # # ][ # # ]: 0 : aBitmapEx = impModifyBitmapEx(maBColorModifierStack, aBitmapEx);
[ # # ]
543 : :
544 [ # # ][ # # ]: 0 : if(aBitmapEx.IsEmpty())
545 : : {
546 : : // color gets completely replaced, get it
547 [ # # ]: 0 : const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(basegfx::BColor()));
548 [ # # ]: 0 : basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
549 [ # # ]: 0 : aPolygon.transform(aLocalTransform);
550 : :
551 [ # # ]: 0 : mpOutputDevice->SetFillColor(Color(aModifiedColor));
552 [ # # ]: 0 : mpOutputDevice->SetLineColor();
553 [ # # ]: 0 : mpOutputDevice->DrawPolygon(aPolygon);
554 : :
555 [ # # ]: 0 : bPainted = true;
556 : : }
557 : : }
558 : :
559 [ + - ]: 313 : if(!bPainted)
560 : : {
561 : 313 : const basegfx::B2DPoint aObjTopLeft(aTranslate.getX(), aTranslate.getY());
562 : 313 : const basegfx::B2DPoint aObjBottomRight(aTranslate.getX() + aScale.getX(), aTranslate.getY() + aScale.getY());
563 [ + - ]: 313 : const Point aObjTL(mpOutputDevice->LogicToPixel(Point((sal_Int32)aObjTopLeft.getX(), (sal_Int32)aObjTopLeft.getY())));
564 [ + - ]: 313 : const Point aObjBR(mpOutputDevice->LogicToPixel(Point((sal_Int32)aObjBottomRight.getX(), (sal_Int32)aObjBottomRight.getY())));
565 : :
566 [ + - ][ + - ]: 313 : const basegfx::B2DPoint aBmpTopLeft(aLocalTransform * rFillBitmapAttribute.getTopLeft());
567 [ + - ][ + - ]: 313 : const basegfx::B2DPoint aBmpBottomRight(aLocalTransform * basegfx::B2DPoint(rFillBitmapAttribute.getTopLeft() + rFillBitmapAttribute.getSize()));
[ + - ]
568 [ + - ]: 313 : const Point aBmpTL(mpOutputDevice->LogicToPixel(Point((sal_Int32)aBmpTopLeft.getX(), (sal_Int32)aBmpTopLeft.getY())));
569 [ + - ]: 313 : const Point aBmpBR(mpOutputDevice->LogicToPixel(Point((sal_Int32)aBmpBottomRight.getX(), (sal_Int32)aBmpBottomRight.getY())));
570 : :
571 : 313 : sal_Int32 nOWidth(aObjBR.X() - aObjTL.X());
572 : 313 : sal_Int32 nOHeight(aObjBR.Y() - aObjTL.Y());
573 : :
574 : : // only do something when object has a size in discrete units
575 [ + - ][ + - ]: 313 : if(nOWidth > 0 && nOHeight > 0)
576 : : {
577 : 313 : sal_Int32 nBWidth(aBmpBR.X() - aBmpTL.X());
578 : 313 : sal_Int32 nBHeight(aBmpBR.Y() - aBmpTL.Y());
579 : :
580 : : // only do something when bitmap fill has a size in discrete units
581 [ + - ][ + - ]: 313 : if(nBWidth > 0 && nBHeight > 0)
582 : : {
583 : 313 : sal_Int32 nBLeft(aBmpTL.X());
584 : 313 : sal_Int32 nBTop(aBmpTL.Y());
585 : :
586 [ + - ]: 313 : if(nBLeft > aObjTL.X())
587 : : {
588 : 313 : nBLeft -= ((nBLeft / nBWidth) + 1L) * nBWidth;
589 : : }
590 : :
591 [ - + ]: 313 : if(nBLeft + nBWidth <= aObjTL.X())
592 : : {
593 : 0 : nBLeft -= (nBLeft / nBWidth) * nBWidth;
594 : : }
595 : :
596 [ + - ]: 313 : if(nBTop > aObjTL.Y())
597 : : {
598 : 313 : nBTop -= ((nBTop / nBHeight) + 1L) * nBHeight;
599 : : }
600 : :
601 [ - + ]: 313 : if(nBTop + nBHeight <= aObjTL.Y())
602 : : {
603 : 0 : nBTop -= (nBTop / nBHeight) * nBHeight;
604 : : }
605 : :
606 : : // nBWidth, nBHeight is the pixel size of the neede bitmap. To not need to scale it
607 : : // in vcl many times, create a size-optimized version
608 : 313 : const Size aNeededBitmapSizePixel(nBWidth, nBHeight);
609 : :
610 [ + - ]: 313 : if(aNeededBitmapSizePixel != aBitmapEx.GetSizePixel())
611 : : {
612 [ + - ]: 313 : aBitmapEx.Scale(aNeededBitmapSizePixel);
613 : : }
614 : :
615 : : // prepare OutDev
616 : 313 : const Point aEmptyPoint(0, 0);
617 [ + - ]: 313 : const Rectangle aVisiblePixel(aEmptyPoint, mpOutputDevice->GetOutputSizePixel());
618 : 313 : const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled());
619 [ + - ]: 313 : mpOutputDevice->EnableMapMode(false);
620 : :
621 [ + + ]: 5634 : for(sal_Int32 nXPos(nBLeft); nXPos < aObjTL.X() + nOWidth; nXPos += nBWidth)
622 : : {
623 [ + + ]: 42568 : for(sal_Int32 nYPos(nBTop); nYPos < aObjTL.Y() + nOHeight; nYPos += nBHeight)
624 : : {
625 [ + - ]: 37247 : const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel);
626 : :
627 [ + - ][ + - ]: 37247 : if(aOutRectPixel.IsOver(aVisiblePixel))
628 : : {
629 [ + - ]: 37247 : mpOutputDevice->DrawBitmapEx(aOutRectPixel.TopLeft(), aBitmapEx);
630 : : }
631 : : }
632 : : }
633 : :
634 : : // restore OutDev
635 [ + - ]: 313 : mpOutputDevice->EnableMapMode(bWasEnabled);
636 : : }
637 : 313 : }
638 [ + - ]: 313 : }
639 [ + - ]: 313 : }
640 : : }
641 : :
642 [ - + ]: 313 : if(!bPrimitiveAccepted)
643 : : {
644 : : // do not accept, use decomposition
645 [ # # ]: 0 : process(rFillBitmapCandidate.get2DDecomposition(getViewInformation2D()));
646 : : }
647 : 313 : }
648 : :
649 : : // direct draw of gradient
650 : 235 : void VclProcessor2D::RenderPolyPolygonGradientPrimitive2D(const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate)
651 : : {
652 : 235 : const attribute::FillGradientAttribute& rGradient(rPolygonCandidate.getFillGradient());
653 [ + - ][ + - ]: 235 : basegfx::BColor aStartColor(maBColorModifierStack.getModifiedColor(rGradient.getStartColor()));
654 [ + - ][ + - ]: 235 : basegfx::BColor aEndColor(maBColorModifierStack.getModifiedColor(rGradient.getEndColor()));
655 [ + - ]: 235 : basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
656 : :
657 [ + - ][ + - ]: 235 : if(aLocalPolyPolygon.count())
658 : : {
659 [ + - ]: 235 : aLocalPolyPolygon.transform(maCurrentTransformation);
660 : :
661 [ - + ]: 235 : if(aStartColor == aEndColor)
662 : : {
663 : : // no gradient at all, draw as polygon in AA and non-AA case
664 [ # # ]: 0 : mpOutputDevice->SetLineColor();
665 [ # # ]: 0 : mpOutputDevice->SetFillColor(Color(aStartColor));
666 [ # # ]: 0 : mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
667 : : }
668 [ + - ][ - + ]: 235 : else if(getOptionsDrawinglayer().IsAntiAliasing())
669 : : {
670 : : // For AA, direct render has to be avoided since it uses XOR maskings which will not
671 : : // work with AA. Instead, the decompose which uses MaskPrimitive2D with fillings is
672 : : // used
673 [ # # ][ # # ]: 0 : process(rPolygonCandidate.get2DDecomposition(getViewInformation2D()));
[ # # ]
674 : : }
675 : : else
676 : : {
677 : : impDrawGradientToOutDev(
678 [ + - ]: 235 : *mpOutputDevice, aLocalPolyPolygon, rGradient.getStyle(), rGradient.getSteps(),
679 : : aStartColor, aEndColor, rGradient.getBorder(),
680 [ + - ][ + - ]: 470 : rGradient.getAngle(), rGradient.getOffsetX(), rGradient.getOffsetY(), false);
[ + - ][ + - ]
[ + - ][ + - ]
681 : : }
682 [ + - ]: 235 : }
683 : 235 : }
684 : :
685 : : // direct draw of bitmap
686 : 313 : void VclProcessor2D::RenderPolyPolygonBitmapPrimitive2D(const primitive2d::PolyPolygonBitmapPrimitive2D& rPolygonCandidate)
687 : : {
688 : 313 : bool bDone(false);
689 : 313 : const basegfx::B2DPolyPolygon& rPolyPolygon = rPolygonCandidate.getB2DPolyPolygon();
690 : :
691 [ + - ]: 313 : if(rPolyPolygon.count())
692 : : {
693 : 313 : const attribute::FillBitmapAttribute& rFillBitmapAttribute = rPolygonCandidate.getFillBitmap();
694 : 313 : const BitmapEx& rBitmapEx = rFillBitmapAttribute.getBitmapEx();
695 : :
696 [ - + ]: 313 : if(rBitmapEx.IsEmpty())
697 : : {
698 : : // empty bitmap, done
699 : 0 : bDone = true;
700 : : }
701 : : else
702 : : {
703 : : // try to catch cases where the bitmap will be color-modified to a single
704 : : // color (e.g. shadow). This would NOT be optimizable with an transparence channel
705 : : // at the Bitmap which we do not have here. When this should change, this
706 : : // optimization has to be reworked accordingly.
707 : 313 : const sal_uInt32 nBColorModifierStackCount(maBColorModifierStack.count());
708 : :
709 [ - + ]: 313 : if(nBColorModifierStackCount)
710 : : {
711 : 0 : const basegfx::BColorModifier& rTopmostModifier = maBColorModifierStack.getBColorModifier(nBColorModifierStackCount - 1);
712 : :
713 [ # # ]: 0 : if(basegfx::BCOLORMODIFYMODE_REPLACE == rTopmostModifier.getMode())
714 : : {
715 : : // the bitmap fill is in unified color, so we can replace it with
716 : : // a single polygon fill. The form of the fill depends on tiling
717 [ # # ]: 0 : if(rFillBitmapAttribute.getTiling())
718 : : {
719 : : // with tiling, fill the whole PolyPolygon with the modifier color
720 [ # # ]: 0 : basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolyPolygon);
721 : :
722 [ # # ]: 0 : aLocalPolyPolygon.transform(maCurrentTransformation);
723 [ # # ]: 0 : mpOutputDevice->SetLineColor();
724 [ # # ]: 0 : mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor()));
725 [ # # ][ # # ]: 0 : mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
726 : : }
727 : : else
728 : : {
729 : : // without tiling, only the area common to the bitmap tile and the
730 : : // PolyPolygon is filled. Create the bitmap tile area in object
731 : : // coordinates. For this, the object transformation needs to be created
732 : : // from the already scaled PolyPolygon. The tile area in object
733 : : // coordinates wil always be non-rotated, so it's not necessary to
734 : : // work with a polygon here
735 [ # # ]: 0 : basegfx::B2DRange aTileRange(rFillBitmapAttribute.getTopLeft(),
736 [ # # ][ # # ]: 0 : rFillBitmapAttribute.getTopLeft() + rFillBitmapAttribute.getSize());
[ # # ]
737 [ # # ]: 0 : const basegfx::B2DRange aPolyPolygonRange(rPolyPolygon.getB2DRange());
738 [ # # ]: 0 : basegfx::B2DHomMatrix aNewObjectTransform;
739 : :
740 [ # # ][ # # ]: 0 : aNewObjectTransform.set(0, 0, aPolyPolygonRange.getWidth());
741 [ # # ][ # # ]: 0 : aNewObjectTransform.set(1, 1, aPolyPolygonRange.getHeight());
742 [ # # ][ # # ]: 0 : aNewObjectTransform.set(0, 2, aPolyPolygonRange.getMinX());
743 [ # # ][ # # ]: 0 : aNewObjectTransform.set(1, 2, aPolyPolygonRange.getMinY());
744 [ # # ]: 0 : aTileRange.transform(aNewObjectTransform);
745 : :
746 : : // now clip the object polyPolygon against the tile range
747 : : // to get the common area (OR)
748 [ # # ]: 0 : basegfx::B2DPolyPolygon aTarget = basegfx::tools::clipPolyPolygonOnRange(rPolyPolygon, aTileRange, true, false);
749 : :
750 [ # # ][ # # ]: 0 : if(aTarget.count())
751 : : {
752 [ # # ]: 0 : aTarget.transform(maCurrentTransformation);
753 [ # # ]: 0 : mpOutputDevice->SetLineColor();
754 [ # # ]: 0 : mpOutputDevice->SetFillColor(Color(rTopmostModifier.getBColor()));
755 [ # # ]: 0 : mpOutputDevice->DrawPolyPolygon(aTarget);
756 [ # # ][ # # ]: 0 : }
757 : : }
758 : :
759 : 0 : bDone = true;
760 : : }
761 : : }
762 : : }
763 : : }
764 : : else
765 : : {
766 : : // empty polyPolygon, done
767 : 0 : bDone = true;
768 : : }
769 : :
770 [ + - ]: 313 : if(!bDone)
771 : : {
772 : : // use default decomposition
773 [ + - ]: 313 : process(rPolygonCandidate.get2DDecomposition(getViewInformation2D()));
774 : : }
775 : 313 : }
776 : :
777 : : // direct draw of PolyPolygon with color
778 : 261939 : void VclProcessor2D::RenderPolyPolygonColorPrimitive2D(const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate)
779 : : {
780 [ + - ]: 261939 : const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor()));
781 [ + - ]: 261939 : mpOutputDevice->SetFillColor(Color(aPolygonColor));
782 [ + - ]: 261939 : mpOutputDevice->SetLineColor();
783 : :
784 [ + - ]: 261939 : basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
785 [ + - ]: 261939 : aLocalPolyPolygon.transform(maCurrentTransformation);
786 : :
787 : : static bool bCheckTrapezoidDecomposition(false);
788 : : static bool bShowOutlinesThere(false);
789 [ - + ]: 261939 : if(bCheckTrapezoidDecomposition)
790 : : {
791 : : // clip against discrete ViewPort
792 [ # # ]: 0 : const basegfx::B2DRange& rDiscreteViewport = getViewInformation2D().getDiscreteViewport();
793 : : aLocalPolyPolygon = basegfx::tools::clipPolyPolygonOnRange(
794 [ # # ][ # # ]: 0 : aLocalPolyPolygon, rDiscreteViewport, true, false);
[ # # ]
795 : :
796 [ # # ][ # # ]: 0 : if(aLocalPolyPolygon.count())
797 : : {
798 : : // subdivide
799 : : aLocalPolyPolygon = basegfx::tools::adaptiveSubdivideByDistance(
800 [ # # ][ # # ]: 0 : aLocalPolyPolygon, 0.5);
[ # # ]
801 : :
802 : : // trapezoidize
803 [ # # ]: 0 : basegfx::B2DTrapezoidVector aB2DTrapezoidVector;
804 [ # # ]: 0 : basegfx::tools::trapezoidSubdivide(aB2DTrapezoidVector, aLocalPolyPolygon);
805 : :
806 : 0 : const sal_uInt32 nCount(aB2DTrapezoidVector.size());
807 : :
808 [ # # ]: 0 : if(nCount)
809 : : {
810 : 0 : basegfx::BColor aInvPolygonColor(aPolygonColor);
811 : 0 : aInvPolygonColor.invert();
812 : :
813 [ # # ]: 0 : for(sal_uInt32 a(0); a < nCount; a++)
814 : : {
815 [ # # ][ # # ]: 0 : const basegfx::B2DPolygon aTempPolygon(aB2DTrapezoidVector[a].getB2DPolygon());
816 : :
817 [ # # ]: 0 : if(bShowOutlinesThere)
818 : : {
819 [ # # ]: 0 : mpOutputDevice->SetFillColor(Color(aPolygonColor));
820 [ # # ]: 0 : mpOutputDevice->SetLineColor();
821 : : }
822 : :
823 [ # # ]: 0 : mpOutputDevice->DrawPolygon(aTempPolygon);
824 : :
825 [ # # ]: 0 : if(bShowOutlinesThere)
826 : : {
827 [ # # ]: 0 : mpOutputDevice->SetFillColor();
828 [ # # ]: 0 : mpOutputDevice->SetLineColor(Color(aInvPolygonColor));
829 [ # # ]: 0 : mpOutputDevice->DrawPolyLine(aTempPolygon, 0.0);
830 : : }
831 [ # # ]: 0 : }
832 : 0 : }
833 : : }
834 : : }
835 : : else
836 : : {
837 : : // remember that we enter a PolygonStrokePrimitive2D decomposition,
838 : : // used for AA thick line drawing
839 : 261939 : mnPolygonStrokePrimitive2D++;
840 : :
841 [ + - ]: 261939 : mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
842 : :
843 [ + - ]: 523878 : if(mnPolygonStrokePrimitive2D
[ - + # # ]
[ - + ]
844 [ + - ]: 261939 : && getOptionsDrawinglayer().IsAntiAliasing()
845 : 0 : && (mpOutputDevice->GetAntialiasing() & ANTIALIASING_ENABLE_B2DDRAW))
846 : : {
847 : : // when AA is on and this filled polygons are the result of stroked line geometry,
848 : : // draw the geometry once extra as lines to avoid AA 'gaps' between partial polygons
849 [ # # ]: 0 : mpOutputDevice->SetFillColor();
850 [ # # ]: 0 : mpOutputDevice->SetLineColor(Color(aPolygonColor));
851 [ # # ]: 0 : const sal_uInt32 nCount(aLocalPolyPolygon.count());
852 : :
853 [ # # ]: 0 : for(sal_uInt32 a(0); a < nCount; a++)
854 : : {
855 [ # # ][ # # ]: 0 : mpOutputDevice->DrawPolyLine(aLocalPolyPolygon.getB2DPolygon(a), 0.0);
[ # # ]
856 : : }
857 : : }
858 : :
859 : : // leave PolygonStrokePrimitive2D
860 : 261939 : mnPolygonStrokePrimitive2D--;
861 [ + - ]: 261939 : }
862 : 261939 : }
863 : :
864 : : // direct draw of MetaFile
865 : 0 : void VclProcessor2D::RenderMetafilePrimitive2D(const primitive2d::MetafilePrimitive2D& rMetaCandidate)
866 : : {
867 : : // decompose matrix to check for shear, rotate and mirroring
868 [ # # ]: 0 : basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rMetaCandidate.getTransform());
869 : 0 : basegfx::B2DVector aScale, aTranslate;
870 : : double fRotate, fShearX;
871 [ # # ]: 0 : aLocalTransform.decompose(aScale, aTranslate, fRotate, fShearX);
872 : :
873 [ # # ][ # # ]: 0 : if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
874 : : {
875 : : // #i102175# handle special case: If scale is negative in (x,y) (3rd quadrant), it can
876 : : // be expressed as rotation by PI. This needs to be done for Metafiles since
877 : : // these can be rotated, but not really mirrored
878 [ # # ]: 0 : aScale = basegfx::absolute(aScale);
879 : 0 : fRotate += F_PI;
880 : : }
881 : :
882 : : // get BoundRect
883 [ # # ]: 0 : basegfx::B2DRange aOutlineRange(rMetaCandidate.getB2DRange(getViewInformation2D()));
884 [ # # ]: 0 : aOutlineRange.transform(maCurrentTransformation);
885 : :
886 : : // Due to the integer MapModes used from VCL aind inside MetaFiles errors of up to three
887 : : // pixels in size may happen. As long as there is no better way (e.g. convert the MetaFile
888 : : // to primitives) it is necessary to reduce maximum pixel size by 1 in X and Y and to use
889 : : // the inner pixel bounds accordingly (ceil resp. floor). This will also be done for logic
890 : : // units e.g. when creating a new MetaFile, but since much huger value ranges are used
891 : : // there typically will be okay for this compromize.
892 : : Rectangle aDestRectView(
893 : : // !!CAUTION!! Here, ceil and floor are exchanged BY PURPOSE, do NOT copy when
894 : : // looking for a standard conversion to rectangle (!)
895 [ # # ][ # # ]: 0 : (sal_Int32)ceil(aOutlineRange.getMinX()), (sal_Int32)ceil(aOutlineRange.getMinY()),
896 [ # # ][ # # ]: 0 : (sal_Int32)floor(aOutlineRange.getMaxX()), (sal_Int32)floor(aOutlineRange.getMaxY()));
[ # # ]
897 : :
898 : : // get metafile (copy it)
899 [ # # ]: 0 : GDIMetaFile aMetaFile;
900 : :
901 [ # # ]: 0 : if(maBColorModifierStack.count())
902 : : {
903 : 0 : const basegfx::BColor aRGBBaseColor(0, 0, 0);
904 [ # # ]: 0 : const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(aRGBBaseColor));
905 [ # # ][ # # ]: 0 : aMetaFile = rMetaCandidate.getMetaFile().GetMonochromeMtf(Color(aRGBColor));
[ # # ]
906 : : }
907 : : else
908 : : {
909 [ # # ]: 0 : aMetaFile = rMetaCandidate.getMetaFile();
910 : : }
911 : :
912 : : // rotation
913 [ # # ]: 0 : if(!basegfx::fTools::equalZero(fRotate))
914 : : {
915 : : // #i103530#
916 : : // MetaFile::Rotate has no input parameter check, so the parameter needs to be
917 : : // well-aligned to the old range [0..3600] 10th degrees with inverse orientation
918 : 0 : sal_Int16 nRotation((sal_Int16)((fRotate / F_PI180) * -10.0));
919 : :
920 [ # # ]: 0 : while(nRotation < 0)
921 : 0 : nRotation += 3600;
922 : :
923 [ # # ]: 0 : while(nRotation >= 3600)
924 : 0 : nRotation -= 3600;
925 : :
926 [ # # ]: 0 : aMetaFile.Rotate(nRotation);
927 : : }
928 : :
929 : : // Prepare target output size
930 [ # # ]: 0 : Size aDestSize(aDestRectView.GetSize());
931 : :
932 [ # # ][ # # ]: 0 : if(aDestSize.getWidth() && aDestSize.getHeight())
[ # # ]
933 : : {
934 : : // Get preferred Metafile output size. When it's very equal to the output size, it's probably
935 : : // a rounding error somewhere, so correct it to get a 1:1 output without single pixel scalings
936 : : // of the Metafile (esp. for contaned Bitmaps, e.g 3D charts)
937 [ # # ]: 0 : const Size aPrefSize(mpOutputDevice->LogicToPixel(aMetaFile.GetPrefSize(), aMetaFile.GetPrefMapMode()));
938 : :
939 [ # # ][ # # ]: 0 : if(aPrefSize.getWidth() && (aPrefSize.getWidth() - 1 == aDestSize.getWidth() || aPrefSize.getWidth() + 1 == aDestSize.getWidth()))
[ # # ][ # # ]
940 : : {
941 : 0 : aDestSize.setWidth(aPrefSize.getWidth());
942 : : }
943 : :
944 [ # # ][ # # ]: 0 : if(aPrefSize.getHeight() && (aPrefSize.getHeight() - 1 == aDestSize.getHeight() || aPrefSize.getHeight() + 1 == aDestSize.getHeight()))
[ # # ][ # # ]
945 : : {
946 : 0 : aDestSize.setHeight(aPrefSize.getHeight());
947 : : }
948 : :
949 : : // paint it
950 [ # # ]: 0 : aMetaFile.WindStart();
951 [ # # ]: 0 : aMetaFile.Play(mpOutputDevice, aDestRectView.TopLeft(), aDestSize);
952 [ # # ][ # # ]: 0 : }
953 : 0 : }
954 : :
955 : : // mask group. Force output to VDev and create mask from given mask
956 : 1026 : void VclProcessor2D::RenderMaskPrimitive2DPixel(const primitive2d::MaskPrimitive2D& rMaskCandidate)
957 : : {
958 [ + - ]: 1026 : if(rMaskCandidate.getChildren().hasElements())
959 : : {
960 [ + - ]: 1026 : basegfx::B2DPolyPolygon aMask(rMaskCandidate.getMask());
961 : :
962 [ + - ][ + - ]: 1026 : if(aMask.count())
963 : : {
964 [ + - ]: 1026 : aMask.transform(maCurrentTransformation);
965 [ + - ]: 1026 : const basegfx::B2DRange aRange(basegfx::tools::getRange(aMask));
966 [ + - ]: 1026 : impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
967 : :
968 [ + - ][ + - ]: 1026 : if(aBufferDevice.isVisible())
969 : : {
970 : : // remember last OutDev and set to content
971 : 1026 : OutputDevice* pLastOutputDevice = mpOutputDevice;
972 : 1026 : mpOutputDevice = &aBufferDevice.getContent();
973 : :
974 : : // paint to it
975 [ + - ]: 1026 : process(rMaskCandidate.getChildren());
976 : :
977 : : // back to old OutDev
978 : 1026 : mpOutputDevice = pLastOutputDevice;
979 : :
980 : : // draw mask
981 [ + - ][ - + ]: 1026 : if(getOptionsDrawinglayer().IsAntiAliasing())
982 : : {
983 : : // with AA, use 8bit AlphaMask to get nice borders
984 [ # # ]: 0 : VirtualDevice& rTransparence = aBufferDevice.getTransparence();
985 [ # # ]: 0 : rTransparence.SetLineColor();
986 [ # # ]: 0 : rTransparence.SetFillColor(COL_BLACK);
987 [ # # ]: 0 : rTransparence.DrawPolyPolygon(aMask);
988 : :
989 : : // dump buffer to outdev
990 [ # # ]: 0 : aBufferDevice.paint();
991 : : }
992 : : else
993 : : {
994 : : // No AA, use 1bit mask
995 [ + - ]: 1026 : VirtualDevice& rMask = aBufferDevice.getMask();
996 [ + - ]: 1026 : rMask.SetLineColor();
997 [ + - ]: 1026 : rMask.SetFillColor(COL_BLACK);
998 [ + - ]: 1026 : rMask.DrawPolyPolygon(aMask);
999 : :
1000 : : // dump buffer to outdev
1001 [ + - ]: 1026 : aBufferDevice.paint();
1002 : : }
1003 [ + - ]: 1026 : }
1004 [ + - ]: 1026 : }
1005 : : }
1006 : 1026 : }
1007 : :
1008 : : // modified color group. Force output to unified color.
1009 : 726 : void VclProcessor2D::RenderModifiedColorPrimitive2D(const primitive2d::ModifiedColorPrimitive2D& rModifiedCandidate)
1010 : : {
1011 [ + - ]: 726 : if(rModifiedCandidate.getChildren().hasElements())
1012 : : {
1013 : 726 : maBColorModifierStack.push(rModifiedCandidate.getColorModifier());
1014 : 726 : process(rModifiedCandidate.getChildren());
1015 : 726 : maBColorModifierStack.pop();
1016 : : }
1017 : 726 : }
1018 : :
1019 : : // unified sub-transparence. Draw to VDev first.
1020 : 249 : void VclProcessor2D::RenderUnifiedTransparencePrimitive2D(const primitive2d::UnifiedTransparencePrimitive2D& rTransCandidate)
1021 : : {
1022 : : static bool bForceToDecomposition(false);
1023 : :
1024 [ + - ]: 249 : if(rTransCandidate.getChildren().hasElements())
1025 : : {
1026 [ - + ]: 249 : if(bForceToDecomposition)
1027 : : {
1028 : : // use decomposition
1029 [ # # ]: 0 : process(rTransCandidate.get2DDecomposition(getViewInformation2D()));
1030 : : }
1031 : : else
1032 : : {
1033 [ - + ]: 249 : if(0.0 == rTransCandidate.getTransparence())
1034 : : {
1035 : : // no transparence used, so just use the content
1036 : 0 : process(rTransCandidate.getChildren());
1037 : : }
1038 [ + - ][ + - ]: 249 : else if(rTransCandidate.getTransparence() > 0.0 && rTransCandidate.getTransparence() < 1.0)
[ + - ]
1039 : : {
1040 : : // transparence is in visible range
1041 [ + - ]: 249 : basegfx::B2DRange aRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rTransCandidate.getChildren(), getViewInformation2D()));
1042 [ + - ]: 249 : aRange.transform(maCurrentTransformation);
1043 [ + - ]: 249 : impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
1044 : :
1045 [ + - ][ + - ]: 249 : if(aBufferDevice.isVisible())
1046 : : {
1047 : : // remember last OutDev and set to content
1048 : 249 : OutputDevice* pLastOutputDevice = mpOutputDevice;
1049 : 249 : mpOutputDevice = &aBufferDevice.getContent();
1050 : :
1051 : : // paint content to it
1052 [ + - ]: 249 : process(rTransCandidate.getChildren());
1053 : :
1054 : : // back to old OutDev
1055 : 249 : mpOutputDevice = pLastOutputDevice;
1056 : :
1057 : : // dump buffer to outdev using given transparence
1058 [ + - ]: 249 : aBufferDevice.paint(rTransCandidate.getTransparence());
1059 [ + - ]: 249 : }
1060 : : }
1061 : : }
1062 : : }
1063 : 249 : }
1064 : :
1065 : : // sub-transparence group. Draw to VDev first.
1066 : 1638 : void VclProcessor2D::RenderTransparencePrimitive2D(const primitive2d::TransparencePrimitive2D& rTransCandidate)
1067 : : {
1068 [ + - ]: 1638 : if(rTransCandidate.getChildren().hasElements())
1069 : : {
1070 [ + - ]: 1638 : basegfx::B2DRange aRange(primitive2d::getB2DRangeFromPrimitive2DSequence(rTransCandidate.getChildren(), getViewInformation2D()));
1071 [ + - ]: 1638 : aRange.transform(maCurrentTransformation);
1072 [ + - ]: 1638 : impBufferDevice aBufferDevice(*mpOutputDevice, aRange, true);
1073 : :
1074 [ + - ][ + - ]: 1638 : if(aBufferDevice.isVisible())
1075 : : {
1076 : : // remember last OutDev and set to content
1077 : 1638 : OutputDevice* pLastOutputDevice = mpOutputDevice;
1078 : 1638 : mpOutputDevice = &aBufferDevice.getContent();
1079 : :
1080 : : // paint content to it
1081 [ + - ]: 1638 : process(rTransCandidate.getChildren());
1082 : :
1083 : : // set to mask
1084 [ + - ]: 1638 : mpOutputDevice = &aBufferDevice.getTransparence();
1085 : :
1086 : : // when painting transparence masks, reset the color stack
1087 [ + - ]: 1638 : basegfx::BColorModifierStack aLastBColorModifierStack(maBColorModifierStack);
1088 [ + - ]: 1638 : maBColorModifierStack = basegfx::BColorModifierStack();
1089 : :
1090 : : // paint mask to it (always with transparence intensities, evtl. with AA)
1091 [ + - ]: 1638 : process(rTransCandidate.getTransparence());
1092 : :
1093 : : // back to old color stack
1094 [ + - ]: 1638 : maBColorModifierStack = aLastBColorModifierStack;
1095 : :
1096 : : // back to old OutDev
1097 : 1638 : mpOutputDevice = pLastOutputDevice;
1098 : :
1099 : : // dump buffer to outdev
1100 [ + - ]: 1638 : aBufferDevice.paint();
1101 [ + - ]: 1638 : }
1102 : : }
1103 : 1638 : }
1104 : :
1105 : : // transform group.
1106 : 4356 : void VclProcessor2D::RenderTransformPrimitive2D(const primitive2d::TransformPrimitive2D& rTransformCandidate)
1107 : : {
1108 : : // remember current transformation and ViewInformation
1109 [ + - ]: 4356 : const basegfx::B2DHomMatrix aLastCurrentTransformation(maCurrentTransformation);
1110 [ + - ]: 4356 : const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
1111 : :
1112 : : // create new transformations for CurrentTransformation
1113 : : // and for local ViewInformation2D
1114 [ + - ][ + - ]: 4356 : maCurrentTransformation = maCurrentTransformation * rTransformCandidate.getTransformation();
[ + - ]
1115 : : const geometry::ViewInformation2D aViewInformation2D(
1116 [ + - ]: 4356 : getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(),
1117 [ + - ]: 4356 : getViewInformation2D().getViewTransformation(),
1118 [ + - ]: 4356 : getViewInformation2D().getViewport(),
1119 [ + - ]: 4356 : getViewInformation2D().getVisualizedPage(),
1120 : 4356 : getViewInformation2D().getViewTime(),
1121 [ + - + - ]: 13068 : getViewInformation2D().getExtendedInformationSequence());
[ + - ][ + - ]
[ + - ]
1122 [ + - ]: 4356 : updateViewInformation(aViewInformation2D);
1123 : :
1124 : : // proccess content
1125 [ + - ]: 4356 : process(rTransformCandidate.getChildren());
1126 : :
1127 : : // restore transformations
1128 [ + - ]: 4356 : maCurrentTransformation = aLastCurrentTransformation;
1129 [ + - ][ + - ]: 4356 : updateViewInformation(aLastViewInformation2D);
[ + - ][ + - ]
1130 : 4356 : }
1131 : :
1132 : : // new XDrawPage for ViewInformation2D
1133 : 0 : void VclProcessor2D::RenderPagePreviewPrimitive2D(const primitive2d::PagePreviewPrimitive2D& rPagePreviewCandidate)
1134 : : {
1135 : : // remember current transformation and ViewInformation
1136 [ # # ]: 0 : const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
1137 : :
1138 : : // create new local ViewInformation2D
1139 : : const geometry::ViewInformation2D aViewInformation2D(
1140 [ # # ]: 0 : getViewInformation2D().getObjectTransformation(),
1141 [ # # ]: 0 : getViewInformation2D().getViewTransformation(),
1142 [ # # ]: 0 : getViewInformation2D().getViewport(),
1143 : 0 : rPagePreviewCandidate.getXDrawPage(),
1144 : 0 : getViewInformation2D().getViewTime(),
1145 [ # # # # ]: 0 : getViewInformation2D().getExtendedInformationSequence());
[ # # ]
1146 [ # # ]: 0 : updateViewInformation(aViewInformation2D);
1147 : :
1148 : : // proccess decomposed content
1149 [ # # ][ # # ]: 0 : process(rPagePreviewCandidate.get2DDecomposition(getViewInformation2D()));
[ # # ]
1150 : :
1151 : : // restore transformations
1152 [ # # ][ # # ]: 0 : updateViewInformation(aLastViewInformation2D);
[ # # ]
1153 : 0 : }
1154 : :
1155 : : // marker
1156 : 0 : void VclProcessor2D::RenderMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkArrayCandidate)
1157 : : {
1158 : : static bool bCheckCompleteMarkerDecompose(false);
1159 [ # # ]: 0 : if(bCheckCompleteMarkerDecompose)
1160 : : {
1161 [ # # ]: 0 : process(rMarkArrayCandidate.get2DDecomposition(getViewInformation2D()));
1162 : 0 : return;
1163 : : }
1164 : :
1165 : : // get data
1166 : 0 : const std::vector< basegfx::B2DPoint >& rPositions = rMarkArrayCandidate.getPositions();
1167 : 0 : const sal_uInt32 nCount(rPositions.size());
1168 : :
1169 [ # # ][ # # ]: 0 : if(nCount && !rMarkArrayCandidate.getMarker().IsEmpty())
[ # # ]
1170 : : {
1171 : : // get pixel size
1172 : 0 : const BitmapEx& rMarker(rMarkArrayCandidate.getMarker());
1173 : 0 : const Size aBitmapSize(rMarker.GetSizePixel());
1174 : :
1175 [ # # ][ # # ]: 0 : if(aBitmapSize.Width() && aBitmapSize.Height())
[ # # ]
1176 : : {
1177 : : // get discrete half size
1178 : : const basegfx::B2DVector aDiscreteHalfSize(
1179 : 0 : (aBitmapSize.getWidth() - 1.0) * 0.5,
1180 : 0 : (aBitmapSize.getHeight() - 1.0) * 0.5);
1181 : 0 : const bool bWasEnabled(mpOutputDevice->IsMapModeEnabled());
1182 : :
1183 : : // do not forget evtl. moved origin in target device MapMode when
1184 : : // switching it off; it would be missing and lead to wrong positions.
1185 : : // All his could be done using logic sizes and coordinates, too, but
1186 : : // we want a 1:1 bitmap rendering here, so it's more safe and faster
1187 : : // to work with switching off MapMode usage completely.
1188 : 0 : const Point aOrigin(mpOutputDevice->GetMapMode().GetOrigin());
1189 : :
1190 [ # # ]: 0 : mpOutputDevice->EnableMapMode(false);
1191 : :
1192 [ # # ][ # # ]: 0 : for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); ++aIter)
1193 : : {
1194 [ # # ]: 0 : const basegfx::B2DPoint aDiscreteTopLeft((maCurrentTransformation * (*aIter)) - aDiscreteHalfSize);
1195 : 0 : const Point aDiscretePoint(basegfx::fround(aDiscreteTopLeft.getX()), basegfx::fround(aDiscreteTopLeft.getY()));
1196 : :
1197 [ # # ]: 0 : mpOutputDevice->DrawBitmapEx(aDiscretePoint + aOrigin, rMarker);
1198 : 0 : }
1199 : :
1200 [ # # ]: 0 : mpOutputDevice->EnableMapMode(bWasEnabled);
1201 : : }
1202 : : }
1203 : : }
1204 : :
1205 : : // point
1206 : 0 : void VclProcessor2D::RenderPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate)
1207 : : {
1208 : 0 : const std::vector< basegfx::B2DPoint >& rPositions = rPointArrayCandidate.getPositions();
1209 [ # # ]: 0 : const basegfx::BColor aRGBColor(maBColorModifierStack.getModifiedColor(rPointArrayCandidate.getRGBColor()));
1210 : 0 : const Color aVCLColor(aRGBColor);
1211 : :
1212 [ # # ][ # # ]: 0 : for(std::vector< basegfx::B2DPoint >::const_iterator aIter(rPositions.begin()); aIter != rPositions.end(); ++aIter)
1213 : : {
1214 [ # # ]: 0 : const basegfx::B2DPoint aViewPosition(maCurrentTransformation * (*aIter));
1215 : 0 : const Point aPos(basegfx::fround(aViewPosition.getX()), basegfx::fround(aViewPosition.getY()));
1216 : :
1217 [ # # ]: 0 : mpOutputDevice->DrawPixel(aPos, aVCLColor);
1218 : 0 : }
1219 : 0 : }
1220 : :
1221 : 26097 : void VclProcessor2D::RenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate)
1222 : : {
1223 : : // #i101491# method restructured to clearly use the DrawPolyLine
1224 : : // calls starting from a deined line width
1225 : 26097 : const attribute::LineAttribute& rLineAttribute = rPolygonStrokeCandidate.getLineAttribute();
1226 [ + - ]: 26097 : const double fLineWidth(rLineAttribute.getWidth());
1227 : 26097 : bool bDone(false);
1228 : :
1229 [ + + ]: 26097 : if(basegfx::fTools::more(fLineWidth, 0.0))
1230 : : {
1231 [ + - ]: 6932 : const basegfx::B2DVector aDiscreteUnit(maCurrentTransformation * basegfx::B2DVector(fLineWidth, 0.0));
1232 [ + - ]: 6932 : const double fDiscreteLineWidth(aDiscreteUnit.getLength());
1233 : 6932 : const attribute::StrokeAttribute& rStrokeAttribute = rPolygonStrokeCandidate.getStrokeAttribute();
1234 [ + - ][ + - ]: 6932 : const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rLineAttribute.getColor()));
1235 [ + - ]: 6932 : basegfx::B2DPolyPolygon aHairlinePolyPolygon;
1236 : :
1237 [ + - ]: 6932 : mpOutputDevice->SetLineColor(Color(aHairlineColor));
1238 [ + - ]: 6932 : mpOutputDevice->SetFillColor();
1239 : :
1240 [ + - ][ + + ]: 6932 : if(0.0 == rStrokeAttribute.getFullDotDashLen())
1241 : : {
1242 : : // no line dashing, just copy
1243 [ + - ]: 4311 : aHairlinePolyPolygon.append(rPolygonStrokeCandidate.getB2DPolygon());
1244 : : }
1245 : : else
1246 : : {
1247 : : // else apply LineStyle
1248 : 2621 : basegfx::tools::applyLineDashing(rPolygonStrokeCandidate.getB2DPolygon(),
1249 [ + - ]: 2621 : rStrokeAttribute.getDotDashArray(),
1250 [ + - + - ]: 5242 : &aHairlinePolyPolygon, 0, rStrokeAttribute.getFullDotDashLen());
1251 : : }
1252 : :
1253 [ + - ]: 6932 : const sal_uInt32 nCount(aHairlinePolyPolygon.count());
1254 : :
1255 [ + - ]: 6932 : if(nCount)
1256 : : {
1257 [ + - ]: 6932 : const bool bAntiAliased(getOptionsDrawinglayer().IsAntiAliasing());
1258 [ + - ]: 6932 : aHairlinePolyPolygon.transform(maCurrentTransformation);
1259 : :
1260 [ + + ]: 74393 : for(sal_uInt32 a(0); a < nCount; a++)
1261 : : {
1262 [ + - ]: 67461 : basegfx::B2DPolygon aCandidate(aHairlinePolyPolygon.getB2DPolygon(a));
1263 : :
1264 [ - + ]: 67461 : if(bAntiAliased)
1265 : : {
1266 [ # # ]: 0 : if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 1.0))
1267 : : {
1268 : : // line in range ]0.0 .. 1.0[
1269 : : // paint as simple hairline
1270 [ # # ]: 0 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1271 : 0 : bDone = true;
1272 : : }
1273 [ # # ]: 0 : else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 2.0))
1274 : : {
1275 : : // line in range [1.0 .. 2.0[
1276 : : // paint as 2x2 with dynamic line distance
1277 [ # # ]: 0 : basegfx::B2DHomMatrix aMat;
1278 : 0 : const double fDistance(fDiscreteLineWidth - 1.0);
1279 : 0 : const double fHalfDistance(fDistance * 0.5);
1280 : :
1281 [ # # ]: 0 : aMat.set(0, 2, -fHalfDistance);
1282 [ # # ]: 0 : aMat.set(1, 2, -fHalfDistance);
1283 [ # # ]: 0 : aCandidate.transform(aMat);
1284 [ # # ]: 0 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1285 : :
1286 [ # # ]: 0 : aMat.set(0, 2, fDistance);
1287 [ # # ]: 0 : aMat.set(1, 2, 0.0);
1288 [ # # ]: 0 : aCandidate.transform(aMat);
1289 [ # # ]: 0 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1290 : :
1291 [ # # ]: 0 : aMat.set(0, 2, 0.0);
1292 [ # # ]: 0 : aMat.set(1, 2, fDistance);
1293 [ # # ]: 0 : aCandidate.transform(aMat);
1294 [ # # ]: 0 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1295 : :
1296 [ # # ]: 0 : aMat.set(0, 2, -fDistance);
1297 [ # # ]: 0 : aMat.set(1, 2, 0.0);
1298 [ # # ]: 0 : aCandidate.transform(aMat);
1299 [ # # ]: 0 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1300 [ # # ]: 0 : bDone = true;
1301 : : }
1302 [ # # ]: 0 : else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 3.0))
1303 : : {
1304 : : // line in range [2.0 .. 3.0]
1305 : : // paint as cross in a 3x3 with dynamic line distance
1306 [ # # ]: 0 : basegfx::B2DHomMatrix aMat;
1307 : 0 : const double fDistance((fDiscreteLineWidth - 1.0) * 0.5);
1308 : :
1309 [ # # ]: 0 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1310 : :
1311 [ # # ]: 0 : aMat.set(0, 2, -fDistance);
1312 [ # # ]: 0 : aMat.set(1, 2, 0.0);
1313 [ # # ]: 0 : aCandidate.transform(aMat);
1314 [ # # ]: 0 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1315 : :
1316 [ # # ]: 0 : aMat.set(0, 2, fDistance);
1317 [ # # ]: 0 : aMat.set(1, 2, -fDistance);
1318 [ # # ]: 0 : aCandidate.transform(aMat);
1319 [ # # ]: 0 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1320 : :
1321 [ # # ]: 0 : aMat.set(0, 2, fDistance);
1322 [ # # ]: 0 : aMat.set(1, 2, fDistance);
1323 [ # # ]: 0 : aCandidate.transform(aMat);
1324 [ # # ]: 0 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1325 : :
1326 [ # # ]: 0 : aMat.set(0, 2, -fDistance);
1327 [ # # ]: 0 : aMat.set(1, 2, fDistance);
1328 [ # # ]: 0 : aCandidate.transform(aMat);
1329 [ # # ]: 0 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1330 [ # # ]: 0 : bDone = true;
1331 : : }
1332 : : else
1333 : : {
1334 : : // #i101491# line width above 3.0
1335 : : }
1336 : : }
1337 : : else
1338 : : {
1339 [ + + ]: 67461 : if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 1.5))
1340 : : {
1341 : : // line width below 1.5, draw the basic hairline polygon
1342 [ + - ]: 44100 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1343 : 44100 : bDone = true;
1344 : : }
1345 [ + + ]: 23361 : else if(basegfx::fTools::lessOrEqual(fDiscreteLineWidth, 2.5))
1346 : : {
1347 : : // line width is in range ]1.5 .. 2.5], use four hairlines
1348 : : // drawn in a square
1349 [ + - ]: 1141 : basegfx::B2DHomMatrix aMat;
1350 [ + - ]: 1141 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1351 : :
1352 [ + - ]: 1141 : aMat.set(0, 2, 1.0);
1353 [ + - ]: 1141 : aMat.set(1, 2, 0.0);
1354 [ + - ]: 1141 : aCandidate.transform(aMat);
1355 : :
1356 [ + - ]: 1141 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1357 : :
1358 [ + - ]: 1141 : aMat.set(0, 2, 0.0);
1359 [ + - ]: 1141 : aMat.set(1, 2, 1.0);
1360 [ + - ]: 1141 : aCandidate.transform(aMat);
1361 : :
1362 [ + - ]: 1141 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1363 : :
1364 [ + - ]: 1141 : aMat.set(0, 2, -1.0);
1365 [ + - ]: 1141 : aMat.set(1, 2, 0.0);
1366 [ + - ]: 1141 : aCandidate.transform(aMat);
1367 : :
1368 [ + - ]: 1141 : mpOutputDevice->DrawPolyLine(aCandidate, 0.0);
1369 [ + - ]: 1141 : bDone = true;
1370 : : }
1371 : : else
1372 : : {
1373 : : // #i101491# line width is above 2.5
1374 : : }
1375 : : }
1376 : :
1377 [ + + ][ + - ]: 67461 : if(!bDone && rPolygonStrokeCandidate.getB2DPolygon().count() > 1000)
[ - + ][ - + ]
1378 : : {
1379 : : // #i101491# If the polygon complexity uses more than a given amount, do
1380 : : // use OuputDevice::DrawPolyLine directly; this will avoid buffering all
1381 : : // decompositions in primtives (memory) and fallback to old line painting
1382 : : // for very complex polygons, too
1383 [ # # ][ # # ]: 0 : mpOutputDevice->DrawPolyLine(aCandidate, fDiscreteLineWidth, rLineAttribute.getLineJoin());
1384 : 0 : bDone = true;
1385 : : }
1386 [ + - ]: 67461 : }
1387 [ + - ]: 6932 : }
1388 : : }
1389 : :
1390 [ + + ]: 26097 : if(!bDone)
1391 : : {
1392 : : // remeber that we enter a PolygonStrokePrimitive2D decomposition,
1393 : : // used for AA thick line drawing
1394 : 23537 : mnPolygonStrokePrimitive2D++;
1395 : :
1396 : : // line width is big enough for standard filled polygon visualisation or zero
1397 [ + - ][ + - ]: 23537 : process(rPolygonStrokeCandidate.get2DDecomposition(getViewInformation2D()));
[ + - ]
1398 : :
1399 : : // leave PolygonStrokePrimitive2D
1400 : 23537 : mnPolygonStrokePrimitive2D--;
1401 : : }
1402 : 26097 : }
1403 : :
1404 : 0 : void VclProcessor2D::RenderEpsPrimitive2D(const primitive2d::EpsPrimitive2D& rEpsPrimitive2D)
1405 : : {
1406 : : // The new decomposition of Metafiles made it necessary to add an Eps
1407 : : // primitive to handle embedded Eps data. On some devices, this can be
1408 : : // painted directly (mac, printer).
1409 : : // To be able to handle the replacement correctly, i need to handle it myself
1410 : : // since DrawEPS will not be able e.g. to rotate the replacement. To be able
1411 : : // to do that, i added a boolean return to OutputDevice::DrawEPS(..)
1412 : : // to know when EPS was handled directly already.
1413 [ # # ]: 0 : basegfx::B2DRange aRange(0.0, 0.0, 1.0, 1.0);
1414 [ # # ][ # # ]: 0 : aRange.transform(maCurrentTransformation * rEpsPrimitive2D.getEpsTransform());
[ # # ]
1415 : :
1416 [ # # ][ # # ]: 0 : if(!aRange.isEmpty())
1417 : : {
1418 : : const Rectangle aRectangle(
1419 [ # # ][ # # ]: 0 : (sal_Int32)floor(aRange.getMinX()), (sal_Int32)floor(aRange.getMinY()),
1420 [ # # ][ # # ]: 0 : (sal_Int32)ceil(aRange.getMaxX()), (sal_Int32)ceil(aRange.getMaxY()));
[ # # ]
1421 : :
1422 [ # # ][ # # ]: 0 : if(!aRectangle.IsEmpty())
1423 : : {
1424 : : // try to paint EPS directly without fallback visualisation
1425 : : const bool bEPSPaintedDirectly(mpOutputDevice->DrawEPS(
1426 : : aRectangle.TopLeft(),
1427 : : aRectangle.GetSize(),
1428 : 0 : rEpsPrimitive2D.getGfxLink(),
1429 [ # # ][ # # ]: 0 : 0));
1430 : :
1431 [ # # ]: 0 : if(!bEPSPaintedDirectly)
1432 : : {
1433 : : // use the decomposition which will correctly handle the
1434 : : // fallback visualisation using full transformation (e.g. rotation)
1435 [ # # ][ # # ]: 0 : process(rEpsPrimitive2D.get2DDecomposition(getViewInformation2D()));
[ # # ]
1436 : : }
1437 : : }
1438 : : }
1439 : 0 : }
1440 : :
1441 : 26097 : void VclProcessor2D::adaptLineToFillDrawMode() const
1442 : : {
1443 : 26097 : const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
1444 : :
1445 [ - + ]: 26097 : if(nOriginalDrawMode & (DRAWMODE_BLACKLINE|DRAWMODE_GRAYLINE|DRAWMODE_GHOSTEDLINE|DRAWMODE_WHITELINE|DRAWMODE_SETTINGSLINE))
1446 : : {
1447 : 0 : sal_uInt32 nAdaptedDrawMode(nOriginalDrawMode);
1448 : :
1449 [ # # ]: 0 : if(nOriginalDrawMode & DRAWMODE_BLACKLINE)
1450 : : {
1451 : 0 : nAdaptedDrawMode |= DRAWMODE_BLACKFILL;
1452 : : }
1453 : : else
1454 : : {
1455 : 0 : nAdaptedDrawMode &= ~DRAWMODE_BLACKFILL;
1456 : : }
1457 : :
1458 [ # # ]: 0 : if(nOriginalDrawMode & DRAWMODE_GRAYLINE)
1459 : : {
1460 : 0 : nAdaptedDrawMode |= DRAWMODE_GRAYFILL;
1461 : : }
1462 : : else
1463 : : {
1464 : 0 : nAdaptedDrawMode &= ~DRAWMODE_GRAYFILL;
1465 : : }
1466 : :
1467 [ # # ]: 0 : if(nOriginalDrawMode & DRAWMODE_GHOSTEDLINE)
1468 : : {
1469 : 0 : nAdaptedDrawMode |= DRAWMODE_GHOSTEDFILL;
1470 : : }
1471 : : else
1472 : : {
1473 : 0 : nAdaptedDrawMode &= ~DRAWMODE_GHOSTEDFILL;
1474 : : }
1475 : :
1476 [ # # ]: 0 : if(nOriginalDrawMode & DRAWMODE_WHITELINE)
1477 : : {
1478 : 0 : nAdaptedDrawMode |= DRAWMODE_WHITEFILL;
1479 : : }
1480 : : else
1481 : : {
1482 : 0 : nAdaptedDrawMode &= ~DRAWMODE_WHITEFILL;
1483 : : }
1484 : :
1485 [ # # ]: 0 : if(nOriginalDrawMode & DRAWMODE_SETTINGSLINE)
1486 : : {
1487 : 0 : nAdaptedDrawMode |= DRAWMODE_SETTINGSFILL;
1488 : : }
1489 : : else
1490 : : {
1491 : 0 : nAdaptedDrawMode &= ~DRAWMODE_SETTINGSFILL;
1492 : : }
1493 : :
1494 : 0 : mpOutputDevice->SetDrawMode(nAdaptedDrawMode);
1495 : : }
1496 : 26097 : }
1497 : :
1498 : 20018 : void VclProcessor2D::adaptTextToFillDrawMode() const
1499 : : {
1500 : 20018 : const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
1501 [ - + ]: 20018 : if(nOriginalDrawMode & (DRAWMODE_BLACKTEXT|DRAWMODE_GRAYTEXT|DRAWMODE_GHOSTEDTEXT|DRAWMODE_WHITETEXT|DRAWMODE_SETTINGSTEXT))
1502 : : {
1503 : 0 : sal_uInt32 nAdaptedDrawMode(nOriginalDrawMode);
1504 : :
1505 [ # # ]: 0 : if(nOriginalDrawMode & DRAWMODE_BLACKTEXT)
1506 : : {
1507 : 0 : nAdaptedDrawMode |= DRAWMODE_BLACKFILL;
1508 : : }
1509 : : else
1510 : : {
1511 : 0 : nAdaptedDrawMode &= ~DRAWMODE_BLACKFILL;
1512 : : }
1513 : :
1514 [ # # ]: 0 : if(nOriginalDrawMode & DRAWMODE_GRAYTEXT)
1515 : : {
1516 : 0 : nAdaptedDrawMode |= DRAWMODE_GRAYFILL;
1517 : : }
1518 : : else
1519 : : {
1520 : 0 : nAdaptedDrawMode &= ~DRAWMODE_GRAYFILL;
1521 : : }
1522 : :
1523 [ # # ]: 0 : if(nOriginalDrawMode & DRAWMODE_GHOSTEDTEXT)
1524 : : {
1525 : 0 : nAdaptedDrawMode |= DRAWMODE_GHOSTEDFILL;
1526 : : }
1527 : : else
1528 : : {
1529 : 0 : nAdaptedDrawMode &= ~DRAWMODE_GHOSTEDFILL;
1530 : : }
1531 : :
1532 [ # # ]: 0 : if(nOriginalDrawMode & DRAWMODE_WHITETEXT)
1533 : : {
1534 : 0 : nAdaptedDrawMode |= DRAWMODE_WHITEFILL;
1535 : : }
1536 : : else
1537 : : {
1538 : 0 : nAdaptedDrawMode &= ~DRAWMODE_WHITEFILL;
1539 : : }
1540 : :
1541 [ # # ]: 0 : if(nOriginalDrawMode & DRAWMODE_SETTINGSTEXT)
1542 : : {
1543 : 0 : nAdaptedDrawMode |= DRAWMODE_SETTINGSFILL;
1544 : : }
1545 : : else
1546 : : {
1547 : 0 : nAdaptedDrawMode &= ~DRAWMODE_SETTINGSFILL;
1548 : : }
1549 : :
1550 : 0 : mpOutputDevice->SetDrawMode(nAdaptedDrawMode);
1551 : : }
1552 : 20018 : }
1553 : :
1554 : : //////////////////////////////////////////////////////////////////////////////
1555 : : // process support
1556 : :
1557 : 46664 : VclProcessor2D::VclProcessor2D(
1558 : : const geometry::ViewInformation2D& rViewInformation,
1559 : : OutputDevice& rOutDev)
1560 : : : BaseProcessor2D(rViewInformation),
1561 : : mpOutputDevice(&rOutDev),
1562 : : maBColorModifierStack(),
1563 : : maCurrentTransformation(),
1564 : : maDrawinglayerOpt(),
1565 [ + - ][ + - ]: 46664 : mnPolygonStrokePrimitive2D(0)
[ + - ]
1566 : : {
1567 : : // set digit language, derived from SvtCTLOptions to have the correct
1568 : : // number display for arabic/hindi numerals
1569 [ + - ][ + - ]: 46664 : rOutDev.SetDigitLanguage(drawinglayer::detail::getDigitLanguage());
1570 : 46664 : }
1571 : :
1572 [ + - ][ + - ]: 46664 : VclProcessor2D::~VclProcessor2D()
1573 : : {
1574 [ - + ]: 46664 : }
1575 : : } // end of namespace processor2d
1576 : : } // end of namespace drawinglayer
1577 : :
1578 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|