[Libreoffice-commits] core.git: include/tools sd/qa tools/qa
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Tue Aug 17 07:22:32 UTC 2021
include/tools/gen.hxx | 4 ++--
sd/qa/unit/SdrPdfImportTest.cxx | 2 +-
tools/qa/cppunit/test_rectangle.cxx | 11 +++++++++++
3 files changed, 14 insertions(+), 3 deletions(-)
New commits:
commit 59e969def7488977be8c554d37bebe535c6511cb
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Tue Aug 17 07:50:25 2021 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Aug 17 09:21:59 2021 +0200
Fix ctor taking Point and Size, to properly handle regative sizes
(alinged to SetSize)
Change-Id: I123a584ead91faae0fec4d25938529b2d68e4a3c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120559
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 5e083e2bffc6..2d23b693fa50 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -622,8 +622,8 @@ constexpr inline tools::Rectangle::Rectangle( tools::Long _nLeft, tools::Long _
constexpr inline tools::Rectangle::Rectangle( const Point& rLT, const Size& rSize )
: nLeft( rLT.X())
, nTop( rLT.Y())
- , nRight( rSize.Width() ? nLeft+(rSize.Width()-1) : RECT_EMPTY )
- , nBottom( rSize.Height() ? nTop+(rSize.Height()-1) : RECT_EMPTY )
+ , nRight(rSize.Width() ? nLeft + (rSize.Width() + (rSize.Width() > 0 ? -1 : 1)) : RECT_EMPTY)
+ , nBottom(rSize.Height() ? nTop + (rSize.Height() + (rSize.Height() > 0 ? -1 : 1)) : RECT_EMPTY)
{}
inline void tools::Rectangle::Move( tools::Long nHorzMove, tools::Long nVertMove )
diff --git a/sd/qa/unit/SdrPdfImportTest.cxx b/sd/qa/unit/SdrPdfImportTest.cxx
index 39d8f74fca54..e88316c35945 100644
--- a/sd/qa/unit/SdrPdfImportTest.cxx
+++ b/sd/qa/unit/SdrPdfImportTest.cxx
@@ -120,7 +120,7 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testImportSimpleText)
CPPUNIT_ASSERT(pImportedObject);
// Check the object position
- CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(2011, 2098), Size(2106 + 1, 302 + 1)),
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(2011, 2102), Size(2106 + 1, 298 + 1)),
pImportedObject->GetLogicRect());
// Object should be a text object containing one paragraph with
diff --git a/tools/qa/cppunit/test_rectangle.cxx b/tools/qa/cppunit/test_rectangle.cxx
index e4992f3f44f9..29aa6cde94df 100644
--- a/tools/qa/cppunit/test_rectangle.cxx
+++ b/tools/qa/cppunit/test_rectangle.cxx
@@ -57,6 +57,17 @@ void Test::test_rectangle()
aRect.SetPosY(12);
CPPUNIT_ASSERT_EQUAL(tools::Long(1), aRect.GetWidth());
}
+
+ {
+ constexpr tools::Rectangle aRect(Point(), Size(-1, -2));
+ static_assert(!aRect.IsEmpty());
+ static_assert(aRect.Right() == 0);
+ static_assert(aRect.Bottom() == -1);
+
+ tools::Rectangle aRect2;
+ aRect2.SetSize(Size(-1, -2));
+ CPPUNIT_ASSERT_EQUAL(aRect, aRect2);
+ }
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
More information about the Libreoffice-commits
mailing list