1*b0724fc6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*b0724fc6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*b0724fc6SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*b0724fc6SAndrew Rist * distributed with this work for additional information
6*b0724fc6SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*b0724fc6SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*b0724fc6SAndrew Rist * "License"); you may not use this file except in compliance
9*b0724fc6SAndrew Rist * with the License. You may obtain a copy of the License at
10*b0724fc6SAndrew Rist *
11*b0724fc6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*b0724fc6SAndrew Rist *
13*b0724fc6SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*b0724fc6SAndrew Rist * software distributed under the License is distributed on an
15*b0724fc6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b0724fc6SAndrew Rist * KIND, either express or implied. See the License for the
17*b0724fc6SAndrew Rist * specific language governing permissions and limitations
18*b0724fc6SAndrew Rist * under the License.
19*b0724fc6SAndrew Rist *
20*b0724fc6SAndrew Rist *************************************************************/
21*b0724fc6SAndrew Rist
22*b0724fc6SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_toolkit.hxx"
26cdf0e10cSrcweir #include <com/sun/star/awt/DeviceCapability.hpp>
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <com/sun/star/util/MeasureUnit.hpp>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <toolkit/awt/vclxdevice.hxx>
31cdf0e10cSrcweir #include <toolkit/awt/vclxfont.hxx>
32cdf0e10cSrcweir #include <toolkit/awt/vclxbitmap.hxx>
33cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
34cdf0e10cSrcweir #include <toolkit/helper/macros.hxx>
35cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir #include <rtl/memory.h>
38cdf0e10cSrcweir #include <rtl/uuid.h>
39cdf0e10cSrcweir
40cdf0e10cSrcweir #include <vcl/svapp.hxx>
41cdf0e10cSrcweir #include <vcl/outdev.hxx>
42cdf0e10cSrcweir #include <vcl/window.hxx>
43cdf0e10cSrcweir #include <vcl/print.hxx>
44cdf0e10cSrcweir #include <vcl/virdev.hxx>
45cdf0e10cSrcweir #include <vcl/bitmapex.hxx>
46cdf0e10cSrcweir #include <vcl/font.hxx>
47cdf0e10cSrcweir
48cdf0e10cSrcweir // ----------------------------------------------------
49cdf0e10cSrcweir // class VCLXDevice
50cdf0e10cSrcweir // ----------------------------------------------------
VCLXDevice()51cdf0e10cSrcweir VCLXDevice::VCLXDevice() : mrMutex( Application::GetSolarMutex() )
52cdf0e10cSrcweir {
53cdf0e10cSrcweir mpOutputDevice = NULL;
54cdf0e10cSrcweir nFlags = 0;
55cdf0e10cSrcweir }
56cdf0e10cSrcweir
~VCLXDevice()57cdf0e10cSrcweir VCLXDevice::~VCLXDevice()
58cdf0e10cSrcweir {
59cdf0e10cSrcweir // Was thought for #88347#, but didn't help, because the interface will not be released
60cdf0e10cSrcweir // But would be a good idea anyway, check after 6.0, it's a little bit dangerous now
61cdf0e10cSrcweir // if( mpOutputDevice && IsCreatedWithToolkit() )
62cdf0e10cSrcweir // {
63cdf0e10cSrcweir // delete mpOutputDevice;
64cdf0e10cSrcweir // }
65cdf0e10cSrcweir }
66cdf0e10cSrcweir
DestroyOutputDevice()67cdf0e10cSrcweir void VCLXDevice::DestroyOutputDevice()
68cdf0e10cSrcweir {
69cdf0e10cSrcweir delete mpOutputDevice;
70cdf0e10cSrcweir mpOutputDevice = NULL;
71cdf0e10cSrcweir }
72cdf0e10cSrcweir
SetCreatedWithToolkit(sal_Bool bCreatedWithToolkit)73cdf0e10cSrcweir void VCLXDevice::SetCreatedWithToolkit( sal_Bool bCreatedWithToolkit )
74cdf0e10cSrcweir {
75cdf0e10cSrcweir if ( bCreatedWithToolkit )
76cdf0e10cSrcweir nFlags |= FLAGS_CREATEDWITHTOOLKIT;
77cdf0e10cSrcweir else
78cdf0e10cSrcweir nFlags &= ~FLAGS_CREATEDWITHTOOLKIT;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
IsCreatedWithToolkit() const81cdf0e10cSrcweir sal_Bool VCLXDevice::IsCreatedWithToolkit() const
82cdf0e10cSrcweir {
83cdf0e10cSrcweir return ( nFlags & FLAGS_CREATEDWITHTOOLKIT ) != 0;
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
86cdf0e10cSrcweir // ::com::sun::star::uno::XInterface
queryInterface(const::com::sun::star::uno::Type & rType)87cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXDevice::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
88cdf0e10cSrcweir {
89cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
90cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XDevice*, this ),
91cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ),
92cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ),
93cdf0e10cSrcweir SAL_STATIC_CAST( ::com::sun::star::awt::XUnitConversion*, this ) );
94cdf0e10cSrcweir return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
97cdf0e10cSrcweir // ::com::sun::star::lang::XUnoTunnel
98cdf0e10cSrcweir IMPL_XUNOTUNNEL( VCLXDevice )
99cdf0e10cSrcweir
100cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider
IMPL_XTYPEPROVIDER_START(VCLXDevice)101cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXDevice )
102cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice>* ) NULL ),
103cdf0e10cSrcweir getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnitConversion>* ) NULL )
104cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END
105cdf0e10cSrcweir
106cdf0e10cSrcweir
107cdf0e10cSrcweir // ::com::sun::star::awt::XDevice,
108cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > VCLXDevice::createGraphics( ) throw(::com::sun::star::uno::RuntimeException)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() );
111cdf0e10cSrcweir
112cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > xRef;
113cdf0e10cSrcweir
114cdf0e10cSrcweir if ( mpOutputDevice )
115cdf0e10cSrcweir xRef = mpOutputDevice->CreateUnoGraphics();
116cdf0e10cSrcweir
117cdf0e10cSrcweir return xRef;
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
createDevice(sal_Int32 nWidth,sal_Int32 nHeight)120cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXDevice::createDevice( sal_Int32 nWidth, sal_Int32 nHeight ) throw(::com::sun::star::uno::RuntimeException)
121cdf0e10cSrcweir {
122cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() );
123cdf0e10cSrcweir
124cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > xRef;
125cdf0e10cSrcweir if ( GetOutputDevice() )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir VCLXVirtualDevice* pVDev = new VCLXVirtualDevice;
128cdf0e10cSrcweir VirtualDevice* pVclVDev = new VirtualDevice( *GetOutputDevice() );
129cdf0e10cSrcweir pVclVDev->SetOutputSizePixel( Size( nWidth, nHeight ) );
130cdf0e10cSrcweir pVDev->SetVirtualDevice( pVclVDev );
131cdf0e10cSrcweir xRef = pVDev;
132cdf0e10cSrcweir }
133cdf0e10cSrcweir return xRef;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir
getInfo()136cdf0e10cSrcweir ::com::sun::star::awt::DeviceInfo VCLXDevice::getInfo() throw(::com::sun::star::uno::RuntimeException)
137cdf0e10cSrcweir {
138cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() );
139cdf0e10cSrcweir
140cdf0e10cSrcweir ::com::sun::star::awt::DeviceInfo aInfo;
141cdf0e10cSrcweir
142cdf0e10cSrcweir if( mpOutputDevice )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir Size aDevSz;
145cdf0e10cSrcweir OutDevType eDevType = mpOutputDevice->GetOutDevType();
146cdf0e10cSrcweir if ( eDevType == OUTDEV_WINDOW )
147cdf0e10cSrcweir {
148cdf0e10cSrcweir aDevSz = ((Window*)mpOutputDevice)->GetSizePixel();
149cdf0e10cSrcweir ((Window*)mpOutputDevice)->GetBorder( aInfo.LeftInset, aInfo.TopInset, aInfo.RightInset, aInfo.BottomInset );
150cdf0e10cSrcweir }
151cdf0e10cSrcweir else if ( eDevType == OUTDEV_PRINTER )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir aDevSz = ((Printer*)mpOutputDevice)->GetPaperSizePixel();
154cdf0e10cSrcweir Size aOutSz = mpOutputDevice->GetOutputSizePixel();
155cdf0e10cSrcweir Point aOffset = ((Printer*)mpOutputDevice)->GetPageOffset();
156cdf0e10cSrcweir aInfo.LeftInset = aOffset.X();
157cdf0e10cSrcweir aInfo.TopInset = aOffset.Y();
158cdf0e10cSrcweir aInfo.RightInset = aDevSz.Width() - aOutSz.Width() - aOffset.X();
159cdf0e10cSrcweir aInfo.BottomInset = aDevSz.Height() - aOutSz.Height() - aOffset.Y();
160cdf0e10cSrcweir }
161cdf0e10cSrcweir else // VirtualDevice
162cdf0e10cSrcweir {
163cdf0e10cSrcweir aDevSz = mpOutputDevice->GetOutputSizePixel();
164cdf0e10cSrcweir aInfo.LeftInset = 0;
165cdf0e10cSrcweir aInfo.TopInset = 0;
166cdf0e10cSrcweir aInfo.RightInset = 0;
167cdf0e10cSrcweir aInfo.BottomInset = 0;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir aInfo.Width = aDevSz.Width();
171cdf0e10cSrcweir aInfo.Height = aDevSz.Height();
172cdf0e10cSrcweir
173cdf0e10cSrcweir Size aTmpSz = mpOutputDevice->LogicToPixel( Size( 1000, 1000 ), MapMode( MAP_CM ) );
174cdf0e10cSrcweir aInfo.PixelPerMeterX = aTmpSz.Width()/10;
175cdf0e10cSrcweir aInfo.PixelPerMeterY = aTmpSz.Height()/10;
176cdf0e10cSrcweir
177cdf0e10cSrcweir aInfo.BitsPerPixel = mpOutputDevice->GetBitCount();
178cdf0e10cSrcweir
179cdf0e10cSrcweir aInfo.Capabilities = 0;
180cdf0e10cSrcweir if ( mpOutputDevice->GetOutDevType() != OUTDEV_PRINTER )
181cdf0e10cSrcweir aInfo.Capabilities = ::com::sun::star::awt::DeviceCapability::RASTEROPERATIONS|::com::sun::star::awt::DeviceCapability::GETBITS;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir
184cdf0e10cSrcweir return aInfo;
185cdf0e10cSrcweir }
186cdf0e10cSrcweir
getFontDescriptors()187cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::awt::FontDescriptor > VCLXDevice::getFontDescriptors( ) throw(::com::sun::star::uno::RuntimeException)
188cdf0e10cSrcweir {
189cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() );
190cdf0e10cSrcweir
191cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::awt::FontDescriptor> aFonts;
192cdf0e10cSrcweir if( mpOutputDevice )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir int nFonts = mpOutputDevice->GetDevFontCount();
195cdf0e10cSrcweir if ( nFonts )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir aFonts = ::com::sun::star::uno::Sequence< ::com::sun::star::awt::FontDescriptor>( nFonts );
198cdf0e10cSrcweir ::com::sun::star::awt::FontDescriptor* pFonts = aFonts.getArray();
199cdf0e10cSrcweir for ( int n = 0; n < nFonts; n++ )
200cdf0e10cSrcweir pFonts[n] = VCLUnoHelper::CreateFontDescriptor( mpOutputDevice->GetDevFont( n ) );
201cdf0e10cSrcweir }
202cdf0e10cSrcweir }
203cdf0e10cSrcweir return aFonts;
204cdf0e10cSrcweir }
205cdf0e10cSrcweir
getFont(const::com::sun::star::awt::FontDescriptor & rDescriptor)206cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > VCLXDevice::getFont( const ::com::sun::star::awt::FontDescriptor& rDescriptor ) throw(::com::sun::star::uno::RuntimeException)
207cdf0e10cSrcweir {
208cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() );
209cdf0e10cSrcweir
210cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > xRef;
211cdf0e10cSrcweir if( mpOutputDevice )
212cdf0e10cSrcweir {
213cdf0e10cSrcweir VCLXFont* pMetric = new VCLXFont;
214cdf0e10cSrcweir pMetric->Init( *this, VCLUnoHelper::CreateFont( rDescriptor, mpOutputDevice->GetFont() ) );
215cdf0e10cSrcweir xRef = pMetric;
216cdf0e10cSrcweir }
217cdf0e10cSrcweir return xRef;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir
createBitmap(sal_Int32 nX,sal_Int32 nY,sal_Int32 nWidth,sal_Int32 nHeight)220cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > VCLXDevice::createBitmap( sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight ) throw(::com::sun::star::uno::RuntimeException)
221cdf0e10cSrcweir {
222cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() );
223cdf0e10cSrcweir
224cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp;
225cdf0e10cSrcweir if( mpOutputDevice )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir Bitmap aBmp = mpOutputDevice->GetBitmap( Point( nX, nY ), Size( nWidth, nHeight ) );
228cdf0e10cSrcweir
229cdf0e10cSrcweir VCLXBitmap* pBmp = new VCLXBitmap;
230cdf0e10cSrcweir pBmp->SetBitmap( BitmapEx( aBmp ) );
231cdf0e10cSrcweir xBmp = pBmp;
232cdf0e10cSrcweir }
233cdf0e10cSrcweir return xBmp;
234cdf0e10cSrcweir }
235cdf0e10cSrcweir
createDisplayBitmap(const::com::sun::star::uno::Reference<::com::sun::star::awt::XBitmap> & rxBitmap)236cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayBitmap > VCLXDevice::createDisplayBitmap( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >& rxBitmap ) throw(::com::sun::star::uno::RuntimeException)
237cdf0e10cSrcweir {
238cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() );
239cdf0e10cSrcweir
240cdf0e10cSrcweir BitmapEx aBmp = VCLUnoHelper::GetBitmap( rxBitmap );
241cdf0e10cSrcweir VCLXBitmap* pBmp = new VCLXBitmap;
242cdf0e10cSrcweir pBmp->SetBitmap( aBmp );
243cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayBitmap > xDBmp = pBmp;
244cdf0e10cSrcweir return xDBmp;
245cdf0e10cSrcweir }
246cdf0e10cSrcweir
247cdf0e10cSrcweir
~VCLXVirtualDevice()248cdf0e10cSrcweir VCLXVirtualDevice::~VCLXVirtualDevice()
249cdf0e10cSrcweir {
250cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() );
251cdf0e10cSrcweir
252cdf0e10cSrcweir DestroyOutputDevice();
253cdf0e10cSrcweir }
254cdf0e10cSrcweir
255cdf0e10cSrcweir
256cdf0e10cSrcweir // -----------------------------------------------------------------------------
257cdf0e10cSrcweir // ::com::sun::star::awt::XTextConstraints
258cdf0e10cSrcweir // -----------------------------------------------------------------------------
259cdf0e10cSrcweir // ::sal_Int32 SAL_CALL VCLXDevice::getTextWidth( const ::rtl::OUString& Text ) throw (::com::sun::star::uno::RuntimeException)
260cdf0e10cSrcweir // {
261cdf0e10cSrcweir // ::vos::OGuard aGuard( GetMutex() );
262cdf0e10cSrcweir // if (Text.getLength() == 0)
263cdf0e10cSrcweir // {
264cdf0e10cSrcweir // return 0;
265cdf0e10cSrcweir // }
266cdf0e10cSrcweir //
267cdf0e10cSrcweir // return 1;
268cdf0e10cSrcweir // }
269cdf0e10cSrcweir //
270cdf0e10cSrcweir // ::sal_Int32 SAL_CALL VCLXDevice::getTextHeight( ) throw (::com::sun::star::uno::RuntimeException)
271cdf0e10cSrcweir // {
272cdf0e10cSrcweir // ::vos::OGuard aGuard( GetMutex() );
273cdf0e10cSrcweir // return 1;
274cdf0e10cSrcweir // }
275cdf0e10cSrcweir
276cdf0e10cSrcweir
277cdf0e10cSrcweir // -----------------------------------------------------------------------------
278cdf0e10cSrcweir // Interface implementation of ::com::sun::star::awt::XUnitConversion
279cdf0e10cSrcweir // -----------------------------------------------------------------------------
280cdf0e10cSrcweir
convertPointToLogic(const::com::sun::star::awt::Point & aPoint,::sal_Int16 TargetUnit)281cdf0e10cSrcweir ::com::sun::star::awt::Point SAL_CALL VCLXDevice::convertPointToLogic( const ::com::sun::star::awt::Point& aPoint, ::sal_Int16 TargetUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
282cdf0e10cSrcweir {
283cdf0e10cSrcweir (void)aPoint;
284cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() );
285cdf0e10cSrcweir if (TargetUnit == com::sun::star::util::MeasureUnit::PERCENT )
286cdf0e10cSrcweir {
287cdf0e10cSrcweir // percentage not allowed here
288cdf0e10cSrcweir throw ::com::sun::star::lang::IllegalArgumentException();
289cdf0e10cSrcweir }
290cdf0e10cSrcweir
291cdf0e10cSrcweir ::com::sun::star::awt::Point aAWTPoint(0,0);
292cdf0e10cSrcweir // X,Y
293cdf0e10cSrcweir
294cdf0e10cSrcweir if( mpOutputDevice )
295cdf0e10cSrcweir {
296cdf0e10cSrcweir MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(TargetUnit));
297cdf0e10cSrcweir ::Point aVCLPoint = VCLUnoHelper::ConvertToVCLPoint(aPoint);
298cdf0e10cSrcweir ::Point aDevPoint = mpOutputDevice->PixelToLogic(aVCLPoint, aMode );
299cdf0e10cSrcweir aAWTPoint = VCLUnoHelper::ConvertToAWTPoint(aDevPoint);
300cdf0e10cSrcweir }
301cdf0e10cSrcweir
302cdf0e10cSrcweir return aAWTPoint;
303cdf0e10cSrcweir }
304cdf0e10cSrcweir
305cdf0e10cSrcweir
convertPointToPixel(const::com::sun::star::awt::Point & aPoint,::sal_Int16 SourceUnit)306cdf0e10cSrcweir ::com::sun::star::awt::Point SAL_CALL VCLXDevice::convertPointToPixel( const ::com::sun::star::awt::Point& aPoint, ::sal_Int16 SourceUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
307cdf0e10cSrcweir {
308cdf0e10cSrcweir (void)aPoint;
309cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() );
310cdf0e10cSrcweir if (SourceUnit == com::sun::star::util::MeasureUnit::PERCENT ||
311cdf0e10cSrcweir SourceUnit == com::sun::star::util::MeasureUnit::PIXEL )
312cdf0e10cSrcweir {
313cdf0e10cSrcweir // pixel or percentage not allowed here
314cdf0e10cSrcweir throw ::com::sun::star::lang::IllegalArgumentException();
315cdf0e10cSrcweir }
316cdf0e10cSrcweir
317cdf0e10cSrcweir ::com::sun::star::awt::Point aAWTPoint(0,0);
318cdf0e10cSrcweir
319cdf0e10cSrcweir if( mpOutputDevice )
320cdf0e10cSrcweir {
321cdf0e10cSrcweir MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(SourceUnit));
322cdf0e10cSrcweir ::Point aVCLPoint = VCLUnoHelper::ConvertToVCLPoint(aPoint);
323cdf0e10cSrcweir ::Point aDevPoint = mpOutputDevice->LogicToPixel(aVCLPoint, aMode );
324cdf0e10cSrcweir aAWTPoint = VCLUnoHelper::ConvertToAWTPoint(aDevPoint);
325cdf0e10cSrcweir }
326cdf0e10cSrcweir
327cdf0e10cSrcweir return aAWTPoint;
328cdf0e10cSrcweir }
329cdf0e10cSrcweir
convertSizeToLogic(const::com::sun::star::awt::Size & aSize,::sal_Int16 TargetUnit)330cdf0e10cSrcweir ::com::sun::star::awt::Size SAL_CALL VCLXDevice::convertSizeToLogic( const ::com::sun::star::awt::Size& aSize, ::sal_Int16 TargetUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
331cdf0e10cSrcweir {
332cdf0e10cSrcweir (void)aSize;
333cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() );
334cdf0e10cSrcweir if (TargetUnit == com::sun::star::util::MeasureUnit::PERCENT)
335cdf0e10cSrcweir {
336cdf0e10cSrcweir // percentage not allowed here
337cdf0e10cSrcweir throw ::com::sun::star::lang::IllegalArgumentException();
338cdf0e10cSrcweir }
339cdf0e10cSrcweir
340cdf0e10cSrcweir ::com::sun::star::awt::Size aAWTSize(0,0);
341cdf0e10cSrcweir // Width, Height
342cdf0e10cSrcweir
343cdf0e10cSrcweir
344cdf0e10cSrcweir if( mpOutputDevice )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(TargetUnit));
347cdf0e10cSrcweir ::Size aVCLSize = VCLUnoHelper::ConvertToVCLSize(aSize);
348cdf0e10cSrcweir ::Size aDevSz = mpOutputDevice->PixelToLogic(aVCLSize, aMode );
349cdf0e10cSrcweir aAWTSize = VCLUnoHelper::ConvertToAWTSize(aDevSz);
350cdf0e10cSrcweir }
351cdf0e10cSrcweir
352cdf0e10cSrcweir return aAWTSize;
353cdf0e10cSrcweir }
354cdf0e10cSrcweir
convertSizeToPixel(const::com::sun::star::awt::Size & aSize,::sal_Int16 SourceUnit)355cdf0e10cSrcweir ::com::sun::star::awt::Size SAL_CALL VCLXDevice::convertSizeToPixel( const ::com::sun::star::awt::Size& aSize, ::sal_Int16 SourceUnit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
356cdf0e10cSrcweir {
357cdf0e10cSrcweir (void)aSize;
358cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() );
359cdf0e10cSrcweir if (SourceUnit == com::sun::star::util::MeasureUnit::PERCENT ||
360cdf0e10cSrcweir SourceUnit == com::sun::star::util::MeasureUnit::PIXEL)
361cdf0e10cSrcweir {
362cdf0e10cSrcweir // pixel or percentage not allowed here
363cdf0e10cSrcweir throw ::com::sun::star::lang::IllegalArgumentException();
364cdf0e10cSrcweir }
365cdf0e10cSrcweir
366cdf0e10cSrcweir ::com::sun::star::awt::Size aAWTSize(0,0);
367cdf0e10cSrcweir // Width, Height
368cdf0e10cSrcweir if( mpOutputDevice )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(SourceUnit));
371cdf0e10cSrcweir ::Size aVCLSize = VCLUnoHelper::ConvertToVCLSize(aSize);
372cdf0e10cSrcweir ::Size aDevSz = mpOutputDevice->LogicToPixel(aVCLSize, aMode );
373cdf0e10cSrcweir aAWTSize = VCLUnoHelper::ConvertToAWTSize(aDevSz);
374cdf0e10cSrcweir }
375cdf0e10cSrcweir
376cdf0e10cSrcweir return aAWTSize;
377cdf0e10cSrcweir }
378cdf0e10cSrcweir
379