summaryrefslogtreecommitdiff
path: root/include/tools
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-05-01 17:20:26 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-05-03 11:10:04 +0200
commit09e28008376e2f2a187067409d3076e81eba022e (patch)
treea026a102ca2e808e0d39a36448730957dad86fd5 /include/tools
parentd4190effb9068dff5ebd3c01c7e3073b1af78b2d (diff)
move unit conversions to UnitConversion, add convertPointToMm100
Change-Id: I3e5a4632e9809562885c1e0ec5c5262acec145d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93332 Tested-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include/tools')
-rw-r--r--include/tools/UnitConversion.hxx25
-rw-r--r--include/tools/mapunit.hxx11
2 files changed, 26 insertions, 10 deletions
diff --git a/include/tools/UnitConversion.hxx b/include/tools/UnitConversion.hxx
new file mode 100644
index 000000000000..8ad489dee590
--- /dev/null
+++ b/include/tools/UnitConversion.hxx
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+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;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/tools/mapunit.hxx b/include/tools/mapunit.hxx
index 2209f4d35261..6112bc7ef461 100644
--- a/include/tools/mapunit.hxx
+++ b/include/tools/mapunit.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_TOOLS_MAPUNIT_HXX
#include <sal/types.h>
+#include <tools/UnitConversion.hxx>
enum class MapUnit
{
@@ -34,16 +35,6 @@ enum class MapUnit
LASTENUMDUMMY // used as an error return
};
-constexpr sal_Int64 convertTwipToMm100(sal_Int64 n)
-{
- return (n >= 0)? (n*127+36)/72: (n*127-36)/72;
-}
-
-constexpr sal_Int64 convertMm100ToTwip(sal_Int64 n)
-{
- return (n >= 0)? (n*72+63)/127: (n*72-63)/127;
-}
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */