summaryrefslogtreecommitdiff
path: root/include/tools/gen.hxx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-03-31 22:51:03 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-04-07 17:00:38 +0200
commitf99b3119640385cae16b22716aa9d3b2b0240586 (patch)
treeb171d08d329727c4e817afd4182a5653517ae566 /include/tools/gen.hxx
parentd75a4d02c9d29321662764cae8bea1707df9cb98 (diff)
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.lunak@collabora.com>
Diffstat (limited to 'include/tools/gen.hxx')
-rw-r--r--include/tools/gen.hxx60
1 files changed, 60 insertions, 0 deletions
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 )