diff options
author | Noel <noelgrandin@gmail.com> | 2020-10-19 10:44:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-10-19 12:56:30 +0200 |
commit | 2646023729dd16c1a613fac7e8e6a37828d7a404 (patch) | |
tree | cba08360a0812ccd3653a6dcfd1cad03704a3724 /include/tools/helpers.hxx | |
parent | tdf#136983 partial revert NFC ww8 cleanup: remove unused variables (diff) | |
download | core-2646023729dd16c1a613fac7e8e6a37828d7a404.tar.gz core-2646023729dd16c1a613fac7e8e6a37828d7a404.zip |
add tools::Long typedef and use it in tools
first step to switching long to a 64-bit type on 64-bit windows
Change-Id: I640d807426dfe713c7a8984ef560575f8288dbeb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104516
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/tools/helpers.hxx')
-rw-r--r-- | include/tools/helpers.hxx | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/include/tools/helpers.hxx b/include/tools/helpers.hxx index 1d00bad7112e..e105ed355b66 100644 --- a/include/tools/helpers.hxx +++ b/include/tools/helpers.hxx @@ -11,6 +11,7 @@ #include <sal/config.h> #include <sal/types.h> +#include <tools/long.hxx> #include <o3tl/safeint.hxx> #include <cassert> #include <type_traits> @@ -19,13 +20,13 @@ template<typename T> inline typename std::enable_if< std::is_signed<T>::value || std::is_floating_point<T>::value, long >::type -MinMax(T nVal, long nMin, long nMax) +MinMax(T nVal, tools::Long nMin, tools::Long nMax) { assert(nMin <= nMax); if (nVal >= nMin) { if (nVal <= nMax) - return static_cast<long>(nVal); + return static_cast<tools::Long>(nVal); else return nMax; } @@ -39,7 +40,7 @@ template<typename T> inline typename std::enable_if< std::is_unsigned<T>::value, long >::type -MinMax(T nVal, long nMin, long nMax) +MinMax(T nVal, tools::Long nMin, tools::Long nMax) { assert(nMin <= nMax); if (nMax < 0) @@ -51,7 +52,7 @@ MinMax(T nVal, long nMin, long nMax) if (nMin < 0 || nVal >= static_cast<unsigned long>(nMin)) { if (nVal <= static_cast<unsigned long>(nMax)) - return static_cast<long>(nVal); + return static_cast<tools::Long>(nVal); else return nMax; } @@ -71,9 +72,9 @@ inline sal_uInt32 AlignedWidth4Bytes(sal_uInt32 nWidthBits) return (nWidthBits >> 5) << 2; } -inline long FRound( double fVal ) +inline tools::Long FRound( double fVal ) { - return fVal > 0.0 ? static_cast<long>( fVal + 0.5 ) : -static_cast<long>( -fVal + 0.5 ); + return fVal > 0.0 ? static_cast<tools::Long>( fVal + 0.5 ) : -static_cast<tools::Long>( -fVal + 0.5 ); } //valid range: (-180,180] |