diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-02-14 09:38:50 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-02-14 14:31:50 +0100 |
commit | 8389dc88a48b366ad7f3dd84129467175e18ab40 (patch) | |
tree | 2de192eab43601ee8b145215504ed6aa2b9db243 /include | |
parent | f67e5ef9a5c71f3b35b1c67eb72794e44cc15410 (diff) |
split out MetricField value conversion functions
Change-Id: I67a33bd2a5cb06dc66e471918b5c378044a2eff2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88679
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/svx/transfrmhelper.hxx | 10 | ||||
-rw-r--r-- | include/vcl/field.hxx | 26 | ||||
-rw-r--r-- | include/vcl/fieldvalues.hxx | 67 |
3 files changed, 72 insertions, 31 deletions
diff --git a/include/svx/transfrmhelper.hxx b/include/svx/transfrmhelper.hxx index 0c9b7e958107..9e683d44522f 100644 --- a/include/svx/transfrmhelper.hxx +++ b/include/svx/transfrmhelper.hxx @@ -24,18 +24,18 @@ #include <tools/fract.hxx> #include <tools/fldunit.hxx> #include <tools/mapunit.hxx> -#include <vcl/field.hxx> +#include <vcl/fieldvalues.hxx> namespace TransfrmHelper { inline void ConvertRect(basegfx::B2DRange& rRange, const sal_uInt16 nDigits, const MapUnit ePoolUnit, const FieldUnit eDlgUnit) { const basegfx::B2DPoint aTopLeft( - static_cast<double>(MetricField::ConvertValue(basegfx::fround(rRange.getMinX()), nDigits, ePoolUnit, eDlgUnit)), - static_cast<double>(MetricField::ConvertValue(basegfx::fround(rRange.getMinY()), nDigits, ePoolUnit, eDlgUnit))); + static_cast<double>(vcl::ConvertValue(basegfx::fround(rRange.getMinX()), nDigits, ePoolUnit, eDlgUnit)), + static_cast<double>(vcl::ConvertValue(basegfx::fround(rRange.getMinY()), nDigits, ePoolUnit, eDlgUnit))); const basegfx::B2DPoint aBottomRight( - static_cast<double>(MetricField::ConvertValue(basegfx::fround(rRange.getMaxX()), nDigits, ePoolUnit, eDlgUnit)), - static_cast<double>(MetricField::ConvertValue(basegfx::fround(rRange.getMaxY()), nDigits, ePoolUnit, eDlgUnit))); + static_cast<double>(vcl::ConvertValue(basegfx::fround(rRange.getMaxX()), nDigits, ePoolUnit, eDlgUnit)), + static_cast<double>(vcl::ConvertValue(basegfx::fround(rRange.getMaxY()), nDigits, ePoolUnit, eDlgUnit))); rRange = basegfx::B2DRange(aTopLeft, aBottomRight); } diff --git a/include/vcl/field.hxx b/include/vcl/field.hxx index 81fd9e5b8023..c011132f4c81 100644 --- a/include/vcl/field.hxx +++ b/include/vcl/field.hxx @@ -448,32 +448,6 @@ public: void SetLast(sal_Int64 last) { SetLast(last, FieldUnit::NONE); } sal_Int64 GetLast( FieldUnit eOutUnit ) const; - static sal_Int64 ConvertValue( sal_Int64 nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, - FieldUnit eInUnit, FieldUnit eOutUnit ); - static sal_Int64 ConvertValue( sal_Int64 nValue, sal_uInt16 nDecDigits, - MapUnit eInUnit, FieldUnit eOutUnit ); - - // for backwards compatibility - // caution: conversion to double loses precision - static double ConvertDoubleValue( double nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, - FieldUnit eInUnit, FieldUnit eOutUnit ); - static double ConvertDoubleValue( double nValue, sal_uInt16 nDecDigits, - FieldUnit eInUnit, MapUnit eOutUnit ); - static double ConvertDoubleValue( double nValue, sal_uInt16 nDecDigits, - MapUnit eInUnit, FieldUnit eOutUnit ); - - // for backwards compatibility - // caution: conversion to double loses precision - static double ConvertDoubleValue( sal_Int64 nValue, sal_Int64 nBaseValue, sal_uInt16 nDecDigits, - FieldUnit eInUnit, FieldUnit eOutUnit ) - { return ConvertDoubleValue( static_cast<double>(nValue), nBaseValue, nDecDigits, eInUnit, eOutUnit ); } - static double ConvertDoubleValue( sal_Int64 nValue, sal_uInt16 nDecDigits, - FieldUnit eInUnit, MapUnit eOutUnit ) - { return ConvertDoubleValue( static_cast<double>(nValue), nDecDigits, eInUnit, eOutUnit ); } - static double ConvertDoubleValue( sal_Int64 nValue, sal_uInt16 nDecDigits, - MapUnit eInUnit, FieldUnit eOutUnit ) - { return ConvertDoubleValue( static_cast<double>(nValue), nDecDigits, eInUnit, eOutUnit ); } - virtual bool set_property(const OString &rKey, const OUString &rValue) override; virtual void dispose() override; diff --git a/include/vcl/fieldvalues.hxx b/include/vcl/fieldvalues.hxx new file mode 100644 index 000000000000..e36b0590ae71 --- /dev/null +++ b/include/vcl/fieldvalues.hxx @@ -0,0 +1,67 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_FIELDVALUES_HXX +#define INCLUDED_VCL_FIELDVALUES_HXX + +#include <vcl/dllapi.h> +#include <tools/fldunit.hxx> +#include <tools/mapunit.hxx> + +namespace vcl +{ +VCL_DLLPUBLIC sal_Int64 ConvertValue(sal_Int64 nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, + FieldUnit eInUnit, FieldUnit eOutUnit); +VCL_DLLPUBLIC sal_Int64 ConvertValue(sal_Int64 nValue, sal_uInt16 nDecDigits, MapUnit eInUnit, + FieldUnit eOutUnit); + +// for backwards compatibility +// caution: conversion to double loses precision +VCL_DLLPUBLIC double ConvertDoubleValue(double nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, + FieldUnit eInUnit, FieldUnit eOutUnit); +VCL_DLLPUBLIC double ConvertDoubleValue(double nValue, sal_uInt16 nDecDigits, FieldUnit eInUnit, + MapUnit eOutUnit); +VCL_DLLPUBLIC double ConvertDoubleValue(double nValue, sal_uInt16 nDecDigits, MapUnit eInUnit, + FieldUnit eOutUnit); + +// for backwards compatibility +// caution: conversion to double loses precision +inline double ConvertDoubleValue(sal_Int64 nValue, sal_Int64 nBaseValue, sal_uInt16 nDecDigits, + FieldUnit eInUnit, FieldUnit eOutUnit) +{ + return ConvertDoubleValue(static_cast<double>(nValue), nBaseValue, nDecDigits, eInUnit, + eOutUnit); +} + +inline double ConvertDoubleValue(sal_Int64 nValue, sal_uInt16 nDecDigits, FieldUnit eInUnit, + MapUnit eOutUnit) +{ + return ConvertDoubleValue(static_cast<double>(nValue), nDecDigits, eInUnit, eOutUnit); +} + +inline double ConvertDoubleValue(sal_Int64 nValue, sal_uInt16 nDecDigits, MapUnit eInUnit, + FieldUnit eOutUnit) +{ + return ConvertDoubleValue(static_cast<double>(nValue), nDecDigits, eInUnit, eOutUnit); +} +} + +#endif // INCLUDED_VCL_FIELDVALUES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |