xref: /trunk/main/sc/source/ui/docshell/sizedev.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 
32 
33 #include <sfx2/printer.hxx>
34 #include <vcl/virdev.hxx>
35 
36 #include "sizedev.hxx"
37 #include "docsh.hxx"
38 #include "scmod.hxx"
39 #include "inputopt.hxx"
40 
41 //------------------------------------------------------------------
42 
43 ScSizeDeviceProvider::ScSizeDeviceProvider( ScDocShell* pDocSh )
44 {
45 	sal_Bool bTextWysiwyg = SC_MOD()->GetInputOptions().GetTextWysiwyg();
46 	if ( bTextWysiwyg )
47 	{
48 		pDevice = pDocSh->GetPrinter();
49 		bOwner = sal_False;
50 
51 		aOldMapMode = pDevice->GetMapMode();
52 		pDevice->SetMapMode( MAP_PIXEL );		// GetNeededSize needs pixel MapMode
53 		// printer has right DigitLanguage already
54 	}
55 	else
56 	{
57 		pDevice = new VirtualDevice;
58 		pDevice->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
59 		bOwner = sal_True;
60 	}
61 
62 	Point aLogic = pDevice->LogicToPixel( Point(1000,1000), MAP_TWIP );
63 	nPPTX = aLogic.X() / 1000.0;
64 	nPPTY = aLogic.Y() / 1000.0;
65 
66 	if ( !bTextWysiwyg )
67 		nPPTX /= pDocSh->GetOutputFactor();
68 }
69 
70 ScSizeDeviceProvider::~ScSizeDeviceProvider()
71 {
72 	if (bOwner)
73 		delete pDevice;
74 	else
75 		pDevice->SetMapMode( aOldMapMode );
76 }
77 
78