xref: /aoo41x/main/sc/source/ui/docshell/sizedev.cxx (revision b3f79822)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 
28 
29 #include <sfx2/printer.hxx>
30 #include <vcl/virdev.hxx>
31 
32 #include "sizedev.hxx"
33 #include "docsh.hxx"
34 #include "scmod.hxx"
35 #include "inputopt.hxx"
36 
37 //------------------------------------------------------------------
38 
ScSizeDeviceProvider(ScDocShell * pDocSh)39 ScSizeDeviceProvider::ScSizeDeviceProvider( ScDocShell* pDocSh )
40 {
41 	sal_Bool bTextWysiwyg = SC_MOD()->GetInputOptions().GetTextWysiwyg();
42 	if ( bTextWysiwyg )
43 	{
44 		pDevice = pDocSh->GetPrinter();
45 		bOwner = sal_False;
46 
47 		aOldMapMode = pDevice->GetMapMode();
48 		pDevice->SetMapMode( MAP_PIXEL );		// GetNeededSize needs pixel MapMode
49 		// printer has right DigitLanguage already
50 	}
51 	else
52 	{
53 		pDevice = new VirtualDevice;
54 		pDevice->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
55 		bOwner = sal_True;
56 	}
57 
58 	Point aLogic = pDevice->LogicToPixel( Point(1000,1000), MAP_TWIP );
59 	nPPTX = aLogic.X() / 1000.0;
60 	nPPTY = aLogic.Y() / 1000.0;
61 
62 	if ( !bTextWysiwyg )
63 		nPPTX /= pDocSh->GetOutputFactor();
64 }
65 
~ScSizeDeviceProvider()66 ScSizeDeviceProvider::~ScSizeDeviceProvider()
67 {
68 	if (bOwner)
69 		delete pDevice;
70 	else
71 		pDevice->SetMapMode( aOldMapMode );
72 }
73 
74