diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2022-08-06 09:28:57 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-08-06 12:10:19 +0200 |
commit | ed4ffba1c180c74e3b9c3aadc279ff92bda8ab5a (patch) | |
tree | 2ee84a3e56ea52e1dad04ede452dd6b7d956d1a2 /sc/source/ui/vba | |
parent | 36333de160c88a3190d799c031b16e1ef6bcaa86 (diff) |
Drop some conversion from vbahelper; use usual functions where needed
Change-Id: I71bea54f095072a0e403bfc7aa48a0f0f9a0ebaa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137891
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc/source/ui/vba')
-rw-r--r-- | sc/source/ui/vba/vbasheetobject.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/vba/vbasheetobjects.cxx | 10 |
2 files changed, 16 insertions, 4 deletions
diff --git a/sc/source/ui/vba/vbasheetobject.cxx b/sc/source/ui/vba/vbasheetobject.cxx index 52513095fac4..ff37ab8addfb 100644 --- a/sc/source/ui/vba/vbasheetobject.cxx +++ b/sc/source/ui/vba/vbasheetobject.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/script/XEventAttacherManager.hpp> #include <com/sun/star/style/VerticalAlignment.hpp> #include <comphelper/documentinfo.hxx> +#include <o3tl/unit_conversion.hxx> #include <ooo/vba/excel/Constants.hpp> #include <ooo/vba/excel/XlOrientation.hpp> #include <ooo/vba/excel/XlPlacement.hpp> @@ -39,6 +40,15 @@ using namespace ::ooo::vba; constexpr OUStringLiteral gaListenerType = u"XActionListener"; constexpr OUStringLiteral gaEventMethod = u"actionPerformed"; +static double HmmToPoints(double nHmm) +{ + return o3tl::convert(nHmm, o3tl::Length::mm100, o3tl::Length::pt); +} + +static sal_Int32 PointsToHmm(double fPoints) +{ + return std::round(o3tl::convert(fPoints, o3tl::Length::pt, o3tl::Length::mm100)); +} ScVbaButtonCharacters::ScVbaButtonCharacters( const uno::Reference< XHelperInterface >& rxParent, diff --git a/sc/source/ui/vba/vbasheetobjects.cxx b/sc/source/ui/vba/vbasheetobjects.cxx index 32e025a3ca7e..a6a9a1233b8e 100644 --- a/sc/source/ui/vba/vbasheetobjects.cxx +++ b/sc/source/ui/vba/vbasheetobjects.cxx @@ -19,6 +19,7 @@ #include "vbasheetobjects.hxx" #include <vector> +#include <o3tl/unit_conversion.hxx> #include <rtl/math.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XIndexContainer.hpp> @@ -58,9 +59,10 @@ bool lclGetProperty( Type& orValue, const uno::Reference< beans::XPropertySet >& @throws uno::RuntimeException */ -double lclPointsToHmm( const uno::Any& rPoints ) +sal_Int32 lclPointsToHmm( const uno::Any& rPoints ) { - return PointsToHmm( ::rtl::math::approxFloor( rPoints.get< double >() / 0.75 ) * 0.75 ); + return std::round(o3tl::convert(::rtl::math::approxFloor(rPoints.get<double>() / 0.75) * 0.75, + o3tl::Length::pt, o3tl::Length::mm100)); } } // namespace @@ -349,8 +351,8 @@ uno::Any SAL_CALL ScVbaGraphicObjectsBase::Add( const uno::Any& rLeft, const uno /* Extract double values from passed Anys (the lclPointsToHmm() helper function will throw a RuntimeException on any error), and convert from points to 1/100 mm. */ - awt::Point aPos( static_cast<sal_Int32>(lclPointsToHmm( rLeft )), static_cast<sal_Int32>(lclPointsToHmm( rTop )) ); - awt::Size aSize( static_cast<sal_Int32>(lclPointsToHmm( rWidth )), static_cast<sal_Int32>(lclPointsToHmm( rHeight )) ); + awt::Point aPos( lclPointsToHmm( rLeft ), lclPointsToHmm( rTop ) ); + awt::Size aSize( lclPointsToHmm( rWidth ), lclPointsToHmm( rHeight ) ); // TODO: translate coordinates for RTL sheets if( (aPos.X < 0) || (aPos.Y < 0) || (aSize.Width <= 0) || (aSize.Height <= 0) ) throw uno::RuntimeException(); |