include/tools/gen.hxx         |    2 +-
 tools/source/generic/gen.cxx  |    6 ++++++
 vcl/source/gdi/mtfxmldump.cxx |    5 +++--
 3 files changed, 10 insertions(+), 3 deletions(-)

New commits:
commit 1ce1c26dd98e6477139e08d1ebe89fa950ff5fb0
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Jul 12 12:06:41 2019 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Jul 12 17:04:02 2019 +0200

    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.gran...@collabora.co.uk>

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)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to