xref: /AOO41X/main/vcl/source/gdi/outdev.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_vcl.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <tools/ref.hxx>
32*cdf0e10cSrcweir #include <tools/debug.hxx>
33*cdf0e10cSrcweir #include <tools/poly.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <vcl/svapp.hxx>
36*cdf0e10cSrcweir #include <vcl/ctrl.hxx>
37*cdf0e10cSrcweir #include <vcl/region.hxx>
38*cdf0e10cSrcweir #include <vcl/virdev.hxx>
39*cdf0e10cSrcweir #include <vcl/window.hxx>
40*cdf0e10cSrcweir #include <vcl/metaact.hxx>
41*cdf0e10cSrcweir #include <vcl/gdimtf.hxx>
42*cdf0e10cSrcweir #include <vcl/print.hxx>
43*cdf0e10cSrcweir #include <vcl/outdev.hxx>
44*cdf0e10cSrcweir #include <vcl/unowrap.hxx>
45*cdf0e10cSrcweir // declare system types in sysdata.hxx
46*cdf0e10cSrcweir #include <svsys.h>
47*cdf0e10cSrcweir #include <vcl/sysdata.hxx>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir #include <salgdi.hxx>
50*cdf0e10cSrcweir #include <sallayout.hxx>
51*cdf0e10cSrcweir #include <salframe.hxx>
52*cdf0e10cSrcweir #include <salvd.hxx>
53*cdf0e10cSrcweir #include <salprn.hxx>
54*cdf0e10cSrcweir #include <svdata.hxx>
55*cdf0e10cSrcweir #include <window.h>
56*cdf0e10cSrcweir #include <outdev.h>
57*cdf0e10cSrcweir #include <region.h>
58*cdf0e10cSrcweir #include <outdata.hxx>
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx>
61*cdf0e10cSrcweir #include <basegfx/vector/b2dvector.hxx>
62*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
63*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygon.hxx>
64*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
65*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
66*cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx>
67*cdf0e10cSrcweir #include <basegfx/polygon/b2dlinegeometry.hxx>
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir #include <com/sun/star/awt/XGraphics.hpp>
70*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
71*cdf0e10cSrcweir #include <com/sun/star/rendering/XCanvas.hpp>
72*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
73*cdf0e10cSrcweir #include <vcl/unohelp.hxx>
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir #include <numeric>
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir using namespace ::com::sun::star;
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir DBG_NAME( OutputDevice )
80*cdf0e10cSrcweir DBG_NAME( Polygon )
81*cdf0e10cSrcweir DBG_NAME( PolyPolygon )
82*cdf0e10cSrcweir DBG_NAMEEX( Region )
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir // -----------------------------------------------------------------------
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir #ifdef DBG_UTIL
87*cdf0e10cSrcweir const char* ImplDbgCheckOutputDevice( const void* pObj )
88*cdf0e10cSrcweir {
89*cdf0e10cSrcweir 	DBG_TESTSOLARMUTEX();
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir 	const OutputDevice* pOutDev = (OutputDevice*)pObj;
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 	if ( (pOutDev->GetOutDevType() != OUTDEV_DONTKNOW) &&
94*cdf0e10cSrcweir 		 (pOutDev->GetOutDevType() != OUTDEV_WINDOW) &&
95*cdf0e10cSrcweir 		 (pOutDev->GetOutDevType() != OUTDEV_PRINTER) &&
96*cdf0e10cSrcweir 		 (pOutDev->GetOutDevType() != OUTDEV_VIRDEV) )
97*cdf0e10cSrcweir 		return "OutputDevice data overwrite";
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 	return NULL;
100*cdf0e10cSrcweir }
101*cdf0e10cSrcweir #endif
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir // =======================================================================
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir #define OUTDEV_POLYPOLY_STACKBUF		32
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir // =======================================================================
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir struct ImplObjStack
110*cdf0e10cSrcweir {
111*cdf0e10cSrcweir     ImplObjStack*   mpPrev;
112*cdf0e10cSrcweir     MapMode*        mpMapMode;
113*cdf0e10cSrcweir     Region*         mpClipRegion;
114*cdf0e10cSrcweir     Color*          mpLineColor;
115*cdf0e10cSrcweir     Color*          mpFillColor;
116*cdf0e10cSrcweir     Font*           mpFont;
117*cdf0e10cSrcweir     Color*          mpTextColor;
118*cdf0e10cSrcweir     Color*          mpTextFillColor;
119*cdf0e10cSrcweir     Color*          mpTextLineColor;
120*cdf0e10cSrcweir     Color*          mpOverlineColor;
121*cdf0e10cSrcweir     Point*          mpRefPoint;
122*cdf0e10cSrcweir     TextAlign       meTextAlign;
123*cdf0e10cSrcweir     RasterOp        meRasterOp;
124*cdf0e10cSrcweir     sal_uLong           mnTextLayoutMode;
125*cdf0e10cSrcweir     LanguageType    meTextLanguage;
126*cdf0e10cSrcweir     sal_uInt16          mnFlags;
127*cdf0e10cSrcweir };
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir // -----------------------------------------------------------------------
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir static void ImplDeleteObjStack( ImplObjStack* pObjStack )
132*cdf0e10cSrcweir {
133*cdf0e10cSrcweir 	if ( pObjStack->mnFlags & PUSH_LINECOLOR )
134*cdf0e10cSrcweir 	{
135*cdf0e10cSrcweir 		if ( pObjStack->mpLineColor )
136*cdf0e10cSrcweir 			delete pObjStack->mpLineColor;
137*cdf0e10cSrcweir 	}
138*cdf0e10cSrcweir 	if ( pObjStack->mnFlags & PUSH_FILLCOLOR )
139*cdf0e10cSrcweir 	{
140*cdf0e10cSrcweir 		if ( pObjStack->mpFillColor )
141*cdf0e10cSrcweir 			delete pObjStack->mpFillColor;
142*cdf0e10cSrcweir 	}
143*cdf0e10cSrcweir 	if ( pObjStack->mnFlags & PUSH_FONT )
144*cdf0e10cSrcweir 		delete pObjStack->mpFont;
145*cdf0e10cSrcweir 	if ( pObjStack->mnFlags & PUSH_TEXTCOLOR )
146*cdf0e10cSrcweir 		delete pObjStack->mpTextColor;
147*cdf0e10cSrcweir 	if ( pObjStack->mnFlags & PUSH_TEXTFILLCOLOR )
148*cdf0e10cSrcweir 	{
149*cdf0e10cSrcweir 		if ( pObjStack->mpTextFillColor )
150*cdf0e10cSrcweir 			delete pObjStack->mpTextFillColor;
151*cdf0e10cSrcweir 	}
152*cdf0e10cSrcweir 	if ( pObjStack->mnFlags & PUSH_TEXTLINECOLOR )
153*cdf0e10cSrcweir 	{
154*cdf0e10cSrcweir 		if ( pObjStack->mpTextLineColor )
155*cdf0e10cSrcweir 			delete pObjStack->mpTextLineColor;
156*cdf0e10cSrcweir 	}
157*cdf0e10cSrcweir 	if ( pObjStack->mnFlags & PUSH_OVERLINECOLOR )
158*cdf0e10cSrcweir 	{
159*cdf0e10cSrcweir 		if ( pObjStack->mpOverlineColor )
160*cdf0e10cSrcweir 			delete pObjStack->mpOverlineColor;
161*cdf0e10cSrcweir 	}
162*cdf0e10cSrcweir 	if ( pObjStack->mnFlags & PUSH_MAPMODE )
163*cdf0e10cSrcweir 	{
164*cdf0e10cSrcweir 		if ( pObjStack->mpMapMode )
165*cdf0e10cSrcweir 			delete pObjStack->mpMapMode;
166*cdf0e10cSrcweir 	}
167*cdf0e10cSrcweir 	if ( pObjStack->mnFlags & PUSH_CLIPREGION )
168*cdf0e10cSrcweir 	{
169*cdf0e10cSrcweir 		if ( pObjStack->mpClipRegion )
170*cdf0e10cSrcweir 			delete pObjStack->mpClipRegion;
171*cdf0e10cSrcweir 	}
172*cdf0e10cSrcweir 	if ( pObjStack->mnFlags & PUSH_REFPOINT )
173*cdf0e10cSrcweir 	{
174*cdf0e10cSrcweir 		if ( pObjStack->mpRefPoint )
175*cdf0e10cSrcweir 			delete pObjStack->mpRefPoint;
176*cdf0e10cSrcweir 	}
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 	delete pObjStack;
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir // -----------------------------------------------------------------------
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir bool OutputDevice::ImplIsAntiparallel() const
184*cdf0e10cSrcweir {
185*cdf0e10cSrcweir     bool bRet = false;
186*cdf0e10cSrcweir     if( ImplGetGraphics() )
187*cdf0e10cSrcweir     {
188*cdf0e10cSrcweir         if( ( (mpGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL) && ! IsRTLEnabled() ) ||
189*cdf0e10cSrcweir             ( ! (mpGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL) && IsRTLEnabled() ) )
190*cdf0e10cSrcweir         {
191*cdf0e10cSrcweir             bRet = true;
192*cdf0e10cSrcweir         }
193*cdf0e10cSrcweir     }
194*cdf0e10cSrcweir     return bRet;
195*cdf0e10cSrcweir }
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir // -----------------------------------------------------------------------
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir bool OutputDevice::ImplSelectClipRegion( const Region& rRegion, SalGraphics* pGraphics )
201*cdf0e10cSrcweir {
202*cdf0e10cSrcweir 	DBG_TESTSOLARMUTEX();
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 	if( !pGraphics )
205*cdf0e10cSrcweir 	{
206*cdf0e10cSrcweir 		if( !mpGraphics )
207*cdf0e10cSrcweir 			if( !ImplGetGraphics() )
208*cdf0e10cSrcweir 				return false;
209*cdf0e10cSrcweir 		pGraphics = mpGraphics;
210*cdf0e10cSrcweir 	}
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir 	bool bClipRegion = pGraphics->SetClipRegion( rRegion, this );
213*cdf0e10cSrcweir 	OSL_ENSURE( bClipRegion, "OutputDevice::ImplSelectClipRegion() - can't cerate region" );
214*cdf0e10cSrcweir 	return bClipRegion;
215*cdf0e10cSrcweir }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir // =======================================================================
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir Polygon ImplSubdivideBezier( const Polygon& rPoly )
221*cdf0e10cSrcweir {
222*cdf0e10cSrcweir     Polygon aPoly;
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir     // #100127# Use adaptive subdivide instead of fixed 25 segments
225*cdf0e10cSrcweir     rPoly.AdaptiveSubdivide( aPoly );
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir     return aPoly;
228*cdf0e10cSrcweir }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir // =======================================================================
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir PolyPolygon ImplSubdivideBezier( const PolyPolygon& rPolyPoly )
233*cdf0e10cSrcweir {
234*cdf0e10cSrcweir     sal_uInt16 i, nPolys = rPolyPoly.Count();
235*cdf0e10cSrcweir     PolyPolygon aPolyPoly( nPolys );
236*cdf0e10cSrcweir     for( i=0; i<nPolys; ++i )
237*cdf0e10cSrcweir         aPolyPoly.Insert( ImplSubdivideBezier( rPolyPoly.GetObject(i) ) );
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir     return aPolyPoly;
240*cdf0e10cSrcweir }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir // =======================================================================
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir // #100127# Extracted from OutputDevice::DrawPolyPolygon()
245*cdf0e10cSrcweir void OutputDevice::ImplDrawPolyPolygon( sal_uInt16 nPoly, const PolyPolygon& rPolyPoly )
246*cdf0e10cSrcweir {
247*cdf0e10cSrcweir     // AW: This crashes on empty PolyPolygons, avoid that
248*cdf0e10cSrcweir     if(!nPoly)
249*cdf0e10cSrcweir         return;
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir     sal_uInt32			aStackAry1[OUTDEV_POLYPOLY_STACKBUF];
252*cdf0e10cSrcweir     PCONSTSALPOINT		aStackAry2[OUTDEV_POLYPOLY_STACKBUF];
253*cdf0e10cSrcweir     sal_uInt8*				aStackAry3[OUTDEV_POLYPOLY_STACKBUF];
254*cdf0e10cSrcweir     sal_uInt32*			pPointAry;
255*cdf0e10cSrcweir     PCONSTSALPOINT* 	pPointAryAry;
256*cdf0e10cSrcweir     const sal_uInt8**	 	pFlagAryAry;
257*cdf0e10cSrcweir     sal_uInt16				i = 0, j = 0, last = 0;
258*cdf0e10cSrcweir     sal_Bool				bHaveBezier = sal_False;
259*cdf0e10cSrcweir     if ( nPoly > OUTDEV_POLYPOLY_STACKBUF )
260*cdf0e10cSrcweir     {
261*cdf0e10cSrcweir         pPointAry		= new sal_uInt32[nPoly];
262*cdf0e10cSrcweir         pPointAryAry	= new PCONSTSALPOINT[nPoly];
263*cdf0e10cSrcweir         pFlagAryAry		= new const sal_uInt8*[nPoly];
264*cdf0e10cSrcweir     }
265*cdf0e10cSrcweir     else
266*cdf0e10cSrcweir     {
267*cdf0e10cSrcweir         pPointAry		= aStackAry1;
268*cdf0e10cSrcweir         pPointAryAry	= aStackAry2;
269*cdf0e10cSrcweir         pFlagAryAry		= (const sal_uInt8**)aStackAry3;
270*cdf0e10cSrcweir     }
271*cdf0e10cSrcweir     do
272*cdf0e10cSrcweir     {
273*cdf0e10cSrcweir         const Polygon&	rPoly = rPolyPoly.GetObject( i );
274*cdf0e10cSrcweir         sal_uInt16			nSize = rPoly.GetSize();
275*cdf0e10cSrcweir         if ( nSize )
276*cdf0e10cSrcweir         {
277*cdf0e10cSrcweir             pPointAry[j]	= nSize;
278*cdf0e10cSrcweir             pPointAryAry[j] = (PCONSTSALPOINT)rPoly.GetConstPointAry();
279*cdf0e10cSrcweir             pFlagAryAry[j]  = rPoly.GetConstFlagAry();
280*cdf0e10cSrcweir             last 			= i;
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir             if( pFlagAryAry[j] )
283*cdf0e10cSrcweir                 bHaveBezier = sal_True;
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir             ++j;
286*cdf0e10cSrcweir         }
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir         ++i;
289*cdf0e10cSrcweir     }
290*cdf0e10cSrcweir     while ( i < nPoly );
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir     if ( j == 1 )
293*cdf0e10cSrcweir     {
294*cdf0e10cSrcweir         // #100127# Forward beziers to sal, if any
295*cdf0e10cSrcweir         if( bHaveBezier )
296*cdf0e10cSrcweir         {
297*cdf0e10cSrcweir             if( !mpGraphics->DrawPolygonBezier( *pPointAry, *pPointAryAry, *pFlagAryAry, this ) )
298*cdf0e10cSrcweir             {
299*cdf0e10cSrcweir                 Polygon aPoly = ImplSubdivideBezier( rPolyPoly.GetObject( last ) );
300*cdf0e10cSrcweir                 mpGraphics->DrawPolygon( aPoly.GetSize(), (const SalPoint*)aPoly.GetConstPointAry(), this );
301*cdf0e10cSrcweir             }
302*cdf0e10cSrcweir         }
303*cdf0e10cSrcweir         else
304*cdf0e10cSrcweir         {
305*cdf0e10cSrcweir             mpGraphics->DrawPolygon( *pPointAry, *pPointAryAry, this );
306*cdf0e10cSrcweir         }
307*cdf0e10cSrcweir     }
308*cdf0e10cSrcweir     else
309*cdf0e10cSrcweir     {
310*cdf0e10cSrcweir         // #100127# Forward beziers to sal, if any
311*cdf0e10cSrcweir         if( bHaveBezier )
312*cdf0e10cSrcweir         {
313*cdf0e10cSrcweir             if( !mpGraphics->DrawPolyPolygonBezier( j, pPointAry, pPointAryAry, pFlagAryAry, this ) )
314*cdf0e10cSrcweir             {
315*cdf0e10cSrcweir                 PolyPolygon aPolyPoly = ImplSubdivideBezier( rPolyPoly );
316*cdf0e10cSrcweir                 ImplDrawPolyPolygon( aPolyPoly.Count(), aPolyPoly );
317*cdf0e10cSrcweir             }
318*cdf0e10cSrcweir         }
319*cdf0e10cSrcweir         else
320*cdf0e10cSrcweir         {
321*cdf0e10cSrcweir             mpGraphics->DrawPolyPolygon( j, pPointAry, pPointAryAry, this );
322*cdf0e10cSrcweir         }
323*cdf0e10cSrcweir     }
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir     if ( pPointAry != aStackAry1 )
326*cdf0e10cSrcweir     {
327*cdf0e10cSrcweir         delete[] pPointAry;
328*cdf0e10cSrcweir         delete[] pPointAryAry;
329*cdf0e10cSrcweir         delete[] pFlagAryAry;
330*cdf0e10cSrcweir     }
331*cdf0e10cSrcweir }
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir // =======================================================================
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir OutputDevice::OutputDevice() :
336*cdf0e10cSrcweir 	maRegion( REGION_NULL ),
337*cdf0e10cSrcweir 	maFillColor( COL_WHITE ),
338*cdf0e10cSrcweir 	maTextLineColor( COL_TRANSPARENT ),
339*cdf0e10cSrcweir 	maSettings( Application::GetSettings() )
340*cdf0e10cSrcweir {
341*cdf0e10cSrcweir 	DBG_CTOR( OutputDevice, ImplDbgCheckOutputDevice );
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir 	mpGraphics			= NULL;
344*cdf0e10cSrcweir 	mpUnoGraphicsList	= NULL;
345*cdf0e10cSrcweir 	mpPrevGraphics		= NULL;
346*cdf0e10cSrcweir 	mpNextGraphics		= NULL;
347*cdf0e10cSrcweir 	mpMetaFile			= NULL;
348*cdf0e10cSrcweir 	mpFontEntry 		= NULL;
349*cdf0e10cSrcweir 	mpFontCache 		= NULL;
350*cdf0e10cSrcweir 	mpFontList			= NULL;
351*cdf0e10cSrcweir 	mpGetDevFontList	= NULL;
352*cdf0e10cSrcweir 	mpGetDevSizeList	= NULL;
353*cdf0e10cSrcweir 	mpObjStack			= NULL;
354*cdf0e10cSrcweir 	mpOutDevData		= NULL;
355*cdf0e10cSrcweir     mpPDFWriter			= NULL;
356*cdf0e10cSrcweir     mpAlphaVDev			= NULL;
357*cdf0e10cSrcweir 	mpExtOutDevData		= NULL;
358*cdf0e10cSrcweir 	mnOutOffX			= 0;
359*cdf0e10cSrcweir 	mnOutOffY			= 0;
360*cdf0e10cSrcweir 	mnOutWidth			= 0;
361*cdf0e10cSrcweir 	mnOutHeight 		= 0;
362*cdf0e10cSrcweir 	mnDPIX				= 0;
363*cdf0e10cSrcweir 	mnDPIY				= 0;
364*cdf0e10cSrcweir 	mnTextOffX			= 0;
365*cdf0e10cSrcweir 	mnTextOffY			= 0;
366*cdf0e10cSrcweir 	mnOutOffOrigX		= 0;
367*cdf0e10cSrcweir 	mnOutOffLogicX		= 0;
368*cdf0e10cSrcweir 	mnOutOffOrigY		= 0;
369*cdf0e10cSrcweir 	mnOutOffLogicY		= 0;
370*cdf0e10cSrcweir 	mnEmphasisAscent	= 0;
371*cdf0e10cSrcweir 	mnEmphasisDescent	= 0;
372*cdf0e10cSrcweir 	mnDrawMode			= 0;
373*cdf0e10cSrcweir 	mnTextLayoutMode        = TEXT_LAYOUT_DEFAULT;
374*cdf0e10cSrcweir 	if( Application::GetSettings().GetLayoutRTL() ) //#i84553# tip BiDi preference to RTL
375*cdf0e10cSrcweir 		mnTextLayoutMode = TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_TEXTORIGIN_LEFT;
376*cdf0e10cSrcweir 	meOutDevType		= OUTDEV_DONTKNOW;
377*cdf0e10cSrcweir     meOutDevViewType    = OUTDEV_VIEWTYPE_DONTKNOW;
378*cdf0e10cSrcweir 	mbMap				= sal_False;
379*cdf0e10cSrcweir 	mbMapIsDefault		= sal_True;
380*cdf0e10cSrcweir 	mbClipRegion		= sal_False;
381*cdf0e10cSrcweir 	mbBackground		= sal_False;
382*cdf0e10cSrcweir 	mbOutput			= sal_True;
383*cdf0e10cSrcweir 	mbDevOutput 		= sal_False;
384*cdf0e10cSrcweir 	mbOutputClipped 	= sal_False;
385*cdf0e10cSrcweir 	maTextColor 		= Color( COL_BLACK );
386*cdf0e10cSrcweir 	maOverlineColor 	= Color( COL_TRANSPARENT );
387*cdf0e10cSrcweir 	meTextAlign 		= maFont.GetAlign();
388*cdf0e10cSrcweir 	meRasterOp			= ROP_OVERPAINT;
389*cdf0e10cSrcweir 	mnAntialiasing		= 0;
390*cdf0e10cSrcweir     meTextLanguage      = 0;  // TODO: get default from configuration?
391*cdf0e10cSrcweir 	mbLineColor 		= sal_True;
392*cdf0e10cSrcweir 	mbFillColor 		= sal_True;
393*cdf0e10cSrcweir 	mbInitLineColor 	= sal_True;
394*cdf0e10cSrcweir 	mbInitFillColor 	= sal_True;
395*cdf0e10cSrcweir 	mbInitFont			= sal_True;
396*cdf0e10cSrcweir 	mbInitTextColor 	= sal_True;
397*cdf0e10cSrcweir 	mbInitClipRegion	= sal_True;
398*cdf0e10cSrcweir 	mbClipRegionSet 	= sal_False;
399*cdf0e10cSrcweir 	mbKerning			= sal_False;
400*cdf0e10cSrcweir 	mbNewFont			= sal_True;
401*cdf0e10cSrcweir 	mbTextLines 		= sal_False;
402*cdf0e10cSrcweir 	mbTextSpecial		= sal_False;
403*cdf0e10cSrcweir 	mbRefPoint			= sal_False;
404*cdf0e10cSrcweir     mbEnableRTL         = sal_False;    // mirroring must be explicitly allowed (typically for windows only)
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir 	// struct ImplMapRes
407*cdf0e10cSrcweir     maMapRes.mnMapOfsX 			= 0;
408*cdf0e10cSrcweir     maMapRes.mnMapOfsY 			= 0;
409*cdf0e10cSrcweir     maMapRes.mnMapScNumX 		= 1;
410*cdf0e10cSrcweir     maMapRes.mnMapScNumY 		= 1;
411*cdf0e10cSrcweir     maMapRes.mnMapScDenomX 		= 1;
412*cdf0e10cSrcweir     maMapRes.mnMapScDenomY		= 1;
413*cdf0e10cSrcweir 	// struct ImplThresholdRes
414*cdf0e10cSrcweir     maThresRes.mnThresLogToPixX	= 0;
415*cdf0e10cSrcweir     maThresRes.mnThresLogToPixY	= 0;
416*cdf0e10cSrcweir     maThresRes.mnThresPixToLogX	= 0;
417*cdf0e10cSrcweir     maThresRes.mnThresPixToLogY	= 0;
418*cdf0e10cSrcweir }
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir // -----------------------------------------------------------------------
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir OutputDevice::~OutputDevice()
423*cdf0e10cSrcweir {
424*cdf0e10cSrcweir 	DBG_DTOR( OutputDevice, ImplDbgCheckOutputDevice );
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir 	if ( GetUnoGraphicsList() )
427*cdf0e10cSrcweir 	{
428*cdf0e10cSrcweir 		UnoWrapperBase* pWrapper = Application::GetUnoWrapper( sal_False );
429*cdf0e10cSrcweir 		if ( pWrapper )
430*cdf0e10cSrcweir 			pWrapper->ReleaseAllGraphics( this );
431*cdf0e10cSrcweir 		delete mpUnoGraphicsList;
432*cdf0e10cSrcweir 		mpUnoGraphicsList = NULL;
433*cdf0e10cSrcweir 	}
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir 	if ( mpOutDevData )
436*cdf0e10cSrcweir 		ImplDeInitOutDevData();
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir 	ImplObjStack* pData = mpObjStack;
439*cdf0e10cSrcweir 	if ( pData )
440*cdf0e10cSrcweir 	{
441*cdf0e10cSrcweir 		DBG_ERRORFILE( "OutputDevice::~OutputDevice(): OutputDevice::Push() calls != OutputDevice::Pop() calls" );
442*cdf0e10cSrcweir 		while ( pData )
443*cdf0e10cSrcweir 		{
444*cdf0e10cSrcweir 			ImplObjStack* pTemp = pData;
445*cdf0e10cSrcweir 			pData = pData->mpPrev;
446*cdf0e10cSrcweir 			ImplDeleteObjStack( pTemp );
447*cdf0e10cSrcweir 		}
448*cdf0e10cSrcweir 	}
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir     // release the active font instance
451*cdf0e10cSrcweir     if( mpFontEntry )
452*cdf0e10cSrcweir         mpFontCache->Release( mpFontEntry );
453*cdf0e10cSrcweir     // remove cached results of GetDevFontList/GetDevSizeList
454*cdf0e10cSrcweir     // TODO: use smart pointers for them
455*cdf0e10cSrcweir     if( mpGetDevFontList )
456*cdf0e10cSrcweir         delete mpGetDevFontList;
457*cdf0e10cSrcweir     if( mpGetDevSizeList )
458*cdf0e10cSrcweir         delete mpGetDevSizeList;
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir     // release ImplFontCache specific to this OutputDevice
461*cdf0e10cSrcweir     // TODO: refcount ImplFontCache
462*cdf0e10cSrcweir     if( mpFontCache
463*cdf0e10cSrcweir     && (mpFontCache != ImplGetSVData()->maGDIData.mpScreenFontCache)
464*cdf0e10cSrcweir     && (ImplGetSVData()->maGDIData.mpScreenFontCache != NULL) )
465*cdf0e10cSrcweir     {
466*cdf0e10cSrcweir         delete mpFontCache;
467*cdf0e10cSrcweir         mpFontCache = NULL;
468*cdf0e10cSrcweir     }
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir     // release ImplFontList specific to this OutputDevice
471*cdf0e10cSrcweir     // TODO: refcount ImplFontList
472*cdf0e10cSrcweir     if( mpFontList
473*cdf0e10cSrcweir     && (mpFontList != ImplGetSVData()->maGDIData.mpScreenFontList)
474*cdf0e10cSrcweir     && (ImplGetSVData()->maGDIData.mpScreenFontList != NULL) )
475*cdf0e10cSrcweir     {
476*cdf0e10cSrcweir         mpFontList->Clear();
477*cdf0e10cSrcweir         delete mpFontList;
478*cdf0e10cSrcweir         mpFontList = NULL;
479*cdf0e10cSrcweir     }
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir     delete mpAlphaVDev;
482*cdf0e10cSrcweir }
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir bool OutputDevice::supportsOperation( OutDevSupportType eType ) const
485*cdf0e10cSrcweir {
486*cdf0e10cSrcweir 	if( !mpGraphics )
487*cdf0e10cSrcweir 		if( !ImplGetGraphics() )
488*cdf0e10cSrcweir 			return false;
489*cdf0e10cSrcweir 	const bool bHasSupport = mpGraphics->supportsOperation( eType );
490*cdf0e10cSrcweir 	return bHasSupport;
491*cdf0e10cSrcweir }
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir // -----------------------------------------------------------------------
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir void OutputDevice::EnableRTL( sal_Bool bEnable )
496*cdf0e10cSrcweir {
497*cdf0e10cSrcweir     mbEnableRTL = (bEnable != 0);
498*cdf0e10cSrcweir     if( meOutDevType == OUTDEV_VIRDEV )
499*cdf0e10cSrcweir     {
500*cdf0e10cSrcweir         // virdevs default to not mirroring, they will only be set to mirroring
501*cdf0e10cSrcweir         // under rare circumstances in the UI, eg the valueset control
502*cdf0e10cSrcweir         // because each virdev has its own SalGraphics we can safely switch the SalGraphics here
503*cdf0e10cSrcweir         // ...hopefully
504*cdf0e10cSrcweir         if( ImplGetGraphics() )
505*cdf0e10cSrcweir             mpGraphics->SetLayout( mbEnableRTL ? SAL_LAYOUT_BIDI_RTL : 0 );
506*cdf0e10cSrcweir     }
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir     // convenience: for controls also switch layout mode
509*cdf0e10cSrcweir     if( dynamic_cast<Control*>(this) != 0 )
510*cdf0e10cSrcweir         SetLayoutMode( bEnable ? TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_TEXTORIGIN_LEFT : TEXT_LAYOUT_BIDI_LTR | TEXT_LAYOUT_TEXTORIGIN_LEFT);
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir     Window* pWin = dynamic_cast<Window*>(this);
513*cdf0e10cSrcweir     if( pWin )
514*cdf0e10cSrcweir         pWin->StateChanged( STATE_CHANGE_MIRRORING );
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir     if( mpAlphaVDev )
517*cdf0e10cSrcweir         mpAlphaVDev->EnableRTL( bEnable );
518*cdf0e10cSrcweir }
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir sal_Bool OutputDevice::ImplHasMirroredGraphics()
521*cdf0e10cSrcweir {
522*cdf0e10cSrcweir    // HOTFIX for #i55719#
523*cdf0e10cSrcweir    if( meOutDevType == OUTDEV_PRINTER )
524*cdf0e10cSrcweir        return sal_False;
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir    return ( ImplGetGraphics() && (mpGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL) );
527*cdf0e10cSrcweir }
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir // note: the coordiantes to be remirrored are in frame coordiantes !
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir void    OutputDevice::ImplReMirror( Point &rPoint ) const
532*cdf0e10cSrcweir {
533*cdf0e10cSrcweir     rPoint.X() = mnOutOffX + mnOutWidth - 1 - rPoint.X() + mnOutOffX;
534*cdf0e10cSrcweir }
535*cdf0e10cSrcweir void    OutputDevice::ImplReMirror( Rectangle &rRect ) const
536*cdf0e10cSrcweir {
537*cdf0e10cSrcweir     long nWidth = rRect.nRight - rRect.nLeft;
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir     //long lc_x = rRect.nLeft - mnOutOffX;    // normalize
540*cdf0e10cSrcweir     //lc_x = mnOutWidth - nWidth - 1 - lc_x;  // mirror
541*cdf0e10cSrcweir     //rRect.nLeft = lc_x + mnOutOffX;         // re-normalize
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir     rRect.nLeft = mnOutOffX + mnOutWidth - nWidth - 1 - rRect.nLeft + mnOutOffX;
544*cdf0e10cSrcweir     rRect.nRight = rRect.nLeft + nWidth;
545*cdf0e10cSrcweir }
546*cdf0e10cSrcweir void    OutputDevice::ImplReMirror( Region &rRegion ) const
547*cdf0e10cSrcweir {
548*cdf0e10cSrcweir 	long				nX;
549*cdf0e10cSrcweir 	long				nY;
550*cdf0e10cSrcweir 	long				nWidth;
551*cdf0e10cSrcweir 	long				nHeight;
552*cdf0e10cSrcweir 	ImplRegionInfo		aInfo;
553*cdf0e10cSrcweir 	sal_Bool				bRegionRect;
554*cdf0e10cSrcweir     Region              aMirroredRegion;
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir 	bRegionRect = rRegion.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight );
557*cdf0e10cSrcweir 	while ( bRegionRect )
558*cdf0e10cSrcweir 	{
559*cdf0e10cSrcweir         Rectangle aRect( Point(nX, nY), Size(nWidth, nHeight) );
560*cdf0e10cSrcweir         ImplReMirror( aRect );
561*cdf0e10cSrcweir         aMirroredRegion.Union( aRect );
562*cdf0e10cSrcweir 		bRegionRect = rRegion.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight );
563*cdf0e10cSrcweir 	}
564*cdf0e10cSrcweir     rRegion = aMirroredRegion;
565*cdf0e10cSrcweir }
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir // -----------------------------------------------------------------------
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir int OutputDevice::ImplGetGraphics() const
571*cdf0e10cSrcweir {
572*cdf0e10cSrcweir 	DBG_TESTSOLARMUTEX();
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir 	if ( mpGraphics )
575*cdf0e10cSrcweir 		return sal_True;
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir 	mbInitLineColor 	= sal_True;
578*cdf0e10cSrcweir 	mbInitFillColor 	= sal_True;
579*cdf0e10cSrcweir 	mbInitFont			= sal_True;
580*cdf0e10cSrcweir 	mbInitTextColor 	= sal_True;
581*cdf0e10cSrcweir 	mbInitClipRegion	= sal_True;
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir 	ImplSVData* pSVData = ImplGetSVData();
584*cdf0e10cSrcweir 	if ( meOutDevType == OUTDEV_WINDOW )
585*cdf0e10cSrcweir 	{
586*cdf0e10cSrcweir 		Window* pWindow = (Window*)this;
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir 		mpGraphics = pWindow->mpWindowImpl->mpFrame->GetGraphics();
589*cdf0e10cSrcweir         // try harder if no wingraphics was available directly
590*cdf0e10cSrcweir 		if ( !mpGraphics )
591*cdf0e10cSrcweir 		{
592*cdf0e10cSrcweir             // find another output device in the same frame
593*cdf0e10cSrcweir 			OutputDevice* pReleaseOutDev = pSVData->maGDIData.mpLastWinGraphics;
594*cdf0e10cSrcweir 			while ( pReleaseOutDev )
595*cdf0e10cSrcweir 			{
596*cdf0e10cSrcweir 				if ( ((Window*)pReleaseOutDev)->mpWindowImpl->mpFrame == pWindow->mpWindowImpl->mpFrame )
597*cdf0e10cSrcweir 					break;
598*cdf0e10cSrcweir 				pReleaseOutDev = pReleaseOutDev->mpPrevGraphics;
599*cdf0e10cSrcweir 			}
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir 			if ( pReleaseOutDev )
602*cdf0e10cSrcweir 			{
603*cdf0e10cSrcweir                 // steal the wingraphics from the other outdev
604*cdf0e10cSrcweir 				mpGraphics = pReleaseOutDev->mpGraphics;
605*cdf0e10cSrcweir 				pReleaseOutDev->ImplReleaseGraphics( sal_False );
606*cdf0e10cSrcweir 			}
607*cdf0e10cSrcweir 			else
608*cdf0e10cSrcweir 			{
609*cdf0e10cSrcweir                 // if needed retry after releasing least recently used wingraphics
610*cdf0e10cSrcweir 				while ( !mpGraphics )
611*cdf0e10cSrcweir 				{
612*cdf0e10cSrcweir 					if ( !pSVData->maGDIData.mpLastWinGraphics )
613*cdf0e10cSrcweir 						break;
614*cdf0e10cSrcweir 					pSVData->maGDIData.mpLastWinGraphics->ImplReleaseGraphics();
615*cdf0e10cSrcweir 					mpGraphics = pWindow->mpWindowImpl->mpFrame->GetGraphics();
616*cdf0e10cSrcweir 				}
617*cdf0e10cSrcweir 			}
618*cdf0e10cSrcweir 		}
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir         // update global LRU list of wingraphics
621*cdf0e10cSrcweir 		if ( mpGraphics )
622*cdf0e10cSrcweir 		{
623*cdf0e10cSrcweir 			mpNextGraphics = pSVData->maGDIData.mpFirstWinGraphics;
624*cdf0e10cSrcweir 			pSVData->maGDIData.mpFirstWinGraphics = const_cast<OutputDevice*>(this);
625*cdf0e10cSrcweir 			if ( mpNextGraphics )
626*cdf0e10cSrcweir 				mpNextGraphics->mpPrevGraphics = const_cast<OutputDevice*>(this);
627*cdf0e10cSrcweir 			if ( !pSVData->maGDIData.mpLastWinGraphics )
628*cdf0e10cSrcweir 				pSVData->maGDIData.mpLastWinGraphics = const_cast<OutputDevice*>(this);
629*cdf0e10cSrcweir 		}
630*cdf0e10cSrcweir 	}
631*cdf0e10cSrcweir 	else if ( meOutDevType == OUTDEV_VIRDEV )
632*cdf0e10cSrcweir 	{
633*cdf0e10cSrcweir 		const VirtualDevice* pVirDev = (const VirtualDevice*)this;
634*cdf0e10cSrcweir 
635*cdf0e10cSrcweir 		if ( pVirDev->mpVirDev )
636*cdf0e10cSrcweir 		{
637*cdf0e10cSrcweir 			mpGraphics = pVirDev->mpVirDev->GetGraphics();
638*cdf0e10cSrcweir             // if needed retry after releasing least recently used virtual device graphics
639*cdf0e10cSrcweir 			while ( !mpGraphics )
640*cdf0e10cSrcweir 			{
641*cdf0e10cSrcweir 				if ( !pSVData->maGDIData.mpLastVirGraphics )
642*cdf0e10cSrcweir 					break;
643*cdf0e10cSrcweir 				pSVData->maGDIData.mpLastVirGraphics->ImplReleaseGraphics();
644*cdf0e10cSrcweir 				mpGraphics = pVirDev->mpVirDev->GetGraphics();
645*cdf0e10cSrcweir 			}
646*cdf0e10cSrcweir             // update global LRU list of virtual device graphics
647*cdf0e10cSrcweir 			if ( mpGraphics )
648*cdf0e10cSrcweir 			{
649*cdf0e10cSrcweir 				mpNextGraphics = pSVData->maGDIData.mpFirstVirGraphics;
650*cdf0e10cSrcweir 				pSVData->maGDIData.mpFirstVirGraphics = const_cast<OutputDevice*>(this);
651*cdf0e10cSrcweir 				if ( mpNextGraphics )
652*cdf0e10cSrcweir 					mpNextGraphics->mpPrevGraphics = const_cast<OutputDevice*>(this);
653*cdf0e10cSrcweir 				if ( !pSVData->maGDIData.mpLastVirGraphics )
654*cdf0e10cSrcweir 					pSVData->maGDIData.mpLastVirGraphics = const_cast<OutputDevice*>(this);
655*cdf0e10cSrcweir 			}
656*cdf0e10cSrcweir 		}
657*cdf0e10cSrcweir 	}
658*cdf0e10cSrcweir 	else if ( meOutDevType == OUTDEV_PRINTER )
659*cdf0e10cSrcweir 	{
660*cdf0e10cSrcweir 		const Printer* pPrinter = (const Printer*)this;
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir 		if ( pPrinter->mpJobGraphics )
663*cdf0e10cSrcweir 			mpGraphics = pPrinter->mpJobGraphics;
664*cdf0e10cSrcweir 		else if ( pPrinter->mpDisplayDev )
665*cdf0e10cSrcweir 		{
666*cdf0e10cSrcweir 			const VirtualDevice* pVirDev = pPrinter->mpDisplayDev;
667*cdf0e10cSrcweir 			mpGraphics = pVirDev->mpVirDev->GetGraphics();
668*cdf0e10cSrcweir             // if needed retry after releasing least recently used virtual device graphics
669*cdf0e10cSrcweir 			while ( !mpGraphics )
670*cdf0e10cSrcweir 			{
671*cdf0e10cSrcweir 				if ( !pSVData->maGDIData.mpLastVirGraphics )
672*cdf0e10cSrcweir 					break;
673*cdf0e10cSrcweir 				pSVData->maGDIData.mpLastVirGraphics->ImplReleaseGraphics();
674*cdf0e10cSrcweir 				mpGraphics = pVirDev->mpVirDev->GetGraphics();
675*cdf0e10cSrcweir 			}
676*cdf0e10cSrcweir             // update global LRU list of virtual device graphics
677*cdf0e10cSrcweir 			if ( mpGraphics )
678*cdf0e10cSrcweir 			{
679*cdf0e10cSrcweir 				mpNextGraphics = pSVData->maGDIData.mpFirstVirGraphics;
680*cdf0e10cSrcweir 				pSVData->maGDIData.mpFirstVirGraphics = const_cast<OutputDevice*>(this);
681*cdf0e10cSrcweir 				if ( mpNextGraphics )
682*cdf0e10cSrcweir 					mpNextGraphics->mpPrevGraphics = const_cast<OutputDevice*>(this);
683*cdf0e10cSrcweir 				if ( !pSVData->maGDIData.mpLastVirGraphics )
684*cdf0e10cSrcweir 					pSVData->maGDIData.mpLastVirGraphics = const_cast<OutputDevice*>(this);
685*cdf0e10cSrcweir 			}
686*cdf0e10cSrcweir 		}
687*cdf0e10cSrcweir 		else
688*cdf0e10cSrcweir 		{
689*cdf0e10cSrcweir 			mpGraphics = pPrinter->mpInfoPrinter->GetGraphics();
690*cdf0e10cSrcweir             // if needed retry after releasing least recently used printer graphics
691*cdf0e10cSrcweir 			while ( !mpGraphics )
692*cdf0e10cSrcweir 			{
693*cdf0e10cSrcweir 				if ( !pSVData->maGDIData.mpLastPrnGraphics )
694*cdf0e10cSrcweir 					break;
695*cdf0e10cSrcweir 				pSVData->maGDIData.mpLastPrnGraphics->ImplReleaseGraphics();
696*cdf0e10cSrcweir 				mpGraphics = pPrinter->mpInfoPrinter->GetGraphics();
697*cdf0e10cSrcweir 			}
698*cdf0e10cSrcweir             // update global LRU list of printer graphics
699*cdf0e10cSrcweir 			if ( mpGraphics )
700*cdf0e10cSrcweir 			{
701*cdf0e10cSrcweir 				mpNextGraphics = pSVData->maGDIData.mpFirstPrnGraphics;
702*cdf0e10cSrcweir 				pSVData->maGDIData.mpFirstPrnGraphics = const_cast<OutputDevice*>(this);
703*cdf0e10cSrcweir 				if ( mpNextGraphics )
704*cdf0e10cSrcweir 					mpNextGraphics->mpPrevGraphics = const_cast<OutputDevice*>(this);
705*cdf0e10cSrcweir 				if ( !pSVData->maGDIData.mpLastPrnGraphics )
706*cdf0e10cSrcweir 					pSVData->maGDIData.mpLastPrnGraphics = const_cast<OutputDevice*>(this);
707*cdf0e10cSrcweir 			}
708*cdf0e10cSrcweir 		}
709*cdf0e10cSrcweir 	}
710*cdf0e10cSrcweir 
711*cdf0e10cSrcweir 	if ( mpGraphics )
712*cdf0e10cSrcweir 	{
713*cdf0e10cSrcweir 		mpGraphics->SetXORMode( (ROP_INVERT == meRasterOp) || (ROP_XOR == meRasterOp), ROP_INVERT == meRasterOp );
714*cdf0e10cSrcweir         mpGraphics->setAntiAliasB2DDraw(mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW);
715*cdf0e10cSrcweir         return sal_True;
716*cdf0e10cSrcweir 	}
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir 	return sal_False;
719*cdf0e10cSrcweir }
720*cdf0e10cSrcweir 
721*cdf0e10cSrcweir // -----------------------------------------------------------------------
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir void OutputDevice::ImplReleaseGraphics( sal_Bool bRelease )
724*cdf0e10cSrcweir {
725*cdf0e10cSrcweir 	DBG_TESTSOLARMUTEX();
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir 	if ( !mpGraphics )
728*cdf0e10cSrcweir 		return;
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir     // release the fonts of the physically released graphics device
731*cdf0e10cSrcweir     if( bRelease )
732*cdf0e10cSrcweir     {
733*cdf0e10cSrcweir #ifndef UNX
734*cdf0e10cSrcweir         // HACK to fix an urgent P1 printing issue fast
735*cdf0e10cSrcweir         // WinSalPrinter does not respect GetGraphics/ReleaseGraphics conventions
736*cdf0e10cSrcweir         // so Printer::mpGraphics often points to a dead WinSalGraphics
737*cdf0e10cSrcweir         // TODO: fix WinSalPrinter's GetGraphics/ReleaseGraphics handling
738*cdf0e10cSrcweir         if( meOutDevType != OUTDEV_PRINTER )
739*cdf0e10cSrcweir #endif
740*cdf0e10cSrcweir         mpGraphics->ReleaseFonts();
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir         mbNewFont = true;
743*cdf0e10cSrcweir         mbInitFont = true;
744*cdf0e10cSrcweir 
745*cdf0e10cSrcweir         if ( mpFontEntry )
746*cdf0e10cSrcweir         {
747*cdf0e10cSrcweir             mpFontCache->Release( mpFontEntry );
748*cdf0e10cSrcweir             mpFontEntry = NULL;
749*cdf0e10cSrcweir         }
750*cdf0e10cSrcweir 
751*cdf0e10cSrcweir         if ( mpGetDevFontList )
752*cdf0e10cSrcweir         {
753*cdf0e10cSrcweir             delete mpGetDevFontList;
754*cdf0e10cSrcweir             mpGetDevFontList = NULL;
755*cdf0e10cSrcweir         }
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir         if ( mpGetDevSizeList )
758*cdf0e10cSrcweir         {
759*cdf0e10cSrcweir             delete mpGetDevSizeList;
760*cdf0e10cSrcweir             mpGetDevSizeList = NULL;
761*cdf0e10cSrcweir         }
762*cdf0e10cSrcweir     }
763*cdf0e10cSrcweir 
764*cdf0e10cSrcweir 	ImplSVData* pSVData = ImplGetSVData();
765*cdf0e10cSrcweir 	if ( meOutDevType == OUTDEV_WINDOW )
766*cdf0e10cSrcweir 	{
767*cdf0e10cSrcweir 		Window* pWindow = (Window*)this;
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir 		if ( bRelease )
770*cdf0e10cSrcweir 			pWindow->mpWindowImpl->mpFrame->ReleaseGraphics( mpGraphics );
771*cdf0e10cSrcweir         // remove from global LRU list of window graphics
772*cdf0e10cSrcweir 		if ( mpPrevGraphics )
773*cdf0e10cSrcweir 			mpPrevGraphics->mpNextGraphics = mpNextGraphics;
774*cdf0e10cSrcweir 		else
775*cdf0e10cSrcweir 			pSVData->maGDIData.mpFirstWinGraphics = mpNextGraphics;
776*cdf0e10cSrcweir 		if ( mpNextGraphics )
777*cdf0e10cSrcweir 			mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
778*cdf0e10cSrcweir 		else
779*cdf0e10cSrcweir 			pSVData->maGDIData.mpLastWinGraphics = mpPrevGraphics;
780*cdf0e10cSrcweir 	}
781*cdf0e10cSrcweir 	else if ( meOutDevType == OUTDEV_VIRDEV )
782*cdf0e10cSrcweir 	{
783*cdf0e10cSrcweir 		VirtualDevice* pVirDev = (VirtualDevice*)this;
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir 		if ( bRelease )
786*cdf0e10cSrcweir 			pVirDev->mpVirDev->ReleaseGraphics( mpGraphics );
787*cdf0e10cSrcweir         // remove from global LRU list of virtual device graphics
788*cdf0e10cSrcweir 		if ( mpPrevGraphics )
789*cdf0e10cSrcweir 			mpPrevGraphics->mpNextGraphics = mpNextGraphics;
790*cdf0e10cSrcweir 		else
791*cdf0e10cSrcweir 			pSVData->maGDIData.mpFirstVirGraphics = mpNextGraphics;
792*cdf0e10cSrcweir 		if ( mpNextGraphics )
793*cdf0e10cSrcweir 			mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
794*cdf0e10cSrcweir 		else
795*cdf0e10cSrcweir 			pSVData->maGDIData.mpLastVirGraphics = mpPrevGraphics;
796*cdf0e10cSrcweir 	}
797*cdf0e10cSrcweir 	else if ( meOutDevType == OUTDEV_PRINTER )
798*cdf0e10cSrcweir 	{
799*cdf0e10cSrcweir 		Printer* pPrinter = (Printer*)this;
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir 		if ( !pPrinter->mpJobGraphics )
802*cdf0e10cSrcweir 		{
803*cdf0e10cSrcweir 			if ( pPrinter->mpDisplayDev )
804*cdf0e10cSrcweir 			{
805*cdf0e10cSrcweir 				VirtualDevice* pVirDev = pPrinter->mpDisplayDev;
806*cdf0e10cSrcweir 				if ( bRelease )
807*cdf0e10cSrcweir 					pVirDev->mpVirDev->ReleaseGraphics( mpGraphics );
808*cdf0e10cSrcweir                 // remove from global LRU list of virtual device graphics
809*cdf0e10cSrcweir 				if ( mpPrevGraphics )
810*cdf0e10cSrcweir 					mpPrevGraphics->mpNextGraphics = mpNextGraphics;
811*cdf0e10cSrcweir 				else
812*cdf0e10cSrcweir 					pSVData->maGDIData.mpFirstVirGraphics = mpNextGraphics;
813*cdf0e10cSrcweir 				if ( mpNextGraphics )
814*cdf0e10cSrcweir 					mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
815*cdf0e10cSrcweir 				else
816*cdf0e10cSrcweir 					pSVData->maGDIData.mpLastVirGraphics = mpPrevGraphics;
817*cdf0e10cSrcweir 			}
818*cdf0e10cSrcweir 			else
819*cdf0e10cSrcweir 			{
820*cdf0e10cSrcweir 				if ( bRelease )
821*cdf0e10cSrcweir 					pPrinter->mpInfoPrinter->ReleaseGraphics( mpGraphics );
822*cdf0e10cSrcweir                 // remove from global LRU list of printer graphics
823*cdf0e10cSrcweir 				if ( mpPrevGraphics )
824*cdf0e10cSrcweir 					mpPrevGraphics->mpNextGraphics = mpNextGraphics;
825*cdf0e10cSrcweir 				else
826*cdf0e10cSrcweir 					pSVData->maGDIData.mpFirstPrnGraphics = mpNextGraphics;
827*cdf0e10cSrcweir 				if ( mpNextGraphics )
828*cdf0e10cSrcweir 					mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
829*cdf0e10cSrcweir 				else
830*cdf0e10cSrcweir 					pSVData->maGDIData.mpLastPrnGraphics = mpPrevGraphics;
831*cdf0e10cSrcweir 		   }
832*cdf0e10cSrcweir 		}
833*cdf0e10cSrcweir 	}
834*cdf0e10cSrcweir 
835*cdf0e10cSrcweir 	mpGraphics		= NULL;
836*cdf0e10cSrcweir 	mpPrevGraphics	= NULL;
837*cdf0e10cSrcweir 	mpNextGraphics	= NULL;
838*cdf0e10cSrcweir }
839*cdf0e10cSrcweir 
840*cdf0e10cSrcweir // -----------------------------------------------------------------------
841*cdf0e10cSrcweir 
842*cdf0e10cSrcweir void OutputDevice::ImplInitOutDevData()
843*cdf0e10cSrcweir {
844*cdf0e10cSrcweir 	if ( !mpOutDevData )
845*cdf0e10cSrcweir 	{
846*cdf0e10cSrcweir 		mpOutDevData = new ImplOutDevData;
847*cdf0e10cSrcweir 		mpOutDevData->mpRotateDev = NULL;
848*cdf0e10cSrcweir         mpOutDevData->mpRecordLayout = NULL;
849*cdf0e10cSrcweir 
850*cdf0e10cSrcweir 		// #i75163#
851*cdf0e10cSrcweir 		mpOutDevData->mpViewTransform = NULL;
852*cdf0e10cSrcweir 		mpOutDevData->mpInverseViewTransform = NULL;
853*cdf0e10cSrcweir 	}
854*cdf0e10cSrcweir }
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir // -----------------------------------------------------------------------
857*cdf0e10cSrcweir 
858*cdf0e10cSrcweir // #i75163#
859*cdf0e10cSrcweir void OutputDevice::ImplInvalidateViewTransform()
860*cdf0e10cSrcweir {
861*cdf0e10cSrcweir 	if(mpOutDevData)
862*cdf0e10cSrcweir 	{
863*cdf0e10cSrcweir 		if(mpOutDevData->mpViewTransform)
864*cdf0e10cSrcweir 		{
865*cdf0e10cSrcweir 			delete mpOutDevData->mpViewTransform;
866*cdf0e10cSrcweir 			mpOutDevData->mpViewTransform = NULL;
867*cdf0e10cSrcweir 		}
868*cdf0e10cSrcweir 
869*cdf0e10cSrcweir 		if(mpOutDevData->mpInverseViewTransform)
870*cdf0e10cSrcweir 		{
871*cdf0e10cSrcweir 			delete mpOutDevData->mpInverseViewTransform;
872*cdf0e10cSrcweir 			mpOutDevData->mpInverseViewTransform = NULL;
873*cdf0e10cSrcweir 		}
874*cdf0e10cSrcweir 	}
875*cdf0e10cSrcweir }
876*cdf0e10cSrcweir 
877*cdf0e10cSrcweir // -----------------------------------------------------------------------
878*cdf0e10cSrcweir 
879*cdf0e10cSrcweir sal_Bool OutputDevice::ImplIsRecordLayout() const
880*cdf0e10cSrcweir {
881*cdf0e10cSrcweir     return mpOutDevData && mpOutDevData->mpRecordLayout;
882*cdf0e10cSrcweir }
883*cdf0e10cSrcweir 
884*cdf0e10cSrcweir // -----------------------------------------------------------------------
885*cdf0e10cSrcweir 
886*cdf0e10cSrcweir void OutputDevice::ImplDeInitOutDevData()
887*cdf0e10cSrcweir {
888*cdf0e10cSrcweir 	if ( mpOutDevData )
889*cdf0e10cSrcweir 	{
890*cdf0e10cSrcweir 		if ( mpOutDevData->mpRotateDev )
891*cdf0e10cSrcweir 			delete mpOutDevData->mpRotateDev;
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir 		// #i75163#
894*cdf0e10cSrcweir 		ImplInvalidateViewTransform();
895*cdf0e10cSrcweir 
896*cdf0e10cSrcweir 		delete mpOutDevData;
897*cdf0e10cSrcweir 	}
898*cdf0e10cSrcweir }
899*cdf0e10cSrcweir 
900*cdf0e10cSrcweir // -----------------------------------------------------------------------
901*cdf0e10cSrcweir 
902*cdf0e10cSrcweir void OutputDevice::ImplInitLineColor()
903*cdf0e10cSrcweir {
904*cdf0e10cSrcweir 	DBG_TESTSOLARMUTEX();
905*cdf0e10cSrcweir 
906*cdf0e10cSrcweir 	if( mbLineColor )
907*cdf0e10cSrcweir 	{
908*cdf0e10cSrcweir 		if( ROP_0 == meRasterOp )
909*cdf0e10cSrcweir 			mpGraphics->SetROPLineColor( SAL_ROP_0 );
910*cdf0e10cSrcweir 		else if( ROP_1 == meRasterOp )
911*cdf0e10cSrcweir 			mpGraphics->SetROPLineColor( SAL_ROP_1 );
912*cdf0e10cSrcweir 		else if( ROP_INVERT == meRasterOp )
913*cdf0e10cSrcweir 			mpGraphics->SetROPLineColor( SAL_ROP_INVERT );
914*cdf0e10cSrcweir 		else
915*cdf0e10cSrcweir 			mpGraphics->SetLineColor( ImplColorToSal( maLineColor ) );
916*cdf0e10cSrcweir 	}
917*cdf0e10cSrcweir 	else
918*cdf0e10cSrcweir 		mpGraphics->SetLineColor();
919*cdf0e10cSrcweir 
920*cdf0e10cSrcweir 	mbInitLineColor = sal_False;
921*cdf0e10cSrcweir }
922*cdf0e10cSrcweir 
923*cdf0e10cSrcweir // -----------------------------------------------------------------------
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir void OutputDevice::ImplInitFillColor()
926*cdf0e10cSrcweir {
927*cdf0e10cSrcweir 	DBG_TESTSOLARMUTEX();
928*cdf0e10cSrcweir 
929*cdf0e10cSrcweir 	if( mbFillColor )
930*cdf0e10cSrcweir 	{
931*cdf0e10cSrcweir 		if( ROP_0 == meRasterOp )
932*cdf0e10cSrcweir 			mpGraphics->SetROPFillColor( SAL_ROP_0 );
933*cdf0e10cSrcweir 		else if( ROP_1 == meRasterOp )
934*cdf0e10cSrcweir 			mpGraphics->SetROPFillColor( SAL_ROP_1 );
935*cdf0e10cSrcweir 		else if( ROP_INVERT == meRasterOp )
936*cdf0e10cSrcweir 			mpGraphics->SetROPFillColor( SAL_ROP_INVERT );
937*cdf0e10cSrcweir 		else
938*cdf0e10cSrcweir 			mpGraphics->SetFillColor( ImplColorToSal( maFillColor ) );
939*cdf0e10cSrcweir 	}
940*cdf0e10cSrcweir 	else
941*cdf0e10cSrcweir 		mpGraphics->SetFillColor();
942*cdf0e10cSrcweir 
943*cdf0e10cSrcweir 	mbInitFillColor = sal_False;
944*cdf0e10cSrcweir }
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir // -----------------------------------------------------------------------
947*cdf0e10cSrcweir 
948*cdf0e10cSrcweir void OutputDevice::ImplInitClipRegion()
949*cdf0e10cSrcweir {
950*cdf0e10cSrcweir 	DBG_TESTSOLARMUTEX();
951*cdf0e10cSrcweir 
952*cdf0e10cSrcweir 	if ( GetOutDevType() == OUTDEV_WINDOW )
953*cdf0e10cSrcweir 	{
954*cdf0e10cSrcweir 		Window* pWindow = (Window*)this;
955*cdf0e10cSrcweir 		Region	aRegion;
956*cdf0e10cSrcweir 
957*cdf0e10cSrcweir 		// Hintergrund-Sicherung zuruecksetzen
958*cdf0e10cSrcweir 		if ( pWindow->mpWindowImpl->mpFrameData->mpFirstBackWin )
959*cdf0e10cSrcweir 			pWindow->ImplInvalidateAllOverlapBackgrounds();
960*cdf0e10cSrcweir 		if ( pWindow->mpWindowImpl->mbInPaint )
961*cdf0e10cSrcweir 			aRegion = *(pWindow->mpWindowImpl->mpPaintRegion);
962*cdf0e10cSrcweir 		else
963*cdf0e10cSrcweir         {
964*cdf0e10cSrcweir 			aRegion = *(pWindow->ImplGetWinChildClipRegion());
965*cdf0e10cSrcweir             // --- RTL -- only this region is in frame coordinates, so re-mirror it
966*cdf0e10cSrcweir             // the mpWindowImpl->mpPaintRegion above is already correct (see ImplCallPaint()) !
967*cdf0e10cSrcweir             if( ImplIsAntiparallel() )
968*cdf0e10cSrcweir 	            ImplReMirror ( aRegion );
969*cdf0e10cSrcweir         }
970*cdf0e10cSrcweir 		if ( mbClipRegion )
971*cdf0e10cSrcweir 			aRegion.Intersect( ImplPixelToDevicePixel( maRegion ) );
972*cdf0e10cSrcweir 		if ( aRegion.IsEmpty() )
973*cdf0e10cSrcweir 			mbOutputClipped = sal_True;
974*cdf0e10cSrcweir 		else
975*cdf0e10cSrcweir 		{
976*cdf0e10cSrcweir 			mbOutputClipped = sal_False;
977*cdf0e10cSrcweir 			ImplSelectClipRegion( aRegion );
978*cdf0e10cSrcweir 		}
979*cdf0e10cSrcweir 		mbClipRegionSet = sal_True;
980*cdf0e10cSrcweir 	}
981*cdf0e10cSrcweir 	else
982*cdf0e10cSrcweir 	{
983*cdf0e10cSrcweir 		if ( mbClipRegion )
984*cdf0e10cSrcweir 		{
985*cdf0e10cSrcweir 			if ( maRegion.IsEmpty() )
986*cdf0e10cSrcweir 				mbOutputClipped = sal_True;
987*cdf0e10cSrcweir 			else
988*cdf0e10cSrcweir 			{
989*cdf0e10cSrcweir 				mbOutputClipped = sal_False;
990*cdf0e10cSrcweir 
991*cdf0e10cSrcweir 				// #102532# Respect output offset also for clip region
992*cdf0e10cSrcweir                 Region aRegion( ImplPixelToDevicePixel( maRegion ) );
993*cdf0e10cSrcweir                 const bool bClipDeviceBounds( ! GetPDFWriter()
994*cdf0e10cSrcweir                                               && GetOutDevType() != OUTDEV_PRINTER );
995*cdf0e10cSrcweir                 if( bClipDeviceBounds )
996*cdf0e10cSrcweir                 {
997*cdf0e10cSrcweir                     // #b6520266# Perform actual rect clip against outdev
998*cdf0e10cSrcweir                     // dimensions, to generate empty clips whenever one of the
999*cdf0e10cSrcweir                     // values is completely off the device.
1000*cdf0e10cSrcweir                     Rectangle aDeviceBounds( mnOutOffX, mnOutOffY,
1001*cdf0e10cSrcweir                                              mnOutOffX+GetOutputWidthPixel()-1,
1002*cdf0e10cSrcweir                                              mnOutOffY+GetOutputHeightPixel()-1 );
1003*cdf0e10cSrcweir                     aRegion.Intersect( aDeviceBounds );
1004*cdf0e10cSrcweir                 }
1005*cdf0e10cSrcweir                 ImplSelectClipRegion( aRegion );
1006*cdf0e10cSrcweir 			}
1007*cdf0e10cSrcweir 
1008*cdf0e10cSrcweir 			mbClipRegionSet = sal_True;
1009*cdf0e10cSrcweir 		}
1010*cdf0e10cSrcweir 		else
1011*cdf0e10cSrcweir 		{
1012*cdf0e10cSrcweir 			if ( mbClipRegionSet )
1013*cdf0e10cSrcweir 			{
1014*cdf0e10cSrcweir 				mpGraphics->ResetClipRegion();
1015*cdf0e10cSrcweir 				mbClipRegionSet = sal_False;
1016*cdf0e10cSrcweir 			}
1017*cdf0e10cSrcweir 
1018*cdf0e10cSrcweir 			mbOutputClipped = sal_False;
1019*cdf0e10cSrcweir 		}
1020*cdf0e10cSrcweir 	}
1021*cdf0e10cSrcweir 
1022*cdf0e10cSrcweir 	mbInitClipRegion = sal_False;
1023*cdf0e10cSrcweir }
1024*cdf0e10cSrcweir 
1025*cdf0e10cSrcweir // -----------------------------------------------------------------------
1026*cdf0e10cSrcweir 
1027*cdf0e10cSrcweir void OutputDevice::ImplSetClipRegion( const Region* pRegion )
1028*cdf0e10cSrcweir {
1029*cdf0e10cSrcweir 	DBG_TESTSOLARMUTEX();
1030*cdf0e10cSrcweir 
1031*cdf0e10cSrcweir 	if ( !pRegion )
1032*cdf0e10cSrcweir 	{
1033*cdf0e10cSrcweir 		if ( mbClipRegion )
1034*cdf0e10cSrcweir 		{
1035*cdf0e10cSrcweir 			maRegion			= Region( REGION_NULL );
1036*cdf0e10cSrcweir 			mbClipRegion		= sal_False;
1037*cdf0e10cSrcweir 			mbInitClipRegion	= sal_True;
1038*cdf0e10cSrcweir 		}
1039*cdf0e10cSrcweir 	}
1040*cdf0e10cSrcweir 	else
1041*cdf0e10cSrcweir 	{
1042*cdf0e10cSrcweir 		maRegion			= *pRegion;
1043*cdf0e10cSrcweir 		mbClipRegion		= sal_True;
1044*cdf0e10cSrcweir 		mbInitClipRegion	= sal_True;
1045*cdf0e10cSrcweir 	}
1046*cdf0e10cSrcweir }
1047*cdf0e10cSrcweir 
1048*cdf0e10cSrcweir // -----------------------------------------------------------------------
1049*cdf0e10cSrcweir 
1050*cdf0e10cSrcweir void OutputDevice::SetClipRegion()
1051*cdf0e10cSrcweir {
1052*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::SetClipRegion()" );
1053*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1054*cdf0e10cSrcweir 
1055*cdf0e10cSrcweir 	if ( mpMetaFile )
1056*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaClipRegionAction( Region(), sal_False ) );
1057*cdf0e10cSrcweir 
1058*cdf0e10cSrcweir 	ImplSetClipRegion( NULL );
1059*cdf0e10cSrcweir 
1060*cdf0e10cSrcweir     if( mpAlphaVDev )
1061*cdf0e10cSrcweir         mpAlphaVDev->SetClipRegion();
1062*cdf0e10cSrcweir }
1063*cdf0e10cSrcweir 
1064*cdf0e10cSrcweir // -----------------------------------------------------------------------
1065*cdf0e10cSrcweir 
1066*cdf0e10cSrcweir void OutputDevice::SetClipRegion( const Region& rRegion )
1067*cdf0e10cSrcweir {
1068*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::SetClipRegion( rRegion )" );
1069*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1070*cdf0e10cSrcweir 	DBG_CHKOBJ( &rRegion, Region, ImplDbgTestRegion );
1071*cdf0e10cSrcweir 
1072*cdf0e10cSrcweir 	if ( mpMetaFile )
1073*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaClipRegionAction( rRegion, sal_True ) );
1074*cdf0e10cSrcweir 
1075*cdf0e10cSrcweir 	if ( rRegion.GetType() == REGION_NULL )
1076*cdf0e10cSrcweir 		ImplSetClipRegion( NULL );
1077*cdf0e10cSrcweir 	else
1078*cdf0e10cSrcweir 	{
1079*cdf0e10cSrcweir 		Region aRegion = LogicToPixel( rRegion );
1080*cdf0e10cSrcweir 		ImplSetClipRegion( &aRegion );
1081*cdf0e10cSrcweir 	}
1082*cdf0e10cSrcweir 
1083*cdf0e10cSrcweir     if( mpAlphaVDev )
1084*cdf0e10cSrcweir         mpAlphaVDev->SetClipRegion( rRegion );
1085*cdf0e10cSrcweir }
1086*cdf0e10cSrcweir 
1087*cdf0e10cSrcweir // -----------------------------------------------------------------------
1088*cdf0e10cSrcweir 
1089*cdf0e10cSrcweir Region OutputDevice::GetClipRegion() const
1090*cdf0e10cSrcweir {
1091*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1092*cdf0e10cSrcweir 
1093*cdf0e10cSrcweir 	return PixelToLogic( maRegion );
1094*cdf0e10cSrcweir }
1095*cdf0e10cSrcweir 
1096*cdf0e10cSrcweir // -----------------------------------------------------------------------
1097*cdf0e10cSrcweir 
1098*cdf0e10cSrcweir Region OutputDevice::GetActiveClipRegion() const
1099*cdf0e10cSrcweir {
1100*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1101*cdf0e10cSrcweir 
1102*cdf0e10cSrcweir 	if ( GetOutDevType() == OUTDEV_WINDOW )
1103*cdf0e10cSrcweir 	{
1104*cdf0e10cSrcweir 		Region aRegion( REGION_NULL );
1105*cdf0e10cSrcweir 		Window* pWindow = (Window*)this;
1106*cdf0e10cSrcweir 		if ( pWindow->mpWindowImpl->mbInPaint )
1107*cdf0e10cSrcweir 		{
1108*cdf0e10cSrcweir 			aRegion = *(pWindow->mpWindowImpl->mpPaintRegion);
1109*cdf0e10cSrcweir 			aRegion.Move( -mnOutOffX, -mnOutOffY );
1110*cdf0e10cSrcweir 		}
1111*cdf0e10cSrcweir 		if ( mbClipRegion )
1112*cdf0e10cSrcweir 			aRegion.Intersect( maRegion );
1113*cdf0e10cSrcweir 		return PixelToLogic( aRegion );
1114*cdf0e10cSrcweir 	}
1115*cdf0e10cSrcweir 	else
1116*cdf0e10cSrcweir 		return GetClipRegion();
1117*cdf0e10cSrcweir }
1118*cdf0e10cSrcweir 
1119*cdf0e10cSrcweir // -----------------------------------------------------------------------
1120*cdf0e10cSrcweir 
1121*cdf0e10cSrcweir void OutputDevice::MoveClipRegion( long nHorzMove, long nVertMove )
1122*cdf0e10cSrcweir {
1123*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::MoveClipRegion()" );
1124*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1125*cdf0e10cSrcweir 
1126*cdf0e10cSrcweir 	if ( mbClipRegion )
1127*cdf0e10cSrcweir 	{
1128*cdf0e10cSrcweir 		if( mpMetaFile )
1129*cdf0e10cSrcweir 			mpMetaFile->AddAction( new MetaMoveClipRegionAction( nHorzMove, nVertMove ) );
1130*cdf0e10cSrcweir 
1131*cdf0e10cSrcweir 		maRegion.Move( ImplLogicWidthToDevicePixel( nHorzMove ),
1132*cdf0e10cSrcweir 					   ImplLogicHeightToDevicePixel( nVertMove ) );
1133*cdf0e10cSrcweir 		mbInitClipRegion = sal_True;
1134*cdf0e10cSrcweir 	}
1135*cdf0e10cSrcweir 
1136*cdf0e10cSrcweir     if( mpAlphaVDev )
1137*cdf0e10cSrcweir         mpAlphaVDev->MoveClipRegion( nHorzMove, nVertMove );
1138*cdf0e10cSrcweir }
1139*cdf0e10cSrcweir 
1140*cdf0e10cSrcweir // -----------------------------------------------------------------------
1141*cdf0e10cSrcweir 
1142*cdf0e10cSrcweir void OutputDevice::IntersectClipRegion( const Rectangle& rRect )
1143*cdf0e10cSrcweir {
1144*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::IntersectClipRegion( rRect )" );
1145*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1146*cdf0e10cSrcweir 
1147*cdf0e10cSrcweir 	if ( mpMetaFile )
1148*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaISectRectClipRegionAction( rRect ) );
1149*cdf0e10cSrcweir 
1150*cdf0e10cSrcweir 	Rectangle aRect = LogicToPixel( rRect );
1151*cdf0e10cSrcweir 	maRegion.Intersect( aRect );
1152*cdf0e10cSrcweir 	mbClipRegion		= sal_True;
1153*cdf0e10cSrcweir 	mbInitClipRegion	= sal_True;
1154*cdf0e10cSrcweir 
1155*cdf0e10cSrcweir     if( mpAlphaVDev )
1156*cdf0e10cSrcweir         mpAlphaVDev->IntersectClipRegion( rRect );
1157*cdf0e10cSrcweir }
1158*cdf0e10cSrcweir 
1159*cdf0e10cSrcweir // -----------------------------------------------------------------------
1160*cdf0e10cSrcweir 
1161*cdf0e10cSrcweir void OutputDevice::IntersectClipRegion( const Region& rRegion )
1162*cdf0e10cSrcweir {
1163*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::IntersectClipRegion( rRegion )" );
1164*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1165*cdf0e10cSrcweir 	DBG_CHKOBJ( &rRegion, Region, ImplDbgTestRegion );
1166*cdf0e10cSrcweir 
1167*cdf0e10cSrcweir 	RegionType eType = rRegion.GetType();
1168*cdf0e10cSrcweir 
1169*cdf0e10cSrcweir 	if ( eType != REGION_NULL )
1170*cdf0e10cSrcweir 	{
1171*cdf0e10cSrcweir 		if ( mpMetaFile )
1172*cdf0e10cSrcweir 			mpMetaFile->AddAction( new MetaISectRegionClipRegionAction( rRegion ) );
1173*cdf0e10cSrcweir 
1174*cdf0e10cSrcweir 		Region aRegion = LogicToPixel( rRegion );
1175*cdf0e10cSrcweir 		maRegion.Intersect( aRegion );
1176*cdf0e10cSrcweir 		mbClipRegion		= sal_True;
1177*cdf0e10cSrcweir 		mbInitClipRegion	= sal_True;
1178*cdf0e10cSrcweir 	}
1179*cdf0e10cSrcweir 
1180*cdf0e10cSrcweir     if( mpAlphaVDev )
1181*cdf0e10cSrcweir         mpAlphaVDev->IntersectClipRegion( rRegion );
1182*cdf0e10cSrcweir }
1183*cdf0e10cSrcweir 
1184*cdf0e10cSrcweir // -----------------------------------------------------------------------
1185*cdf0e10cSrcweir 
1186*cdf0e10cSrcweir void OutputDevice::SetDrawMode( sal_uLong nDrawMode )
1187*cdf0e10cSrcweir {
1188*cdf0e10cSrcweir 	DBG_TRACE1( "OutputDevice::SetDrawMode( %lx )", nDrawMode );
1189*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1190*cdf0e10cSrcweir 
1191*cdf0e10cSrcweir 	mnDrawMode = nDrawMode;
1192*cdf0e10cSrcweir 
1193*cdf0e10cSrcweir     if( mpAlphaVDev )
1194*cdf0e10cSrcweir         mpAlphaVDev->SetDrawMode( nDrawMode );
1195*cdf0e10cSrcweir }
1196*cdf0e10cSrcweir 
1197*cdf0e10cSrcweir // -----------------------------------------------------------------------
1198*cdf0e10cSrcweir 
1199*cdf0e10cSrcweir void OutputDevice::SetRasterOp( RasterOp eRasterOp )
1200*cdf0e10cSrcweir {
1201*cdf0e10cSrcweir 	DBG_TRACE1( "OutputDevice::SetRasterOp( %d )", (int)eRasterOp );
1202*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1203*cdf0e10cSrcweir 
1204*cdf0e10cSrcweir 	if ( mpMetaFile )
1205*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaRasterOpAction( eRasterOp ) );
1206*cdf0e10cSrcweir 
1207*cdf0e10cSrcweir 	if ( meRasterOp != eRasterOp )
1208*cdf0e10cSrcweir 	{
1209*cdf0e10cSrcweir 		meRasterOp = eRasterOp;
1210*cdf0e10cSrcweir 		mbInitLineColor = mbInitFillColor = sal_True;
1211*cdf0e10cSrcweir 
1212*cdf0e10cSrcweir 		if( mpGraphics || ImplGetGraphics() )
1213*cdf0e10cSrcweir 			mpGraphics->SetXORMode( (ROP_INVERT == meRasterOp) || (ROP_XOR == meRasterOp), ROP_INVERT == meRasterOp );
1214*cdf0e10cSrcweir 	}
1215*cdf0e10cSrcweir 
1216*cdf0e10cSrcweir     if( mpAlphaVDev )
1217*cdf0e10cSrcweir         mpAlphaVDev->SetRasterOp( eRasterOp );
1218*cdf0e10cSrcweir }
1219*cdf0e10cSrcweir 
1220*cdf0e10cSrcweir // -----------------------------------------------------------------------
1221*cdf0e10cSrcweir 
1222*cdf0e10cSrcweir void OutputDevice::SetLineColor()
1223*cdf0e10cSrcweir {
1224*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::SetLineColor()" );
1225*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1226*cdf0e10cSrcweir 
1227*cdf0e10cSrcweir 	if ( mpMetaFile )
1228*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaLineColorAction( Color(), sal_False ) );
1229*cdf0e10cSrcweir 
1230*cdf0e10cSrcweir 	if ( mbLineColor )
1231*cdf0e10cSrcweir 	{
1232*cdf0e10cSrcweir 		mbInitLineColor = sal_True;
1233*cdf0e10cSrcweir 		mbLineColor = sal_False;
1234*cdf0e10cSrcweir 		maLineColor = Color( COL_TRANSPARENT );
1235*cdf0e10cSrcweir 	}
1236*cdf0e10cSrcweir 
1237*cdf0e10cSrcweir     if( mpAlphaVDev )
1238*cdf0e10cSrcweir         mpAlphaVDev->SetLineColor();
1239*cdf0e10cSrcweir }
1240*cdf0e10cSrcweir 
1241*cdf0e10cSrcweir // -----------------------------------------------------------------------
1242*cdf0e10cSrcweir 
1243*cdf0e10cSrcweir void OutputDevice::SetLineColor( const Color& rColor )
1244*cdf0e10cSrcweir {
1245*cdf0e10cSrcweir 	DBG_TRACE1( "OutputDevice::SetLineColor( %lx )", rColor.GetColor() );
1246*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1247*cdf0e10cSrcweir 
1248*cdf0e10cSrcweir 	Color aColor( rColor );
1249*cdf0e10cSrcweir 
1250*cdf0e10cSrcweir 	if( mnDrawMode & ( DRAWMODE_BLACKLINE | DRAWMODE_WHITELINE |
1251*cdf0e10cSrcweir 					   DRAWMODE_GRAYLINE | DRAWMODE_GHOSTEDLINE |
1252*cdf0e10cSrcweir                        DRAWMODE_SETTINGSLINE ) )
1253*cdf0e10cSrcweir 	{
1254*cdf0e10cSrcweir 		if( !ImplIsColorTransparent( aColor ) )
1255*cdf0e10cSrcweir 		{
1256*cdf0e10cSrcweir 			if( mnDrawMode & DRAWMODE_BLACKLINE )
1257*cdf0e10cSrcweir 			{
1258*cdf0e10cSrcweir 				aColor = Color( COL_BLACK );
1259*cdf0e10cSrcweir 			}
1260*cdf0e10cSrcweir 			else if( mnDrawMode & DRAWMODE_WHITELINE )
1261*cdf0e10cSrcweir 			{
1262*cdf0e10cSrcweir 				aColor = Color( COL_WHITE );
1263*cdf0e10cSrcweir 			}
1264*cdf0e10cSrcweir 			else if( mnDrawMode & DRAWMODE_GRAYLINE )
1265*cdf0e10cSrcweir 			{
1266*cdf0e10cSrcweir 				const sal_uInt8 cLum = aColor.GetLuminance();
1267*cdf0e10cSrcweir 				aColor = Color( cLum, cLum, cLum );
1268*cdf0e10cSrcweir 			}
1269*cdf0e10cSrcweir             else if( mnDrawMode & DRAWMODE_SETTINGSLINE )
1270*cdf0e10cSrcweir             {
1271*cdf0e10cSrcweir                 aColor = GetSettings().GetStyleSettings().GetFontColor();
1272*cdf0e10cSrcweir             }
1273*cdf0e10cSrcweir 
1274*cdf0e10cSrcweir 			if( mnDrawMode & DRAWMODE_GHOSTEDLINE )
1275*cdf0e10cSrcweir 			{
1276*cdf0e10cSrcweir 				aColor = Color( ( aColor.GetRed() >> 1 ) | 0x80,
1277*cdf0e10cSrcweir 								( aColor.GetGreen() >> 1 ) | 0x80,
1278*cdf0e10cSrcweir 								( aColor.GetBlue() >> 1 ) | 0x80);
1279*cdf0e10cSrcweir 			}
1280*cdf0e10cSrcweir 		}
1281*cdf0e10cSrcweir 	}
1282*cdf0e10cSrcweir 
1283*cdf0e10cSrcweir 	if( mpMetaFile )
1284*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaLineColorAction( aColor, sal_True ) );
1285*cdf0e10cSrcweir 
1286*cdf0e10cSrcweir 	if( ImplIsColorTransparent( aColor ) )
1287*cdf0e10cSrcweir 	{
1288*cdf0e10cSrcweir 		if ( mbLineColor )
1289*cdf0e10cSrcweir 		{
1290*cdf0e10cSrcweir 			mbInitLineColor = sal_True;
1291*cdf0e10cSrcweir 			mbLineColor = sal_False;
1292*cdf0e10cSrcweir 			maLineColor = Color( COL_TRANSPARENT );
1293*cdf0e10cSrcweir 		}
1294*cdf0e10cSrcweir 	}
1295*cdf0e10cSrcweir 	else
1296*cdf0e10cSrcweir 	{
1297*cdf0e10cSrcweir 		if( maLineColor != aColor )
1298*cdf0e10cSrcweir 		{
1299*cdf0e10cSrcweir 			mbInitLineColor = sal_True;
1300*cdf0e10cSrcweir 			mbLineColor = sal_True;
1301*cdf0e10cSrcweir 			maLineColor = aColor;
1302*cdf0e10cSrcweir 		}
1303*cdf0e10cSrcweir 	}
1304*cdf0e10cSrcweir 
1305*cdf0e10cSrcweir     if( mpAlphaVDev )
1306*cdf0e10cSrcweir         mpAlphaVDev->SetLineColor( COL_BLACK );
1307*cdf0e10cSrcweir }
1308*cdf0e10cSrcweir 
1309*cdf0e10cSrcweir // -----------------------------------------------------------------------
1310*cdf0e10cSrcweir 
1311*cdf0e10cSrcweir void OutputDevice::SetFillColor()
1312*cdf0e10cSrcweir {
1313*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::SetFillColor()" );
1314*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1315*cdf0e10cSrcweir 
1316*cdf0e10cSrcweir 	if ( mpMetaFile )
1317*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaFillColorAction( Color(), sal_False ) );
1318*cdf0e10cSrcweir 
1319*cdf0e10cSrcweir 	if ( mbFillColor )
1320*cdf0e10cSrcweir 	{
1321*cdf0e10cSrcweir 		mbInitFillColor = sal_True;
1322*cdf0e10cSrcweir 		mbFillColor = sal_False;
1323*cdf0e10cSrcweir 		maFillColor = Color( COL_TRANSPARENT );
1324*cdf0e10cSrcweir 	}
1325*cdf0e10cSrcweir 
1326*cdf0e10cSrcweir     if( mpAlphaVDev )
1327*cdf0e10cSrcweir         mpAlphaVDev->SetFillColor();
1328*cdf0e10cSrcweir }
1329*cdf0e10cSrcweir 
1330*cdf0e10cSrcweir // -----------------------------------------------------------------------
1331*cdf0e10cSrcweir 
1332*cdf0e10cSrcweir void OutputDevice::SetFillColor( const Color& rColor )
1333*cdf0e10cSrcweir {
1334*cdf0e10cSrcweir 	DBG_TRACE1( "OutputDevice::SetFillColor( %lx )", rColor.GetColor() );
1335*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1336*cdf0e10cSrcweir 
1337*cdf0e10cSrcweir 	Color aColor( rColor );
1338*cdf0e10cSrcweir 
1339*cdf0e10cSrcweir 	if( mnDrawMode & ( DRAWMODE_BLACKFILL | DRAWMODE_WHITEFILL |
1340*cdf0e10cSrcweir 					   DRAWMODE_GRAYFILL | DRAWMODE_NOFILL |
1341*cdf0e10cSrcweir 					   DRAWMODE_GHOSTEDFILL | DRAWMODE_SETTINGSFILL ) )
1342*cdf0e10cSrcweir 	{
1343*cdf0e10cSrcweir 		if( !ImplIsColorTransparent( aColor ) )
1344*cdf0e10cSrcweir 		{
1345*cdf0e10cSrcweir 			if( mnDrawMode & DRAWMODE_BLACKFILL )
1346*cdf0e10cSrcweir 			{
1347*cdf0e10cSrcweir 				aColor = Color( COL_BLACK );
1348*cdf0e10cSrcweir 			}
1349*cdf0e10cSrcweir 			else if( mnDrawMode & DRAWMODE_WHITEFILL )
1350*cdf0e10cSrcweir 			{
1351*cdf0e10cSrcweir 				aColor = Color( COL_WHITE );
1352*cdf0e10cSrcweir 			}
1353*cdf0e10cSrcweir 			else if( mnDrawMode & DRAWMODE_GRAYFILL )
1354*cdf0e10cSrcweir 			{
1355*cdf0e10cSrcweir 				const sal_uInt8 cLum = aColor.GetLuminance();
1356*cdf0e10cSrcweir 				aColor = Color( cLum, cLum, cLum );
1357*cdf0e10cSrcweir 			}
1358*cdf0e10cSrcweir 			else if( mnDrawMode & DRAWMODE_NOFILL )
1359*cdf0e10cSrcweir 			{
1360*cdf0e10cSrcweir 				aColor = Color( COL_TRANSPARENT );
1361*cdf0e10cSrcweir 			}
1362*cdf0e10cSrcweir             else if( mnDrawMode & DRAWMODE_SETTINGSFILL )
1363*cdf0e10cSrcweir             {
1364*cdf0e10cSrcweir                 aColor = GetSettings().GetStyleSettings().GetWindowColor();
1365*cdf0e10cSrcweir             }
1366*cdf0e10cSrcweir 
1367*cdf0e10cSrcweir 			if( mnDrawMode & DRAWMODE_GHOSTEDFILL )
1368*cdf0e10cSrcweir 			{
1369*cdf0e10cSrcweir 				aColor = Color( (aColor.GetRed() >> 1) | 0x80,
1370*cdf0e10cSrcweir 								(aColor.GetGreen() >> 1) | 0x80,
1371*cdf0e10cSrcweir 								(aColor.GetBlue() >> 1) | 0x80);
1372*cdf0e10cSrcweir 			}
1373*cdf0e10cSrcweir 		}
1374*cdf0e10cSrcweir 	}
1375*cdf0e10cSrcweir 
1376*cdf0e10cSrcweir 	if ( mpMetaFile )
1377*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaFillColorAction( aColor, sal_True ) );
1378*cdf0e10cSrcweir 
1379*cdf0e10cSrcweir 	if ( ImplIsColorTransparent( aColor ) )
1380*cdf0e10cSrcweir 	{
1381*cdf0e10cSrcweir 		if ( mbFillColor )
1382*cdf0e10cSrcweir 		{
1383*cdf0e10cSrcweir 			mbInitFillColor = sal_True;
1384*cdf0e10cSrcweir 			mbFillColor = sal_False;
1385*cdf0e10cSrcweir 			maFillColor = Color( COL_TRANSPARENT );
1386*cdf0e10cSrcweir 		}
1387*cdf0e10cSrcweir 	}
1388*cdf0e10cSrcweir 	else
1389*cdf0e10cSrcweir 	{
1390*cdf0e10cSrcweir 		if ( maFillColor != aColor )
1391*cdf0e10cSrcweir 		{
1392*cdf0e10cSrcweir 			mbInitFillColor = sal_True;
1393*cdf0e10cSrcweir 			mbFillColor = sal_True;
1394*cdf0e10cSrcweir 			maFillColor = aColor;
1395*cdf0e10cSrcweir 		}
1396*cdf0e10cSrcweir 	}
1397*cdf0e10cSrcweir 
1398*cdf0e10cSrcweir     if( mpAlphaVDev )
1399*cdf0e10cSrcweir         mpAlphaVDev->SetFillColor( COL_BLACK );
1400*cdf0e10cSrcweir }
1401*cdf0e10cSrcweir 
1402*cdf0e10cSrcweir // -----------------------------------------------------------------------
1403*cdf0e10cSrcweir 
1404*cdf0e10cSrcweir void OutputDevice::SetBackground()
1405*cdf0e10cSrcweir {
1406*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::SetBackground()" );
1407*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1408*cdf0e10cSrcweir 
1409*cdf0e10cSrcweir 	maBackground = Wallpaper();
1410*cdf0e10cSrcweir 	mbBackground = sal_False;
1411*cdf0e10cSrcweir 
1412*cdf0e10cSrcweir     if( mpAlphaVDev )
1413*cdf0e10cSrcweir         mpAlphaVDev->SetBackground();
1414*cdf0e10cSrcweir }
1415*cdf0e10cSrcweir 
1416*cdf0e10cSrcweir // -----------------------------------------------------------------------
1417*cdf0e10cSrcweir 
1418*cdf0e10cSrcweir void OutputDevice::SetBackground( const Wallpaper& rBackground )
1419*cdf0e10cSrcweir {
1420*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::SetBackground( rBackground )" );
1421*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1422*cdf0e10cSrcweir 
1423*cdf0e10cSrcweir 	maBackground = rBackground;
1424*cdf0e10cSrcweir 
1425*cdf0e10cSrcweir 	if( rBackground.GetStyle() == WALLPAPER_NULL )
1426*cdf0e10cSrcweir 		mbBackground = sal_False;
1427*cdf0e10cSrcweir 	else
1428*cdf0e10cSrcweir 		mbBackground = sal_True;
1429*cdf0e10cSrcweir 
1430*cdf0e10cSrcweir     if( mpAlphaVDev )
1431*cdf0e10cSrcweir         mpAlphaVDev->SetBackground( rBackground );
1432*cdf0e10cSrcweir }
1433*cdf0e10cSrcweir 
1434*cdf0e10cSrcweir // -----------------------------------------------------------------------
1435*cdf0e10cSrcweir 
1436*cdf0e10cSrcweir void OutputDevice::SetRefPoint()
1437*cdf0e10cSrcweir {
1438*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::SetRefPoint()" );
1439*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1440*cdf0e10cSrcweir 
1441*cdf0e10cSrcweir 	if ( mpMetaFile )
1442*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaRefPointAction( Point(), sal_False ) );
1443*cdf0e10cSrcweir 
1444*cdf0e10cSrcweir 	mbRefPoint = sal_False;
1445*cdf0e10cSrcweir 	maRefPoint.X() = maRefPoint.Y() = 0L;
1446*cdf0e10cSrcweir 
1447*cdf0e10cSrcweir     if( mpAlphaVDev )
1448*cdf0e10cSrcweir         mpAlphaVDev->SetRefPoint();
1449*cdf0e10cSrcweir }
1450*cdf0e10cSrcweir 
1451*cdf0e10cSrcweir // -----------------------------------------------------------------------
1452*cdf0e10cSrcweir 
1453*cdf0e10cSrcweir void OutputDevice::SetRefPoint( const Point& rRefPoint )
1454*cdf0e10cSrcweir {
1455*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::SetRefPoint( rRefPoint )" );
1456*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1457*cdf0e10cSrcweir 
1458*cdf0e10cSrcweir 	if ( mpMetaFile )
1459*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaRefPointAction( rRefPoint, sal_True ) );
1460*cdf0e10cSrcweir 
1461*cdf0e10cSrcweir 	mbRefPoint = sal_True;
1462*cdf0e10cSrcweir 	maRefPoint = rRefPoint;
1463*cdf0e10cSrcweir 
1464*cdf0e10cSrcweir     if( mpAlphaVDev )
1465*cdf0e10cSrcweir         mpAlphaVDev->SetRefPoint( rRefPoint );
1466*cdf0e10cSrcweir }
1467*cdf0e10cSrcweir 
1468*cdf0e10cSrcweir // -----------------------------------------------------------------------
1469*cdf0e10cSrcweir 
1470*cdf0e10cSrcweir void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt )
1471*cdf0e10cSrcweir {
1472*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::DrawLine()" );
1473*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1474*cdf0e10cSrcweir 
1475*cdf0e10cSrcweir 	if ( mpMetaFile )
1476*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaLineAction( rStartPt, rEndPt ) );
1477*cdf0e10cSrcweir 
1478*cdf0e10cSrcweir 	if ( !IsDeviceOutputNecessary() || !mbLineColor || ImplIsRecordLayout() )
1479*cdf0e10cSrcweir 		return;
1480*cdf0e10cSrcweir 
1481*cdf0e10cSrcweir 	if ( !mpGraphics )
1482*cdf0e10cSrcweir 	{
1483*cdf0e10cSrcweir 		if ( !ImplGetGraphics() )
1484*cdf0e10cSrcweir 			return;
1485*cdf0e10cSrcweir 	}
1486*cdf0e10cSrcweir 
1487*cdf0e10cSrcweir 	if ( mbInitClipRegion )
1488*cdf0e10cSrcweir 		ImplInitClipRegion();
1489*cdf0e10cSrcweir 	if ( mbOutputClipped )
1490*cdf0e10cSrcweir 		return;
1491*cdf0e10cSrcweir 
1492*cdf0e10cSrcweir 	if ( mbInitLineColor )
1493*cdf0e10cSrcweir 		ImplInitLineColor();
1494*cdf0e10cSrcweir 
1495*cdf0e10cSrcweir 	// #i101598# support AA and snap for lines, too
1496*cdf0e10cSrcweir 	if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW)
1497*cdf0e10cSrcweir 		&& mpGraphics->supportsOperation(OutDevSupport_B2DDraw)
1498*cdf0e10cSrcweir 		&& ROP_OVERPAINT == GetRasterOp()
1499*cdf0e10cSrcweir 		&& IsLineColor())
1500*cdf0e10cSrcweir 	{
1501*cdf0e10cSrcweir 		// at least transform with double precision to device coordinates; this will
1502*cdf0e10cSrcweir 		// avoid pixel snap of single, appended lines
1503*cdf0e10cSrcweir 		const basegfx::B2DHomMatrix aTransform(ImplGetDeviceTransformation());
1504*cdf0e10cSrcweir         const basegfx::B2DVector aB2DLineWidth( 1.0, 1.0 );
1505*cdf0e10cSrcweir 		basegfx::B2DPolygon aB2DPolyLine;
1506*cdf0e10cSrcweir 
1507*cdf0e10cSrcweir 		aB2DPolyLine.append(basegfx::B2DPoint(rStartPt.X(), rStartPt.Y()));
1508*cdf0e10cSrcweir 		aB2DPolyLine.append(basegfx::B2DPoint(rEndPt.X(), rEndPt.Y()));
1509*cdf0e10cSrcweir 		aB2DPolyLine.transform( aTransform );
1510*cdf0e10cSrcweir 
1511*cdf0e10cSrcweir         if(mnAntialiasing & ANTIALIASING_PIXELSNAPHAIRLINE)
1512*cdf0e10cSrcweir         {
1513*cdf0e10cSrcweir             aB2DPolyLine = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aB2DPolyLine);
1514*cdf0e10cSrcweir         }
1515*cdf0e10cSrcweir 
1516*cdf0e10cSrcweir 		if( mpGraphics->DrawPolyLine( aB2DPolyLine, 0.0, aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this))
1517*cdf0e10cSrcweir 		{
1518*cdf0e10cSrcweir 			return;
1519*cdf0e10cSrcweir 		}
1520*cdf0e10cSrcweir 	}
1521*cdf0e10cSrcweir 
1522*cdf0e10cSrcweir 	const Point aStartPt(ImplLogicToDevicePixel(rStartPt));
1523*cdf0e10cSrcweir 	const Point aEndPt(ImplLogicToDevicePixel(rEndPt));
1524*cdf0e10cSrcweir 
1525*cdf0e10cSrcweir 	mpGraphics->DrawLine( aStartPt.X(), aStartPt.Y(), aEndPt.X(), aEndPt.Y(), this );
1526*cdf0e10cSrcweir 
1527*cdf0e10cSrcweir     if( mpAlphaVDev )
1528*cdf0e10cSrcweir         mpAlphaVDev->DrawLine( rStartPt, rEndPt );
1529*cdf0e10cSrcweir }
1530*cdf0e10cSrcweir 
1531*cdf0e10cSrcweir // -----------------------------------------------------------------------
1532*cdf0e10cSrcweir 
1533*cdf0e10cSrcweir void OutputDevice::impPaintLineGeometryWithEvtlExpand(
1534*cdf0e10cSrcweir     const LineInfo& rInfo,
1535*cdf0e10cSrcweir     basegfx::B2DPolyPolygon aLinePolyPolygon)
1536*cdf0e10cSrcweir {
1537*cdf0e10cSrcweir     const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW)
1538*cdf0e10cSrcweir         && mpGraphics->supportsOperation(OutDevSupport_B2DDraw)
1539*cdf0e10cSrcweir         && ROP_OVERPAINT == GetRasterOp()
1540*cdf0e10cSrcweir         && IsLineColor());
1541*cdf0e10cSrcweir     basegfx::B2DPolyPolygon aFillPolyPolygon;
1542*cdf0e10cSrcweir     const bool bDashUsed(LINE_DASH == rInfo.GetStyle());
1543*cdf0e10cSrcweir     const bool bLineWidthUsed(rInfo.GetWidth() > 1);
1544*cdf0e10cSrcweir 
1545*cdf0e10cSrcweir     if(bDashUsed && aLinePolyPolygon.count())
1546*cdf0e10cSrcweir     {
1547*cdf0e10cSrcweir         ::std::vector< double > fDotDashArray;
1548*cdf0e10cSrcweir         const double fDashLen(rInfo.GetDashLen());
1549*cdf0e10cSrcweir         const double fDotLen(rInfo.GetDotLen());
1550*cdf0e10cSrcweir         const double fDistance(rInfo.GetDistance());
1551*cdf0e10cSrcweir 
1552*cdf0e10cSrcweir         for(sal_uInt16 a(0); a < rInfo.GetDashCount(); a++)
1553*cdf0e10cSrcweir         {
1554*cdf0e10cSrcweir             fDotDashArray.push_back(fDashLen);
1555*cdf0e10cSrcweir             fDotDashArray.push_back(fDistance);
1556*cdf0e10cSrcweir         }
1557*cdf0e10cSrcweir 
1558*cdf0e10cSrcweir         for(sal_uInt16 b(0); b < rInfo.GetDotCount(); b++)
1559*cdf0e10cSrcweir         {
1560*cdf0e10cSrcweir             fDotDashArray.push_back(fDotLen);
1561*cdf0e10cSrcweir             fDotDashArray.push_back(fDistance);
1562*cdf0e10cSrcweir         }
1563*cdf0e10cSrcweir 
1564*cdf0e10cSrcweir         const double fAccumulated(::std::accumulate(fDotDashArray.begin(), fDotDashArray.end(), 0.0));
1565*cdf0e10cSrcweir 
1566*cdf0e10cSrcweir         if(fAccumulated > 0.0)
1567*cdf0e10cSrcweir         {
1568*cdf0e10cSrcweir             basegfx::B2DPolyPolygon aResult;
1569*cdf0e10cSrcweir 
1570*cdf0e10cSrcweir             for(sal_uInt32 c(0); c < aLinePolyPolygon.count(); c++)
1571*cdf0e10cSrcweir             {
1572*cdf0e10cSrcweir                 basegfx::B2DPolyPolygon aLineTraget;
1573*cdf0e10cSrcweir                 basegfx::tools::applyLineDashing(
1574*cdf0e10cSrcweir                     aLinePolyPolygon.getB2DPolygon(c),
1575*cdf0e10cSrcweir                     fDotDashArray,
1576*cdf0e10cSrcweir                     &aLineTraget);
1577*cdf0e10cSrcweir                 aResult.append(aLineTraget);
1578*cdf0e10cSrcweir             }
1579*cdf0e10cSrcweir 
1580*cdf0e10cSrcweir             aLinePolyPolygon = aResult;
1581*cdf0e10cSrcweir         }
1582*cdf0e10cSrcweir     }
1583*cdf0e10cSrcweir 
1584*cdf0e10cSrcweir     if(bLineWidthUsed && aLinePolyPolygon.count())
1585*cdf0e10cSrcweir     {
1586*cdf0e10cSrcweir 	    const double fHalfLineWidth((rInfo.GetWidth() * 0.5) + 0.5);
1587*cdf0e10cSrcweir 
1588*cdf0e10cSrcweir 		if(aLinePolyPolygon.areControlPointsUsed())
1589*cdf0e10cSrcweir 		{
1590*cdf0e10cSrcweir 			// #i110768# When area geometry has to be created, do not
1591*cdf0e10cSrcweir 			// use the fallback bezier decomposition inside createAreaGeometry,
1592*cdf0e10cSrcweir 			// but one that is at least as good as ImplSubdivideBezier was.
1593*cdf0e10cSrcweir 			// There, Polygon::AdaptiveSubdivide was used with default parameter
1594*cdf0e10cSrcweir 			// 1.0 as quality index.
1595*cdf0e10cSrcweir 			aLinePolyPolygon = basegfx::tools::adaptiveSubdivideByDistance(aLinePolyPolygon, 1.0);
1596*cdf0e10cSrcweir 		}
1597*cdf0e10cSrcweir 
1598*cdf0e10cSrcweir         for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++)
1599*cdf0e10cSrcweir         {
1600*cdf0e10cSrcweir 	        aFillPolyPolygon.append(basegfx::tools::createAreaGeometry(
1601*cdf0e10cSrcweir                 aLinePolyPolygon.getB2DPolygon(a),
1602*cdf0e10cSrcweir                 fHalfLineWidth,
1603*cdf0e10cSrcweir                 rInfo.GetLineJoin()));
1604*cdf0e10cSrcweir         }
1605*cdf0e10cSrcweir 
1606*cdf0e10cSrcweir         aLinePolyPolygon.clear();
1607*cdf0e10cSrcweir     }
1608*cdf0e10cSrcweir 
1609*cdf0e10cSrcweir     GDIMetaFile* pOldMetaFile = mpMetaFile;
1610*cdf0e10cSrcweir     mpMetaFile = NULL;
1611*cdf0e10cSrcweir 
1612*cdf0e10cSrcweir     if(aLinePolyPolygon.count())
1613*cdf0e10cSrcweir     {
1614*cdf0e10cSrcweir         for(sal_uInt32 a(0); a < aLinePolyPolygon.count(); a++)
1615*cdf0e10cSrcweir         {
1616*cdf0e10cSrcweir             const basegfx::B2DPolygon aCandidate(aLinePolyPolygon.getB2DPolygon(a));
1617*cdf0e10cSrcweir             bool bDone(false);
1618*cdf0e10cSrcweir 
1619*cdf0e10cSrcweir             if(bTryAA)
1620*cdf0e10cSrcweir             {
1621*cdf0e10cSrcweir                 bDone = mpGraphics->DrawPolyLine( aCandidate, 0.0, basegfx::B2DVector(1.0,1.0), basegfx::B2DLINEJOIN_NONE, this);
1622*cdf0e10cSrcweir             }
1623*cdf0e10cSrcweir 
1624*cdf0e10cSrcweir             if(!bDone)
1625*cdf0e10cSrcweir             {
1626*cdf0e10cSrcweir                 const Polygon aPolygon(aCandidate);
1627*cdf0e10cSrcweir 		        mpGraphics->DrawPolyLine(aPolygon.GetSize(), (const SalPoint*)aPolygon.GetConstPointAry(), this);
1628*cdf0e10cSrcweir             }
1629*cdf0e10cSrcweir         }
1630*cdf0e10cSrcweir     }
1631*cdf0e10cSrcweir 
1632*cdf0e10cSrcweir     if(aFillPolyPolygon.count())
1633*cdf0e10cSrcweir     {
1634*cdf0e10cSrcweir         const Color 	aOldLineColor( maLineColor );
1635*cdf0e10cSrcweir         const Color 	aOldFillColor( maFillColor );
1636*cdf0e10cSrcweir 
1637*cdf0e10cSrcweir         SetLineColor();
1638*cdf0e10cSrcweir         ImplInitLineColor();
1639*cdf0e10cSrcweir         SetFillColor( aOldLineColor );
1640*cdf0e10cSrcweir         ImplInitFillColor();
1641*cdf0e10cSrcweir 
1642*cdf0e10cSrcweir         bool bDone(false);
1643*cdf0e10cSrcweir 
1644*cdf0e10cSrcweir         if(bTryAA)
1645*cdf0e10cSrcweir         {
1646*cdf0e10cSrcweir             bDone = mpGraphics->DrawPolyPolygon(aFillPolyPolygon, 0.0, this);
1647*cdf0e10cSrcweir         }
1648*cdf0e10cSrcweir 
1649*cdf0e10cSrcweir         if(!bDone)
1650*cdf0e10cSrcweir         {
1651*cdf0e10cSrcweir             for(sal_uInt32 a(0); a < aFillPolyPolygon.count(); a++)
1652*cdf0e10cSrcweir             {
1653*cdf0e10cSrcweir                 const Polygon aPolygon(aFillPolyPolygon.getB2DPolygon(a));
1654*cdf0e10cSrcweir 			    mpGraphics->DrawPolygon(aPolygon.GetSize(), (const SalPoint*)aPolygon.GetConstPointAry(), this);
1655*cdf0e10cSrcweir             }
1656*cdf0e10cSrcweir         }
1657*cdf0e10cSrcweir 
1658*cdf0e10cSrcweir         SetFillColor( aOldFillColor );
1659*cdf0e10cSrcweir         SetLineColor( aOldLineColor );
1660*cdf0e10cSrcweir     }
1661*cdf0e10cSrcweir 
1662*cdf0e10cSrcweir     mpMetaFile = pOldMetaFile;
1663*cdf0e10cSrcweir }
1664*cdf0e10cSrcweir 
1665*cdf0e10cSrcweir // -----------------------------------------------------------------------
1666*cdf0e10cSrcweir 
1667*cdf0e10cSrcweir void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt,
1668*cdf0e10cSrcweir 							 const LineInfo& rLineInfo )
1669*cdf0e10cSrcweir {
1670*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::DrawLine()" );
1671*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1672*cdf0e10cSrcweir 
1673*cdf0e10cSrcweir 	if ( rLineInfo.IsDefault() )
1674*cdf0e10cSrcweir 	{
1675*cdf0e10cSrcweir 		DrawLine( rStartPt, rEndPt );
1676*cdf0e10cSrcweir 		return;
1677*cdf0e10cSrcweir 	}
1678*cdf0e10cSrcweir 
1679*cdf0e10cSrcweir 	if ( mpMetaFile )
1680*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaLineAction( rStartPt, rEndPt, rLineInfo ) );
1681*cdf0e10cSrcweir 
1682*cdf0e10cSrcweir 	if ( !IsDeviceOutputNecessary() || !mbLineColor || ( LINE_NONE == rLineInfo.GetStyle() ) || ImplIsRecordLayout() )
1683*cdf0e10cSrcweir 		return;
1684*cdf0e10cSrcweir 
1685*cdf0e10cSrcweir 	if( !mpGraphics && !ImplGetGraphics() )
1686*cdf0e10cSrcweir 		return;
1687*cdf0e10cSrcweir 
1688*cdf0e10cSrcweir 	if ( mbInitClipRegion )
1689*cdf0e10cSrcweir 		ImplInitClipRegion();
1690*cdf0e10cSrcweir 
1691*cdf0e10cSrcweir 	if ( mbOutputClipped )
1692*cdf0e10cSrcweir 		return;
1693*cdf0e10cSrcweir 
1694*cdf0e10cSrcweir 	const Point aStartPt( ImplLogicToDevicePixel( rStartPt ) );
1695*cdf0e10cSrcweir 	const Point aEndPt( ImplLogicToDevicePixel( rEndPt ) );
1696*cdf0e10cSrcweir 	const LineInfo aInfo( ImplLogicToDevicePixel( rLineInfo ) );
1697*cdf0e10cSrcweir     const bool bDashUsed(LINE_DASH == aInfo.GetStyle());
1698*cdf0e10cSrcweir     const bool bLineWidthUsed(aInfo.GetWidth() > 1);
1699*cdf0e10cSrcweir 
1700*cdf0e10cSrcweir     if ( mbInitLineColor )
1701*cdf0e10cSrcweir         ImplInitLineColor();
1702*cdf0e10cSrcweir 
1703*cdf0e10cSrcweir     if(bDashUsed || bLineWidthUsed)
1704*cdf0e10cSrcweir     {
1705*cdf0e10cSrcweir         basegfx::B2DPolygon aLinePolygon;
1706*cdf0e10cSrcweir         aLinePolygon.append(basegfx::B2DPoint(aStartPt.X(), aStartPt.Y()));
1707*cdf0e10cSrcweir         aLinePolygon.append(basegfx::B2DPoint(aEndPt.X(), aEndPt.Y()));
1708*cdf0e10cSrcweir 
1709*cdf0e10cSrcweir         impPaintLineGeometryWithEvtlExpand(aInfo, basegfx::B2DPolyPolygon(aLinePolygon));
1710*cdf0e10cSrcweir     }
1711*cdf0e10cSrcweir 	else
1712*cdf0e10cSrcweir 	{
1713*cdf0e10cSrcweir 		mpGraphics->DrawLine( aStartPt.X(), aStartPt.Y(), aEndPt.X(), aEndPt.Y(), this );
1714*cdf0e10cSrcweir 	}
1715*cdf0e10cSrcweir 
1716*cdf0e10cSrcweir     if( mpAlphaVDev )
1717*cdf0e10cSrcweir         mpAlphaVDev->DrawLine( rStartPt, rEndPt, rLineInfo );
1718*cdf0e10cSrcweir }
1719*cdf0e10cSrcweir 
1720*cdf0e10cSrcweir // -----------------------------------------------------------------------
1721*cdf0e10cSrcweir 
1722*cdf0e10cSrcweir void OutputDevice::DrawRect( const Rectangle& rRect )
1723*cdf0e10cSrcweir {
1724*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::DrawRect()" );
1725*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1726*cdf0e10cSrcweir 
1727*cdf0e10cSrcweir 	if ( mpMetaFile )
1728*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaRectAction( rRect ) );
1729*cdf0e10cSrcweir 
1730*cdf0e10cSrcweir 	if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
1731*cdf0e10cSrcweir 		return;
1732*cdf0e10cSrcweir 
1733*cdf0e10cSrcweir 	Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
1734*cdf0e10cSrcweir 
1735*cdf0e10cSrcweir 	if ( aRect.IsEmpty() )
1736*cdf0e10cSrcweir 		return;
1737*cdf0e10cSrcweir 	aRect.Justify();
1738*cdf0e10cSrcweir 
1739*cdf0e10cSrcweir 	if ( !mpGraphics )
1740*cdf0e10cSrcweir 	{
1741*cdf0e10cSrcweir 		if ( !ImplGetGraphics() )
1742*cdf0e10cSrcweir 			return;
1743*cdf0e10cSrcweir 	}
1744*cdf0e10cSrcweir 
1745*cdf0e10cSrcweir 	if ( mbInitClipRegion )
1746*cdf0e10cSrcweir 		ImplInitClipRegion();
1747*cdf0e10cSrcweir 	if ( mbOutputClipped )
1748*cdf0e10cSrcweir 		return;
1749*cdf0e10cSrcweir 
1750*cdf0e10cSrcweir 	if ( mbInitLineColor )
1751*cdf0e10cSrcweir 		ImplInitLineColor();
1752*cdf0e10cSrcweir 	if ( mbInitFillColor )
1753*cdf0e10cSrcweir 		ImplInitFillColor();
1754*cdf0e10cSrcweir 
1755*cdf0e10cSrcweir 	mpGraphics->DrawRect( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), this );
1756*cdf0e10cSrcweir 
1757*cdf0e10cSrcweir     if( mpAlphaVDev )
1758*cdf0e10cSrcweir         mpAlphaVDev->DrawRect( rRect );
1759*cdf0e10cSrcweir }
1760*cdf0e10cSrcweir 
1761*cdf0e10cSrcweir // -----------------------------------------------------------------------
1762*cdf0e10cSrcweir 
1763*cdf0e10cSrcweir void OutputDevice::DrawPolyLine( const Polygon& rPoly )
1764*cdf0e10cSrcweir {
1765*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::DrawPolyLine()" );
1766*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1767*cdf0e10cSrcweir 	DBG_CHKOBJ( &rPoly, Polygon, NULL );
1768*cdf0e10cSrcweir 
1769*cdf0e10cSrcweir 	if( mpMetaFile )
1770*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaPolyLineAction( rPoly ) );
1771*cdf0e10cSrcweir 
1772*cdf0e10cSrcweir 	sal_uInt16 nPoints = rPoly.GetSize();
1773*cdf0e10cSrcweir 
1774*cdf0e10cSrcweir 	if ( !IsDeviceOutputNecessary() || !mbLineColor || (nPoints < 2) || ImplIsRecordLayout() )
1775*cdf0e10cSrcweir 		return;
1776*cdf0e10cSrcweir 
1777*cdf0e10cSrcweir 	// we need a graphics
1778*cdf0e10cSrcweir 	if ( !mpGraphics )
1779*cdf0e10cSrcweir 		if ( !ImplGetGraphics() )
1780*cdf0e10cSrcweir 			return;
1781*cdf0e10cSrcweir 
1782*cdf0e10cSrcweir 	if ( mbInitClipRegion )
1783*cdf0e10cSrcweir 		ImplInitClipRegion();
1784*cdf0e10cSrcweir 	if ( mbOutputClipped )
1785*cdf0e10cSrcweir 		return;
1786*cdf0e10cSrcweir 
1787*cdf0e10cSrcweir 	if ( mbInitLineColor )
1788*cdf0e10cSrcweir 		ImplInitLineColor();
1789*cdf0e10cSrcweir 
1790*cdf0e10cSrcweir     const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW)
1791*cdf0e10cSrcweir         && mpGraphics->supportsOperation(OutDevSupport_B2DDraw)
1792*cdf0e10cSrcweir         && ROP_OVERPAINT == GetRasterOp()
1793*cdf0e10cSrcweir         && IsLineColor());
1794*cdf0e10cSrcweir 
1795*cdf0e10cSrcweir 	// use b2dpolygon drawing if possible
1796*cdf0e10cSrcweir 	if(bTryAA && ImpTryDrawPolyLineDirect(rPoly.getB2DPolygon(), 0.0, basegfx::B2DLINEJOIN_NONE))
1797*cdf0e10cSrcweir 	{
1798*cdf0e10cSrcweir 		basegfx::B2DPolygon aB2DPolyLine(rPoly.getB2DPolygon());
1799*cdf0e10cSrcweir 		const ::basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation();
1800*cdf0e10cSrcweir         const ::basegfx::B2DVector aB2DLineWidth( 1.0, 1.0 );
1801*cdf0e10cSrcweir 
1802*cdf0e10cSrcweir         // transform the polygon
1803*cdf0e10cSrcweir 		aB2DPolyLine.transform( aTransform );
1804*cdf0e10cSrcweir 
1805*cdf0e10cSrcweir         if(mnAntialiasing & ANTIALIASING_PIXELSNAPHAIRLINE)
1806*cdf0e10cSrcweir         {
1807*cdf0e10cSrcweir             aB2DPolyLine = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aB2DPolyLine);
1808*cdf0e10cSrcweir         }
1809*cdf0e10cSrcweir 
1810*cdf0e10cSrcweir 		if(mpGraphics->DrawPolyLine( aB2DPolyLine, 0.0, aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this))
1811*cdf0e10cSrcweir 		{
1812*cdf0e10cSrcweir 			return;
1813*cdf0e10cSrcweir 		}
1814*cdf0e10cSrcweir 	}
1815*cdf0e10cSrcweir 
1816*cdf0e10cSrcweir 	Polygon aPoly = ImplLogicToDevicePixel( rPoly );
1817*cdf0e10cSrcweir     const SalPoint* pPtAry = (const SalPoint*)aPoly.GetConstPointAry();
1818*cdf0e10cSrcweir 
1819*cdf0e10cSrcweir     // #100127# Forward beziers to sal, if any
1820*cdf0e10cSrcweir     if( aPoly.HasFlags() )
1821*cdf0e10cSrcweir     {
1822*cdf0e10cSrcweir         const sal_uInt8* pFlgAry = aPoly.GetConstFlagAry();
1823*cdf0e10cSrcweir         if( !mpGraphics->DrawPolyLineBezier( nPoints, pPtAry, pFlgAry, this ) )
1824*cdf0e10cSrcweir         {
1825*cdf0e10cSrcweir             aPoly = ImplSubdivideBezier(aPoly);
1826*cdf0e10cSrcweir             pPtAry = (const SalPoint*)aPoly.GetConstPointAry();
1827*cdf0e10cSrcweir             mpGraphics->DrawPolyLine( aPoly.GetSize(), pPtAry, this );
1828*cdf0e10cSrcweir         }
1829*cdf0e10cSrcweir     }
1830*cdf0e10cSrcweir     else
1831*cdf0e10cSrcweir     {
1832*cdf0e10cSrcweir         mpGraphics->DrawPolyLine( nPoints, pPtAry, this );
1833*cdf0e10cSrcweir     }
1834*cdf0e10cSrcweir 
1835*cdf0e10cSrcweir     if( mpAlphaVDev )
1836*cdf0e10cSrcweir         mpAlphaVDev->DrawPolyLine( rPoly );
1837*cdf0e10cSrcweir }
1838*cdf0e10cSrcweir 
1839*cdf0e10cSrcweir // -----------------------------------------------------------------------
1840*cdf0e10cSrcweir 
1841*cdf0e10cSrcweir void OutputDevice::DrawPolyLine( const Polygon& rPoly, const LineInfo& rLineInfo )
1842*cdf0e10cSrcweir {
1843*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::DrawPolyLine()" );
1844*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1845*cdf0e10cSrcweir 	DBG_CHKOBJ( &rPoly, Polygon, NULL );
1846*cdf0e10cSrcweir 
1847*cdf0e10cSrcweir 	if ( rLineInfo.IsDefault() )
1848*cdf0e10cSrcweir 	{
1849*cdf0e10cSrcweir 		DrawPolyLine( rPoly );
1850*cdf0e10cSrcweir 		return;
1851*cdf0e10cSrcweir 	}
1852*cdf0e10cSrcweir 
1853*cdf0e10cSrcweir     // #i101491#
1854*cdf0e10cSrcweir     // Try direct Fallback to B2D-Version of DrawPolyLine
1855*cdf0e10cSrcweir     if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW)
1856*cdf0e10cSrcweir         && LINE_SOLID == rLineInfo.GetStyle())
1857*cdf0e10cSrcweir     {
1858*cdf0e10cSrcweir 		DrawPolyLine( rPoly.getB2DPolygon(), (double)rLineInfo.GetWidth(), rLineInfo.GetLineJoin());
1859*cdf0e10cSrcweir 		return;
1860*cdf0e10cSrcweir     }
1861*cdf0e10cSrcweir 
1862*cdf0e10cSrcweir 	if ( mpMetaFile )
1863*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaPolyLineAction( rPoly, rLineInfo ) );
1864*cdf0e10cSrcweir 
1865*cdf0e10cSrcweir     ImpDrawPolyLineWithLineInfo(rPoly, rLineInfo);
1866*cdf0e10cSrcweir }
1867*cdf0e10cSrcweir 
1868*cdf0e10cSrcweir void OutputDevice::ImpDrawPolyLineWithLineInfo(const Polygon& rPoly, const LineInfo& rLineInfo)
1869*cdf0e10cSrcweir {
1870*cdf0e10cSrcweir 	sal_uInt16 nPoints(rPoly.GetSize());
1871*cdf0e10cSrcweir 
1872*cdf0e10cSrcweir 	if ( !IsDeviceOutputNecessary() || !mbLineColor || ( nPoints < 2 ) || ( LINE_NONE == rLineInfo.GetStyle() ) || ImplIsRecordLayout() )
1873*cdf0e10cSrcweir 		return;
1874*cdf0e10cSrcweir 
1875*cdf0e10cSrcweir     Polygon aPoly = ImplLogicToDevicePixel( rPoly );
1876*cdf0e10cSrcweir 
1877*cdf0e10cSrcweir     // #100127# LineInfo is not curve-safe, subdivide always
1878*cdf0e10cSrcweir     //
1879*cdf0e10cSrcweir     // What shall this mean? It's wrong to subdivide here when the
1880*cdf0e10cSrcweir     // polygon is a fat line. In that case, the painted geometry
1881*cdf0e10cSrcweir     // WILL be much different.
1882*cdf0e10cSrcweir     // I also have no idea how this could be related to the given ID
1883*cdf0e10cSrcweir     // which reads 'consolidate boost versions' in the task description.
1884*cdf0e10cSrcweir     // Removing.
1885*cdf0e10cSrcweir     //
1886*cdf0e10cSrcweir     //if( aPoly.HasFlags() )
1887*cdf0e10cSrcweir     //{
1888*cdf0e10cSrcweir     //    aPoly = ImplSubdivideBezier( aPoly );
1889*cdf0e10cSrcweir     //    nPoints = aPoly.GetSize();
1890*cdf0e10cSrcweir     //}
1891*cdf0e10cSrcweir 
1892*cdf0e10cSrcweir 	// we need a graphics
1893*cdf0e10cSrcweir 	if ( !mpGraphics && !ImplGetGraphics() )
1894*cdf0e10cSrcweir 		return;
1895*cdf0e10cSrcweir 
1896*cdf0e10cSrcweir 	if ( mbInitClipRegion )
1897*cdf0e10cSrcweir 		ImplInitClipRegion();
1898*cdf0e10cSrcweir 
1899*cdf0e10cSrcweir 	if ( mbOutputClipped )
1900*cdf0e10cSrcweir 		return;
1901*cdf0e10cSrcweir 
1902*cdf0e10cSrcweir 	if ( mbInitLineColor )
1903*cdf0e10cSrcweir 		ImplInitLineColor();
1904*cdf0e10cSrcweir 
1905*cdf0e10cSrcweir     const LineInfo aInfo( ImplLogicToDevicePixel( rLineInfo ) );
1906*cdf0e10cSrcweir     const bool bDashUsed(LINE_DASH == aInfo.GetStyle());
1907*cdf0e10cSrcweir     const bool bLineWidthUsed(aInfo.GetWidth() > 1);
1908*cdf0e10cSrcweir 
1909*cdf0e10cSrcweir     if(bDashUsed || bLineWidthUsed)
1910*cdf0e10cSrcweir     {
1911*cdf0e10cSrcweir         impPaintLineGeometryWithEvtlExpand(aInfo, basegfx::B2DPolyPolygon(aPoly.getB2DPolygon()));
1912*cdf0e10cSrcweir     }
1913*cdf0e10cSrcweir     else
1914*cdf0e10cSrcweir     {
1915*cdf0e10cSrcweir         // #100127# the subdivision HAS to be done here since only a pointer
1916*cdf0e10cSrcweir         // to an array of points is given to the DrawPolyLine method, there is
1917*cdf0e10cSrcweir         // NO way to find out there that it's a curve.
1918*cdf0e10cSrcweir         if( aPoly.HasFlags() )
1919*cdf0e10cSrcweir         {
1920*cdf0e10cSrcweir             aPoly = ImplSubdivideBezier( aPoly );
1921*cdf0e10cSrcweir             nPoints = aPoly.GetSize();
1922*cdf0e10cSrcweir         }
1923*cdf0e10cSrcweir 
1924*cdf0e10cSrcweir         mpGraphics->DrawPolyLine(nPoints, (const SalPoint*)aPoly.GetConstPointAry(), this);
1925*cdf0e10cSrcweir     }
1926*cdf0e10cSrcweir 
1927*cdf0e10cSrcweir     if( mpAlphaVDev )
1928*cdf0e10cSrcweir         mpAlphaVDev->DrawPolyLine( rPoly, rLineInfo );
1929*cdf0e10cSrcweir }
1930*cdf0e10cSrcweir 
1931*cdf0e10cSrcweir // -----------------------------------------------------------------------
1932*cdf0e10cSrcweir 
1933*cdf0e10cSrcweir void OutputDevice::DrawPolygon( const Polygon& rPoly )
1934*cdf0e10cSrcweir {
1935*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::DrawPolygon()" );
1936*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
1937*cdf0e10cSrcweir 	DBG_CHKOBJ( &rPoly, Polygon, NULL );
1938*cdf0e10cSrcweir 
1939*cdf0e10cSrcweir 	if( mpMetaFile )
1940*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaPolygonAction( rPoly ) );
1941*cdf0e10cSrcweir 
1942*cdf0e10cSrcweir 	sal_uInt16 nPoints = rPoly.GetSize();
1943*cdf0e10cSrcweir 
1944*cdf0e10cSrcweir 	if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || (nPoints < 2) || ImplIsRecordLayout() )
1945*cdf0e10cSrcweir 		return;
1946*cdf0e10cSrcweir 
1947*cdf0e10cSrcweir 	// we need a graphics
1948*cdf0e10cSrcweir 	if ( !mpGraphics )
1949*cdf0e10cSrcweir 		if ( !ImplGetGraphics() )
1950*cdf0e10cSrcweir 			return;
1951*cdf0e10cSrcweir 
1952*cdf0e10cSrcweir 	if ( mbInitClipRegion )
1953*cdf0e10cSrcweir 		ImplInitClipRegion();
1954*cdf0e10cSrcweir 	if ( mbOutputClipped )
1955*cdf0e10cSrcweir 		return;
1956*cdf0e10cSrcweir 
1957*cdf0e10cSrcweir 	if ( mbInitLineColor )
1958*cdf0e10cSrcweir 		ImplInitLineColor();
1959*cdf0e10cSrcweir 	if ( mbInitFillColor )
1960*cdf0e10cSrcweir 		ImplInitFillColor();
1961*cdf0e10cSrcweir 
1962*cdf0e10cSrcweir 	// use b2dpolygon drawing if possible
1963*cdf0e10cSrcweir 	if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW)
1964*cdf0e10cSrcweir 		&& mpGraphics->supportsOperation(OutDevSupport_B2DDraw)
1965*cdf0e10cSrcweir 		&& ROP_OVERPAINT == GetRasterOp()
1966*cdf0e10cSrcweir 		&& (IsLineColor() || IsFillColor()))
1967*cdf0e10cSrcweir 	{
1968*cdf0e10cSrcweir 		const ::basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation();
1969*cdf0e10cSrcweir 		basegfx::B2DPolygon aB2DPolygon(rPoly.getB2DPolygon());
1970*cdf0e10cSrcweir 		bool bSuccess(true);
1971*cdf0e10cSrcweir 
1972*cdf0e10cSrcweir         // transform the polygon and ensure closed
1973*cdf0e10cSrcweir 		aB2DPolygon.transform(aTransform);
1974*cdf0e10cSrcweir         aB2DPolygon.setClosed(true);
1975*cdf0e10cSrcweir 
1976*cdf0e10cSrcweir 		if(IsFillColor())
1977*cdf0e10cSrcweir 		{
1978*cdf0e10cSrcweir 			bSuccess = mpGraphics->DrawPolyPolygon(basegfx::B2DPolyPolygon(aB2DPolygon), 0.0, this);
1979*cdf0e10cSrcweir 		}
1980*cdf0e10cSrcweir 
1981*cdf0e10cSrcweir 		if(bSuccess && IsLineColor())
1982*cdf0e10cSrcweir 		{
1983*cdf0e10cSrcweir 			const ::basegfx::B2DVector aB2DLineWidth( 1.0, 1.0 );
1984*cdf0e10cSrcweir 
1985*cdf0e10cSrcweir 			if(mnAntialiasing & ANTIALIASING_PIXELSNAPHAIRLINE)
1986*cdf0e10cSrcweir 			{
1987*cdf0e10cSrcweir 				aB2DPolygon = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aB2DPolygon);
1988*cdf0e10cSrcweir 			}
1989*cdf0e10cSrcweir 
1990*cdf0e10cSrcweir 			bSuccess = mpGraphics->DrawPolyLine( aB2DPolygon, 0.0, aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this);
1991*cdf0e10cSrcweir 		}
1992*cdf0e10cSrcweir 
1993*cdf0e10cSrcweir 		if(bSuccess)
1994*cdf0e10cSrcweir 		{
1995*cdf0e10cSrcweir 			return;
1996*cdf0e10cSrcweir 		}
1997*cdf0e10cSrcweir 	}
1998*cdf0e10cSrcweir 
1999*cdf0e10cSrcweir 	Polygon aPoly = ImplLogicToDevicePixel( rPoly );
2000*cdf0e10cSrcweir 	const SalPoint* pPtAry = (const SalPoint*)aPoly.GetConstPointAry();
2001*cdf0e10cSrcweir 
2002*cdf0e10cSrcweir     // #100127# Forward beziers to sal, if any
2003*cdf0e10cSrcweir     if( aPoly.HasFlags() )
2004*cdf0e10cSrcweir     {
2005*cdf0e10cSrcweir         const sal_uInt8* pFlgAry = aPoly.GetConstFlagAry();
2006*cdf0e10cSrcweir         if( !mpGraphics->DrawPolygonBezier( nPoints, pPtAry, pFlgAry, this ) )
2007*cdf0e10cSrcweir         {
2008*cdf0e10cSrcweir             aPoly = ImplSubdivideBezier(aPoly);
2009*cdf0e10cSrcweir             pPtAry = (const SalPoint*)aPoly.GetConstPointAry();
2010*cdf0e10cSrcweir             mpGraphics->DrawPolygon( aPoly.GetSize(), pPtAry, this );
2011*cdf0e10cSrcweir         }
2012*cdf0e10cSrcweir     }
2013*cdf0e10cSrcweir     else
2014*cdf0e10cSrcweir     {
2015*cdf0e10cSrcweir         mpGraphics->DrawPolygon( nPoints, pPtAry, this );
2016*cdf0e10cSrcweir     }
2017*cdf0e10cSrcweir     if( mpAlphaVDev )
2018*cdf0e10cSrcweir         mpAlphaVDev->DrawPolygon( rPoly );
2019*cdf0e10cSrcweir }
2020*cdf0e10cSrcweir 
2021*cdf0e10cSrcweir // -----------------------------------------------------------------------
2022*cdf0e10cSrcweir 
2023*cdf0e10cSrcweir void OutputDevice::DrawPolyPolygon( const PolyPolygon& rPolyPoly )
2024*cdf0e10cSrcweir {
2025*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::DrawPolyPolygon()" );
2026*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
2027*cdf0e10cSrcweir 	DBG_CHKOBJ( &rPolyPoly, PolyPolygon, NULL );
2028*cdf0e10cSrcweir 
2029*cdf0e10cSrcweir 	if( mpMetaFile )
2030*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaPolyPolygonAction( rPolyPoly ) );
2031*cdf0e10cSrcweir 
2032*cdf0e10cSrcweir 	sal_uInt16 nPoly = rPolyPoly.Count();
2033*cdf0e10cSrcweir 
2034*cdf0e10cSrcweir 	if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || !nPoly || ImplIsRecordLayout() )
2035*cdf0e10cSrcweir 		return;
2036*cdf0e10cSrcweir 
2037*cdf0e10cSrcweir 	// we need a graphics
2038*cdf0e10cSrcweir 	if ( !mpGraphics )
2039*cdf0e10cSrcweir 		if ( !ImplGetGraphics() )
2040*cdf0e10cSrcweir 			return;
2041*cdf0e10cSrcweir 
2042*cdf0e10cSrcweir 	if ( mbInitClipRegion )
2043*cdf0e10cSrcweir 		ImplInitClipRegion();
2044*cdf0e10cSrcweir 	if ( mbOutputClipped )
2045*cdf0e10cSrcweir 		return;
2046*cdf0e10cSrcweir 
2047*cdf0e10cSrcweir 	if ( mbInitLineColor )
2048*cdf0e10cSrcweir 		ImplInitLineColor();
2049*cdf0e10cSrcweir 	if ( mbInitFillColor )
2050*cdf0e10cSrcweir 		ImplInitFillColor();
2051*cdf0e10cSrcweir 
2052*cdf0e10cSrcweir 	// use b2dpolygon drawing if possible
2053*cdf0e10cSrcweir 	if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW)
2054*cdf0e10cSrcweir 		&& mpGraphics->supportsOperation(OutDevSupport_B2DDraw)
2055*cdf0e10cSrcweir 		&& ROP_OVERPAINT == GetRasterOp()
2056*cdf0e10cSrcweir 		&& (IsLineColor() || IsFillColor()))
2057*cdf0e10cSrcweir 	{
2058*cdf0e10cSrcweir 		const ::basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation();
2059*cdf0e10cSrcweir 		basegfx::B2DPolyPolygon aB2DPolyPolygon(rPolyPoly.getB2DPolyPolygon());
2060*cdf0e10cSrcweir 		bool bSuccess(true);
2061*cdf0e10cSrcweir 
2062*cdf0e10cSrcweir 		// transform the polygon and ensure closed
2063*cdf0e10cSrcweir 		aB2DPolyPolygon.transform(aTransform);
2064*cdf0e10cSrcweir         aB2DPolyPolygon.setClosed(true);
2065*cdf0e10cSrcweir 
2066*cdf0e10cSrcweir 		if(IsFillColor())
2067*cdf0e10cSrcweir 		{
2068*cdf0e10cSrcweir 			bSuccess = mpGraphics->DrawPolyPolygon(aB2DPolyPolygon, 0.0, this);
2069*cdf0e10cSrcweir 		}
2070*cdf0e10cSrcweir 
2071*cdf0e10cSrcweir 		if(bSuccess && IsLineColor())
2072*cdf0e10cSrcweir 		{
2073*cdf0e10cSrcweir 			const ::basegfx::B2DVector aB2DLineWidth( 1.0, 1.0 );
2074*cdf0e10cSrcweir 
2075*cdf0e10cSrcweir 			if(mnAntialiasing & ANTIALIASING_PIXELSNAPHAIRLINE)
2076*cdf0e10cSrcweir 			{
2077*cdf0e10cSrcweir 				aB2DPolyPolygon = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aB2DPolyPolygon);
2078*cdf0e10cSrcweir 			}
2079*cdf0e10cSrcweir 
2080*cdf0e10cSrcweir 			for(sal_uInt32 a(0); bSuccess && a < aB2DPolyPolygon.count(); a++)
2081*cdf0e10cSrcweir 			{
2082*cdf0e10cSrcweir 				bSuccess = mpGraphics->DrawPolyLine( aB2DPolyPolygon.getB2DPolygon(a), 0.0, aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this);
2083*cdf0e10cSrcweir 			}
2084*cdf0e10cSrcweir 		}
2085*cdf0e10cSrcweir 
2086*cdf0e10cSrcweir 		if(bSuccess)
2087*cdf0e10cSrcweir 		{
2088*cdf0e10cSrcweir 			return;
2089*cdf0e10cSrcweir 		}
2090*cdf0e10cSrcweir 	}
2091*cdf0e10cSrcweir 
2092*cdf0e10cSrcweir 	if ( nPoly == 1 )
2093*cdf0e10cSrcweir 	{
2094*cdf0e10cSrcweir         // #100127# Map to DrawPolygon
2095*cdf0e10cSrcweir         Polygon aPoly = rPolyPoly.GetObject( 0 );
2096*cdf0e10cSrcweir 		if( aPoly.GetSize() >= 2 )
2097*cdf0e10cSrcweir         {
2098*cdf0e10cSrcweir             GDIMetaFile* pOldMF = mpMetaFile;
2099*cdf0e10cSrcweir             mpMetaFile = NULL;
2100*cdf0e10cSrcweir 
2101*cdf0e10cSrcweir 			DrawPolygon( aPoly );
2102*cdf0e10cSrcweir 
2103*cdf0e10cSrcweir             mpMetaFile = pOldMF;
2104*cdf0e10cSrcweir         }
2105*cdf0e10cSrcweir 	}
2106*cdf0e10cSrcweir 	else
2107*cdf0e10cSrcweir 	{
2108*cdf0e10cSrcweir         // #100127# moved real PolyPolygon draw to separate method,
2109*cdf0e10cSrcweir         // have to call recursively, avoiding duplicate
2110*cdf0e10cSrcweir         // ImplLogicToDevicePixel calls
2111*cdf0e10cSrcweir         ImplDrawPolyPolygon( nPoly, ImplLogicToDevicePixel( rPolyPoly ) );
2112*cdf0e10cSrcweir 	}
2113*cdf0e10cSrcweir     if( mpAlphaVDev )
2114*cdf0e10cSrcweir         mpAlphaVDev->DrawPolyPolygon( rPolyPoly );
2115*cdf0e10cSrcweir }
2116*cdf0e10cSrcweir 
2117*cdf0e10cSrcweir // -----------------------------------------------------------------------
2118*cdf0e10cSrcweir 
2119*cdf0e10cSrcweir void OutputDevice::DrawPolygon( const ::basegfx::B2DPolygon& rB2DPolygon)
2120*cdf0e10cSrcweir {
2121*cdf0e10cSrcweir     // AW: Do NOT paint empty polygons
2122*cdf0e10cSrcweir     if(rB2DPolygon.count())
2123*cdf0e10cSrcweir     {
2124*cdf0e10cSrcweir         ::basegfx::B2DPolyPolygon aPP( rB2DPolygon );
2125*cdf0e10cSrcweir         DrawPolyPolygon( aPP );
2126*cdf0e10cSrcweir     }
2127*cdf0e10cSrcweir }
2128*cdf0e10cSrcweir 
2129*cdf0e10cSrcweir // -----------------------------------------------------------------------
2130*cdf0e10cSrcweir // Caution: This method is nearly the same as
2131*cdf0e10cSrcweir // OutputDevice::DrawTransparent( const basegfx::B2DPolyPolygon& rB2DPolyPoly, double fTransparency),
2132*cdf0e10cSrcweir // so when changes are made here do not forget to make change sthere, too
2133*cdf0e10cSrcweir 
2134*cdf0e10cSrcweir void OutputDevice::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rB2DPolyPoly )
2135*cdf0e10cSrcweir {
2136*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::DrawPolyPolygon(B2D&)" );
2137*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
2138*cdf0e10cSrcweir 
2139*cdf0e10cSrcweir #if 0
2140*cdf0e10cSrcweir     // MetaB2DPolyPolygonAction is not implemented yet:
2141*cdf0e10cSrcweir     // according to AW adding it is very dangerous since there is a lot
2142*cdf0e10cSrcweir     // of code that uses the metafile actions directly and unless every
2143*cdf0e10cSrcweir     // place that does this knows about the new action we need to fallback
2144*cdf0e10cSrcweir     if( mpMetaFile )
2145*cdf0e10cSrcweir         mpMetaFile->AddAction( new MetaB2DPolyPolygonAction( rB2DPolyPoly ) );
2146*cdf0e10cSrcweir #else
2147*cdf0e10cSrcweir     if( mpMetaFile )
2148*cdf0e10cSrcweir         mpMetaFile->AddAction( new MetaPolyPolygonAction( PolyPolygon( rB2DPolyPoly ) ) );
2149*cdf0e10cSrcweir #endif
2150*cdf0e10cSrcweir 
2151*cdf0e10cSrcweir 	// call helper
2152*cdf0e10cSrcweir 	ImpDrawPolyPolygonWithB2DPolyPolygon(rB2DPolyPoly);
2153*cdf0e10cSrcweir }
2154*cdf0e10cSrcweir 
2155*cdf0e10cSrcweir void OutputDevice::ImpDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyPolygon& rB2DPolyPoly)
2156*cdf0e10cSrcweir {
2157*cdf0e10cSrcweir     // AW: Do NOT paint empty PolyPolygons
2158*cdf0e10cSrcweir     if(!rB2DPolyPoly.count())
2159*cdf0e10cSrcweir         return;
2160*cdf0e10cSrcweir 
2161*cdf0e10cSrcweir     // we need a graphics
2162*cdf0e10cSrcweir     if( !mpGraphics )
2163*cdf0e10cSrcweir 	    if( !ImplGetGraphics() )
2164*cdf0e10cSrcweir 		    return;
2165*cdf0e10cSrcweir 
2166*cdf0e10cSrcweir     if( mbInitClipRegion )
2167*cdf0e10cSrcweir 	    ImplInitClipRegion();
2168*cdf0e10cSrcweir     if( mbOutputClipped )
2169*cdf0e10cSrcweir 	    return;
2170*cdf0e10cSrcweir 
2171*cdf0e10cSrcweir     if( mbInitLineColor )
2172*cdf0e10cSrcweir 	    ImplInitLineColor();
2173*cdf0e10cSrcweir     if( mbInitFillColor )
2174*cdf0e10cSrcweir 	    ImplInitFillColor();
2175*cdf0e10cSrcweir 
2176*cdf0e10cSrcweir 	if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW)
2177*cdf0e10cSrcweir 		&& mpGraphics->supportsOperation(OutDevSupport_B2DDraw)
2178*cdf0e10cSrcweir 		&& ROP_OVERPAINT == GetRasterOp()
2179*cdf0e10cSrcweir 		&& (IsLineColor() || IsFillColor()))
2180*cdf0e10cSrcweir     {
2181*cdf0e10cSrcweir 		const basegfx::B2DHomMatrix aTransform(ImplGetDeviceTransformation());
2182*cdf0e10cSrcweir 		basegfx::B2DPolyPolygon aB2DPolyPolygon(rB2DPolyPoly);
2183*cdf0e10cSrcweir 		bool bSuccess(true);
2184*cdf0e10cSrcweir 
2185*cdf0e10cSrcweir 		// transform the polygon and ensure closed
2186*cdf0e10cSrcweir 		aB2DPolyPolygon.transform(aTransform);
2187*cdf0e10cSrcweir         aB2DPolyPolygon.setClosed(true);
2188*cdf0e10cSrcweir 
2189*cdf0e10cSrcweir 		if(IsFillColor())
2190*cdf0e10cSrcweir 		{
2191*cdf0e10cSrcweir 			bSuccess = mpGraphics->DrawPolyPolygon(aB2DPolyPolygon, 0.0, this);
2192*cdf0e10cSrcweir 		}
2193*cdf0e10cSrcweir 
2194*cdf0e10cSrcweir 		if(bSuccess && IsLineColor())
2195*cdf0e10cSrcweir 		{
2196*cdf0e10cSrcweir 			const ::basegfx::B2DVector aB2DLineWidth( 1.0, 1.0 );
2197*cdf0e10cSrcweir 
2198*cdf0e10cSrcweir 			if(mnAntialiasing & ANTIALIASING_PIXELSNAPHAIRLINE)
2199*cdf0e10cSrcweir 			{
2200*cdf0e10cSrcweir 				aB2DPolyPolygon = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aB2DPolyPolygon);
2201*cdf0e10cSrcweir 			}
2202*cdf0e10cSrcweir 
2203*cdf0e10cSrcweir 			for(sal_uInt32 a(0);bSuccess && a < aB2DPolyPolygon.count(); a++)
2204*cdf0e10cSrcweir 			{
2205*cdf0e10cSrcweir 				bSuccess = mpGraphics->DrawPolyLine( aB2DPolyPolygon.getB2DPolygon(a), 0.0, aB2DLineWidth, basegfx::B2DLINEJOIN_NONE, this);
2206*cdf0e10cSrcweir 			}
2207*cdf0e10cSrcweir 		}
2208*cdf0e10cSrcweir 
2209*cdf0e10cSrcweir 		if(bSuccess)
2210*cdf0e10cSrcweir 		{
2211*cdf0e10cSrcweir 			return;
2212*cdf0e10cSrcweir 		}
2213*cdf0e10cSrcweir     }
2214*cdf0e10cSrcweir 
2215*cdf0e10cSrcweir     // fallback to old polygon drawing if needed
2216*cdf0e10cSrcweir     const PolyPolygon aToolsPolyPolygon( rB2DPolyPoly );
2217*cdf0e10cSrcweir     const PolyPolygon aPixelPolyPolygon = ImplLogicToDevicePixel( aToolsPolyPolygon );
2218*cdf0e10cSrcweir     ImplDrawPolyPolygon( aPixelPolyPolygon.Count(), aPixelPolyPolygon );
2219*cdf0e10cSrcweir }
2220*cdf0e10cSrcweir 
2221*cdf0e10cSrcweir // -----------------------------------------------------------------------
2222*cdf0e10cSrcweir 
2223*cdf0e10cSrcweir bool OutputDevice::ImpTryDrawPolyLineDirect(
2224*cdf0e10cSrcweir 	const basegfx::B2DPolygon& rB2DPolygon,
2225*cdf0e10cSrcweir     double fLineWidth,
2226*cdf0e10cSrcweir     basegfx::B2DLineJoin eLineJoin)
2227*cdf0e10cSrcweir {
2228*cdf0e10cSrcweir     const basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation();
2229*cdf0e10cSrcweir     basegfx::B2DVector aB2DLineWidth(1.0, 1.0);
2230*cdf0e10cSrcweir 
2231*cdf0e10cSrcweir 	// transform the line width if used
2232*cdf0e10cSrcweir     if( fLineWidth != 0.0 )
2233*cdf0e10cSrcweir 	{
2234*cdf0e10cSrcweir         aB2DLineWidth = aTransform * ::basegfx::B2DVector( fLineWidth, fLineWidth );
2235*cdf0e10cSrcweir 	}
2236*cdf0e10cSrcweir 
2237*cdf0e10cSrcweir     // transform the polygon
2238*cdf0e10cSrcweir     basegfx::B2DPolygon aB2DPolygon(rB2DPolygon);
2239*cdf0e10cSrcweir     aB2DPolygon.transform(aTransform);
2240*cdf0e10cSrcweir 
2241*cdf0e10cSrcweir     if((mnAntialiasing & ANTIALIASING_PIXELSNAPHAIRLINE)
2242*cdf0e10cSrcweir 		&& aB2DPolygon.count() < 1000)
2243*cdf0e10cSrcweir     {
2244*cdf0e10cSrcweir 		// #i98289#, #i101491#
2245*cdf0e10cSrcweir         // better to remove doubles on device coordinates. Also assume from a given amount
2246*cdf0e10cSrcweir         // of points that the single edges are not long enough to smooth
2247*cdf0e10cSrcweir         aB2DPolygon.removeDoublePoints();
2248*cdf0e10cSrcweir         aB2DPolygon = basegfx::tools::snapPointsOfHorizontalOrVerticalEdges(aB2DPolygon);
2249*cdf0e10cSrcweir     }
2250*cdf0e10cSrcweir 
2251*cdf0e10cSrcweir     // draw the polyline
2252*cdf0e10cSrcweir     return mpGraphics->DrawPolyLine( aB2DPolygon, 0.0, aB2DLineWidth, eLineJoin, this);
2253*cdf0e10cSrcweir }
2254*cdf0e10cSrcweir 
2255*cdf0e10cSrcweir void OutputDevice::DrawPolyLine(
2256*cdf0e10cSrcweir     const basegfx::B2DPolygon& rB2DPolygon,
2257*cdf0e10cSrcweir     double fLineWidth,
2258*cdf0e10cSrcweir     basegfx::B2DLineJoin eLineJoin)
2259*cdf0e10cSrcweir {
2260*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::DrawPolyLine(B2D&)" );
2261*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
2262*cdf0e10cSrcweir     (void)eLineJoin; // ATM used in UNX, but not in WNT, access it for warning-free
2263*cdf0e10cSrcweir 
2264*cdf0e10cSrcweir #if 0 // MetaB2DPolyLineAction is not implemented yet:
2265*cdf0e10cSrcweir       // according to AW adding it is very dangerous since there is a lot
2266*cdf0e10cSrcweir       // of code that uses the metafile actions directly and unless every
2267*cdf0e10cSrcweir       // place that does this knows about the new action we need to fallback
2268*cdf0e10cSrcweir     if( mpMetaFile )
2269*cdf0e10cSrcweir         mpMetaFile->AddAction( new MetaB2DPolyLineAction( rB2DPolygon ) );
2270*cdf0e10cSrcweir #else
2271*cdf0e10cSrcweir     if( mpMetaFile )
2272*cdf0e10cSrcweir     {
2273*cdf0e10cSrcweir         LineInfo aLineInfo;
2274*cdf0e10cSrcweir         if( fLineWidth != 0.0 )
2275*cdf0e10cSrcweir             aLineInfo.SetWidth( static_cast<long>(fLineWidth+0.5) );
2276*cdf0e10cSrcweir         const Polygon aToolsPolygon( rB2DPolygon );
2277*cdf0e10cSrcweir         mpMetaFile->AddAction( new MetaPolyLineAction( aToolsPolygon, aLineInfo ) );
2278*cdf0e10cSrcweir     }
2279*cdf0e10cSrcweir #endif
2280*cdf0e10cSrcweir 
2281*cdf0e10cSrcweir     // AW: Do NOT paint empty PolyPolygons
2282*cdf0e10cSrcweir     if(!rB2DPolygon.count())
2283*cdf0e10cSrcweir         return;
2284*cdf0e10cSrcweir 
2285*cdf0e10cSrcweir     // we need a graphics
2286*cdf0e10cSrcweir 	if( !mpGraphics )
2287*cdf0e10cSrcweir 		if( !ImplGetGraphics() )
2288*cdf0e10cSrcweir 			return;
2289*cdf0e10cSrcweir 
2290*cdf0e10cSrcweir 	if( mbInitClipRegion )
2291*cdf0e10cSrcweir 		ImplInitClipRegion();
2292*cdf0e10cSrcweir 	if( mbOutputClipped )
2293*cdf0e10cSrcweir 		return;
2294*cdf0e10cSrcweir 
2295*cdf0e10cSrcweir 	if( mbInitLineColor )
2296*cdf0e10cSrcweir 		ImplInitLineColor();
2297*cdf0e10cSrcweir 
2298*cdf0e10cSrcweir     const bool bTryAA((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW)
2299*cdf0e10cSrcweir         && mpGraphics->supportsOperation(OutDevSupport_B2DDraw)
2300*cdf0e10cSrcweir         && ROP_OVERPAINT == GetRasterOp()
2301*cdf0e10cSrcweir         && IsLineColor());
2302*cdf0e10cSrcweir 
2303*cdf0e10cSrcweir 	// use b2dpolygon drawing if possible
2304*cdf0e10cSrcweir 	if(bTryAA && ImpTryDrawPolyLineDirect(rB2DPolygon, fLineWidth, eLineJoin))
2305*cdf0e10cSrcweir 	{
2306*cdf0e10cSrcweir 		return;
2307*cdf0e10cSrcweir 	}
2308*cdf0e10cSrcweir 
2309*cdf0e10cSrcweir 	// #i101491#
2310*cdf0e10cSrcweir 	// no output yet; fallback to geometry decomposition and use filled polygon paint
2311*cdf0e10cSrcweir 	// when line is fat and not too complex. ImpDrawPolyPolygonWithB2DPolyPolygon
2312*cdf0e10cSrcweir 	// will do internal needed AA checks etc.
2313*cdf0e10cSrcweir 	if(fLineWidth >= 2.5
2314*cdf0e10cSrcweir 		&& rB2DPolygon.count()
2315*cdf0e10cSrcweir 		&& rB2DPolygon.count() <= 1000)
2316*cdf0e10cSrcweir 	{
2317*cdf0e10cSrcweir 		const double fHalfLineWidth((fLineWidth * 0.5) + 0.5);
2318*cdf0e10cSrcweir 		const basegfx::B2DPolyPolygon aAreaPolyPolygon(basegfx::tools::createAreaGeometry(
2319*cdf0e10cSrcweir 			rB2DPolygon, fHalfLineWidth, eLineJoin));
2320*cdf0e10cSrcweir 
2321*cdf0e10cSrcweir 		const Color aOldLineColor(maLineColor);
2322*cdf0e10cSrcweir 		const Color aOldFillColor(maFillColor);
2323*cdf0e10cSrcweir 
2324*cdf0e10cSrcweir 		SetLineColor();
2325*cdf0e10cSrcweir 		ImplInitLineColor();
2326*cdf0e10cSrcweir 		SetFillColor(aOldLineColor);
2327*cdf0e10cSrcweir 		ImplInitFillColor();
2328*cdf0e10cSrcweir 
2329*cdf0e10cSrcweir 		// draw usig a loop; else the topology will paint a PolyPolygon
2330*cdf0e10cSrcweir 		for(sal_uInt32 a(0); a < aAreaPolyPolygon.count(); a++)
2331*cdf0e10cSrcweir 		{
2332*cdf0e10cSrcweir 			ImpDrawPolyPolygonWithB2DPolyPolygon(
2333*cdf0e10cSrcweir 				basegfx::B2DPolyPolygon(aAreaPolyPolygon.getB2DPolygon(a)));
2334*cdf0e10cSrcweir 		}
2335*cdf0e10cSrcweir 
2336*cdf0e10cSrcweir         SetLineColor(aOldLineColor);
2337*cdf0e10cSrcweir 		ImplInitLineColor();
2338*cdf0e10cSrcweir 		SetFillColor(aOldFillColor);
2339*cdf0e10cSrcweir 		ImplInitFillColor();
2340*cdf0e10cSrcweir 
2341*cdf0e10cSrcweir 		if(bTryAA)
2342*cdf0e10cSrcweir 		{
2343*cdf0e10cSrcweir 			// when AA it is necessary to also paint the filled polygon's outline
2344*cdf0e10cSrcweir 			// to avoid optical gaps
2345*cdf0e10cSrcweir 			for(sal_uInt32 a(0); a < aAreaPolyPolygon.count(); a++)
2346*cdf0e10cSrcweir 			{
2347*cdf0e10cSrcweir 				ImpTryDrawPolyLineDirect(aAreaPolyPolygon.getB2DPolygon(a), 0.0, basegfx::B2DLINEJOIN_NONE);
2348*cdf0e10cSrcweir 			}
2349*cdf0e10cSrcweir 		}
2350*cdf0e10cSrcweir 	}
2351*cdf0e10cSrcweir 	else
2352*cdf0e10cSrcweir 	{
2353*cdf0e10cSrcweir 		// fallback to old polygon drawing if needed
2354*cdf0e10cSrcweir 		const Polygon aToolsPolygon( rB2DPolygon );
2355*cdf0e10cSrcweir 		LineInfo aLineInfo;
2356*cdf0e10cSrcweir 		if( fLineWidth != 0.0 )
2357*cdf0e10cSrcweir 			aLineInfo.SetWidth( static_cast<long>(fLineWidth+0.5) );
2358*cdf0e10cSrcweir 		ImpDrawPolyLineWithLineInfo( aToolsPolygon, aLineInfo );
2359*cdf0e10cSrcweir 	}
2360*cdf0e10cSrcweir }
2361*cdf0e10cSrcweir 
2362*cdf0e10cSrcweir // -----------------------------------------------------------------------
2363*cdf0e10cSrcweir 
2364*cdf0e10cSrcweir sal_uInt32 OutputDevice::GetGCStackDepth() const
2365*cdf0e10cSrcweir {
2366*cdf0e10cSrcweir     const ImplObjStack* pData = mpObjStack;
2367*cdf0e10cSrcweir     sal_uInt32 nDepth = 0;
2368*cdf0e10cSrcweir     while( pData )
2369*cdf0e10cSrcweir     {
2370*cdf0e10cSrcweir         nDepth++;
2371*cdf0e10cSrcweir         pData = pData->mpPrev;
2372*cdf0e10cSrcweir     }
2373*cdf0e10cSrcweir     return nDepth;
2374*cdf0e10cSrcweir }
2375*cdf0e10cSrcweir 
2376*cdf0e10cSrcweir // -----------------------------------------------------------------------
2377*cdf0e10cSrcweir 
2378*cdf0e10cSrcweir void OutputDevice::Push( sal_uInt16 nFlags )
2379*cdf0e10cSrcweir {
2380*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::Push()" );
2381*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
2382*cdf0e10cSrcweir 
2383*cdf0e10cSrcweir 	if ( mpMetaFile )
2384*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaPushAction( nFlags ) );
2385*cdf0e10cSrcweir 
2386*cdf0e10cSrcweir 	ImplObjStack* pData = new ImplObjStack;
2387*cdf0e10cSrcweir 	pData->mpPrev = mpObjStack;
2388*cdf0e10cSrcweir 	mpObjStack = pData;
2389*cdf0e10cSrcweir 
2390*cdf0e10cSrcweir 	pData->mnFlags = nFlags;
2391*cdf0e10cSrcweir 
2392*cdf0e10cSrcweir 	if ( nFlags & PUSH_LINECOLOR )
2393*cdf0e10cSrcweir 	{
2394*cdf0e10cSrcweir 		if ( mbLineColor )
2395*cdf0e10cSrcweir 			pData->mpLineColor = new Color( maLineColor );
2396*cdf0e10cSrcweir 		else
2397*cdf0e10cSrcweir 			pData->mpLineColor = NULL;
2398*cdf0e10cSrcweir 	}
2399*cdf0e10cSrcweir 	if ( nFlags & PUSH_FILLCOLOR )
2400*cdf0e10cSrcweir 	{
2401*cdf0e10cSrcweir 		if ( mbFillColor )
2402*cdf0e10cSrcweir 			pData->mpFillColor = new Color( maFillColor );
2403*cdf0e10cSrcweir 		else
2404*cdf0e10cSrcweir 			pData->mpFillColor = NULL;
2405*cdf0e10cSrcweir 	}
2406*cdf0e10cSrcweir 	if ( nFlags & PUSH_FONT )
2407*cdf0e10cSrcweir 		pData->mpFont = new Font( maFont );
2408*cdf0e10cSrcweir 	if ( nFlags & PUSH_TEXTCOLOR )
2409*cdf0e10cSrcweir 		pData->mpTextColor = new Color( GetTextColor() );
2410*cdf0e10cSrcweir 	if ( nFlags & PUSH_TEXTFILLCOLOR )
2411*cdf0e10cSrcweir 	{
2412*cdf0e10cSrcweir 		if ( IsTextFillColor() )
2413*cdf0e10cSrcweir 			pData->mpTextFillColor = new Color( GetTextFillColor() );
2414*cdf0e10cSrcweir 		else
2415*cdf0e10cSrcweir 			pData->mpTextFillColor = NULL;
2416*cdf0e10cSrcweir 	}
2417*cdf0e10cSrcweir 	if ( nFlags & PUSH_TEXTLINECOLOR )
2418*cdf0e10cSrcweir 	{
2419*cdf0e10cSrcweir 		if ( IsTextLineColor() )
2420*cdf0e10cSrcweir 			pData->mpTextLineColor = new Color( GetTextLineColor() );
2421*cdf0e10cSrcweir 		else
2422*cdf0e10cSrcweir 			pData->mpTextLineColor = NULL;
2423*cdf0e10cSrcweir 	}
2424*cdf0e10cSrcweir 	if ( nFlags & PUSH_OVERLINECOLOR )
2425*cdf0e10cSrcweir 	{
2426*cdf0e10cSrcweir 		if ( IsOverlineColor() )
2427*cdf0e10cSrcweir 			pData->mpOverlineColor = new Color( GetOverlineColor() );
2428*cdf0e10cSrcweir 		else
2429*cdf0e10cSrcweir 			pData->mpOverlineColor = NULL;
2430*cdf0e10cSrcweir 	}
2431*cdf0e10cSrcweir 	if ( nFlags & PUSH_TEXTALIGN )
2432*cdf0e10cSrcweir 		pData->meTextAlign = GetTextAlign();
2433*cdf0e10cSrcweir 	if( nFlags & PUSH_TEXTLAYOUTMODE )
2434*cdf0e10cSrcweir 		pData->mnTextLayoutMode = GetLayoutMode();
2435*cdf0e10cSrcweir 	if( nFlags & PUSH_TEXTLANGUAGE )
2436*cdf0e10cSrcweir 		pData->meTextLanguage = GetDigitLanguage();
2437*cdf0e10cSrcweir 	if ( nFlags & PUSH_RASTEROP )
2438*cdf0e10cSrcweir 		pData->meRasterOp = GetRasterOp();
2439*cdf0e10cSrcweir 	if ( nFlags & PUSH_MAPMODE )
2440*cdf0e10cSrcweir 	{
2441*cdf0e10cSrcweir 		if ( mbMap )
2442*cdf0e10cSrcweir 			pData->mpMapMode = new MapMode( maMapMode );
2443*cdf0e10cSrcweir 		else
2444*cdf0e10cSrcweir 			pData->mpMapMode = NULL;
2445*cdf0e10cSrcweir 	}
2446*cdf0e10cSrcweir 	if ( nFlags & PUSH_CLIPREGION )
2447*cdf0e10cSrcweir 	{
2448*cdf0e10cSrcweir 		if ( mbClipRegion )
2449*cdf0e10cSrcweir 			pData->mpClipRegion = new Region( maRegion );
2450*cdf0e10cSrcweir 		else
2451*cdf0e10cSrcweir 			pData->mpClipRegion = NULL;
2452*cdf0e10cSrcweir 	}
2453*cdf0e10cSrcweir 	if ( nFlags & PUSH_REFPOINT )
2454*cdf0e10cSrcweir 	{
2455*cdf0e10cSrcweir 		if ( mbRefPoint )
2456*cdf0e10cSrcweir 			pData->mpRefPoint = new Point( maRefPoint );
2457*cdf0e10cSrcweir 		else
2458*cdf0e10cSrcweir 			pData->mpRefPoint = NULL;
2459*cdf0e10cSrcweir 	}
2460*cdf0e10cSrcweir 
2461*cdf0e10cSrcweir     if( mpAlphaVDev )
2462*cdf0e10cSrcweir         mpAlphaVDev->Push();
2463*cdf0e10cSrcweir }
2464*cdf0e10cSrcweir 
2465*cdf0e10cSrcweir // -----------------------------------------------------------------------
2466*cdf0e10cSrcweir 
2467*cdf0e10cSrcweir void OutputDevice::Pop()
2468*cdf0e10cSrcweir {
2469*cdf0e10cSrcweir 	DBG_TRACE( "OutputDevice::Pop()" );
2470*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
2471*cdf0e10cSrcweir 
2472*cdf0e10cSrcweir 	if( mpMetaFile )
2473*cdf0e10cSrcweir 		mpMetaFile->AddAction( new MetaPopAction() );
2474*cdf0e10cSrcweir 
2475*cdf0e10cSrcweir 	GDIMetaFile*	pOldMetaFile = mpMetaFile;
2476*cdf0e10cSrcweir 	ImplObjStack*	pData = mpObjStack;
2477*cdf0e10cSrcweir 	mpMetaFile = NULL;
2478*cdf0e10cSrcweir 
2479*cdf0e10cSrcweir 	if ( !pData )
2480*cdf0e10cSrcweir 	{
2481*cdf0e10cSrcweir 		DBG_ERRORFILE( "OutputDevice::Pop() without OutputDevice::Push()" );
2482*cdf0e10cSrcweir 		return;
2483*cdf0e10cSrcweir 	}
2484*cdf0e10cSrcweir 
2485*cdf0e10cSrcweir     if( mpAlphaVDev )
2486*cdf0e10cSrcweir         mpAlphaVDev->Pop();
2487*cdf0e10cSrcweir 
2488*cdf0e10cSrcweir 	mpObjStack = pData->mpPrev;
2489*cdf0e10cSrcweir 
2490*cdf0e10cSrcweir 	if ( pData->mnFlags & PUSH_LINECOLOR )
2491*cdf0e10cSrcweir 	{
2492*cdf0e10cSrcweir 		if ( pData->mpLineColor )
2493*cdf0e10cSrcweir 			SetLineColor( *pData->mpLineColor );
2494*cdf0e10cSrcweir 		else
2495*cdf0e10cSrcweir 			SetLineColor();
2496*cdf0e10cSrcweir 	}
2497*cdf0e10cSrcweir 	if ( pData->mnFlags & PUSH_FILLCOLOR )
2498*cdf0e10cSrcweir 	{
2499*cdf0e10cSrcweir 		if ( pData->mpFillColor )
2500*cdf0e10cSrcweir 			SetFillColor( *pData->mpFillColor );
2501*cdf0e10cSrcweir 		else
2502*cdf0e10cSrcweir 			SetFillColor();
2503*cdf0e10cSrcweir 	}
2504*cdf0e10cSrcweir 	if ( pData->mnFlags & PUSH_FONT )
2505*cdf0e10cSrcweir 		SetFont( *pData->mpFont );
2506*cdf0e10cSrcweir 	if ( pData->mnFlags & PUSH_TEXTCOLOR )
2507*cdf0e10cSrcweir 		SetTextColor( *pData->mpTextColor );
2508*cdf0e10cSrcweir 	if ( pData->mnFlags & PUSH_TEXTFILLCOLOR )
2509*cdf0e10cSrcweir 	{
2510*cdf0e10cSrcweir 		if ( pData->mpTextFillColor )
2511*cdf0e10cSrcweir 			SetTextFillColor( *pData->mpTextFillColor );
2512*cdf0e10cSrcweir 		else
2513*cdf0e10cSrcweir 			SetTextFillColor();
2514*cdf0e10cSrcweir 	}
2515*cdf0e10cSrcweir 	if ( pData->mnFlags & PUSH_TEXTLINECOLOR )
2516*cdf0e10cSrcweir 	{
2517*cdf0e10cSrcweir 		if ( pData->mpTextLineColor )
2518*cdf0e10cSrcweir 			SetTextLineColor( *pData->mpTextLineColor );
2519*cdf0e10cSrcweir 		else
2520*cdf0e10cSrcweir 			SetTextLineColor();
2521*cdf0e10cSrcweir 	}
2522*cdf0e10cSrcweir 	if ( pData->mnFlags & PUSH_OVERLINECOLOR )
2523*cdf0e10cSrcweir 	{
2524*cdf0e10cSrcweir 		if ( pData->mpOverlineColor )
2525*cdf0e10cSrcweir 			SetOverlineColor( *pData->mpOverlineColor );
2526*cdf0e10cSrcweir 		else
2527*cdf0e10cSrcweir 			SetOverlineColor();
2528*cdf0e10cSrcweir 	}
2529*cdf0e10cSrcweir 	if ( pData->mnFlags & PUSH_TEXTALIGN )
2530*cdf0e10cSrcweir 		SetTextAlign( pData->meTextAlign );
2531*cdf0e10cSrcweir 	if( pData->mnFlags & PUSH_TEXTLAYOUTMODE )
2532*cdf0e10cSrcweir 		SetLayoutMode( pData->mnTextLayoutMode );
2533*cdf0e10cSrcweir 	if( pData->mnFlags & PUSH_TEXTLANGUAGE )
2534*cdf0e10cSrcweir 		SetDigitLanguage( pData->meTextLanguage );
2535*cdf0e10cSrcweir 	if ( pData->mnFlags & PUSH_RASTEROP )
2536*cdf0e10cSrcweir 		SetRasterOp( pData->meRasterOp );
2537*cdf0e10cSrcweir 	if ( pData->mnFlags & PUSH_MAPMODE )
2538*cdf0e10cSrcweir 	{
2539*cdf0e10cSrcweir 		if ( pData->mpMapMode )
2540*cdf0e10cSrcweir 			SetMapMode( *pData->mpMapMode );
2541*cdf0e10cSrcweir 		else
2542*cdf0e10cSrcweir 			SetMapMode();
2543*cdf0e10cSrcweir 	}
2544*cdf0e10cSrcweir 	if ( pData->mnFlags & PUSH_CLIPREGION )
2545*cdf0e10cSrcweir 		ImplSetClipRegion( pData->mpClipRegion );
2546*cdf0e10cSrcweir 	if ( pData->mnFlags & PUSH_REFPOINT )
2547*cdf0e10cSrcweir 	{
2548*cdf0e10cSrcweir 		if ( pData->mpRefPoint )
2549*cdf0e10cSrcweir 			SetRefPoint( *pData->mpRefPoint );
2550*cdf0e10cSrcweir 		else
2551*cdf0e10cSrcweir 			SetRefPoint();
2552*cdf0e10cSrcweir 	}
2553*cdf0e10cSrcweir 
2554*cdf0e10cSrcweir 	ImplDeleteObjStack( pData );
2555*cdf0e10cSrcweir 
2556*cdf0e10cSrcweir 	mpMetaFile = pOldMetaFile;
2557*cdf0e10cSrcweir }
2558*cdf0e10cSrcweir 
2559*cdf0e10cSrcweir // -----------------------------------------------------------------------
2560*cdf0e10cSrcweir 
2561*cdf0e10cSrcweir void OutputDevice::SetConnectMetaFile( GDIMetaFile* pMtf )
2562*cdf0e10cSrcweir {
2563*cdf0e10cSrcweir     mpMetaFile = pMtf;
2564*cdf0e10cSrcweir }
2565*cdf0e10cSrcweir 
2566*cdf0e10cSrcweir // -----------------------------------------------------------------------
2567*cdf0e10cSrcweir 
2568*cdf0e10cSrcweir void OutputDevice::EnableOutput( sal_Bool bEnable )
2569*cdf0e10cSrcweir {
2570*cdf0e10cSrcweir     mbOutput = (bEnable != 0);
2571*cdf0e10cSrcweir 
2572*cdf0e10cSrcweir     if( mpAlphaVDev )
2573*cdf0e10cSrcweir         mpAlphaVDev->EnableOutput( bEnable );
2574*cdf0e10cSrcweir }
2575*cdf0e10cSrcweir 
2576*cdf0e10cSrcweir // -----------------------------------------------------------------------
2577*cdf0e10cSrcweir 
2578*cdf0e10cSrcweir void OutputDevice::SetSettings( const AllSettings& rSettings )
2579*cdf0e10cSrcweir {
2580*cdf0e10cSrcweir     maSettings = rSettings;
2581*cdf0e10cSrcweir 
2582*cdf0e10cSrcweir     if( mpAlphaVDev )
2583*cdf0e10cSrcweir         mpAlphaVDev->SetSettings( rSettings );
2584*cdf0e10cSrcweir }
2585*cdf0e10cSrcweir 
2586*cdf0e10cSrcweir // -----------------------------------------------------------------------
2587*cdf0e10cSrcweir 
2588*cdf0e10cSrcweir sal_uInt16 OutputDevice::GetBitCount() const
2589*cdf0e10cSrcweir {
2590*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
2591*cdf0e10cSrcweir 
2592*cdf0e10cSrcweir 	if ( meOutDevType == OUTDEV_VIRDEV )
2593*cdf0e10cSrcweir 		return ((VirtualDevice*)this)->mnBitCount;
2594*cdf0e10cSrcweir 
2595*cdf0e10cSrcweir 	// we need a graphics
2596*cdf0e10cSrcweir 	if ( !mpGraphics )
2597*cdf0e10cSrcweir 	{
2598*cdf0e10cSrcweir 		if ( !((OutputDevice*)this)->ImplGetGraphics() )
2599*cdf0e10cSrcweir 			return 0;
2600*cdf0e10cSrcweir 	}
2601*cdf0e10cSrcweir 
2602*cdf0e10cSrcweir 	return (sal_uInt16)mpGraphics->GetBitCount();
2603*cdf0e10cSrcweir }
2604*cdf0e10cSrcweir 
2605*cdf0e10cSrcweir // -----------------------------------------------------------------------
2606*cdf0e10cSrcweir 
2607*cdf0e10cSrcweir sal_uInt16 OutputDevice::GetAlphaBitCount() const
2608*cdf0e10cSrcweir {
2609*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
2610*cdf0e10cSrcweir 
2611*cdf0e10cSrcweir 	if ( meOutDevType == OUTDEV_VIRDEV &&
2612*cdf0e10cSrcweir         mpAlphaVDev != NULL )
2613*cdf0e10cSrcweir     {
2614*cdf0e10cSrcweir 		return mpAlphaVDev->GetBitCount();
2615*cdf0e10cSrcweir     }
2616*cdf0e10cSrcweir 
2617*cdf0e10cSrcweir     return 0;
2618*cdf0e10cSrcweir }
2619*cdf0e10cSrcweir 
2620*cdf0e10cSrcweir // -----------------------------------------------------------------------
2621*cdf0e10cSrcweir 
2622*cdf0e10cSrcweir sal_uLong OutputDevice::GetColorCount() const
2623*cdf0e10cSrcweir {
2624*cdf0e10cSrcweir 	DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
2625*cdf0e10cSrcweir 
2626*cdf0e10cSrcweir 	const sal_uInt16 nBitCount = GetBitCount();
2627*cdf0e10cSrcweir 	return( ( nBitCount > 31 ) ? ULONG_MAX : ( ( (sal_uLong) 1 ) << nBitCount) );
2628*cdf0e10cSrcweir }
2629*cdf0e10cSrcweir 
2630*cdf0e10cSrcweir // -----------------------------------------------------------------------
2631*cdf0e10cSrcweir 
2632*cdf0e10cSrcweir sal_Bool OutputDevice::HasAlpha()
2633*cdf0e10cSrcweir {
2634*cdf0e10cSrcweir     return mpAlphaVDev != NULL;
2635*cdf0e10cSrcweir }
2636*cdf0e10cSrcweir 
2637*cdf0e10cSrcweir // -----------------------------------------------------------------------
2638*cdf0e10cSrcweir 
2639*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > OutputDevice::CreateUnoGraphics()
2640*cdf0e10cSrcweir {
2641*cdf0e10cSrcweir 	UnoWrapperBase* pWrapper = Application::GetUnoWrapper();
2642*cdf0e10cSrcweir 	return pWrapper ? pWrapper->CreateGraphics( this ) : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >();
2643*cdf0e10cSrcweir }
2644*cdf0e10cSrcweir 
2645*cdf0e10cSrcweir // -----------------------------------------------------------------------
2646*cdf0e10cSrcweir 
2647*cdf0e10cSrcweir SystemGraphicsData OutputDevice::GetSystemGfxData() const
2648*cdf0e10cSrcweir {
2649*cdf0e10cSrcweir 	if ( !mpGraphics )
2650*cdf0e10cSrcweir 	{
2651*cdf0e10cSrcweir 		if ( !ImplGetGraphics() )
2652*cdf0e10cSrcweir 			return SystemGraphicsData();
2653*cdf0e10cSrcweir 	}
2654*cdf0e10cSrcweir 
2655*cdf0e10cSrcweir     return mpGraphics->GetGraphicsData();
2656*cdf0e10cSrcweir }
2657*cdf0e10cSrcweir 
2658*cdf0e10cSrcweir // -----------------------------------------------------------------------
2659*cdf0e10cSrcweir 
2660*cdf0e10cSrcweir ::com::sun::star::uno::Any OutputDevice::GetSystemGfxDataAny() const
2661*cdf0e10cSrcweir {
2662*cdf0e10cSrcweir     ::com::sun::star::uno::Any aRet;
2663*cdf0e10cSrcweir     const SystemGraphicsData aSysData = GetSystemGfxData();
2664*cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( (sal_Int8*)&aSysData,
2665*cdf0e10cSrcweir                                                       aSysData.nSize );
2666*cdf0e10cSrcweir 
2667*cdf0e10cSrcweir     return uno::makeAny(aSeq);
2668*cdf0e10cSrcweir }
2669*cdf0e10cSrcweir 
2670*cdf0e10cSrcweir // -----------------------------------------------------------------------
2671*cdf0e10cSrcweir 
2672*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvas > OutputDevice::GetCanvas() const
2673*cdf0e10cSrcweir {
2674*cdf0e10cSrcweir     uno::Sequence< uno::Any > aArg(6);
2675*cdf0e10cSrcweir 
2676*cdf0e10cSrcweir     aArg[ 0 ] = uno::makeAny( reinterpret_cast<sal_Int64>(this) );
2677*cdf0e10cSrcweir     aArg[ 2 ] = uno::makeAny( ::com::sun::star::awt::Rectangle( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight ) );
2678*cdf0e10cSrcweir     aArg[ 3 ] = uno::makeAny( sal_False );
2679*cdf0e10cSrcweir     aArg[ 5 ] = GetSystemGfxDataAny();
2680*cdf0e10cSrcweir 
2681*cdf0e10cSrcweir     uno::Reference<lang::XMultiServiceFactory> xFactory = vcl::unohelper::GetMultiServiceFactory();
2682*cdf0e10cSrcweir 
2683*cdf0e10cSrcweir     uno::Reference<rendering::XCanvas> xCanvas;
2684*cdf0e10cSrcweir 
2685*cdf0e10cSrcweir     // Create canvas instance with window handle
2686*cdf0e10cSrcweir     // =========================================
2687*cdf0e10cSrcweir     if ( xFactory.is() )
2688*cdf0e10cSrcweir     {
2689*cdf0e10cSrcweir         static uno::Reference<lang::XMultiServiceFactory> xCanvasFactory(
2690*cdf0e10cSrcweir             xFactory->createInstance(
2691*cdf0e10cSrcweir                 OUString( RTL_CONSTASCII_USTRINGPARAM(
2692*cdf0e10cSrcweir                               "com.sun.star."
2693*cdf0e10cSrcweir                               "rendering.CanvasFactory") ) ),
2694*cdf0e10cSrcweir             uno::UNO_QUERY );
2695*cdf0e10cSrcweir         if(xCanvasFactory.is())
2696*cdf0e10cSrcweir         {
2697*cdf0e10cSrcweir             xCanvas.set(
2698*cdf0e10cSrcweir                 xCanvasFactory->createInstanceWithArguments(
2699*cdf0e10cSrcweir                     OUString( RTL_CONSTASCII_USTRINGPARAM(
2700*cdf0e10cSrcweir                                   "com.sun.star.rendering.Canvas" )),
2701*cdf0e10cSrcweir                     aArg ),
2702*cdf0e10cSrcweir                 uno::UNO_QUERY );
2703*cdf0e10cSrcweir         }
2704*cdf0e10cSrcweir     }
2705*cdf0e10cSrcweir 
2706*cdf0e10cSrcweir     return xCanvas;
2707*cdf0e10cSrcweir }
2708*cdf0e10cSrcweir 
2709*cdf0e10cSrcweir // -----------------------------------------------------------------------
2710