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