Bump version to 21.06.18.1
[LibreOffice.git] / include / tools / UnitConversion.hxx
blobb139af6d7bed1ffa1a0de5eea4510e42969034c4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #pragma once
13 #include <sal/types.h>
15 constexpr sal_Int64 convertTwipToMm100(sal_Int64 n)
17 return (n >= 0) ? (n * 127 + 36) / 72 : (n * 127 - 36) / 72;
20 constexpr sal_Int64 convertMm100ToTwip(sal_Int64 n)
22 return (n >= 0) ? (n * 72 + 63) / 127 : (n * 72 - 63) / 127;
25 constexpr sal_Int64 convertPointToTwip(sal_Int64 nNumber) { return nNumber * 20; }
27 constexpr sal_Int64 convertPointToMm100(sal_Int64 nNumber)
29 return convertTwipToMm100(convertPointToTwip(nNumber));
32 constexpr double convertTwipToPixel(double nNumber) { return nNumber / 15.0; }
34 constexpr double convertPointToTwip(double fNumber) { return fNumber * 20.0; }
36 constexpr double convertPointToMm100(double fNumber) { return fNumber * (2540.0 / 72.0); }
38 // Convert PPT's "master unit" (1/576 inch) to mm/100
39 constexpr sal_Int64 convertMasterUnitToMm100(sal_Int64 n) { return n * (2540.0 / 576.0); }
41 // Convert mm/100 to PPT's "master unit"
42 constexpr sal_Int64 convertMm100ToMasterUnit(sal_Int64 n) { return n / (2540.0 / 576.0); }
44 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */