xref: /trunk/main/vcl/source/gdi/virdev.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/debug.hxx>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <vcl/settings.hxx>
34*cdf0e10cSrcweir #include <vcl/svapp.hxx>
35*cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
36*cdf0e10cSrcweir #include <vcl/virdev.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <salinst.hxx>
39*cdf0e10cSrcweir #include <salgdi.hxx>
40*cdf0e10cSrcweir #include <salframe.hxx>
41*cdf0e10cSrcweir #include <salvd.hxx>
42*cdf0e10cSrcweir #include <outdev.h>
43*cdf0e10cSrcweir #include <svdata.hxx>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir // =======================================================================
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir void VirtualDevice::ImplInitVirDev( const OutputDevice* pOutDev,
50*cdf0e10cSrcweir                                     long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData )
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir     DBG_ASSERT( nBitCount <= 1,
53*cdf0e10cSrcweir                 "VirtualDevice::VirtualDevice(): Only 0 or 1 is for BitCount allowed" );
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir     if ( nDX < 1 )
56*cdf0e10cSrcweir         nDX = 1;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir     if ( nDY < 1 )
59*cdf0e10cSrcweir         nDY = 1;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir     if ( !pOutDev )
64*cdf0e10cSrcweir         pOutDev = ImplGetDefaultWindow();
65*cdf0e10cSrcweir     if( !pOutDev )
66*cdf0e10cSrcweir         return;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir     SalGraphics* pGraphics;
69*cdf0e10cSrcweir     if ( !pOutDev->mpGraphics )
70*cdf0e10cSrcweir         ((OutputDevice*)pOutDev)->ImplGetGraphics();
71*cdf0e10cSrcweir     pGraphics = pOutDev->mpGraphics;
72*cdf0e10cSrcweir     if ( pGraphics )
73*cdf0e10cSrcweir         mpVirDev = pSVData->mpDefInst->CreateVirtualDevice( pGraphics, nDX, nDY, nBitCount, pData );
74*cdf0e10cSrcweir     else
75*cdf0e10cSrcweir         mpVirDev = NULL;
76*cdf0e10cSrcweir     if ( !mpVirDev )
77*cdf0e10cSrcweir     {
78*cdf0e10cSrcweir         // do not abort but throw an exception, may be the current thread terminates anyway (plugin-scenario)
79*cdf0e10cSrcweir         throw ::com::sun::star::uno::RuntimeException(
80*cdf0e10cSrcweir             OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not create system bitmap!" ) ),
81*cdf0e10cSrcweir             ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
82*cdf0e10cSrcweir         //GetpApp()->Exception( EXC_SYSOBJNOTCREATED );
83*cdf0e10cSrcweir     }
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     mnBitCount      = ( nBitCount ? nBitCount : pOutDev->GetBitCount() );
86*cdf0e10cSrcweir     mnOutWidth      = nDX;
87*cdf0e10cSrcweir     mnOutHeight     = nDY;
88*cdf0e10cSrcweir     mbScreenComp    = sal_True;
89*cdf0e10cSrcweir     mnAlphaDepth    = -1;
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir     // #i59315# init vdev size from system object, when passed a
92*cdf0e10cSrcweir     // SystemGraphicsData. Otherwise, output size will always
93*cdf0e10cSrcweir     // incorrectly stay at (1,1)
94*cdf0e10cSrcweir     if( pData && mpVirDev )
95*cdf0e10cSrcweir         mpVirDev->GetSize(mnOutWidth,mnOutHeight);
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir     if( mnBitCount < 8 )
98*cdf0e10cSrcweir         SetAntialiasing( ANTIALIASING_DISABLE_TEXT );
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir     if ( pOutDev->GetOutDevType() == OUTDEV_PRINTER )
101*cdf0e10cSrcweir         mbScreenComp = sal_False;
102*cdf0e10cSrcweir     else if ( pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
103*cdf0e10cSrcweir         mbScreenComp = ((VirtualDevice*)pOutDev)->mbScreenComp;
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir     meOutDevType    = OUTDEV_VIRDEV;
106*cdf0e10cSrcweir     mbDevOutput     = sal_True;
107*cdf0e10cSrcweir     mpFontList      = pSVData->maGDIData.mpScreenFontList;
108*cdf0e10cSrcweir     mpFontCache     = pSVData->maGDIData.mpScreenFontCache;
109*cdf0e10cSrcweir     mnDPIX          = pOutDev->mnDPIX;
110*cdf0e10cSrcweir     mnDPIY          = pOutDev->mnDPIY;
111*cdf0e10cSrcweir     maFont          = pOutDev->maFont;
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir     if( maTextColor != pOutDev->maTextColor )
114*cdf0e10cSrcweir     {
115*cdf0e10cSrcweir         maTextColor = pOutDev->maTextColor;
116*cdf0e10cSrcweir         mbInitTextColor = true;
117*cdf0e10cSrcweir     }
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir     // Virtuelle Devices haben defaultmaessig einen weissen Hintergrund
120*cdf0e10cSrcweir     SetBackground( Wallpaper( Color( COL_WHITE ) ) );
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     // #i59283# don't erase user-provided surface
123*cdf0e10cSrcweir     if( !pData )
124*cdf0e10cSrcweir         Erase();
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir     // VirDev in Liste eintragen
127*cdf0e10cSrcweir     mpNext = pSVData->maGDIData.mpFirstVirDev;
128*cdf0e10cSrcweir     mpPrev = NULL;
129*cdf0e10cSrcweir     if ( mpNext )
130*cdf0e10cSrcweir         mpNext->mpPrev = this;
131*cdf0e10cSrcweir     else
132*cdf0e10cSrcweir         pSVData->maGDIData.mpLastVirDev = this;
133*cdf0e10cSrcweir     pSVData->maGDIData.mpFirstVirDev = this;
134*cdf0e10cSrcweir }
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir // -----------------------------------------------------------------------
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir VirtualDevice::VirtualDevice( sal_uInt16 nBitCount )
139*cdf0e10cSrcweir :   mpVirDev( NULL ),
140*cdf0e10cSrcweir     meRefDevMode( REFDEV_NONE )
141*cdf0e10cSrcweir {
142*cdf0e10cSrcweir     DBG_TRACE1( "VirtualDevice::VirtualDevice( %hu )", nBitCount );
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir     ImplInitVirDev( Application::GetDefaultDevice(), 1, 1, nBitCount );
145*cdf0e10cSrcweir }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir // -----------------------------------------------------------------------
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir VirtualDevice::VirtualDevice( const OutputDevice& rCompDev, sal_uInt16 nBitCount )
150*cdf0e10cSrcweir     : mpVirDev( NULL ),
151*cdf0e10cSrcweir     meRefDevMode( REFDEV_NONE )
152*cdf0e10cSrcweir {
153*cdf0e10cSrcweir     DBG_TRACE1( "VirtualDevice::VirtualDevice( %hu )", nBitCount );
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     ImplInitVirDev( &rCompDev, 1, 1, nBitCount );
156*cdf0e10cSrcweir }
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir // -----------------------------------------------------------------------
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir VirtualDevice::VirtualDevice( const OutputDevice& rCompDev, sal_uInt16 nBitCount, sal_uInt16 nAlphaBitCount )
161*cdf0e10cSrcweir     : mpVirDev( NULL ),
162*cdf0e10cSrcweir     meRefDevMode( REFDEV_NONE )
163*cdf0e10cSrcweir {
164*cdf0e10cSrcweir     DBG_TRACE1( "VirtualDevice::VirtualDevice( %hu )", nBitCount );
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     ImplInitVirDev( &rCompDev, 1, 1, nBitCount );
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir     // #110958# Enable alpha channel
169*cdf0e10cSrcweir     mnAlphaDepth = sal::static_int_cast<sal_Int8>(nAlphaBitCount);
170*cdf0e10cSrcweir }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir // -----------------------------------------------------------------------
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir VirtualDevice::VirtualDevice( const SystemGraphicsData *pData, sal_uInt16 nBitCount )
175*cdf0e10cSrcweir :   mpVirDev( NULL ),
176*cdf0e10cSrcweir     meRefDevMode( REFDEV_NONE )
177*cdf0e10cSrcweir {
178*cdf0e10cSrcweir     DBG_TRACE1( "VirtualDevice::VirtualDevice( %hu )", nBitCount );
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir     ImplInitVirDev( Application::GetDefaultDevice(), 1, 1, nBitCount, pData );
181*cdf0e10cSrcweir }
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir // -----------------------------------------------------------------------
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir VirtualDevice::~VirtualDevice()
186*cdf0e10cSrcweir {
187*cdf0e10cSrcweir     DBG_TRACE( "VirtualDevice::~VirtualDevice()" );
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir     ImplReleaseGraphics();
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir     if ( mpVirDev )
194*cdf0e10cSrcweir         pSVData->mpDefInst->DestroyVirtualDevice( mpVirDev );
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir     // remove this VirtualDevice from the double-linked global list
197*cdf0e10cSrcweir     if( mpPrev )
198*cdf0e10cSrcweir         mpPrev->mpNext = mpNext;
199*cdf0e10cSrcweir     else
200*cdf0e10cSrcweir         pSVData->maGDIData.mpFirstVirDev = mpNext;
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir     if( mpNext )
203*cdf0e10cSrcweir         mpNext->mpPrev = mpPrev;
204*cdf0e10cSrcweir     else
205*cdf0e10cSrcweir         pSVData->maGDIData.mpLastVirDev = mpPrev;
206*cdf0e10cSrcweir }
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir // -----------------------------------------------------------------------
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir sal_Bool VirtualDevice::ImplSetOutputSizePixel( const Size& rNewSize, sal_Bool bErase )
211*cdf0e10cSrcweir {
212*cdf0e10cSrcweir     DBG_TRACE3( "VirtualDevice::ImplSetOutputSizePixel( %ld, %ld, %d )", rNewSize.Width(), rNewSize.Height(), (int)bErase );
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir     if ( !mpVirDev )
215*cdf0e10cSrcweir         return sal_False;
216*cdf0e10cSrcweir     else if ( rNewSize == GetOutputSizePixel() )
217*cdf0e10cSrcweir     {
218*cdf0e10cSrcweir         if ( bErase )
219*cdf0e10cSrcweir             Erase();
220*cdf0e10cSrcweir         return sal_True;
221*cdf0e10cSrcweir     }
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir     sal_Bool bRet;
224*cdf0e10cSrcweir     long nNewWidth = rNewSize.Width(), nNewHeight = rNewSize.Height();
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir     if ( nNewWidth < 1 )
227*cdf0e10cSrcweir         nNewWidth = 1;
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir     if ( nNewHeight < 1 )
230*cdf0e10cSrcweir         nNewHeight = 1;
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir     if ( bErase )
233*cdf0e10cSrcweir     {
234*cdf0e10cSrcweir         bRet = mpVirDev->SetSize( nNewWidth, nNewHeight );
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir         if ( bRet )
237*cdf0e10cSrcweir         {
238*cdf0e10cSrcweir             mnOutWidth  = rNewSize.Width();
239*cdf0e10cSrcweir             mnOutHeight = rNewSize.Height();
240*cdf0e10cSrcweir             Erase();
241*cdf0e10cSrcweir         }
242*cdf0e10cSrcweir     }
243*cdf0e10cSrcweir     else
244*cdf0e10cSrcweir     {
245*cdf0e10cSrcweir         SalVirtualDevice*   pNewVirDev;
246*cdf0e10cSrcweir         ImplSVData*         pSVData = ImplGetSVData();
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir         // we need a graphics
249*cdf0e10cSrcweir         if ( !mpGraphics )
250*cdf0e10cSrcweir         {
251*cdf0e10cSrcweir             if ( !ImplGetGraphics() )
252*cdf0e10cSrcweir                 return sal_False;
253*cdf0e10cSrcweir         }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir         pNewVirDev = pSVData->mpDefInst->CreateVirtualDevice( mpGraphics, nNewWidth, nNewHeight, mnBitCount );
256*cdf0e10cSrcweir         if ( pNewVirDev )
257*cdf0e10cSrcweir         {
258*cdf0e10cSrcweir             SalGraphics* pGraphics = pNewVirDev->GetGraphics();
259*cdf0e10cSrcweir             if ( pGraphics )
260*cdf0e10cSrcweir             {
261*cdf0e10cSrcweir                 SalTwoRect aPosAry;
262*cdf0e10cSrcweir                 long nWidth;
263*cdf0e10cSrcweir                 long nHeight;
264*cdf0e10cSrcweir                 if ( mnOutWidth < nNewWidth )
265*cdf0e10cSrcweir                     nWidth = mnOutWidth;
266*cdf0e10cSrcweir                 else
267*cdf0e10cSrcweir                     nWidth = nNewWidth;
268*cdf0e10cSrcweir                 if ( mnOutHeight < nNewHeight )
269*cdf0e10cSrcweir                     nHeight = mnOutHeight;
270*cdf0e10cSrcweir                 else
271*cdf0e10cSrcweir                     nHeight = nNewHeight;
272*cdf0e10cSrcweir                 aPosAry.mnSrcX       = 0;
273*cdf0e10cSrcweir                 aPosAry.mnSrcY       = 0;
274*cdf0e10cSrcweir                 aPosAry.mnSrcWidth   = nWidth;
275*cdf0e10cSrcweir                 aPosAry.mnSrcHeight  = nHeight;
276*cdf0e10cSrcweir                 aPosAry.mnDestX      = 0;
277*cdf0e10cSrcweir                 aPosAry.mnDestY      = 0;
278*cdf0e10cSrcweir                 aPosAry.mnDestWidth  = nWidth;
279*cdf0e10cSrcweir                 aPosAry.mnDestHeight = nHeight;
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir                 pGraphics->CopyBits( &aPosAry, mpGraphics, this, this );
282*cdf0e10cSrcweir                 pNewVirDev->ReleaseGraphics( pGraphics );
283*cdf0e10cSrcweir                 ImplReleaseGraphics();
284*cdf0e10cSrcweir                 pSVData->mpDefInst->DestroyVirtualDevice( mpVirDev );
285*cdf0e10cSrcweir                 mpVirDev = pNewVirDev;
286*cdf0e10cSrcweir                 mnOutWidth  = rNewSize.Width();
287*cdf0e10cSrcweir                 mnOutHeight = rNewSize.Height();
288*cdf0e10cSrcweir                 bRet = sal_True;
289*cdf0e10cSrcweir             }
290*cdf0e10cSrcweir             else
291*cdf0e10cSrcweir             {
292*cdf0e10cSrcweir                 bRet = sal_False;
293*cdf0e10cSrcweir                 pSVData->mpDefInst->DestroyVirtualDevice( pNewVirDev );
294*cdf0e10cSrcweir             }
295*cdf0e10cSrcweir         }
296*cdf0e10cSrcweir         else
297*cdf0e10cSrcweir             bRet = sal_False;
298*cdf0e10cSrcweir     }
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir     return bRet;
301*cdf0e10cSrcweir }
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir // -----------------------------------------------------------------------
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir // #i32109#: Fill opaque areas correctly (without relying on
306*cdf0e10cSrcweir // fill/linecolor state)
307*cdf0e10cSrcweir void VirtualDevice::ImplFillOpaqueRectangle( const Rectangle& rRect )
308*cdf0e10cSrcweir {
309*cdf0e10cSrcweir     // Set line and fill color to black (->opaque),
310*cdf0e10cSrcweir     // fill rect with that (linecolor, too, because of
311*cdf0e10cSrcweir     // those pesky missing pixel problems)
312*cdf0e10cSrcweir     Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
313*cdf0e10cSrcweir     SetLineColor( COL_BLACK );
314*cdf0e10cSrcweir     SetFillColor( COL_BLACK );
315*cdf0e10cSrcweir     DrawRect( rRect );
316*cdf0e10cSrcweir     Pop();
317*cdf0e10cSrcweir }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir // -----------------------------------------------------------------------
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir sal_Bool VirtualDevice::SetOutputSizePixel( const Size& rNewSize, sal_Bool bErase )
322*cdf0e10cSrcweir {
323*cdf0e10cSrcweir     if( ImplSetOutputSizePixel(rNewSize, bErase) )
324*cdf0e10cSrcweir     {
325*cdf0e10cSrcweir         if( mnAlphaDepth != -1 )
326*cdf0e10cSrcweir         {
327*cdf0e10cSrcweir             // #110958# Setup alpha bitmap
328*cdf0e10cSrcweir             if(mpAlphaVDev && mpAlphaVDev->GetOutputSizePixel() != rNewSize)
329*cdf0e10cSrcweir             {
330*cdf0e10cSrcweir                 delete mpAlphaVDev;
331*cdf0e10cSrcweir                 mpAlphaVDev = 0L;
332*cdf0e10cSrcweir             }
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir             if( !mpAlphaVDev )
335*cdf0e10cSrcweir             {
336*cdf0e10cSrcweir                 mpAlphaVDev = new VirtualDevice( *this, mnAlphaDepth );
337*cdf0e10cSrcweir                 mpAlphaVDev->ImplSetOutputSizePixel(rNewSize, bErase);
338*cdf0e10cSrcweir             }
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir             // TODO: copy full outdev state to new one, here. Also needed in outdev2.cxx:DrawOutDev
341*cdf0e10cSrcweir             if( GetLineColor() != Color( COL_TRANSPARENT ) )
342*cdf0e10cSrcweir                 mpAlphaVDev->SetLineColor( COL_BLACK );
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir             if( GetFillColor() != Color( COL_TRANSPARENT ) )
345*cdf0e10cSrcweir                 mpAlphaVDev->SetFillColor( COL_BLACK );
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir             mpAlphaVDev->SetMapMode( GetMapMode() );
348*cdf0e10cSrcweir         }
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir         return sal_True;
351*cdf0e10cSrcweir     }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir     return sal_False;
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir // -----------------------------------------------------------------------
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir void VirtualDevice::SetReferenceDevice( RefDevMode i_eRefDevMode )
359*cdf0e10cSrcweir {
360*cdf0e10cSrcweir     sal_Int32 nDPIX = 600, nDPIY = 600;
361*cdf0e10cSrcweir     switch( i_eRefDevMode )
362*cdf0e10cSrcweir     {
363*cdf0e10cSrcweir     case REFDEV_NONE:
364*cdf0e10cSrcweir     default:
365*cdf0e10cSrcweir         DBG_ASSERT( sal_False, "VDev::SetRefDev illegal argument!" );
366*cdf0e10cSrcweir         break;
367*cdf0e10cSrcweir     case REFDEV_MODE06:
368*cdf0e10cSrcweir         nDPIX = nDPIY = 600;
369*cdf0e10cSrcweir         break;
370*cdf0e10cSrcweir     case REFDEV_MODE48:
371*cdf0e10cSrcweir         nDPIX = nDPIY = 4800;
372*cdf0e10cSrcweir         break;
373*cdf0e10cSrcweir     case REFDEV_MODE_MSO1:
374*cdf0e10cSrcweir         nDPIX = nDPIY = 6*1440;
375*cdf0e10cSrcweir         break;
376*cdf0e10cSrcweir     case REFDEV_MODE_PDF1:
377*cdf0e10cSrcweir         nDPIX = nDPIY = 720;
378*cdf0e10cSrcweir         break;
379*cdf0e10cSrcweir     }
380*cdf0e10cSrcweir     ImplSetReferenceDevice( i_eRefDevMode, nDPIX, nDPIY );
381*cdf0e10cSrcweir }
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir void VirtualDevice::SetReferenceDevice( sal_Int32 i_nDPIX, sal_Int32 i_nDPIY )
384*cdf0e10cSrcweir {
385*cdf0e10cSrcweir     ImplSetReferenceDevice( REFDEV_CUSTOM, i_nDPIX, i_nDPIY );
386*cdf0e10cSrcweir }
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir void VirtualDevice::ImplSetReferenceDevice( RefDevMode i_eRefDevMode, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY )
389*cdf0e10cSrcweir {
390*cdf0e10cSrcweir     mnDPIX = i_nDPIX;
391*cdf0e10cSrcweir     mnDPIY = i_nDPIY;
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir     EnableOutput( sal_False );  // prevent output on reference device
394*cdf0e10cSrcweir     mbScreenComp = sal_False;
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir     // invalidate currently selected fonts
397*cdf0e10cSrcweir     mbInitFont = sal_True;
398*cdf0e10cSrcweir     mbNewFont = sal_True;
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir     // avoid adjusting font lists when already in refdev mode
401*cdf0e10cSrcweir     sal_uInt8 nOldRefDevMode = meRefDevMode;
402*cdf0e10cSrcweir     sal_uInt8 nOldCompatFlag = (sal_uInt8)meRefDevMode & REFDEV_FORCE_ZERO_EXTLEAD;
403*cdf0e10cSrcweir     meRefDevMode = (sal_uInt8)(i_eRefDevMode | nOldCompatFlag);
404*cdf0e10cSrcweir     if( (nOldRefDevMode ^ nOldCompatFlag) != REFDEV_NONE )
405*cdf0e10cSrcweir         return;
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir     // the reference device should have only scalable fonts
408*cdf0e10cSrcweir     // => clean up the original font lists before getting new ones
409*cdf0e10cSrcweir     if ( mpFontEntry )
410*cdf0e10cSrcweir     {
411*cdf0e10cSrcweir         mpFontCache->Release( mpFontEntry );
412*cdf0e10cSrcweir         mpFontEntry = NULL;
413*cdf0e10cSrcweir     }
414*cdf0e10cSrcweir     if ( mpGetDevFontList )
415*cdf0e10cSrcweir     {
416*cdf0e10cSrcweir         delete mpGetDevFontList;
417*cdf0e10cSrcweir         mpGetDevFontList = NULL;
418*cdf0e10cSrcweir     }
419*cdf0e10cSrcweir     if ( mpGetDevSizeList )
420*cdf0e10cSrcweir     {
421*cdf0e10cSrcweir         delete mpGetDevSizeList;
422*cdf0e10cSrcweir         mpGetDevSizeList = NULL;
423*cdf0e10cSrcweir     }
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir     // preserve global font lists
426*cdf0e10cSrcweir     ImplSVData* pSVData = ImplGetSVData();
427*cdf0e10cSrcweir     if( mpFontList && (mpFontList != pSVData->maGDIData.mpScreenFontList) )
428*cdf0e10cSrcweir         delete mpFontList;
429*cdf0e10cSrcweir     if( mpFontCache && (mpFontCache != pSVData->maGDIData.mpScreenFontCache) )
430*cdf0e10cSrcweir         delete mpFontCache;
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir     // get font list with scalable fonts only
433*cdf0e10cSrcweir     ImplGetGraphics();
434*cdf0e10cSrcweir     mpFontList = pSVData->maGDIData.mpScreenFontList->Clone( true, false );
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir     // prepare to use new font lists
437*cdf0e10cSrcweir     mpFontCache = new ImplFontCache( false );
438*cdf0e10cSrcweir }
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir // -----------------------------------------------------------------------
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir void VirtualDevice::Compat_ZeroExtleadBug()
443*cdf0e10cSrcweir {
444*cdf0e10cSrcweir     meRefDevMode = (sal_uInt8)meRefDevMode | REFDEV_FORCE_ZERO_EXTLEAD;
445*cdf0e10cSrcweir }
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir // -----------------------------------------------------------------------
448*cdf0e10cSrcweir 
449