include/tools/gen.hxx | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
New commits: commit f99b3119640385cae16b22716aa9d3b2b0240586 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Wed Mar 31 22:51:03 2021 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Wed Apr 7 17:00:38 2021 +0200 implement operators +,-,*,/ for tools::Size If they exist for tools::Point, I don't see why they couldn't do the same also for Size. Change-Id: I02ca1bb413b0bd2694a904372e9a18a7a50be17b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113725 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx index 73dee3fd6925..d88e65516951 100644 --- a/include/tools/gen.hxx +++ b/include/tools/gen.hxx @@ -210,6 +210,17 @@ public: Pair & toPair() { return *this; } using Pair::toString; + + Size& operator += ( const Size& rSize ); + Size& operator -= ( const Size& rSize ); + Size& operator *= ( const tools::Long nVal ); + Size& operator /= ( const tools::Long nVal ); + + friend inline Size operator+( const Size &rVal1, const Size &rVal2 ); + friend inline Size operator-( const Size &rVal1, const Size &rVal2 ); + friend inline Size operator*( const Size &rVal1, const tools::Long nVal2 ); + friend inline Size operator/( const Size &rVal1, const tools::Long nVal2 ); + }; inline bool operator ==(Size const & s1, Size const & s2) @@ -222,6 +233,55 @@ inline bool operator !=(Size const & s1, Size const & s2) return !(s1 == s2); } +inline Size& Size::operator += ( const Size& rSize ) +{ + nA += rSize.nA; + nB += rSize.nB; + return *this; +} + +inline Size& Size::operator -= ( const Size& rSize ) +{ + nA -= rSize.nA; + nB -= rSize.nB; + return *this; +} + +inline Size& Size::operator *= ( const tools::Long nVal ) +{ + nA *= nVal; + nB *= nVal; + return *this; +} + +inline Size& Size::operator /= ( const tools::Long nVal ) +{ + nA /= nVal; + nB /= nVal; + return *this; +} + +inline Size operator+( const Size &rVal1, const Size &rVal2 ) +{ + return Size( rVal1.nA+rVal2.nA, rVal1.nB+rVal2.nB ); +} + +inline Size operator-( const Size &rVal1, const Size &rVal2 ) +{ + return Size( rVal1.nA-rVal2.nA, rVal1.nB-rVal2.nB ); +} + +inline Size operator*( const Size &rVal1, const tools::Long nVal2 ) +{ + return Size( rVal1.nA*nVal2, rVal1.nB*nVal2 ); +} + +inline Size operator/( const Size &rVal1, const tools::Long nVal2 ) +{ + return Size( rVal1.nA/nVal2, rVal1.nB/nVal2 ); +} + + template< typename charT, typename traits > inline std::basic_ostream<charT, traits> & operator <<( std::basic_ostream<charT, traits> & stream, const Size& size ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits