vcl/inc/osx/salprn.h | 7 +++---- vcl/unx/generic/print/genprnpsp.cxx | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-)
New commits: commit 6c688ee8625f3f5e7be50912e02cdf59f6ae7e5f Author: Okhuomon Ajayi <[email protected]> AuthorDate: Mon Oct 20 21:57:58 2025 +0100 Commit: Ilmari Lauhakangas <[email protected]> CommitDate: Wed Oct 22 08:25:06 2025 +0200 tdf#168226 Use o3tl::convert() for unit conversion instead of custom formula Change-Id: I2a9060a6f562db7d2bfbcc5a60bf0997dad38c29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192757 Reviewed-by: Ilmari Lauhakangas <[email protected]> Tested-by: Jenkins diff --git a/vcl/inc/osx/salprn.h b/vcl/inc/osx/salprn.h index 933dd2bdfa14..491d80b02501 100644 --- a/vcl/inc/osx/salprn.h +++ b/vcl/inc/osx/salprn.h @@ -22,6 +22,7 @@ #include <sal/config.h> #include <tools/long.hxx> +#include <o3tl/unit_conversion.hxx> #include <osx/osxvcltypes.h> @@ -148,10 +149,8 @@ class AquaSalPrinter : public SalPrinter AquaSalPrinter& operator=(const AquaSalPrinter&) = delete; }; -const double fPtTo100thMM = 35.27777778; +inline int PtTo10Mu( double nPoints ) { return o3tl::convert(nPoints, o3tl::Length::pt, o3tl::Length::mm100); } -inline int PtTo10Mu( double nPoints ) { return static_cast<int>((nPoints*fPtTo100thMM)+0.5); } - -inline double TenMuToPt( double nUnits ) { return floor((nUnits/fPtTo100thMM)+0.5); } +inline double TenMuToPt( double nUnits ) { return o3tl::convert(nUnits, o3tl::Length::mm100, o3tl::Length::pt); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx index bbba1230b624..e078fe9c6dc5 100644 --- a/vcl/unx/generic/print/genprnpsp.cxx +++ b/vcl/unx/generic/print/genprnpsp.cxx @@ -40,6 +40,7 @@ #include <comphelper/fileurl.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/unit_conversion.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/ustring.hxx> #include <sal/log.hxx> @@ -142,9 +143,9 @@ namespace } } -static int PtTo10Mu( int nPoints ) { return static_cast<int>((static_cast<double>(nPoints)*35.27777778)+0.5); } +static int PtTo10Mu( int nPoints ) { return o3tl::convert(nPoints, o3tl::Length::pt, o3tl::Length::mm100); } -static int TenMuToPt( int nUnits ) { return static_cast<int>((static_cast<double>(nUnits)/35.27777778)+0.5); } +static int TenMuToPt( int nUnits ) { return o3tl::convert(nUnits, o3tl::Length::mm100, o3tl::Length::pt); } static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) {
