diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2022-09-21 12:17:00 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-07-13 13:19:00 +0200 |
commit | f896bbcffeccd27248f908d2628d03dddf83ea94 (patch) | |
tree | ffbf0300461780c94e897cad2ad29906695ac91d /include | |
parent | 6086d896183a529d4a0b83d4862970c8f320b0aa (diff) |
basegfx: replace typedef with a class B2ISize based on Size2D
Change-Id: Iaf7d02bb236f81a38a67a1430a718b6c3c78efae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139708
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/basegfx/tuple/Size2D.hxx | 2 | ||||
-rw-r--r-- | include/basegfx/utils/canvastools.hxx | 5 | ||||
-rw-r--r-- | include/basegfx/vector/b2dsize.hxx | 12 | ||||
-rw-r--r-- | include/basegfx/vector/b2isize.hxx | 38 | ||||
-rw-r--r-- | include/vcl/outdev.hxx | 2 |
5 files changed, 49 insertions, 10 deletions
diff --git a/include/basegfx/tuple/Size2D.hxx b/include/basegfx/tuple/Size2D.hxx index d4e2a2a784bc..28b967636fe2 100644 --- a/include/basegfx/tuple/Size2D.hxx +++ b/include/basegfx/tuple/Size2D.hxx @@ -76,6 +76,8 @@ public: } Size2D<TYPE> operator-(void) const { return Tuple2D<TYPE>::operator-(); } + + using Tuple2D<TYPE>::equalZero; }; template <typename TYPE> diff --git a/include/basegfx/utils/canvastools.hxx b/include/basegfx/utils/canvastools.hxx index 228a1b0f504a..46466097723d 100644 --- a/include/basegfx/utils/canvastools.hxx +++ b/include/basegfx/utils/canvastools.hxx @@ -61,6 +61,7 @@ namespace basegfx class B2DPolygon; class B2DPolyPolygon; class B2DSize; + class B2ISize; } namespace basegfx::unotools @@ -129,9 +130,9 @@ namespace basegfx::unotools BASEGFX_DLLPUBLIC ::basegfx::B2DRange b2DRectangleFromRealRectangle2D( const css::geometry::RealRectangle2D& ); ::basegfx::B3DRange b3DRectangleFromRealRectangle3D( const css::geometry::RealRectangle3D& ); - BASEGFX_DLLPUBLIC css::geometry::IntegerSize2D integerSize2DFromB2ISize( const ::basegfx::B2IVector& ); + BASEGFX_DLLPUBLIC css::geometry::IntegerSize2D integerSize2DFromB2ISize(basegfx::B2ISize const& rSize); - BASEGFX_DLLPUBLIC ::basegfx::B2IVector b2ISizeFromIntegerSize2D( const css::geometry::IntegerSize2D& ); + BASEGFX_DLLPUBLIC ::basegfx::B2ISize b2ISizeFromIntegerSize2D( const css::geometry::IntegerSize2D& ); BASEGFX_DLLPUBLIC ::basegfx::B2IRange b2IRectangleFromIntegerRectangle2D( const css::geometry::IntegerRectangle2D& ); BASEGFX_DLLPUBLIC ::basegfx::B2IRange b2IRectangleFromAwtRectangle( const css::awt::Rectangle& ); diff --git a/include/basegfx/vector/b2dsize.hxx b/include/basegfx/vector/b2dsize.hxx index e15158fbf9fd..aaffee618888 100644 --- a/include/basegfx/vector/b2dsize.hxx +++ b/include/basegfx/vector/b2dsize.hxx @@ -46,7 +46,7 @@ public: } explicit B2DSize(B2ISize const& rSize) - : Size2D(rSize.getX(), rSize.getY()) + : Size2D(rSize.getWidth(), rSize.getHeight()) { } @@ -81,12 +81,20 @@ public: } }; +template <typename charT, typename traits> +inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream, + const B2DSize& size) +{ + return stream << "(" << size.getWidth() << "," << size.getHeight() << ")"; +} + inline B2DSize operator*(B2DHomMatrix const& rMatrix, B2DSize const& rSize) { B2DSize aRes(rSize); aRes *= rMatrix; return aRes; } -} + +} // end basegfx /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basegfx/vector/b2isize.hxx b/include/basegfx/vector/b2isize.hxx index 926910b4827d..b26429bb434e 100644 --- a/include/basegfx/vector/b2isize.hxx +++ b/include/basegfx/vector/b2isize.hxx @@ -19,15 +19,43 @@ #pragma once -#include <basegfx/vector/b2ivector.hxx> +#include <basegfx/tuple/Size2D.hxx> +#include <basegfx/basegfxdllapi.h> namespace basegfx { -// syntactic sugar: a B2IVector exactly models a Size object, -// thus, for interface clarity, we provide an alias name +class B2ISize : public Size2D<sal_Int32> +{ +public: + B2ISize() + : Size2D(0, 0) + { + } + + B2ISize(sal_Int32 nX, sal_Int32 nY) + : Size2D(nX, nY) + { + } + + B2ISize(Size2D<sal_Int32> const& rSize) + : Size2D(rSize) + { + } -/// Alias name for interface clarity (not everybody is aware of the identity) -typedef B2IVector B2ISize; + using Size2D<sal_Int32>::operator+=; + using Size2D<sal_Int32>::operator-=; + using Size2D<sal_Int32>::operator*=; + using Size2D<sal_Int32>::operator/=; + using Size2D<sal_Int32>::operator-; +}; + +template <typename charT, typename traits> +inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream, + const B2ISize& size) +{ + return stream << "(" << size.getWidth() << "," << size.getHeight() << ")"; } +} // end basegfx + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index d550ecfce293..cfa423759202 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -122,7 +122,7 @@ namespace basegfx { class B2DHomMatrix; class B2DPolygon; class B2IVector; - typedef B2IVector B2ISize; + class B2ISize; } namespace com::sun::star::awt { |