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