summaryrefslogtreecommitdiff
path: root/chart2/source
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-02-05 19:35:14 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-02-06 17:05:44 +0100
commit956c09ca7d690471f62e8e2e14ad04fefcebf7e7 (patch)
treec681ace388370acf5842c73d45e9e9d8880777af /chart2/source
parentca074a47e8fdae396633dad6f59450508bb2c9f0 (diff)
Use more conversion functions from <tools/UnitConversion.hxx>
This unifies conversion functions to provide both floating-point and integral overloads, with correct rounding for the latter. Also sanitizing code it templatized to allow reuse if needed. Change-Id: Ibe1c9fe4d5baa226c600445779dbaf7dc41a02cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110487 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'chart2/source')
-rw-r--r--chart2/source/view/charttypes/VSeriesPlotter.cxx4
-rw-r--r--chart2/source/view/main/ShapeFactory.cxx3
-rw-r--r--chart2/source/view/main/VLegend.cxx4
3 files changed, 6 insertions, 5 deletions
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index f405396e113c..92cb3786d594 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -61,6 +61,7 @@
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <tools/color.hxx>
+#include <tools/UnitConversion.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/math.hxx>
#include <basegfx/vector/b2dvector.hxx>
@@ -451,8 +452,7 @@ uno::Reference< drawing::XShape > VSeriesPlotter::createDataLabel( const uno::Re
uno::Reference< beans::XPropertySet > xProps( rDataSeries.getPropertiesOfPoint( nPointIndex ) );
if( xProps.is() )
xProps->getPropertyValue( "CharHeight") >>= fViewFontSize;
- // pt -> 1/100th mm
- fViewFontSize *= (2540.0f / 72.0f);
+ fViewFontSize = convertPointToMm100(fViewFontSize);
}
// the font height is used for computing the size of an optional legend
diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx
index 22b9f8d07820..5b7c4859beb8 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -56,6 +56,7 @@
#include <basegfx/matrix/b3dhommatrix.hxx>
#include <tools/diagnose_ex.h>
#include <tools/helpers.hxx>
+#include <tools/UnitConversion.hxx>
#include <sal/log.hxx>
#include <algorithm>
@@ -2391,7 +2392,7 @@ uno::Reference< drawing::XShape >
float fFontHeight = 0.0;
if ( xShapeProp.is() && ( xShapeProp->getPropertyValue( "CharHeight" ) >>= fFontHeight ) )
{
- fFontHeight *= ( 2540.0f / 72.0f ); // pt -> 1/100 mm
+ fFontHeight = convertPointToMm100(fFontHeight);
sal_Int32 nXDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * 0.18f ) );
sal_Int32 nYDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * 0.30f ) );
xShapeProp->setPropertyValue( "TextLeftDistance", uno::Any( nXDistance ) );
diff --git a/chart2/source/view/main/VLegend.cxx b/chart2/source/view/main/VLegend.cxx
index 77e6b5800dc5..e05aa94db702 100644
--- a/chart2/source/view/main/VLegend.cxx
+++ b/chart2/source/view/main/VLegend.cxx
@@ -42,6 +42,7 @@
#include <rtl/math.hxx>
#include <svl/languageoptions.hxx>
#include <tools/diagnose_ex.h>
+#include <tools/UnitConversion.hxx>
#include <vector>
#include <algorithm>
@@ -85,8 +86,7 @@ double lcl_CalcViewFontSize(
}
}
- // pt -> 1/100th mm
- return (fResult * (2540.0 / 72.0));
+ return convertPointToMm100(fResult);
}
void lcl_getProperties(