summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-07-12 12:06:41 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-07-12 17:04:02 +0200
commit1ce1c26dd98e6477139e08d1ebe89fa950ff5fb0 (patch)
tree462fdc3beda919e1b399d8bb168f472cf175a48f
parentb11ea5e9c37b19f0d60a4075146668954a7bf728 (diff)
make tools::Rectangle::Right return Left when empty
I tried making this assert, but there are just too many places where we pass around empty rectangles, so rather just return the value of nLeft, in a similar fashion to methods like Rectangle::TopLeft Change-Id: I3377071ecae26f13e895ae411cd269f0bdbe0ef6 Reviewed-on: https://gerrit.libreoffice.org/75486 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--include/tools/gen.hxx2
-rw-r--r--tools/source/generic/gen.cxx6
-rw-r--r--vcl/source/gdi/mtfxmldump.cxx5
3 files changed, 10 insertions, 3 deletions
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 54a438bfa161..dd0514396567 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -386,7 +386,7 @@ public:
Rectangle( const Point& rLT, const Size& rSize );
long Left() const { return nLeft; }
- long Right() const { return nRight; }
+ long Right() const;
long Top() const { return nTop; }
long Bottom() const { return nBottom; }
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index fc927f50e41e..459687dc961a 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -20,6 +20,7 @@
#include <sal/config.h>
#include <algorithm>
+#include <cassert>
#include <sstream>
#include <o3tl/safeint.hxx>
#include <tools/gen.hxx>
@@ -291,4 +292,9 @@ void tools::Rectangle::setY( long y )
nTop = y;
}
+long tools::Rectangle::Right() const
+{
+ return nRight == RECT_EMPTY ? nLeft : nRight;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index 8c168a89d4c4..c679b08e86e6 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -459,8 +459,9 @@ void writeRectangle(tools::XmlWriter& rWriter, tools::Rectangle const& rRectangl
{
rWriter.attribute("left", rRectangle.Left());
rWriter.attribute("top", rRectangle.Top());
- rWriter.attribute("right", rRectangle.Right());
- rWriter.attribute("bottom", rRectangle.Bottom());
+ // FIXME what should we write for empty?
+ rWriter.attribute("right", rRectangle.IsWidthEmpty() ? -32767 : rRectangle.Right());
+ rWriter.attribute("bottom", rRectangle.IsHeightEmpty() ? -32767 : rRectangle.Bottom());
}
void writeLineInfo(tools::XmlWriter& rWriter, LineInfo const& rLineInfo)