From 956c09ca7d690471f62e8e2e14ad04fefcebf7e7 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Fri, 5 Feb 2021 19:35:14 +0300 Subject: Use more conversion functions from 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 --- chart2/source/view/charttypes/VSeriesPlotter.cxx | 4 ++-- chart2/source/view/main/ShapeFactory.cxx | 3 ++- chart2/source/view/main/VLegend.cxx | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'chart2') 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 #include #include +#include #include #include #include @@ -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 #include #include +#include #include #include @@ -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 #include #include +#include #include #include @@ -85,8 +86,7 @@ double lcl_CalcViewFontSize( } } - // pt -> 1/100th mm - return (fResult * (2540.0 / 72.0)); + return convertPointToMm100(fResult); } void lcl_getProperties( -- cgit