[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 3 commits - basegfx/test include/svx include/tools svx/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jun 9 11:58:50 UTC 2020
basegfx/test/B2DHomMatrixTest.cxx | 32 ++++++++++++++++++++++++++++++++
include/svx/svdmrkv.hxx | 6 +++---
include/tools/UnitConversion.hxx | 6 +++++-
svx/source/svdraw/svdmrkv.cxx | 24 +++++++++---------------
4 files changed, 49 insertions(+), 19 deletions(-)
New commits:
commit 716fa0cc58a39a9975a6827088e9209b7b3311e6
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed May 27 12:54:54 2020 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Jun 9 13:55:52 2020 +0200
svx: convert ImplMarkingOverlay and friends to use unique_ptr
Change-Id: I19ba9e93f2804fded237b760a28f3ce62e4b2c5f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95305
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
(cherry picked from commit a6c0dc079700d662e14d422d18c6c3a9c2c3b7af)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95916
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx
index b62749f41335..5b57da626d4f 100644
--- a/include/svx/svdmrkv.hxx
+++ b/include/svx/svdmrkv.hxx
@@ -90,9 +90,9 @@ class SVX_DLLPUBLIC SdrMarkView : public SdrSnapView
friend class SdrPageView;
// #114409#-3 Migrate selections
- ImplMarkingOverlay* mpMarkObjOverlay;
- ImplMarkingOverlay* mpMarkPointsOverlay;
- ImplMarkingOverlay* mpMarkGluePointsOverlay;
+ std::unique_ptr<ImplMarkingOverlay> mpMarkObjOverlay;
+ std::unique_ptr<ImplMarkingOverlay> mpMarkPointsOverlay;
+ std::unique_ptr<ImplMarkingOverlay> mpMarkGluePointsOverlay;
protected:
SdrObject* mpMarkedObj; // If not just one object ( i.e. More than one object ) is marked.
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 937464b85571..c6dd6928c755 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -165,9 +165,6 @@ SdrMarkView::SdrMarkView(
SdrModel& rSdrModel,
OutputDevice* pOut)
: SdrSnapView(rSdrModel, pOut),
- mpMarkObjOverlay(nullptr),
- mpMarkPointsOverlay(nullptr),
- mpMarkGluePointsOverlay(nullptr),
maHdlList(this)
{
ImpClearVars();
@@ -363,10 +360,10 @@ void SdrMarkView::BegMarkObj(const Point& rPnt, bool bUnmark)
{
BrkAction();
- DBG_ASSERT(nullptr == mpMarkObjOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkObjOverlay (!)");
+ DBG_ASSERT(!mpMarkObjOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkObjOverlay (!)");
basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
- mpMarkObjOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
+ mpMarkObjOverlay.reset(new ImplMarkingOverlay(*this, aStartPos, bUnmark));
maDragStat.Reset(rPnt);
maDragStat.NextPoint();
@@ -410,8 +407,7 @@ void SdrMarkView::BrkMarkObj()
if(IsMarkObj())
{
DBG_ASSERT(mpMarkObjOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
- delete mpMarkObjOverlay;
- mpMarkObjOverlay = nullptr;
+ mpMarkObjOverlay.reset();
}
}
@@ -422,9 +418,9 @@ bool SdrMarkView::BegMarkPoints(const Point& rPnt, bool bUnmark)
{
BrkAction();
- DBG_ASSERT(nullptr == mpMarkPointsOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkPointsOverlay (!)");
+ DBG_ASSERT(!mpMarkPointsOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkPointsOverlay (!)");
basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
- mpMarkPointsOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
+ mpMarkPointsOverlay.reset(new ImplMarkingOverlay(*this, aStartPos, bUnmark));
maDragStat.Reset(rPnt);
maDragStat.NextPoint();
@@ -475,8 +471,7 @@ void SdrMarkView::BrkMarkPoints()
if(IsMarkPoints())
{
DBG_ASSERT(mpMarkPointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
- delete mpMarkPointsOverlay;
- mpMarkPointsOverlay = nullptr;
+ mpMarkPointsOverlay.reset();
}
}
@@ -487,10 +482,10 @@ bool SdrMarkView::BegMarkGluePoints(const Point& rPnt, bool bUnmark)
{
BrkAction();
- DBG_ASSERT(nullptr == mpMarkGluePointsOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkGluePointsOverlay (!)");
+ DBG_ASSERT(!mpMarkGluePointsOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkGluePointsOverlay (!)");
basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
- mpMarkGluePointsOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
+ mpMarkGluePointsOverlay.reset(new ImplMarkingOverlay(*this, aStartPos, bUnmark));
maDragStat.Reset(rPnt);
maDragStat.NextPoint();
maDragStat.SetMinMove(mnMinMovLog);
@@ -534,8 +529,7 @@ void SdrMarkView::BrkMarkGluePoints()
if(IsMarkGluePoints())
{
DBG_ASSERT(mpMarkGluePointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
- delete mpMarkGluePointsOverlay;
- mpMarkGluePointsOverlay = nullptr;
+ mpMarkGluePointsOverlay.reset();
}
}
commit 2ea69ca9ef6160535b5d5ed3d437b767085d7493
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed May 27 12:50:14 2020 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Jun 9 13:54:39 2020 +0200
basegfx: test of coordinate system conversion
Change-Id: I059d1f272f0633c450287f272083bb09732357b0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95304
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
(cherry picked from commit b5dee02018f9f7cd8d9afc6e8991e6e20ebb0e81)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95915
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/basegfx/test/B2DHomMatrixTest.cxx b/basegfx/test/B2DHomMatrixTest.cxx
index 8063587ac2dd..e5b923e6dd82 100644
--- a/basegfx/test/B2DHomMatrixTest.cxx
+++ b/basegfx/test/B2DHomMatrixTest.cxx
@@ -503,6 +503,36 @@ public:
CPPUNIT_ASSERT_DOUBLES_EQUAL(26, aRange.getMaxY(), 1E-12);
}
+ void testCoordinateSystemConversion()
+ {
+ // Use case when we convert
+
+ B2DRange aWindow(50, 50, 150, 150);
+
+ B2DRange aSubPage(0, 0, 2000, 2000);
+
+ B2DHomMatrix aB2DMatrix;
+ aB2DMatrix.scale(aWindow.getWidth() / aSubPage.getWidth(),
+ aWindow.getHeight() / aSubPage.getHeight());
+ aB2DMatrix.translate(aWindow.getMinX(), aWindow.getMinY());
+
+ B2DPoint aPoint1(0, 0);
+ aPoint1 *= aB2DMatrix;
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(50, aPoint1.getX(), 1E-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(50, aPoint1.getY(), 1E-12);
+
+ B2DPoint aPoint2(1000, 1000);
+ aPoint2 *= aB2DMatrix;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(100, aPoint2.getX(), 1E-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(100, aPoint2.getY(), 1E-12);
+
+ B2DPoint aPoint3(2000, 2000);
+ aPoint3 *= aB2DMatrix;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(150, aPoint3.getX(), 1E-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(150, aPoint3.getY(), 1E-12);
+ }
+
// Change the following lines only, if you add, remove or rename
// member functions of the current class,
// because these macros are need by auto register mechanism.
@@ -520,6 +550,8 @@ public:
CPPUNIT_TEST(testMultiplyWithAnotherMatrix);
CPPUNIT_TEST(testTransformPoint);
CPPUNIT_TEST(testTransformRange);
+ CPPUNIT_TEST(testCoordinateSystemConversion);
+
CPPUNIT_TEST_SUITE_END();
}; // class b2dhommatrix
commit 37543a1bad3122461fd7b2ebe61f4a60e16a4ba4
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat May 23 11:54:01 2020 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Jun 9 13:54:15 2020 +0200
vcl: add conversion point to twip int64 & double values
Change-Id: Id54d28b57c055269259317521f59d37dcdf9a456
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95274
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
(cherry picked from commit 5f8f8889a47a7079fc1beaa179e29cc32aa10e0e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95914
diff --git a/include/tools/UnitConversion.hxx b/include/tools/UnitConversion.hxx
index 2093db6181d9..2585fecbb590 100644
--- a/include/tools/UnitConversion.hxx
+++ b/include/tools/UnitConversion.hxx
@@ -20,11 +20,15 @@ constexpr sal_Int64 convertMm100ToTwip(sal_Int64 n)
return (n >= 0) ? (n * 72 + 63) / 127 : (n * 72 - 63) / 127;
}
+constexpr sal_Int64 convertPointToTwip(sal_Int64 nNumber) { return nNumber * 20; }
+
constexpr sal_Int64 convertPointToMm100(sal_Int64 nNumber)
{
- return convertTwipToMm100(nNumber * 20);
+ return convertTwipToMm100(convertPointToTwip(nNumber));
}
+constexpr double convertPointToTwip(double fNumber) { return fNumber * 20.0; }
+
constexpr double convertPointToMm100(double fNumber) { return fNumber * 35.27777777778; }
// Convert PPT's "master unit" (1/576 inch) to twips
More information about the Libreoffice-commits
mailing list