diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-05-17 20:12:33 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-06-01 12:21:37 +0200 |
commit | 0e29e9ea7f4fe58d8dbdc7a9b9f58543a93d5bf5 (patch) | |
tree | 5d77613871ae44df9e56ae4d17a89c879e0dcac4 | |
parent | 4062b3f87689e48fd250d9cf0297a24b5427bf59 (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>
-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; } |