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 | |
parent | 1086654d6e8cc22f1f99195668db3f305437e570 (diff) |
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>
-rw-r--r-- | include/tools/bigint.hxx | 5 | ||||
-rw-r--r-- | include/tools/fract.hxx | 3 | ||||
-rw-r--r-- | include/tools/gen.hxx | 203 | ||||
-rw-r--r-- | include/tools/helpers.hxx | 13 | ||||
-rw-r--r-- | include/tools/long.hxx | 33 | ||||
-rw-r--r-- | include/tools/poly.hxx | 6 | ||||
-rw-r--r-- | include/tools/stream.hxx | 3 | ||||
-rw-r--r-- | include/tools/svborder.hxx | 21 | ||||
-rw-r--r-- | include/tools/zcodec.hxx | 9 | ||||
-rw-r--r-- | tools/inc/poly.h | 2 | ||||
-rw-r--r-- | tools/qa/cppunit/test_minmax.cxx | 8 | ||||
-rw-r--r-- | tools/qa/cppunit/test_rectangle.cxx | 24 | ||||
-rw-r--r-- | tools/source/generic/color.cxx | 13 | ||||
-rw-r--r-- | tools/source/generic/gen.cxx | 32 | ||||
-rw-r--r-- | tools/source/generic/point.cxx | 22 | ||||
-rw-r--r-- | tools/source/generic/poly.cxx | 64 | ||||
-rw-r--r-- | tools/source/generic/poly2.cxx | 4 | ||||
-rw-r--r-- | tools/source/stream/stream.cxx | 15 | ||||
-rw-r--r-- | tools/source/zcodec/zcodec.cxx | 19 |
19 files changed, 271 insertions, 228 deletions
diff --git a/include/tools/bigint.hxx b/include/tools/bigint.hxx index 66ce1dd3b1b8..f80d64fe87c3 100644 --- a/include/tools/bigint.hxx +++ b/include/tools/bigint.hxx @@ -21,6 +21,7 @@ #include <rtl/ustring.hxx> #include <tools/toolsdllapi.h> +#include <tools/long.hxx> #define MAX_DIGITS 8 @@ -88,7 +89,7 @@ public: operator sal_uInt32() const; operator double() const; #if SAL_TYPES_SIZEOFLONG == 8 - operator long() const; + operator tools::Long() const; #endif bool IsSet() const { return bIsSet; } @@ -156,7 +157,7 @@ inline BigInt::operator sal_uInt32() const } #if SAL_TYPES_SIZEOFLONG == 8 -inline BigInt::operator long() const +inline BigInt::operator tools::Long() const { // Clamp to int32 since long is int32 on Windows. if (!bIsBig) diff --git a/include/tools/fract.hxx b/include/tools/fract.hxx index 7caf9c6a93f5..79f5b525aed4 100644 --- a/include/tools/fract.hxx +++ b/include/tools/fract.hxx @@ -21,6 +21,7 @@ #include <sal/types.h> #include <tools/toolsdllapi.h> +#include <tools/long.hxx> #include <ostream> #include <type_traits> @@ -53,7 +54,7 @@ public: explicit operator sal_Int32() const; #if SAL_TYPES_SIZEOFLONG == 8 - explicit operator long() const { return sal_Int32(*this); } + explicit operator ::tools::Long() const { return sal_Int32(*this); } #endif explicit operator double() const; diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx index 4f6927c62f0b..b357d2198de1 100644 --- a/include/tools/gen.hxx +++ b/include/tools/gen.hxx @@ -21,6 +21,7 @@ #include <tools/toolsdllapi.h> +#include <tools/long.hxx> #include <limits.h> #include <algorithm> #include <ostream> @@ -40,19 +41,19 @@ class SAL_WARN_UNUSED Pair { public: Pair() : nA(0), nB(0) {} - Pair( long _nA, long _nB ) : nA(_nA), nB(_nB) {} + Pair( tools::Long _nA, tools::Long _nB ) : nA(_nA), nB(_nB) {} - long A() const { return nA; } - long B() const { return nB; } + tools::Long A() const { return nA; } + tools::Long B() const { return nB; } - long& A() { return nA; } - long& B() { return nB; } + tools::Long& A() { return nA; } + tools::Long& B() { return nB; } TOOLS_DLLPUBLIC rtl::OString toString() const; protected: - long nA; - long nB; + tools::Long nA; + tools::Long nB; }; namespace tools::detail { @@ -72,33 +73,33 @@ class SAL_WARN_UNUSED UNLESS_MERGELIBS(SAL_DLLPUBLIC_EXPORT) Point final : prote { public: Point() {} - Point( long nX, long nY ) : Pair( nX, nY ) {} + Point( tools::Long nX, tools::Long nY ) : Pair( nX, nY ) {} - long X() const { return nA; } - long Y() const { return nB; } + tools::Long X() const { return nA; } + tools::Long Y() const { return nB; } - void Move( long nHorzMove, long nVertMove ); + void Move( tools::Long nHorzMove, tools::Long nVertMove ); void Move( Size const & s ); - long AdjustX( long nHorzMove ) { nA += nHorzMove; return nA; } - long AdjustY( long nVertMove ) { nB += nVertMove; return nB; } + tools::Long AdjustX( tools::Long nHorzMove ) { nA += nHorzMove; return nA; } + tools::Long AdjustY( tools::Long nVertMove ) { nB += nVertMove; return nB; } - void RotateAround( long& rX, long& rY, short nOrientation ) const; + void RotateAround( tools::Long& rX, tools::Long& rY, short nOrientation ) const; void RotateAround( Point&, short nOrientation ) const; Point& operator += ( const Point& rPoint ); Point& operator -= ( const Point& rPoint ); - Point& operator *= ( const long nVal ); - Point& operator /= ( const long nVal ); + Point& operator *= ( const tools::Long nVal ); + Point& operator /= ( const tools::Long nVal ); friend inline Point operator+( const Point &rVal1, const Point &rVal2 ); friend inline Point operator-( const Point &rVal1, const Point &rVal2 ); - friend inline Point operator*( const Point &rVal1, const long nVal2 ); - friend inline Point operator/( const Point &rVal1, const long nVal2 ); + friend inline Point operator*( const Point &rVal1, const tools::Long nVal2 ); + friend inline Point operator/( const Point &rVal1, const tools::Long nVal2 ); - long getX() const { return X(); } - long getY() const { return Y(); } - void setX(long nX) { nA = nX; } - void setY(long nY) { nB = nY; } + tools::Long getX() const { return X(); } + tools::Long getY() const { return Y(); } + void setX(tools::Long nX) { nA = nX; } + void setY(tools::Long nY) { nB = nY; } Pair const & toPair() const { return *this; } Pair & toPair() { return *this; } @@ -106,7 +107,7 @@ public: using Pair::toString; }; -inline void Point::Move( long nHorzMove, long nVertMove ) +inline void Point::Move( tools::Long nHorzMove, tools::Long nVertMove ) { nA += nHorzMove; nB += nVertMove; @@ -126,14 +127,14 @@ inline Point& Point::operator -= ( const Point& rPoint ) return *this; } -inline Point& Point::operator *= ( const long nVal ) +inline Point& Point::operator *= ( const tools::Long nVal ) { nA *= nVal; nB *= nVal; return *this; } -inline Point& Point::operator /= ( const long nVal ) +inline Point& Point::operator /= ( const tools::Long nVal ) { nA /= nVal; nB /= nVal; @@ -150,12 +151,12 @@ inline Point operator-( const Point &rVal1, const Point &rVal2 ) return Point( rVal1.nA-rVal2.nA, rVal1.nB-rVal2.nB ); } -inline Point operator*( const Point &rVal1, const long nVal2 ) +inline Point operator*( const Point &rVal1, const tools::Long nVal2 ) { return Point( rVal1.nA*nVal2, rVal1.nB*nVal2 ); } -inline Point operator/( const Point &rVal1, const long nVal2 ) +inline Point operator/( const Point &rVal1, const tools::Long nVal2 ) { return Point( rVal1.nA/nVal2, rVal1.nB/nVal2 ); } @@ -183,22 +184,22 @@ class SAL_WARN_UNUSED Size final : protected Pair { public: Size() {} - Size( long nWidth, long nHeight ) : Pair( nWidth, nHeight ) {} + Size( tools::Long nWidth, tools::Long nHeight ) : Pair( nWidth, nHeight ) {} - long Width() const { return nA; } - long Height() const { return nB; } + tools::Long Width() const { return nA; } + tools::Long Height() const { return nB; } - long AdjustWidth( long n ) { nA += n; return nA; } - long AdjustHeight( long n ) { nB += n; return nB; } + tools::Long AdjustWidth( tools::Long n ) { nA += n; return nA; } + tools::Long AdjustHeight( tools::Long n ) { nB += n; return nB; } - long getWidth() const { return Width(); } - long getHeight() const { return Height(); } - void setWidth(long nWidth) { nA = nWidth; } - void setHeight(long nHeight) { nB = nHeight; } + tools::Long getWidth() const { return Width(); } + tools::Long getHeight() const { return Height(); } + void setWidth(tools::Long nWidth) { nA = nWidth; } + void setHeight(tools::Long nHeight) { nB = nHeight; } bool IsEmpty() const { return nA <= 0 || nB <= 0; } - void extendBy(long x, long y) + void extendBy(tools::Long x, tools::Long y) { nA += x; nB += y; @@ -241,16 +242,16 @@ class SAL_WARN_UNUSED Range final : protected Pair { public: Range() {} - Range( long nMin, long nMax ) : Pair( nMin, nMax ) {} + Range( tools::Long nMin, tools::Long nMax ) : Pair( nMin, nMax ) {} - long Min() const { return nA; } - long Max() const { return nB; } - long Len() const { return nB - nA + 1; } + tools::Long Min() const { return nA; } + tools::Long Max() const { return nB; } + tools::Long Len() const { return nB - nA + 1; } - long& Min() { return nA; } - long& Max() { return nB; } + tools::Long& Min() { return nA; } + tools::Long& Max() { return nB; } - bool IsInside( long nIs ) const; + bool IsInside( tools::Long nIs ) const; void Justify(); @@ -260,7 +261,7 @@ public: using Pair::toString; }; -inline bool Range::IsInside( long nIs ) const +inline bool Range::IsInside( tools::Long nIs ) const { return ((nA <= nIs) && (nIs <= nB )); } @@ -269,7 +270,7 @@ inline void Range::Justify() { if ( nA > nB ) { - long nHelp = nA; + tools::Long nHelp = nA; nA = nB; nB = nHelp; } @@ -301,25 +302,25 @@ class SAL_WARN_UNUSED Selection final : protected Pair { public: Selection() {} - Selection( long nPos ) : Pair( nPos, nPos ) {} - Selection( long nMin, long nMax ) : Pair( nMin, nMax ) {} + Selection( tools::Long nPos ) : Pair( nPos, nPos ) {} + Selection( tools::Long nMin, tools::Long nMax ) : Pair( nMin, nMax ) {} - long Min() const { return nA; } - long Max() const { return nB; } - long Len() const { return nB - nA; } + tools::Long Min() const { return nA; } + tools::Long Max() const { return nB; } + tools::Long Len() const { return nB - nA; } - long& Min() { return nA; } - long& Max() { return nB; } + tools::Long& Min() { return nA; } + tools::Long& Max() { return nB; } - bool IsInside( long nIs ) const; + bool IsInside( tools::Long nIs ) const; void Justify(); bool operator !() const { return !Len(); } - long getMin() const { return Min(); } - void setMin(long nMin) { Min() = nMin; } - void setMax(long nMax) { Max() = nMax; } + tools::Long getMin() const { return Min(); } + void setMin(tools::Long nMin) { Min() = nMin; } + void setMax(tools::Long nMax) { Max() = nMax; } Pair const & toPair() const { return *this; } Pair & toPair() { return *this; } @@ -327,7 +328,7 @@ public: using Pair::toString; }; -inline bool Selection::IsInside( long nIs ) const +inline bool Selection::IsInside( tools::Long nIs ) const { return ((nA <= nIs) && (nIs < nB )); } @@ -336,7 +337,7 @@ inline void Selection::Justify() { if ( nA > nB ) { - long nHelp = nA; + tools::Long nHelp = nA; nA = nB; nB = nHelp; } @@ -380,23 +381,23 @@ class SAL_WARN_UNUSED TOOLS_DLLPUBLIC Rectangle final public: Rectangle(); Rectangle( const Point& rLT, const Point& rRB ); - Rectangle( long nLeft, long nTop, - long nRight, long nBottom ); + Rectangle( tools::Long nLeft, tools::Long nTop, + tools::Long nRight, tools::Long nBottom ); /// Constructs an empty Rectangle, with top/left at the specified params - Rectangle( long nLeft, long nTop ); + Rectangle( tools::Long nLeft, tools::Long nTop ); Rectangle( const Point& rLT, const Size& rSize ); static Rectangle Justify( const Point& rLT, const Point& rRB ); - long Left() const { return nLeft; } - long Right() const; - long Top() const { return nTop; } - long Bottom() const; + tools::Long Left() const { return nLeft; } + tools::Long Right() const; + tools::Long Top() const { return nTop; } + tools::Long Bottom() const; - void SetLeft(long v) { nLeft = v; } - void SetRight(long v) { nRight = v; } - void SetTop(long v) { nTop = v; } - void SetBottom(long v) { nBottom = v; } + void SetLeft(tools::Long v) { nLeft = v; } + void SetRight(tools::Long v) { nRight = v; } + void SetTop(tools::Long v) { nTop = v; } + void SetBottom(tools::Long v) { nBottom = v; } inline Point TopLeft() const; inline Point TopRight() const; @@ -409,20 +410,20 @@ public: inline Point Center() const; /// Move the top and left edges by a delta, preserving width and height - inline void Move( long nHorzMoveDelta, long nVertMoveDelta ); + inline void Move( tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta ); void Move( Size const & s ) { Move(s.Width(), s.Height()); } - long AdjustLeft( long nHorzMoveDelta ) { nLeft += nHorzMoveDelta; return nLeft; } - long AdjustRight( long nHorzMoveDelta ); - long AdjustTop( long nVertMoveDelta ) { nTop += nVertMoveDelta; return nTop; } - long AdjustBottom( long nVertMoveDelta ); + tools::Long AdjustLeft( tools::Long nHorzMoveDelta ) { nLeft += nHorzMoveDelta; return nLeft; } + tools::Long AdjustRight( tools::Long nHorzMoveDelta ); + tools::Long AdjustTop( tools::Long nVertMoveDelta ) { nTop += nVertMoveDelta; return nTop; } + tools::Long AdjustBottom( tools::Long nVertMoveDelta ); inline void SetPos( const Point& rPoint ); void SetSize( const Size& rSize ); inline Size GetSize() const; /// Returns the difference between right and left, assuming the range is inclusive. - inline long GetWidth() const; + inline tools::Long GetWidth() const; /// Returns the difference between bottom and top, assuming the range is inclusive. - inline long GetHeight() const; + inline tools::Long GetHeight() const; tools::Rectangle& Union( const tools::Rectangle& rRect ); tools::Rectangle& Intersection( const tools::Rectangle& rRect ); @@ -452,39 +453,39 @@ public: friend inline tools::Rectangle operator - ( const tools::Rectangle& rRect, const Point& rPt ); // ONE - long getX() const { return nLeft; } - long getY() const { return nTop; } + tools::Long getX() const { return nLeft; } + tools::Long getY() const { return nTop; } /// Returns the difference between right and left, assuming the range includes one end, but not the other. - long getWidth() const; + tools::Long getWidth() const; /// Returns the difference between bottom and top, assuming the range includes one end, but not the other. - long getHeight() const; + tools::Long getHeight() const; /// Set the left edge of the rectangle to x, preserving the width - void setX( long x ); + void setX( tools::Long x ); /// Set the top edge of the rectangle to y, preserving the height - void setY( long y ); - void setWidth( long n ) { nRight = nLeft + n; } - void setHeight( long n ) { nBottom = nTop + n; } + void setY( tools::Long y ); + void setWidth( tools::Long n ) { nRight = nLeft + n; } + void setHeight( tools::Long n ) { nBottom = nTop + n; } /// Returns the string representation of the rectangle, format is "x, y, width, height". rtl::OString toString() const; /** * Expands the rectangle in all directions by the input value. */ - void expand(long nExpandBy); - void shrink(long nShrinkBy); + void expand(tools::Long nExpandBy); + void shrink(tools::Long nShrinkBy); /** * Sanitizing variants for handling data from the outside */ void SaturatingSetSize(const Size& rSize); - void SaturatingSetX(long x); - void SaturatingSetY(long y); + void SaturatingSetX(tools::Long x); + void SaturatingSetY(tools::Long y); private: - long nLeft; - long nTop; - long nRight; - long nBottom; + tools::Long nLeft; + tools::Long nTop; + tools::Long nRight; + tools::Long nBottom; }; } @@ -502,8 +503,8 @@ inline tools::Rectangle::Rectangle( const Point& rLT, const Point& rRB ) nBottom = rRB.Y(); } -inline tools::Rectangle::Rectangle( long _nLeft, long _nTop, - long _nRight, long _nBottom ) +inline tools::Rectangle::Rectangle( tools::Long _nLeft, tools::Long _nTop, + tools::Long _nRight, tools::Long _nBottom ) { nLeft = _nLeft; nTop = _nTop; @@ -511,7 +512,7 @@ inline tools::Rectangle::Rectangle( long _nLeft, long _nTop, nBottom = _nBottom; } -inline tools::Rectangle::Rectangle( long _nLeft, long _nTop ) +inline tools::Rectangle::Rectangle( tools::Long _nLeft, tools::Long _nTop ) { nLeft = _nLeft; nTop = _nTop; @@ -594,7 +595,7 @@ inline Point tools::Rectangle::Center() const return Point( nLeft+(nRight-nLeft)/2 , nTop+(nBottom-nTop)/2 ); } -inline void tools::Rectangle::Move( long nHorzMove, long nVertMove ) +inline void tools::Rectangle::Move( tools::Long nHorzMove, tools::Long nVertMove ) { nLeft += nHorzMove; nTop += nVertMove; @@ -614,9 +615,9 @@ inline void tools::Rectangle::SetPos( const Point& rPoint ) nTop = rPoint.Y(); } -inline long tools::Rectangle::GetWidth() const +inline tools::Long tools::Rectangle::GetWidth() const { - long n; + tools::Long n; if ( nRight == RECT_EMPTY ) n = 0; else @@ -631,9 +632,9 @@ inline long tools::Rectangle::GetWidth() const return n; } -inline long tools::Rectangle::GetHeight() const +inline tools::Long tools::Rectangle::GetHeight() const { - long n; + tools::Long n; if ( nBottom == RECT_EMPTY ) n = 0; else 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] diff --git a/include/tools/long.hxx b/include/tools/long.hxx new file mode 100644 index 000000000000..0a633e0f23cc --- /dev/null +++ b/include/tools/long.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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 + +#include <sal/types.h> + +/** + * We have an unfortunate problem in that, on Windows (both 32 and 64-bit), long is always 32-bit. + * But on Linux (64-bit) long is 64-bit. Which leads to nasty situations where things that work + * on Linux, fail on Windows. + * So....., + * (1) introduce a typedef that will replace all usage of long in our codebase. + * (2) to start with, that typedef acts that same as the long it replaces + * (3) once the replacement is complete, this typedef will, on windows, become 64-bit. + * (4) and once the fallout from (3) is fixed, we can start replacing tools::Long with things + * like sal_Int64. + */ +namespace tools +{ +typedef long Long; +typedef unsigned long ULong; +// stage 3: +//typedef sal_Int64 Long; +//typedef sal_uInt64 ULong; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/tools/poly.hxx b/include/tools/poly.hxx index 12194c64c752..d9f39fb080f4 100644 --- a/include/tools/poly.hxx +++ b/include/tools/poly.hxx @@ -88,7 +88,7 @@ public: Polygon( const tools::Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVertRound ); Polygon( const Point& rCenter, - long nRadX, long nRadY ); + tools::Long nRadX, tools::Long nRadY ); Polygon( const tools::Rectangle& rBound, const Point& rStart, const Point& rEnd, PolyStyle ePolyStyle = PolyStyle::Arc ); @@ -141,7 +141,7 @@ public: void AdaptiveSubdivide( tools::Polygon& rResult, const double d = 1.0 ) const; static Polygon SubdivideBezier( const Polygon& rPoly ); - void Move( long nHorzMove, long nVertMove ); + void Move( tools::Long nHorzMove, tools::Long nVertMove ); void Translate( const Point& rTrans ); void Scale( double fScaleX, double fScaleY ); void Rotate( const Point& rCenter, double fSin, double fCos ); @@ -232,7 +232,7 @@ public: void GetIntersection( const tools::PolyPolygon& rPolyPoly, tools::PolyPolygon& rResult ) const; void GetUnion( const tools::PolyPolygon& rPolyPoly, tools::PolyPolygon& rResult ) const; - void Move( long nHorzMove, long nVertMove ); + void Move( tools::Long nHorzMove, tools::Long nVertMove ); void Translate( const Point& rTrans ); void Scale( double fScaleX, double fScaleY ); void Rotate( const Point& rCenter, double fSin, double fCos ); diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx index 4cbe1a3e930c..0d88c014da65 100644 --- a/include/tools/stream.hxx +++ b/include/tools/stream.hxx @@ -21,6 +21,7 @@ #include <tools/toolsdllapi.h> #include <tools/lineend.hxx> +#include <tools/long.hxx> #include <tools/ref.hxx> #include <vcl/errcode.hxx> #include <rtl/string.hxx> @@ -638,7 +639,7 @@ protected: /// Set to 0 , if new block size is 0 bytes /// - nSize: New block size /// - nPos: Set to 0 if position outside of block - bool ReAllocateMemory( long nDiff ); + bool ReAllocateMemory( tools::Long nDiff ); /// Is called when this stream allocated the buffer or the buffer is /// resized. FreeMemory may need to NULLify handles in derived classes. diff --git a/include/tools/svborder.hxx b/include/tools/svborder.hxx index 61e1270e1ccd..92f779cac344 100644 --- a/include/tools/svborder.hxx +++ b/include/tools/svborder.hxx @@ -21,19 +21,20 @@ #define INCLUDED_TOOLS_SVBORDER_HXX #include <tools/toolsdllapi.h> +#include <tools/long.hxx> namespace tools { class Rectangle; } class SAL_WARN_UNUSED TOOLS_DLLPUBLIC SvBorder { - long nTop, nRight, nBottom, nLeft; + tools::Long nTop, nRight, nBottom, nLeft; public: SvBorder() { nTop = nRight = nBottom = nLeft = 0; } - SvBorder( long nLeftP, long nTopP, long nRightP, long nBottomP ) + SvBorder( tools::Long nLeftP, tools::Long nTopP, tools::Long nRightP, tools::Long nBottomP ) { nLeft = nLeftP; nTop = nTopP; @@ -55,14 +56,14 @@ public: Bottom() += rBorder.Bottom(); return *this; } - long & Top() { return nTop; } - long & Right() { return nRight; } - long & Bottom() { return nBottom; } - long & Left() { return nLeft; } - long Top() const { return nTop; } - long Right() const { return nRight; } - long Bottom() const { return nBottom; } - long Left() const { return nLeft; } + tools::Long & Top() { return nTop; } + tools::Long & Right() { return nRight; } + tools::Long & Bottom() { return nBottom; } + tools::Long & Left() { return nLeft; } + tools::Long Top() const { return nTop; } + tools::Long Right() const { return nRight; } + tools::Long Bottom() const { return nBottom; } + tools::Long Left() const { return nLeft; } }; TOOLS_DLLPUBLIC tools::Rectangle & operator += ( tools::Rectangle & rRect, const SvBorder & rBorder ); diff --git a/include/tools/zcodec.hxx b/include/tools/zcodec.hxx index 23922e197f91..f8bdc44451dc 100644 --- a/include/tools/zcodec.hxx +++ b/include/tools/zcodec.hxx @@ -21,6 +21,7 @@ #define INCLUDED_TOOLS_ZCODEC_HXX #include <tools/toolsdllapi.h> +#include <tools/long.hxx> #define ZCODEC_NO_COMPRESSION 0 #define ZCODEC_DEFAULT_COMPRESSION 6 @@ -59,15 +60,15 @@ public: ~ZCodec(); void BeginCompression( int nCompressLevel = ZCODEC_DEFAULT_COMPRESSION, bool gzLib = false ); - long EndCompression(); + tools::Long EndCompression(); void Compress( SvStream& rIStm, SvStream& rOStm ); - long Decompress( SvStream& rIStm, SvStream& rOStm ); + tools::Long Decompress( SvStream& rIStm, SvStream& rOStm ); bool AttemptDecompression( SvStream& rIStm, SvStream& rOStm ); void Write( SvStream& rOStm, const sal_uInt8* pData, sal_uInt32 nSize ); - long Read( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize ); - long ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize ); + tools::Long Read( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize ); + tools::Long ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize ); void SetBreak( size_t ); size_t GetBreak() const; diff --git a/tools/inc/poly.h b/tools/inc/poly.h index 708ebb69bd95..f621a73e223f 100644 --- a/tools/inc/poly.h +++ b/tools/inc/poly.h @@ -36,7 +36,7 @@ public: ImplPolygon( const ImplPolygon& rImplPoly ); ImplPolygon( const tools::Rectangle& rRect ); ImplPolygon( const tools::Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVertRound); - ImplPolygon( const Point& rCenter, long nRadX, long nRadY ); + ImplPolygon( const Point& rCenter, tools::Long nRadX, tools::Long nRadY ); ImplPolygon( const tools::Rectangle& rBound, const Point& rStart, const Point& rEnd, PolyStyle eStyle ); ImplPolygon( const Point& rBezPt1, const Point& rCtrlPt1, const Point& rBezPt2, diff --git a/tools/qa/cppunit/test_minmax.cxx b/tools/qa/cppunit/test_minmax.cxx index 93709def974e..509499910216 100644 --- a/tools/qa/cppunit/test_minmax.cxx +++ b/tools/qa/cppunit/test_minmax.cxx @@ -31,8 +31,8 @@ public: void testSignedMinMax() { sal_Int32 nSignedVal = -10; - long nMin = 1; - long nMax = 10; + tools::Long nMin = 1; + tools::Long nMax = 10; CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(nMin), static_cast<sal_Int32>(MinMax(nSignedVal, nMin, nMax))); @@ -50,8 +50,8 @@ public: void testUnsignedMinMax() { sal_uInt32 nUnsignedVal = 5; - long nMin = 1; - long nMax = 10; + tools::Long nMin = 1; + tools::Long nMax = 10; CPPUNIT_ASSERT_EQUAL(nUnsignedVal, static_cast<sal_uInt32>(MinMax(nUnsignedVal, nMin, nMax))); diff --git a/tools/qa/cppunit/test_rectangle.cxx b/tools/qa/cppunit/test_rectangle.cxx index 8b10ece6239b..76ab1827f622 100644 --- a/tools/qa/cppunit/test_rectangle.cxx +++ b/tools/qa/cppunit/test_rectangle.cxx @@ -30,28 +30,28 @@ void Test::test_rectangle() { tools::Rectangle aRect(1,1,1,1); - CPPUNIT_ASSERT_EQUAL(long(1), aRect.GetWidth()); - CPPUNIT_ASSERT_EQUAL(long(1), aRect.GetHeight()); + CPPUNIT_ASSERT_EQUAL(tools::Long(1), aRect.GetWidth()); + CPPUNIT_ASSERT_EQUAL(tools::Long(1), aRect.GetHeight()); - CPPUNIT_ASSERT_EQUAL(long(0), aRect.getWidth()); - CPPUNIT_ASSERT_EQUAL(long(0), aRect.getHeight()); + CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRect.getWidth()); + CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRect.getHeight()); } { tools::Rectangle aRect(Point(), Size(1,1)); - CPPUNIT_ASSERT_EQUAL(long(0), aRect.Left()); - CPPUNIT_ASSERT_EQUAL(long(0), aRect.Top()); - CPPUNIT_ASSERT_EQUAL(long(0), aRect.Right()); - CPPUNIT_ASSERT_EQUAL(long(0), aRect.Bottom()); + CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRect.Left()); + CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRect.Top()); + CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRect.Right()); + CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRect.Bottom()); - CPPUNIT_ASSERT_EQUAL(long(1), aRect.GetWidth()); - CPPUNIT_ASSERT_EQUAL(long(1), aRect.GetHeight()); + CPPUNIT_ASSERT_EQUAL(tools::Long(1), aRect.GetWidth()); + CPPUNIT_ASSERT_EQUAL(tools::Long(1), aRect.GetHeight()); aRect.setX(12); - CPPUNIT_ASSERT_EQUAL(long(1), aRect.GetHeight()); + CPPUNIT_ASSERT_EQUAL(tools::Long(1), aRect.GetHeight()); aRect.setY(12); - CPPUNIT_ASSERT_EQUAL(long(1), aRect.GetWidth()); + CPPUNIT_ASSERT_EQUAL(tools::Long(1), aRect.GetWidth()); } } diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx index 061435ed61c9..5c43a051d609 100644 --- a/tools/source/generic/color.cxx +++ b/tools/source/generic/color.cxx @@ -26,20 +26,21 @@ #include <tools/color.hxx> #include <tools/helpers.hxx> +#include <tools/long.hxx> #include <basegfx/color/bcolortools.hxx> void Color::IncreaseLuminance(sal_uInt8 cLumInc) { - R = sal_uInt8(std::clamp(long(R) + cLumInc, 0L, 255L)); - G = sal_uInt8(std::clamp(long(G) + cLumInc, 0L, 255L)); - B = sal_uInt8(std::clamp(long(B) + cLumInc, 0L, 255L)); + R = sal_uInt8(std::clamp(tools::Long(R) + cLumInc, 0L, 255L)); + G = sal_uInt8(std::clamp(tools::Long(G) + cLumInc, 0L, 255L)); + B = sal_uInt8(std::clamp(tools::Long(B) + cLumInc, 0L, 255L)); } void Color::DecreaseLuminance(sal_uInt8 cLumDec) { - R = sal_uInt8(std::clamp(long(R) - cLumDec, 0L, 255L)); - G = sal_uInt8(std::clamp(long(G) - cLumDec, 0L, 255L)); - B = sal_uInt8(std::clamp(long(B) - cLumDec, 0L, 255L)); + R = sal_uInt8(std::clamp(tools::Long(R) - cLumDec, 0L, 255L)); + G = sal_uInt8(std::clamp(tools::Long(G) - cLumDec, 0L, 255L)); + B = sal_uInt8(std::clamp(tools::Long(B) - cLumDec, 0L, 255L)); } void Color::DecreaseContrast(sal_uInt8 nContDec) diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx index 7a275eea3088..78025c459d07 100644 --- a/tools/source/generic/gen.cxx +++ b/tools/source/generic/gen.cxx @@ -39,10 +39,10 @@ OString Pair::toString() const tools::Rectangle tools::Rectangle::Justify( const Point& rLT, const Point& rRB ) { - long nLeft = std::min(rLT.X(), rRB.X()); - long nTop = std::min(rLT.Y(), rRB.Y()); - long nRight = std::max(rLT.X(), rRB.X()); - long nBottom = std::max(rLT.Y(), rRB.Y()); + tools::Long nLeft = std::min(rLT.X(), rRB.X()); + tools::Long nTop = std::min(rLT.Y(), rRB.Y()); + tools::Long nRight = std::max(rLT.X(), rRB.X()); + tools::Long nBottom = std::max(rLT.Y(), rRB.Y()); return Rectangle( nLeft, nTop, nRight, nBottom ); } @@ -80,14 +80,14 @@ void tools::Rectangle::SaturatingSetSize(const Size& rSize) nBottom = RECT_EMPTY; } -void tools::Rectangle::SaturatingSetX(long x) +void tools::Rectangle::SaturatingSetX(tools::Long x) { if (nRight != RECT_EMPTY) nRight = o3tl::saturating_add(nRight, x - nLeft); nLeft = x; } -void tools::Rectangle::SaturatingSetY(long y) +void tools::Rectangle::SaturatingSetY(tools::Long y) { if (nBottom != RECT_EMPTY) nBottom = o3tl::saturating_add(nBottom, y - nTop); @@ -202,7 +202,7 @@ OString tools::Rectangle::toString() const return ss.str().c_str(); } -void tools::Rectangle::expand(long nExpandBy) +void tools::Rectangle::expand(tools::Long nExpandBy) { nLeft -= nExpandBy; nTop -= nExpandBy; @@ -216,7 +216,7 @@ void tools::Rectangle::expand(long nExpandBy) nBottom += nExpandBy; } -void tools::Rectangle::shrink(long nShrinkBy) +void tools::Rectangle::shrink(tools::Long nShrinkBy) { nLeft += nShrinkBy; nTop += nShrinkBy; @@ -226,7 +226,7 @@ void tools::Rectangle::shrink(long nShrinkBy) nBottom -= nShrinkBy; } -long tools::Rectangle::AdjustRight(long nHorzMoveDelta) +tools::Long tools::Rectangle::AdjustRight(tools::Long nHorzMoveDelta) { if (nRight == RECT_EMPTY) nRight = nLeft + nHorzMoveDelta - 1; @@ -235,7 +235,7 @@ long tools::Rectangle::AdjustRight(long nHorzMoveDelta) return nRight; } -long tools::Rectangle::AdjustBottom( long nVertMoveDelta ) +tools::Long tools::Rectangle::AdjustBottom( tools::Long nVertMoveDelta ) { if (nBottom == RECT_EMPTY) nBottom = nTop + nVertMoveDelta - 1; @@ -244,38 +244,38 @@ long tools::Rectangle::AdjustBottom( long nVertMoveDelta ) return nBottom; } -void tools::Rectangle::setX( long x ) +void tools::Rectangle::setX( tools::Long x ) { if (nRight != RECT_EMPTY) nRight += x - nLeft; nLeft = x; } -void tools::Rectangle::setY( long y ) +void tools::Rectangle::setY( tools::Long y ) { if (nBottom != RECT_EMPTY) nBottom += y - nTop; nTop = y; } -long tools::Rectangle::Right() const +tools::Long tools::Rectangle::Right() const { return nRight == RECT_EMPTY ? nLeft : nRight; } -long tools::Rectangle::Bottom() const +tools::Long tools::Rectangle::Bottom() const { return nBottom == RECT_EMPTY ? nTop : nBottom; } /// Returns the difference between right and left, assuming the range includes one end, but not the other. -long tools::Rectangle::getWidth() const +tools::Long tools::Rectangle::getWidth() const { return nRight == RECT_EMPTY ? 0 : nRight - nLeft; } /// Returns the difference between bottom and top, assuming the range includes one end, but not the other. -long tools::Rectangle::getHeight() const +tools::Long tools::Rectangle::getHeight() const { return nBottom == RECT_EMPTY ? 0 : nBottom - nTop; } diff --git a/tools/source/generic/point.cxx b/tools/source/generic/point.cxx index f33fe9a28803..c38e0f183451 100644 --- a/tools/source/generic/point.cxx +++ b/tools/source/generic/point.cxx @@ -23,18 +23,18 @@ void Point::RotateAround( Point& rPoint, short nOrientation ) const { - long nX = rPoint.X(); - long nY = rPoint.Y(); + tools::Long nX = rPoint.X(); + tools::Long nY = rPoint.Y(); RotateAround(nX, nY, nOrientation); rPoint.setX(nX); rPoint.setY(nY); } -void Point::RotateAround( long& rX, long& rY, +void Point::RotateAround( tools::Long& rX, tools::Long& rY, short nOrientation ) const { - const long nOriginX = X(); - const long nOriginY = Y(); + const tools::Long nOriginX = X(); + const tools::Long nOriginY = Y(); if ( (nOrientation >= 0) && !(nOrientation % 900) ) { @@ -48,7 +48,7 @@ void Point::RotateAround( long& rX, long& rY, if ( nOrientation == 900 ) { - long nTemp = rX; + tools::Long nTemp = rX; rX = rY; rY = -nTemp; } @@ -59,7 +59,7 @@ void Point::RotateAround( long& rX, long& rY, } else /* ( nOrientation == 2700 ) */ { - long nTemp = rX; + tools::Long nTemp = rX; rX = -rY; rY = nTemp; } @@ -75,12 +75,12 @@ void Point::RotateAround( long& rX, long& rY, double nSin = sin( nRealOrientation ); // Translation... - long nX = rX-nOriginX; - long nY = rY-nOriginY; + tools::Long nX = rX-nOriginX; + tools::Long nY = rY-nOriginY; // Rotation... - rX = + static_cast<long>(nCos*nX + nSin*nY) + nOriginX; - rY = - static_cast<long>(nSin*nX - nCos*nY) + nOriginY; + rX = + static_cast<tools::Long>(nCos*nX + nSin*nY) + nOriginX; + rY = - static_cast<tools::Long>(nSin*nX - nCos*nY) + nOriginY; } } diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index eab7a81acc39..7e972714ad2a 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -55,7 +55,7 @@ static double ImplGetParameter( const Point& rCenter, const Point& rPt, double fWR, double fHR ) { - const long nDX = rPt.X() - rCenter.X(); + const tools::Long nDX = rPt.X() - rCenter.X(); double fAngle = atan2( -rPt.Y() + rCenter.Y(), ( ( nDX == 0 ) ? 0.000000001 : nDX ) ); return atan2(fWR*sin(fAngle), fHR*cos(fAngle)); @@ -167,13 +167,13 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rRect, sal_uInt32 nHorzRound, mnPoints = 0; } -ImplPolygon::ImplPolygon( const Point& rCenter, long nRadX, long nRadY ) +ImplPolygon::ImplPolygon( const Point& rCenter, tools::Long nRadX, tools::Long nRadY ) { if( nRadX && nRadY ) { sal_uInt16 nPoints; // Compute default (depends on size) - long nRadXY; + tools::Long nRadXY; const bool bOverflow = o3tl::checked_multiply(nRadX, nRadY, nRadXY); if (!bOverflow) { @@ -202,8 +202,8 @@ ImplPolygon::ImplPolygon( const Point& rCenter, long nRadX, long nRadY ) for( i=0, nAngle = 0.0; i < nPoints4; i++, nAngle += nAngleStep ) { - long nX = FRound( nRadX * cos( nAngle ) ); - long nY = FRound( -nRadY * sin( nAngle ) ); + tools::Long nX = FRound( nRadX * cos( nAngle ) ); + tools::Long nY = FRound( -nRadY * sin( nAngle ) ); Point* pPt = &(mxPointAry[i]); pPt->setX( nX + rCenter.X() ); @@ -226,17 +226,17 @@ ImplPolygon::ImplPolygon( const Point& rCenter, long nRadX, long nRadY ) ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, const Point& rStart, const Point& rEnd, PolyStyle eStyle ) { - const long nWidth = rBound.GetWidth(); - const long nHeight = rBound.GetHeight(); + const tools::Long nWidth = rBound.GetWidth(); + const tools::Long nHeight = rBound.GetHeight(); if( ( nWidth > 1 ) && ( nHeight > 1 ) ) { const Point aCenter( rBound.Center() ); - const long nRadX = aCenter.X() - rBound.Left(); - const long nRadY = aCenter.Y() - rBound.Top(); + const tools::Long nRadX = aCenter.X() - rBound.Left(); + const tools::Long nRadY = aCenter.Y() - rBound.Top(); sal_uInt16 nPoints; - long nRadXY; + tools::Long nRadXY; const bool bOverflow = o3tl::checked_multiply(nRadX, nRadY, nRadXY); if (!bOverflow) { @@ -697,14 +697,14 @@ class ImplEdgePointFilter : public ImplPointFilter Point maFirstPoint; Point maLastPoint; ImplPointFilter& mrNextFilter; - const long mnLow; - const long mnHigh; + const tools::Long mnLow; + const tools::Long mnHigh; const int mnEdge; int mnLastOutside; bool mbFirst; public: - ImplEdgePointFilter( int nEdge, long nLow, long nHigh, + ImplEdgePointFilter( int nEdge, tools::Long nLow, tools::Long nHigh, ImplPointFilter& rNextFilter ) : mrNextFilter( rNextFilter ), mnLow( nLow ), @@ -744,17 +744,17 @@ inline int ImplEdgePointFilter::VisibleSide( const Point& rPoint ) const Point ImplEdgePointFilter::EdgeSection( const Point& rPoint, int nEdge ) const { - long lx = maLastPoint.X(); - long ly = maLastPoint.Y(); - long md = rPoint.X() - lx; - long mn = rPoint.Y() - ly; - long nNewX; - long nNewY; + tools::Long lx = maLastPoint.X(); + tools::Long ly = maLastPoint.Y(); + tools::Long md = rPoint.X() - lx; + tools::Long mn = rPoint.Y() - ly; + tools::Long nNewX; + tools::Long nNewY; if ( nEdge & EDGE_VERT ) { nNewY = (nEdge == EDGE_TOP) ? mnLow : mnHigh; - long dy = nNewY - ly; + tools::Long dy = nNewY - ly; if ( !md ) nNewX = lx; else if ( (LONG_MAX / std::abs(md)) >= std::abs(dy) ) @@ -774,13 +774,13 @@ Point ImplEdgePointFilter::EdgeSection( const Point& rPoint, int nEdge ) const else ady += mn/2; ady /= mn; - nNewX = static_cast<long>(ady) + lx; + nNewX = static_cast<tools::Long>(ady) + lx; } } else { nNewX = (nEdge == EDGE_LEFT) ? mnLow : mnHigh; - long dx = nNewX - lx; + tools::Long dx = nNewX - lx; if ( !mn ) nNewY = ly; else if ( (LONG_MAX / std::abs(mn)) >= std::abs(dx) ) @@ -800,7 +800,7 @@ Point ImplEdgePointFilter::EdgeSection( const Point& rPoint, int nEdge ) const else adx += md/2; adx /= md; - nNewY = static_cast<long>(adx) + ly; + nNewY = static_cast<tools::Long>(adx) + ly; } } @@ -893,7 +893,7 @@ Polygon::Polygon( const tools::Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt { } -Polygon::Polygon( const Point& rCenter, long nRadX, long nRadY ) +Polygon::Polygon( const Point& rCenter, tools::Long nRadX, tools::Long nRadY ) : mpImplPolygon(ImplPolygon(rCenter, nRadX, nRadY)) { } @@ -1363,7 +1363,7 @@ void Polygon::ImplReduceEdges( tools::Polygon& rPoly, const double& rArea, sal_u } } -void Polygon::Move( long nHorzMove, long nVertMove ) +void Polygon::Move( tools::Long nHorzMove, tools::Long nVertMove ) { // This check is required for DrawEngine if ( !nHorzMove && !nVertMove ) @@ -1390,8 +1390,8 @@ void Polygon::Scale( double fScaleX, double fScaleY ) for ( sal_uInt16 i = 0, nCount = mpImplPolygon->mnPoints; i < nCount; i++ ) { Point& rPnt = mpImplPolygon->mxPointAry[i]; - rPnt.setX( static_cast<long>( fScaleX * rPnt.X() ) ); - rPnt.setY( static_cast<long>( fScaleY * rPnt.Y() ) ); + rPnt.setX( static_cast<tools::Long>( fScaleX * rPnt.X() ) ); + rPnt.setY( static_cast<tools::Long>( fScaleY * rPnt.Y() ) ); } } @@ -1408,15 +1408,15 @@ void Polygon::Rotate( const Point& rCenter, sal_uInt16 nAngle10 ) void Polygon::Rotate( const Point& rCenter, double fSin, double fCos ) { - long nCenterX = rCenter.X(); - long nCenterY = rCenter.Y(); + tools::Long nCenterX = rCenter.X(); + tools::Long nCenterY = rCenter.Y(); for( sal_uInt16 i = 0, nCount = mpImplPolygon->mnPoints; i < nCount; i++ ) { Point& rPt = mpImplPolygon->mxPointAry[ i ]; - const long nX = rPt.X() - nCenterX; - const long nY = rPt.Y() - nCenterY; + const tools::Long nX = rPt.X() - nCenterX; + const tools::Long nY = rPt.Y() - nCenterY; rPt.setX( FRound( fCos * nX + fSin * nY ) + nCenterX ); rPt.setY( - FRound( fSin * nX - fCos * nY ) + nCenterY ); } @@ -1462,7 +1462,7 @@ tools::Rectangle Polygon::GetBoundRect() const if( ! nCount ) return tools::Rectangle(); - long nXMin, nXMax, nYMin, nYMax; + tools::Long nXMin, nXMax, nYMin, nYMax; const Point& pFirstPt = mpImplPolygon->mxPointAry[0]; nXMin = nXMax = pFirstPt.X(); diff --git a/tools/source/generic/poly2.cxx b/tools/source/generic/poly2.cxx index 5591ea4e6d83..a1c4fe0cbe69 100644 --- a/tools/source/generic/poly2.cxx +++ b/tools/source/generic/poly2.cxx @@ -228,7 +228,7 @@ sal_uInt16 PolyPolygon::Count() const return mpImplPolyPolygon->mvPolyAry.size(); } -void PolyPolygon::Move( long nHorzMove, long nVertMove ) +void PolyPolygon::Move( tools::Long nHorzMove, tools::Long nVertMove ) { // Required for DrawEngine if( nHorzMove || nVertMove ) @@ -293,7 +293,7 @@ void PolyPolygon::Clip( const tools::Rectangle& rRect ) tools::Rectangle PolyPolygon::GetBoundRect() const { - long nXMin=0, nXMax=0, nYMin=0, nYMax=0; + tools::Long nXMin=0, nXMax=0, nYMin=0, nYMax=0; bool bFirst = true; sal_uInt16 nPolyCount = mpImplPolyPolygon->mvPolyAry.size(); diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index 404b9eb67537..fe2470766be3 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -34,6 +34,7 @@ #include <rtl/strbuf.hxx> #include <rtl/ustrbuf.hxx> #include <sal/log.hxx> +#include <tools/long.hxx> #include <comphelper/fileformat.h> @@ -1517,7 +1518,7 @@ void SvStream::EncryptBuffer(void* pStart, std::size_t nLen) const } } -static unsigned char implGetCryptMask(const char* pStr, sal_Int32 nLen, long nVersion) +static unsigned char implGetCryptMask(const char* pStr, sal_Int32 nLen, tools::Long nVersion) { unsigned char nCryptMask = 0; @@ -1718,7 +1719,7 @@ std::size_t SvMemoryStream::PutData( const void* pData, std::size_t nCount ) } else { - long nNewResize; + tools::Long nNewResize; if( nSize && nSize > nResize ) nNewResize = nSize; else @@ -1772,8 +1773,8 @@ sal_uInt64 SvMemoryStream::SeekPos(sal_uInt64 const nNewPos) { if( nResize ) // Is extension possible? { - long nDiff = static_cast<long>(nNewPos - nSize + 1); - nDiff += static_cast<long>(nResize); + tools::Long nDiff = static_cast<tools::Long>(nNewPos - nSize + 1); + nDiff += static_cast<tools::Long>(nResize); ReAllocateMemory( nDiff ); nPos = nNewPos; nEndOfData = nNewPos; @@ -1808,13 +1809,13 @@ void SvMemoryStream::AllocateMemory( std::size_t nNewSize ) } // (using Bozo algorithm) -bool SvMemoryStream::ReAllocateMemory( long nDiff ) +bool SvMemoryStream::ReAllocateMemory( tools::Long nDiff ) { if (!m_isWritable || !bOwnsData) return false; bool bRetVal = false; - long nTemp = static_cast<long>(nSize); + tools::Long nTemp = static_cast<tools::Long>(nSize); nTemp += nDiff; std::size_t nNewSize = static_cast<std::size_t>(nTemp); @@ -1899,7 +1900,7 @@ void SvMemoryStream::SetSize(sal_uInt64 const nNewSize) return; } - long nDiff = static_cast<long>(nNewSize) - static_cast<long>(nSize); + tools::Long nDiff = static_cast<tools::Long>(nNewSize) - static_cast<tools::Long>(nSize); ReAllocateMemory( nDiff ); } diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx index 36386b9bb498..1707793839c2 100644 --- a/tools/source/zcodec/zcodec.cxx +++ b/tools/source/zcodec/zcodec.cxx @@ -26,6 +26,7 @@ #include <zlib.h> #include <tools/zcodec.hxx> +#include <tools/long.hxx> /* gzip flag byte */ // GZ_ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ @@ -77,9 +78,9 @@ void ZCodec::BeginCompression( int nCompressLevel, bool gzLib ) pStream->avail_out = pStream->avail_in = 0; } -long ZCodec::EndCompression() +tools::Long ZCodec::EndCompression() { - long retvalue = 0; + tools::Long retvalue = 0; auto pStream = static_cast<z_stream*>(mpsC_Stream); if (meState != STATE_INIT) @@ -135,12 +136,12 @@ void ZCodec::Compress( SvStream& rIStm, SvStream& rOStm ) }; } -long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm ) +tools::Long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm ) { int err; size_t nInToRead; auto pStream = static_cast<z_stream*>(mpsC_Stream); - long nOldTotal_Out = pStream->total_out; + tools::Long nOldTotal_Out = pStream->total_out; assert(meState == STATE_INIT); mpOStm = &rOStm; @@ -168,7 +169,7 @@ long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm ) while ( ( err != Z_STREAM_END) && ( pStream->avail_in || mnInToRead ) ); ImplWriteBack(); - return mbStatus ? static_cast<long>(pStream->total_out - nOldTotal_Out) : -1; + return mbStatus ? static_cast<tools::Long>(pStream->total_out - nOldTotal_Out) : -1; } void ZCodec::Write( SvStream& rOStm, const sal_uInt8* pData, sal_uInt32 nSize ) @@ -197,7 +198,7 @@ void ZCodec::Write( SvStream& rOStm, const sal_uInt8* pData, sal_uInt32 nSize ) } } -long ZCodec::Read( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize ) +tools::Long ZCodec::Read( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize ) { int err; size_t nInToRead; @@ -235,10 +236,10 @@ long ZCodec::Read( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize ) if ( err == Z_STREAM_END ) mbFinish = true; - return (mbStatus ? static_cast<long>(nSize - pStream->avail_out) : -1); + return (mbStatus ? static_cast<tools::Long>(nSize - pStream->avail_out) : -1); } -long ZCodec::ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize ) +tools::Long ZCodec::ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize ) { int err = 0; size_t nInToRead; @@ -285,7 +286,7 @@ long ZCodec::ReadAsynchron( SvStream& rIStm, sal_uInt8* pData, sal_uInt32 nSize if ( err == Z_STREAM_END ) mbFinish = true; - return (mbStatus ? static_cast<long>(nSize - pStream->avail_out) : -1); + return (mbStatus ? static_cast<tools::Long>(nSize - pStream->avail_out) : -1); } void ZCodec::ImplWriteBack() |