summaryrefslogtreecommitdiff
path: root/toolkit/source/awt/vclxdevice.cxx
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2008-06-25 13:21:47 +0000
committerKurt Zenker <kz@openoffice.org>2008-06-25 13:21:47 +0000
commit9f35384f9e88483842ead009ef70557da5bc2e3d (patch)
tree11358d9207333eea8f4e2b762108b85953864361 /toolkit/source/awt/vclxdevice.cxx
parent9ede065284db3439e1edc8dfb7281be73f881ada (diff)
INTEGRATION: CWS rptwizard01 (1.6.190); FILE MERGED
2008/05/21 10:11:57 lla 1.6.190.3: RESYNC: (1.6-1.7); FILE MERGED 2008/03/14 14:00:22 lla 1.6.190.2: #i86925# cleanup 2008/03/14 13:47:16 lla 1.6.190.1: #i86925# Unit Converter
Diffstat (limited to 'toolkit/source/awt/vclxdevice.cxx')
-rw-r--r--toolkit/source/awt/vclxdevice.cxx135
1 files changed, 132 insertions, 3 deletions
diff --git a/toolkit/source/awt/vclxdevice.cxx b/toolkit/source/awt/vclxdevice.cxx
index 2f5370438a74..af26e36072ed 100644
--- a/toolkit/source/awt/vclxdevice.cxx
+++ b/toolkit/source/awt/vclxdevice.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: vclxdevice.cxx,v $
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
* This file is part of OpenOffice.org.
*
@@ -32,6 +32,8 @@
#include "precompiled_toolkit.hxx"
#include <com/sun/star/awt/DeviceCapability.hpp>
+#include <com/sun/star/util/MeasureUnit.hpp>
+
#include <toolkit/awt/vclxdevice.hxx>
#include <toolkit/awt/vclxfont.hxx>
#include <toolkit/awt/vclxbitmap.hxx>
@@ -94,7 +96,8 @@ sal_Bool VCLXDevice::IsCreatedWithToolkit() const
::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
SAL_STATIC_CAST( ::com::sun::star::awt::XDevice*, this ),
SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ),
- SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) );
+ SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ),
+ SAL_STATIC_CAST( ::com::sun::star::awt::XUnitConversion*, this ) );
return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
}
@@ -103,7 +106,8 @@ IMPL_XUNOTUNNEL( VCLXDevice )
// ::com::sun::star::lang::XTypeProvider
IMPL_XTYPEPROVIDER_START( VCLXDevice )
- getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice>* ) NULL )
+ getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice>* ) NULL ),
+ getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnitConversion>* ) NULL )
IMPL_XTYPEPROVIDER_END
@@ -256,3 +260,128 @@ VCLXVirtualDevice::~VCLXVirtualDevice()
}
+// -----------------------------------------------------------------------------
+// ::com::sun::star::awt::XTextConstraints
+// -----------------------------------------------------------------------------
+// ::sal_Int32 SAL_CALL VCLXDevice::getTextWidth( const ::rtl::OUString& Text ) throw (::com::sun::star::uno::RuntimeException)
+// {
+// ::vos::OGuard aGuard( GetMutex() );
+// if (Text.getLength() == 0)
+// {
+// return 0;
+// }
+//
+// return 1;
+// }
+//
+// ::sal_Int32 SAL_CALL VCLXDevice::getTextHeight( ) throw (::com::sun::star::uno::RuntimeException)
+// {
+// ::vos::OGuard aGuard( GetMutex() );
+// return 1;
+// }
+
+
+// -----------------------------------------------------------------------------
+// ::com::sun::star::awt::XUnitConversion
+// -----------------------------------------------------------------------------
+
+::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)
+{
+ (void)aPoint;
+ ::vos::OGuard aGuard( GetMutex() );
+ if (TargetUnit == com::sun::star::util::MeasureUnit::PERCENT ||
+ TargetUnit == com::sun::star::util::MeasureUnit::PIXEL)
+ {
+ // pixel or percentage not allowed here
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+
+ ::com::sun::star::awt::Point aAWTPoint(0,0);
+ // X,Y
+
+ if( mpOutputDevice )
+ {
+ MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(TargetUnit));
+ ::Point aVCLPoint = VCLUnoHelper::ConvertToVCLPoint(aPoint);
+ ::Point aDevPoint = mpOutputDevice->PixelToLogic(aVCLPoint, aMode );
+ aAWTPoint = VCLUnoHelper::ConvertToAWTPoint(aDevPoint);
+ }
+
+ return aAWTPoint;
+}
+
+
+::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)
+{
+ (void)aPoint;
+ ::vos::OGuard aGuard( GetMutex() );
+ if (SourceUnit == com::sun::star::util::MeasureUnit::PERCENT ||
+ SourceUnit == com::sun::star::util::MeasureUnit::PIXEL)
+ {
+ // pixel or percentage not allowed here
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+
+ ::com::sun::star::awt::Point aAWTPoint(0,0);
+
+ if( mpOutputDevice )
+ {
+ MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(SourceUnit));
+ ::Point aVCLPoint = VCLUnoHelper::ConvertToVCLPoint(aPoint);
+ ::Point aDevPoint = mpOutputDevice->LogicToPixel(aVCLPoint, aMode );
+ aAWTPoint = VCLUnoHelper::ConvertToAWTPoint(aDevPoint);
+ }
+
+ return aAWTPoint;
+}
+
+::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)
+{
+ (void)aSize;
+ ::vos::OGuard aGuard( GetMutex() );
+ if (TargetUnit == com::sun::star::util::MeasureUnit::PERCENT ||
+ TargetUnit == com::sun::star::util::MeasureUnit::PIXEL)
+ {
+ // pixel or percentage not allowed here
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+
+ ::com::sun::star::awt::Size aAWTSize(0,0);
+ // Width, Height
+
+
+ if( mpOutputDevice )
+ {
+ MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(TargetUnit));
+ ::Size aVCLSize = VCLUnoHelper::ConvertToVCLSize(aSize);
+ ::Size aDevSz = mpOutputDevice->PixelToLogic(aVCLSize, aMode );
+ aAWTSize = VCLUnoHelper::ConvertToAWTSize(aDevSz);
+ }
+
+ return aAWTSize;
+}
+
+::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)
+{
+ (void)aSize;
+ ::vos::OGuard aGuard( GetMutex() );
+ if (SourceUnit == com::sun::star::util::MeasureUnit::PERCENT ||
+ SourceUnit == com::sun::star::util::MeasureUnit::PIXEL)
+ {
+ // pixel or percentage not allowed here
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ }
+
+ ::com::sun::star::awt::Size aAWTSize(0,0);
+ // Width, Height
+ if( mpOutputDevice )
+ {
+ MapMode aMode(VCLUnoHelper::ConvertToMapModeUnit(SourceUnit));
+ ::Size aVCLSize = VCLUnoHelper::ConvertToVCLSize(aSize);
+ ::Size aDevSz = mpOutputDevice->LogicToPixel(aVCLSize, aMode );
+ aAWTSize = VCLUnoHelper::ConvertToAWTSize(aDevSz);
+ }
+
+ return aAWTSize;
+}
+