diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/generic/gen.cxx | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx index 2627d9202842..5fe6eeeaa3d6 100644 --- a/tools/source/generic/gen.cxx +++ b/tools/source/generic/gen.cxx @@ -20,7 +20,7 @@ #include <sal/config.h> #include <sstream> - +#include <o3tl/safeint.hxx> #include <tools/gen.hxx> #include <tools/stream.hxx> @@ -68,6 +68,23 @@ void tools::Rectangle::SetSize( const Size& rSize ) nBottom = RECT_EMPTY; } +void tools::Rectangle::SaturatingSetSize(const Size& rSize) +{ + if (rSize.Width() < 0) + nRight = o3tl::saturating_add(nLeft, (rSize.Width() + 1)); + else if ( rSize.Width() > 0 ) + nRight = o3tl::saturating_add(nLeft, (rSize.Width() - 1)); + else + nRight = RECT_EMPTY; + + if ( rSize.Height() < 0 ) + nBottom = o3tl::saturating_add(nTop, (rSize.Height() + 1)); + else if ( rSize.Height() > 0 ) + nBottom = o3tl::saturating_add(nTop, (rSize.Height() - 1)); + else + nBottom = RECT_EMPTY; +} + tools::Rectangle& tools::Rectangle::Union( const tools::Rectangle& rRect ) { if ( rRect.IsEmpty() ) |