[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/tools

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 9 11:40:44 UTC 2020


 include/tools/UnitConversion.hxx |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 5eb4a8b5562fde916b4049580c62a3e400922446
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun May 17 20:12:33 2020 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Jun 9 13:40:10 2020 +0200

    vcl: add conversion point to 100th mm for double values
    
    Integer conversion throws away percision, which is problematic
    when we work with floating point values.
    
    Change-Id: Ib34e46bd59aa67e933d49bc800e96cc6426414e5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95260
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit 0e29e9ea7f4fe58d8dbdc7a9b9f58543a93d5bf5)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95831
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/tools/UnitConversion.hxx b/include/tools/UnitConversion.hxx
index e59077d8a5fa..2093db6181d9 100644
--- a/include/tools/UnitConversion.hxx
+++ b/include/tools/UnitConversion.hxx
@@ -15,13 +15,18 @@ constexpr sal_Int64 convertTwipToMm100(sal_Int64 n)
     return (n >= 0) ? (n * 127 + 36) / 72 : (n * 127 - 36) / 72;
 }
 
-constexpr sal_Int64 convertPointToMm100(sal_Int64 n) { return convertTwipToMm100(n * 20); }
-
 constexpr sal_Int64 convertMm100ToTwip(sal_Int64 n)
 {
     return (n >= 0) ? (n * 72 + 63) / 127 : (n * 72 - 63) / 127;
 }
 
+constexpr sal_Int64 convertPointToMm100(sal_Int64 nNumber)
+{
+    return convertTwipToMm100(nNumber * 20);
+}
+
+constexpr double convertPointToMm100(double fNumber) { return fNumber * 35.27777777778; }
+
 // Convert PPT's "master unit" (1/576 inch) to twips
 constexpr sal_Int64 convertMasterUnitToTwip(sal_Int64 n) { return n * 2540.0 / 576.0; }
 


More information about the Libreoffice-commits mailing list