summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-08-06 09:28:57 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-08-06 12:10:19 +0200
commited4ffba1c180c74e3b9c3aadc279ff92bda8ab5a (patch)
tree2ee84a3e56ea52e1dad04ede452dd6b7d956d1a2 /vbahelper
parent36333de160c88a3190d799c031b16e1ef6bcaa86 (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 'vbahelper')
-rw-r--r--vbahelper/source/vbahelper/vbahelper.cxx26
1 files changed, 7 insertions, 19 deletions
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index a6e7ac1da2aa..be4098ce6ae9 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -62,6 +62,7 @@
#include <basic/sbmod.hxx>
#include <basic/sbuno.hxx>
#include <basic/sberrors.hxx>
+#include <o3tl/unit_conversion.hxx>
#include <rtl/ustrbuf.hxx>
#include <sfx2/viewsh.hxx>
#include <sal/log.hxx>
@@ -607,35 +608,22 @@ OUString VBAToRegexp(const OUString &rIn)
return sResult.makeStringAndClear( );
}
-double getPixelTo100thMillimeterConversionFactor( const css::uno::Reference< css::awt::XDevice >& xDevice, bool bVertical)
+static double getPixelToMeterConversionFactor( const css::uno::Reference< css::awt::XDevice >& xDevice, bool bVertical)
{
- double fConvertFactor = 1.0;
- if( bVertical )
- {
- fConvertFactor = xDevice->getInfo().PixelPerMeterY/100000;
- }
- else
- {
- fConvertFactor = xDevice->getInfo().PixelPerMeterX/100000;
- }
- return fConvertFactor;
+ return bVertical ? xDevice->getInfo().PixelPerMeterY : xDevice->getInfo().PixelPerMeterX;
}
double PointsToPixels( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, bool bVertical)
{
- double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical );
- return convertPointToMm100(fPoints) * fConvertFactor;
+ double fConvertFactor = getPixelToMeterConversionFactor( xDevice, bVertical );
+ return o3tl::convert(fPoints, o3tl::Length::pt, o3tl::Length::m) * fConvertFactor;
}
double PixelsToPoints( const css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, bool bVertical)
{
- double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical );
- return convertMm100ToPoint(fPixels / fConvertFactor);
+ double fConvertFactor = getPixelToMeterConversionFactor( xDevice, bVertical );
+ return o3tl::convert(fPixels / fConvertFactor, o3tl::Length::m, o3tl::Length::pt);
}
-sal_Int32 PointsToHmm(double fPoints) { return std::round(convertPointToMm100(fPoints)); }
-
-double HmmToPoints(sal_Int32 nHmm) { return convertMm100ToPoint<double>(nHmm); }
-
ConcreteXShapeGeometryAttributes::ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::drawing::XShape >& xShape )
{
m_pShapeHelper.reset( new ShapeHelper( xShape ) );