oovbaapi/ooo/vba/word/XApplication.idl |   11 +++++
 sw/source/ui/vba/vbaapplication.cxx    |   61 ++++++++++++++++++++++++++++++++-
 sw/source/ui/vba/vbaapplication.hxx    |   12 ++++++
 3 files changed, 82 insertions(+), 2 deletions(-)

New commits:
commit c9b57b7226de7062b9feaf7706825f6dc2a6fee8
Author:     Hannah Meeks <hmeeks4...@gmail.com>
AuthorDate: Thu Aug 4 09:45:22 2022 +0100
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Fri Aug 5 12:06:59 2022 +0200

    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.kagan...@collabora.com>
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>

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;

Reply via email to