include/tools/UnitConversion.hxx | 25 +++++++++++++++++++++++++ include/tools/mapunit.hxx | 11 +---------- 2 files changed, 26 insertions(+), 10 deletions(-)
New commits: commit 09e28008376e2f2a187067409d3076e81eba022e Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri May 1 17:20:26 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sun May 3 11:10:04 2020 +0200 move unit conversions to UnitConversion, add convertPointToMm100 Change-Id: I3e5a4632e9809562885c1e0ec5c5262acec145d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93332 Tested-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> 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: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits