diff options
author | Hannah Meeks <hmeeks4135@gmail.com> | 2022-08-04 09:45:22 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2022-08-05 12:06:59 +0200 |
commit | c9b57b7226de7062b9feaf7706825f6dc2a6fee8 (patch) | |
tree | 35457f53b9bebd53d11ffcf8c211a2afae6c0f62 | |
parent | f3234f4f14702da71528561418f07ee6670a8c2a (diff) |
VBA Add conversion methods to Application
Change-Id: Ic0de06699a647565deca7985742965a72614df16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137787
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r-- | oovbaapi/ooo/vba/word/XApplication.idl | 11 | ||||
-rw-r--r-- | sw/source/ui/vba/vbaapplication.cxx | 61 | ||||
-rw-r--r-- | sw/source/ui/vba/vbaapplication.hxx | 12 |
3 files changed, 82 insertions, 2 deletions
diff --git a/oovbaapi/ooo/vba/word/XApplication.idl b/oovbaapi/ooo/vba/word/XApplication.idl index 257903eb47f2..0475c2d82829 100644 --- a/oovbaapi/ooo/vba/word/XApplication.idl +++ b/oovbaapi/ooo/vba/word/XApplication.idl @@ -52,7 +52,16 @@ interface XApplication : XConnectable any Addins( [in] any Index ); any Dialogs( [in] any Index ); any ListGalleries( [in] any aIndex ); - float CentimetersToPoints([in] float Centimeters ); + float CentimetersToPoints( [in] float Centimeters ); + float PointsToCentimeters( [in] float Points); + float PixelsToPoints( [in] float Pixels, [in] boolean fVertical ); + float PointsToPixels( [in] float Points, [in] boolean fVertical); + float InchesToPoints( [in] float Inches); + float PointsToInches( [in] float Points); + float MillimetersToPoints( [in] float Millimeters ); + float PointsToMillimeters( [in] float Points); + float PicasToPoints( [in] float Picas); + float PointsToPicas( [in] float Points); void ShowMe(); void Resize( [in] long Width, [in] long Height ); void Move( [in] long Left, [in] long Top ); diff --git a/sw/source/ui/vba/vbaapplication.cxx b/sw/source/ui/vba/vbaapplication.cxx index 1cab0573121a..c95c855c01fd 100644 --- a/sw/source/ui/vba/vbaapplication.cxx +++ b/sw/source/ui/vba/vbaapplication.cxx @@ -20,6 +20,7 @@ #include <com/sun/star/task/XStatusIndicatorSupplier.hpp> #include <com/sun/star/task/XStatusIndicator.hpp> #include <com/sun/star/util/thePathSettings.hpp> +#include <com/sun/star/awt/XDevice.hpp> #include "vbaapplication.hxx" #include "vbadocument.hxx" @@ -417,9 +418,67 @@ float SAL_CALL SwVbaApplication::CentimetersToPoints( float Centimeters ) return VbaApplicationBase::CentimetersToPoints( Centimeters ); } +float SAL_CALL SwVbaApplication::PointsToCentimeters( float Points ) +{ + return o3tl::convert(Points, o3tl::Length::pt, o3tl::Length::cm); +} + +float SAL_CALL SwVbaApplication::PixelsToPoints( float Pixels, ::sal_Bool fVertical ) +{ + //Set up xDevice + uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_SET_THROW ); + uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW ); + uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_SET_THROW ); + uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_SET_THROW ); + css::uno::Reference< css::awt::XDevice > xDevice( xWindow, css::uno::UNO_QUERY ); + + return ooo::vba::PixelsToPoints(xDevice, Pixels, fVertical); +} + +float SAL_CALL SwVbaApplication::PointsToPixels( float Pixels, ::sal_Bool fVertical ) +{ + uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_SET_THROW ); + uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW ); + uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_SET_THROW ); + uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_SET_THROW ); + css::uno::Reference< css::awt::XDevice > xDevice( xWindow, css::uno::UNO_QUERY ); + + return ooo::vba::PointsToPixels(xDevice, Pixels, fVertical); +} + +float SAL_CALL SwVbaApplication::InchesToPoints( float Inches ) +{ + return o3tl::convert(Inches, o3tl::Length::ch, o3tl::Length::pt); +} + +float SAL_CALL SwVbaApplication::PointsToInches( float Points ) +{ + return o3tl::convert(Points, o3tl::Length::pt, o3tl::Length::ch); +} + +float SAL_CALL SwVbaApplication::MillimetersToPoints( float Millimeters ) +{ + return o3tl::convert(Millimeters, o3tl::Length::mm, o3tl::Length::pt); +} + +float SAL_CALL SwVbaApplication::PointsToMillimeters( float Points ) +{ + return o3tl::convert(Points, o3tl::Length::pt, o3tl::Length::mm); +} + +float SAL_CALL SwVbaApplication::PicasToPoints( float Picas ) +{ + return o3tl::convert(Picas, o3tl::Length::pc, o3tl::Length::pt); +} + +float SAL_CALL SwVbaApplication::PointsToPicas( float Points ) +{ + return o3tl::convert(Points, o3tl::Length::pt, o3tl::Length::pc); +} + void SAL_CALL SwVbaApplication::ShowMe() { - // No idea what we should or could do + // Method no longer supported in word - deprecated } void SAL_CALL SwVbaApplication::Resize( sal_Int32 Width, sal_Int32 Height ) diff --git a/sw/source/ui/vba/vbaapplication.hxx b/sw/source/ui/vba/vbaapplication.hxx index 43cf30bc1a20..90b4322835fd 100644 --- a/sw/source/ui/vba/vbaapplication.hxx +++ b/sw/source/ui/vba/vbaapplication.hxx @@ -91,6 +91,18 @@ public: virtual css::uno::Any SAL_CALL getCustomizationContext() override; virtual void SAL_CALL setCustomizationContext( const css::uno::Any& _customizationcontext ) override; virtual float SAL_CALL CentimetersToPoints( float Centimeters ) override; + virtual float SAL_CALL PointsToCentimeters( float Points ) override; + virtual float SAL_CALL PixelsToPoints( float Pixels, ::sal_Bool fVertical ) override; + virtual float SAL_CALL PointsToPixels( float Pixels, ::sal_Bool fVertical ) override; + virtual float SAL_CALL InchesToPoints( float Inches ) override; + virtual float SAL_CALL PointsToInches( float Points ) override; + virtual float SAL_CALL MillimetersToPoints( float Millimeters ) override; + virtual float SAL_CALL PointsToMillimeters( float Points ) override; + virtual float SAL_CALL PicasToPoints( float Picas ) override; + virtual float SAL_CALL PointsToPicas( float Points ) override; + + + virtual void SAL_CALL ShowMe() override; virtual void SAL_CALL Resize( sal_Int32 Width, sal_Int32 Height ) override; virtual void SAL_CALL Move( sal_Int32 Left, sal_Int32 Top ) override; |