tdf#154349: round before converting to an integer
Commit cfff893b9c82843a90aac4ecdb3a3936721b74a0 (Move unit conversion
code to o3tl, and unify on that in more places, 2021-02-14) changed a
custom conversion code in CalcToUnit doing inexact conversion from
points to mm/20 (with "* 10 / 567"), with correct conversion function.
A side effect was, however, that the imprecise arithmetics provided
floating-point values that rounded down to correct integers (or maybe
it was all the chain of calculations down to this function), while
the correctly converted values could round down to a smaller value.
Fix this problem using rounding.
Change-Id: I42e0d56b068832ef309f6b696f661642e62ddacb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152894
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/svtools/source/misc/unitconv.cxx b/svtools/source/misc/unitconv.cxx
index 395c1b4..cb4fdf6 100644
--- a/svtools/source/misc/unitconv.cxx
+++ b/svtools/source/misc/unitconv.cxx
@@ -128,7 +128,7 @@ tools::Long CalcToUnit( float nIn, MapUnit eUnit )
eUnit == MapUnit::MapCM, "this unit is not implemented" );
if (const auto eTo = MapToO3tlLength(eUnit); eTo != o3tl::Length::invalid)
return o3tl::convert(nIn, o3tl::Length::pt, eTo);
return std::round(o3tl::convert(nIn, o3tl::Length::pt, eTo));
return 0;
}