diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-05-17 20:12:33 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-07-29 20:44:40 +0200 |
commit | 98e9c22ad50acea9567a02162ec067c4a8c2e9ff (patch) | |
tree | d4a8341e9251196491b6f1cc6b635ffe833478dc /include | |
parent | 71adf9126b99405d7928b0d4295d586e4551ac12 (diff) |
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@gmail.com>
(cherry picked from commit 0e29e9ea7f4fe58d8dbdc7a9b9f58543a93d5bf5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95831
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit 5eb4a8b5562fde916b4049580c62a3e400922446)
Diffstat (limited to 'include')
-rw-r--r-- | include/tools/UnitConversion.hxx | 9 |
1 files changed, 7 insertions, 2 deletions
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; } |