Rebased ref, commits from common ancestor:
commit 511bce4886ef26f19187e54d2f17a1d2a4977835
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Wed Nov 23 11:00:13 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sat Jan 28 21:12:58 2023 +0900
svx: convert SdrTextObj rotate and move to use gfx::Length
Change-Id: I82f10f82db8ac9d5653f4902276ee58fc18c52d6
diff --git a/include/basegfx/utils/RectangleWrapper.hxx
b/include/basegfx/utils/RectangleWrapper.hxx
index 00586d6eae71..4f5dbe851f66 100644
--- a/include/basegfx/utils/RectangleWrapper.hxx
+++ b/include/basegfx/utils/RectangleWrapper.hxx
@@ -55,6 +55,11 @@ public:
m_aRange.setSize(width, height);
}
+ void shift(gfx::Length const& rXDelta, gfx::Length const& rYDelta)
+ {
+ m_aRange.shift(rXDelta, rYDelta);
+ }
+
void move(sal_Int32 nXDelta, sal_Int32 nYDelta)
{
auto deltaX = gfx::Length::hmm(nXDelta);
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 1055e5dbe3bb..9ccc69709abf 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -40,6 +40,35 @@
using namespace com::sun::star;
+namespace
+{
+gfx::Tuple2DL rotatePoint(gfx::Tuple2DL const& rPoint, gfx::Tuple2DL const&
rReference, double sinAngle, double cosAngle)
+{
+ gfx::Length dx = rPoint.getX() - rReference.getX();
+ gfx::Length dy = rPoint.getY() - rReference.getY();
+
+ auto x = rReference.getX() + gfx::Length::emu(basegfx::fround(dx.raw() *
cosAngle + dy.raw() * sinAngle));
+ auto y = rReference.getY() + gfx::Length::emu(basegfx::fround(dy.raw() *
cosAngle - dx.raw() * sinAngle));
+
+ return gfx::Tuple2DL(x, y);
+}
+
+gfx::Tuple2DL toTuple(Point const& rPointHmm)
+{
+ auto x = gfx::Length::hmm(rPointHmm.X());
+ auto y = gfx::Length::hmm(rPointHmm.Y());
+ return {x, y};
+}
+
+gfx::Size2DL toSize2D(Size const& rSizeHmm)
+{
+ auto x = gfx::Length::hmm(rSizeHmm.Width());
+ auto y = gfx::Length::hmm(rSizeHmm.Height());
+ return {x, y};
+}
+
+} // end anonymous ns
+
void SdrTextObj::NbcSetSnapRect(const tools::Rectangle& rRect)
{
if (maGeo.nRotationAngle || maGeo.nShearAngle)
@@ -92,7 +121,9 @@ Degree100 SdrTextObj::GetShearAngle(bool /*bVertical*/) const
void SdrTextObj::NbcMove(const Size& rSize)
{
- moveRectangle(rSize.Width(), rSize.Height());
+ gfx::Size2DL aSize2D = toSize2D(rSize);
+ maRectangle.shift(aSize2D.getWidth(), aSize2D.getHeight());
+
moveOutRectangle(rSize.Width(), rSize.Height());
maSnapRect.Move(rSize);
SetBoundAndSnapRectsDirty(true);
@@ -183,27 +214,37 @@ void SdrTextObj::NbcResize(const Point& rRef, const
Fraction& xFact, const Fract
SetBoundAndSnapRectsDirty();
}
-void SdrTextObj::NbcRotate(const Point& rRef, Degree100 nAngle, double sn,
double cs)
+void SdrTextObj::NbcRotate(const Point& rRef, Degree100 nAngle, double
sinAngle, double cosAngle)
{
+ auto aReference = toTuple(rRef);
+
SetGlueReallyAbsolute(true);
- tools::Long dx = getRectangle().Right() - getRectangle().Left();
- tools::Long dy = getRectangle().Bottom() - getRectangle().Top();
- Point aPoint1(getRectangle().TopLeft());
- RotatePoint(aPoint1, rRef, sn, cs);
- Point aPoint2(aPoint1.X() + dx, aPoint1.Y() + dy);
- tools::Rectangle aRectangle(aPoint1, aPoint2);
- setRectangle(aRectangle);
+ auto const& rRange = maRectangle.getRange();
+
+ auto nWidth = rRange.getWidth();
+ auto nHeight = rRange.getHeight();
+
+ gfx::Tuple2DL aPoint1(rRange.getMinX(), rRange.getMinY());
+ aPoint1 = rotatePoint(aPoint1, aReference, sinAngle, cosAngle);
- if (maGeo.nRotationAngle==0_deg100) {
- maGeo.nRotationAngle=NormAngle36000(nAngle);
- maGeo.mfSinRotationAngle=sn;
- maGeo.mfCosRotationAngle=cs;
- } else {
- maGeo.nRotationAngle=NormAngle36000(maGeo.nRotationAngle+nAngle);
+ gfx::Tuple2DL aPoint2(aPoint1.getX() + nWidth, aPoint1.getY() + nHeight);
+
+ gfx::Range2DL aRange{aPoint1, aPoint2};
+ maRectangle.setRange(aRange);
+
+ if (maGeo.nRotationAngle == 0_deg100)
+ {
+ maGeo.nRotationAngle = NormAngle36000(nAngle);
+ maGeo.mfSinRotationAngle = sinAngle;
+ maGeo.mfCosRotationAngle = cosAngle;
+ }
+ else
+ {
+ maGeo.nRotationAngle = NormAngle36000(maGeo.nRotationAngle + nAngle);
maGeo.RecalcSinCos();
}
SetBoundAndSnapRectsDirty();
- NbcRotateGluePoints(rRef,nAngle,sn,cs);
+ NbcRotateGluePoints(rRef, nAngle, sinAngle, cosAngle);
SetGlueReallyAbsolute(false);
}
commit fd5b953116bddbcc5ed6274acca1d9e31c39ea36
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Tue Nov 22 13:33:30 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sat Jan 28 21:12:58 2023 +0900
svx: use RectangleWrapper for maRectangle on SdrTextObj
This is needed so we can now transition to use gfx::Length and
gfx::Range2DL to define the object position and size.
Change-Id: Ie683a869ba061f53d437bd1dfbe72fe454011730
diff --git a/include/basegfx/utils/RectangleWrapper.hxx
b/include/basegfx/utils/RectangleWrapper.hxx
new file mode 100644
index 000000000000..00586d6eae71
--- /dev/null
+++ b/include/basegfx/utils/RectangleWrapper.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <basegfx/units/Length.hxx>
+#include <tools/gen.hxx>
+
+namespace gfx
+{
+/**
+ * Wrapps tools::Rectangle and Range2DL, to make it easier to incrementally
+ * transition to use Range2DL.
+ */
+class RectangleWrapper
+{
+private:
+ gfx::Range2DL m_aRange;
+ mutable tools::Rectangle m_aRectangle;
+
+public:
+ RectangleWrapper() = default;
+
+ RectangleWrapper(gfx::Length x1, gfx::Length y1, gfx::Length x2,
gfx::Length y2)
+ : m_aRange(x1, y1, x2, y2)
+ {
+ }
+
+ gfx::Range2DL const& getRange() const { return m_aRange; }
+
+ void setRange(gfx::Range2DL const& rRange) { m_aRange = rRange; }
+
+ tools::Rectangle const& getRectangle() const
+ {
+ m_aRectangle = gfx::length::toRectangleHmm(m_aRange);
+ return m_aRectangle;
+ }
+
+ void setRectangle(tools::Rectangle const& rRectangle)
+ {
+ m_aRange = gfx::length::fromRectangleHmm(rRectangle);
+ }
+
+ void setSize(sal_Int32 nWidth, sal_Int32 nHeight)
+ {
+ auto width = gfx::Length::hmm(nWidth - 1);
+ auto height = gfx::Length::hmm(nHeight - 1);
+
+ m_aRange.setSize(width, height);
+ }
+
+ void move(sal_Int32 nXDelta, sal_Int32 nYDelta)
+ {
+ auto deltaX = gfx::Length::hmm(nXDelta);
+ auto deltaY = gfx::Length::hmm(nYDelta);
+
+ m_aRange.shift(deltaX, deltaY);
+ }
+
+ void setPosition(sal_Int32 nX, sal_Int32 nY)
+ {
+ auto x = gfx::Length::hmm(nX);
+ auto y = gfx::Length::hmm(nY);
+
+ m_aRange.setPosition(x, y);
+ }
+};
+
+} // end namespace gfx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index a1cccb0804a4..5ac836e03b6d 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -32,6 +32,7 @@
#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
#include <memory>
#include <vector>
+#include <basegfx/utils/RectangleWrapper.hxx>
#include <com/sun/star/drawing/TextFitToSizeType.hpp>
@@ -165,32 +166,17 @@ protected:
// The "aRect" is also the rect of RectObj and CircObj.
// When mbTextFrame=true the text will be formatted into this rect
// When mbTextFrame=false the text will be centered around its middle
- tools::Rectangle maRectangle;
+ gfx::RectangleWrapper maRectangle;
- tools::Rectangle const& getRectangle() const
- {
- return maRectangle;
- }
+ tools::Rectangle const& getRectangle() const;
- void setRectangle(tools::Rectangle const& rRectangle)
- {
- maRectangle = rRectangle;
- }
+ void setRectangle(tools::Rectangle const& rRectangle);
- void setRectangleSize(sal_Int32 nWidth, sal_Int32 nHeight)
- {
- maRectangle.SetSize(Size(nWidth, nHeight));
- }
+ void setRectangleSize(sal_Int32 nWidth, sal_Int32 nHeight);
- void moveRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta)
- {
- maRectangle.Move(nXDelta, nYDelta);
- }
+ void moveRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta);
- void moveRectanglePosition(sal_Int32 nX, sal_Int32 nY)
- {
- maRectangle.SetPos(Point(nX, nY));
- }
+ void moveRectanglePosition(sal_Int32 nX, sal_Int32 nY);
// The GeoStat contains the rotation and shear angles
GeoStat maGeo;
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index ab8bc58ddf85..d8b47be4fbba 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -707,7 +707,6 @@ bool SdrCircObj::MovCreate(SdrDragStat& rStat)
ImpCircUser* pU=static_cast<ImpCircUser*>(rStat.GetUser());
rStat.SetActionRect(pU->aR);
setRectangle(pU->aR); // for ObjName
- ImpJustifyRect(maRectangle);
nStartAngle=pU->nStart;
nEndAngle=pU->nEnd;
SetBoundRectDirty();
@@ -1049,7 +1048,6 @@ void SdrCircObj::NbcSetSnapRect(const tools::Rectangle&
rRect)
NbcMove(Size(rRect.Left()-aSR0.Left(),rRect.Top()-aSR0.Top()));
} else {
setRectangle(rRect);
- ImpJustifyRect(maRectangle);
}
SetBoundAndSnapRectsDirty();
SetXPolyDirty();
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 411269da2c07..e8f1698326d5 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -70,6 +70,7 @@ std::unique_ptr<sdr::contact::ViewContact>
SdrTextObj::CreateObjectSpecificViewC
SdrTextObj::SdrTextObj(SdrModel& rSdrModel)
: SdrAttrObj(rSdrModel)
+ , maRectangle(0_hmm, 0_hmm, 0_hmm, 0_hmm)
, mpEditingOutliner(nullptr)
, meTextKind(SdrObjKind::Text)
, maTextEditOffset(Point(0, 0))
@@ -87,6 +88,7 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel)
SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrTextObj const & rSource)
: SdrAttrObj(rSdrModel, rSource)
+ , maRectangle(rSource.maRectangle)
, mpEditingOutliner(nullptr)
, meTextKind(rSource.meTextKind)
, maTextEditOffset(Point(0, 0))
@@ -101,7 +103,6 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrTextObj
const & rSource)
// #i25616#
mbSupportTextIndentingOnLineWidthChange = true;
- maRectangle = rSource.maRectangle;
maGeo = rSource.maGeo;
maTextSize = rSource.maTextSize;
@@ -156,6 +157,7 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel, const
tools::Rectangle& rNewRect)
SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrObjKind eNewTextKind)
: SdrAttrObj(rSdrModel)
+ , maRectangle(0_hmm, 0_hmm, 0_hmm, 0_hmm)
, mpEditingOutliner(nullptr)
, meTextKind(eNewTextKind)
, maTextEditOffset(Point(0, 0))
@@ -201,8 +203,6 @@ SdrTextObj::~SdrTextObj()
void SdrTextObj::FitFrameToTextSize()
{
- ImpJustifyRect(maRectangle);
-
SdrText* pText = getActiveText();
if(pText==nullptr || !pText->GetOutlinerParaObject())
return;
@@ -312,6 +312,31 @@ bool SdrTextObj::IsAutoGrowHeight() const
return bRet;
}
+tools::Rectangle const& SdrTextObj::getRectangle() const
+{
+ maRectangle.getRectangle();
+}
+
+void SdrTextObj::setRectangle(tools::Rectangle const& rRectangle)
+{
+ maRectangle.setRectangle(rRectangle);
+}
+
+void SdrTextObj::setRectangleSize(sal_Int32 nWidth, sal_Int32 nHeight)
+{
+ maRectangle.setSize(nWidth, nHeight);
+}
+
+void SdrTextObj::moveRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta)
+{
+ maRectangle.move(nXDelta, nYDelta);
+}
+
+void SdrTextObj::moveRectanglePosition(sal_Int32 nX, sal_Int32 nY)
+{
+ maRectangle.setPosition(nX, nY);
+}
+
bool SdrTextObj::IsAutoGrowWidth() const
{
if (!mbTextFrame)
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 5c9f28f5115c..1055e5dbe3bb 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -58,7 +58,6 @@ void SdrTextObj::NbcSetSnapRect(const tools::Rectangle& rRect)
// No rotation or shear.
setRectangle(rRect);
- ImpJustifyRect(maRectangle);
AdaptTextMinSize();
@@ -75,7 +74,6 @@ const tools::Rectangle& SdrTextObj::GetLogicRect() const
void SdrTextObj::NbcSetLogicRect(const tools::Rectangle& rRect)
{
setRectangle(rRect);
- ImpJustifyRect(maRectangle);
AdaptTextMinSize();
@@ -126,7 +124,6 @@ void SdrTextObj::NbcResize(const Point& rRef, const
Fraction& xFact, const Fract
setRectangle(aRectangle);
if (bYMirr)
{
- maRectangle.Normalize();
moveRectangle(aRectangle.Right() - aRectangle.Left(),
aRectangle.Bottom() - aRectangle.Top());
maGeo.nRotationAngle=18000_deg100;
maGeo.RecalcSinCos();
@@ -175,8 +172,6 @@ void SdrTextObj::NbcResize(const Point& rRef, const
Fraction& xFact, const Fract
}
}
- ImpJustifyRect(maRectangle);
-
AdaptTextMinSize();
if(mbTextFrame && !getSdrModelFromSdrObject().IsPasteResize())
@@ -226,7 +221,6 @@ void SdrTextObj::NbcShear(const Point& rRef, Degree100
/*nAngle*/, double tn, bo
auto aRectangle = getRectangle();
Poly2Rect(aPol, aRectangle, maGeo);
setRectangle(aRectangle);
- ImpJustifyRect(maRectangle);
if (mbTextFrame) {
NbcAdjustTextFrameWidthAndHeight();
@@ -282,7 +276,6 @@ void SdrTextObj::NbcMirror(const Point& rRef1, const Point&
rRef2)
maGeo.RecalcTan();
}
- ImpJustifyRect(maRectangle);
if (mbTextFrame) {
NbcAdjustTextFrameWidthAndHeight();
}
commit fd320c0bd29570bddd0c5aec9308bd7af8b1e56b
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Tue Nov 22 13:19:51 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sat Jan 28 21:12:58 2023 +0900
gfx: cover more Range2D methods with a unit test
Change-Id: I894781ad490bf179698b6c6c40dfb05f403eb654
diff --git a/basegfx/test/LengthUnitTest.cxx b/basegfx/test/LengthUnitTest.cxx
index 8537280486af..b7b072493573 100644
--- a/basegfx/test/LengthUnitTest.cxx
+++ b/basegfx/test/LengthUnitTest.cxx
@@ -120,6 +120,18 @@ public:
CPPUNIT_ASSERT_EQUAL(3_cm, aRange.getMinY());
CPPUNIT_ASSERT_EQUAL(3_cm, aRange.getMaxX());
CPPUNIT_ASSERT_EQUAL(40_mm, aRange.getMaxY());
+
+ aRange.setSize(5_cm, 2_cm);
+ CPPUNIT_ASSERT_EQUAL(2_cm, aRange.getMinX());
+ CPPUNIT_ASSERT_EQUAL(3_cm, aRange.getMinY());
+ CPPUNIT_ASSERT_EQUAL(7_cm, aRange.getMaxX());
+ CPPUNIT_ASSERT_EQUAL(5_cm, aRange.getMaxY());
+
+ aRange.setPosition(0_cm, 0_cm);
+ CPPUNIT_ASSERT_EQUAL(0_cm, aRange.getMinX());
+ CPPUNIT_ASSERT_EQUAL(0_cm, aRange.getMinY());
+ CPPUNIT_ASSERT_EQUAL(5_cm, aRange.getMaxX());
+ CPPUNIT_ASSERT_EQUAL(2_cm, aRange.getMaxY());
}
void testInTuple()
@@ -162,17 +174,60 @@ public:
CPPUNIT_ASSERT_EQUAL(true, aSize == aSize + gfx::Size2DL(0_emu,
0_emu));
}
- void testConversionToRectanle()
+ void testConversionToRectangle()
{
- tools::Rectangle aRectangle(10, 20, 110, 120);
- gfx::Range2DL aRange = gfx::length::fromRectangleHmm(aRectangle);
- CPPUNIT_ASSERT_EQUAL(10_hmm, aRange.getMinX());
- CPPUNIT_ASSERT_EQUAL(20_hmm, aRange.getMinY());
- CPPUNIT_ASSERT_EQUAL(110_hmm, aRange.getMaxX());
- CPPUNIT_ASSERT_EQUAL(120_hmm, aRange.getMaxY());
-
- tools::Rectangle aRectangleConverted =
gfx::length::toRectangleHmm(aRange);
- CPPUNIT_ASSERT_EQUAL(aRectangle, aRectangleConverted);
+ {
+ tools::Rectangle aEmpty;
+ gfx::Range2DL aEmptyRange = gfx::length::fromRectangleHmm(aEmpty);
+ CPPUNIT_ASSERT_EQUAL(true, aEmptyRange.isEmpty());
+
+ tools::Rectangle aRectangle(10, 20, 110, 120);
+ gfx::Range2DL aRange = gfx::length::fromRectangleHmm(aRectangle);
+ CPPUNIT_ASSERT_EQUAL(10_hmm, aRange.getMinX());
+ CPPUNIT_ASSERT_EQUAL(20_hmm, aRange.getMinY());
+ CPPUNIT_ASSERT_EQUAL(110_hmm, aRange.getMaxX());
+ CPPUNIT_ASSERT_EQUAL(120_hmm, aRange.getMaxY());
+
+ tools::Rectangle aRectangleConverted =
gfx::length::toRectangleHmm(aRange);
+ CPPUNIT_ASSERT_EQUAL(aRectangle, aRectangleConverted);
+ }
+ {
+ tools::Rectangle aRectangle(10, 20, 110, 120);
+ gfx::Range2DL aRange = gfx::length::fromRectangleHmm(aRectangle);
+
+ aRectangle.Move(1000, 1000);
+ aRange.shift(1000_hmm, 1000_hmm);
+ CPPUNIT_ASSERT_EQUAL(aRectangle,
gfx::length::toRectangleHmm(aRange));
+ }
+ {
+ tools::Rectangle aRectangle(10, 20, 110, 120);
+ gfx::Range2DL aRange = gfx::length::fromRectangleHmm(aRectangle);
+
+ aRectangle.SetSize(Size(201, 201));
+ aRange.setSize(200_hmm, 200_hmm);
+ CPPUNIT_ASSERT_EQUAL(aRectangle,
gfx::length::toRectangleHmm(aRange));
+ }
+ {
+ tools::Rectangle aRectangle(10, 20, 110, 120);
+ gfx::Range2DL aRange = gfx::length::fromRectangleHmm(aRectangle);
+
+ aRectangle.SetPos(Point(500, 500));
+ aRange.setPosition(500_hmm, 500_hmm);
+ CPPUNIT_ASSERT_EQUAL(aRectangle,
gfx::length::toRectangleHmm(aRange));
+ }
+ {
+ tools::Rectangle aRectangle(Point(0, 0), Size(0, 31));
+ CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRectangle.Left());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRectangle.Top());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRectangle.GetWidth());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(31), aRectangle.GetHeight());
+
+ gfx::Range2DL aRange = gfx::length::fromRectangleHmm(aRectangle);
+ CPPUNIT_ASSERT_EQUAL(0_hmm, aRange.getMinX());
+ CPPUNIT_ASSERT_EQUAL(0_hmm, aRange.getMinY());
+ CPPUNIT_ASSERT_EQUAL(0_hmm, aRange.getMaxX());
+ CPPUNIT_ASSERT_EQUAL(30_hmm, aRange.getMaxY());
+ }
}
CPPUNIT_TEST_SUITE(LengthTest);
@@ -180,7 +235,7 @@ public:
CPPUNIT_TEST(testDivision);
CPPUNIT_TEST(testInRange);
CPPUNIT_TEST(testInTuple);
- CPPUNIT_TEST(testConversionToRectanle);
+ CPPUNIT_TEST(testConversionToRectangle);
CPPUNIT_TEST_SUITE_END();
};
commit e09db60f3e28b55dcc477ab6391505fa2be8fac1
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Tue Nov 22 13:16:44 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sat Jan 28 21:12:58 2023 +0900
gfx: move conversion functions to the end of file, handle isEmpty
We need to check for isEmpty or the behaviour doesn't match
Change-Id: I616ff67cc4894d39888e575682ccbf4d397efa6e
diff --git a/include/basegfx/units/Length.hxx b/include/basegfx/units/Length.hxx
index 76b9b1bbe9fc..33361ba39e39 100644
--- a/include/basegfx/units/Length.hxx
+++ b/include/basegfx/units/Length.hxx
@@ -29,55 +29,6 @@ struct LengthTraits
typedef Length DifferenceType;
};
-typedef basegfx::Range2D<gfx::Length, gfx::LengthTraits> Range2DL;
-typedef basegfx::Tuple2D<gfx::Length> Tuple2DL;
-typedef basegfx::Size2D<gfx::Length> Size2DL;
-
-namespace length
-{
-static inline Size2DL fromSizeHmm(Size const& rSize)
-{
- auto width = Length::hmm(rSize.getWidth());
- auto height = Length::hmm(rSize.getHeight());
- return Size2DL(width, height);
-}
-
-static inline Size toSizeHmm(Size2DL const& rTuple)
-{
- auto width = rTuple.getWidth().as_hmm();
- auto height = rTuple.getHeight().as_hmm();
- return Size(width, height);
-}
-
-static inline Range2DL fromRectangleHmm(tools::Rectangle const& rRectangle)
-{
- auto left = Length::hmm(rRectangle.Left());
- auto top = Length::hmm(rRectangle.Top());
- auto right = Length::hmm(rRectangle.Right());
- auto bottom = Length::hmm(rRectangle.Bottom());
- return Range2DL(left, top, right, bottom);
-}
-
-static inline basegfx::B2DRange toB2DRange2DHmm(Range2DL const& rRange2D)
-{
- auto left = rRange2D.getMinX().as_hmm();
- auto top = rRange2D.getMinY().as_hmm();
- auto right = rRange2D.getMaxX().as_hmm();
- auto bottom = rRange2D.getMaxY().as_hmm();
- return basegfx::B2DRange(left, top, right, bottom);
-}
-
-static inline tools::Rectangle toRectangleHmm(Range2DL const& rRange2D)
-{
- auto left = rRange2D.getMinX().as_hmm();
- auto top = rRange2D.getMinY().as_hmm();
- auto right = rRange2D.getMaxX().as_hmm();
- auto bottom = rRange2D.getMaxY().as_hmm();
- return tools::Rectangle(left, top, right, bottom);
-}
-
-} // end namespace length
-
} // end namespace gfx
constexpr gfx::Length operator"" _emu(unsigned long long value) { return
gfx::Length::emu(value); }
@@ -134,3 +85,65 @@ inline std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, t
return stream << rLength.raw() << " (twip=" << rLength.as_twip() << ",
hmm=" << rLength.as_hmm()
<< ")";
}
+
+namespace gfx
+{
+typedef basegfx::Range2D<gfx::Length, gfx::LengthTraits> Range2DL;
+typedef basegfx::Tuple2D<gfx::Length> Tuple2DL;
+typedef basegfx::Size2D<gfx::Length> Size2DL;
+
+namespace length
+{
+static inline Size2DL fromSizeHmm(Size const& rSize)
+{
+ if (rSize.IsEmpty())
+ return Size2DL(0_mm, 0_mm);
+ auto width = Length::hmm(rSize.getWidth());
+ auto height = Length::hmm(rSize.getHeight());
+ return Size2DL(width, height);
+}
+
+static inline Size toSizeHmm(Size2DL const& rSize)
+{
+ auto width = rSize.getWidth().as_hmm();
+ auto height = rSize.getHeight().as_hmm();
+ return Size(width, height);
+}
+
+static inline Range2DL fromRectangleHmm(tools::Rectangle const& rRectangle)
+{
+ if (rRectangle.IsWidthEmpty() && rRectangle.IsHeightEmpty())
+ return Range2DL();
+
+ auto left = Length::hmm(rRectangle.Left());
+ auto top = Length::hmm(rRectangle.Top());
+ auto right = Length::hmm(rRectangle.Right());
+ auto bottom = Length::hmm(rRectangle.Bottom());
+
+ return Range2DL(left, top, right, bottom);
+}
+
+static inline basegfx::B2DRange toB2DRange2DHmm(Range2DL const& rRange2D)
+{
+ if (rRange2D.isEmpty())
+ return basegfx::B2DRange();
+ auto left = rRange2D.getMinX().as_hmm();
+ auto top = rRange2D.getMinY().as_hmm();
+ auto right = rRange2D.getMaxX().as_hmm();
+ auto bottom = rRange2D.getMaxY().as_hmm();
+ return basegfx::B2DRange(left, top, right, bottom);
+}
+
+static inline tools::Rectangle toRectangleHmm(Range2DL const& rRange2D)
+{
+ if (rRange2D.isEmpty())
+ return tools::Rectangle();
+ auto left = rRange2D.getMinX().as_hmm();
+ auto top = rRange2D.getMinY().as_hmm();
+ auto right = rRange2D.getMaxX().as_hmm();
+ auto bottom = rRange2D.getMaxY().as_hmm();
+ return tools::Rectangle(left, top, right, bottom);
+}
+
+} // end namespace gfx
+} // end namespace length
commit 54d5731ae3d238c6a828aa0396a1f28806b1cacb
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Tue Nov 22 13:13:53 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sat Jan 28 21:12:57 2023 +0900
tools: rearrange Rectangle test, add construction test case
Change-Id: I735600181665100e8540b6f5f14ffebfe6f33371
diff --git a/tools/qa/cppunit/test_rectangle.cxx
b/tools/qa/cppunit/test_rectangle.cxx
index 02b355ad0576..12e46910bc2f 100644
--- a/tools/qa/cppunit/test_rectangle.cxx
+++ b/tools/qa/cppunit/test_rectangle.cxx
@@ -14,10 +14,13 @@
namespace
{
-class Test : public CppUnit::TestFixture
+class RectangleTest : public CppUnit::TestFixture
{
public:
- void test_rectangle();
+ void testConstruction();
+ void testOpenClosedSize();
+ void testUnitConvesion();
+ void testSetOperators();
void test_rectnormalize_alreadynormal();
void test_rectnormalize_zerorect();
void test_rectnormalize_reverse_topleft_bottomright();
@@ -26,8 +29,11 @@ public:
void test_rectnormalize_zerowidth_top_bottom_reversed();
void test_rectnormalize_zeroheight_left_right_reversed();
- CPPUNIT_TEST_SUITE(Test);
- CPPUNIT_TEST(test_rectangle);
+ CPPUNIT_TEST_SUITE(RectangleTest);
+ CPPUNIT_TEST(testConstruction);
+ CPPUNIT_TEST(testOpenClosedSize);
+ CPPUNIT_TEST(testUnitConvesion);
+ CPPUNIT_TEST(testSetOperators);
CPPUNIT_TEST(test_rectnormalize_zerorect);
CPPUNIT_TEST(test_rectnormalize_alreadynormal);
CPPUNIT_TEST(test_rectnormalize_reverse_topleft_bottomright);
@@ -38,7 +44,49 @@ public:
CPPUNIT_TEST_SUITE_END();
};
-void Test::test_rectangle()
+void RectangleTest::testConstruction()
+{
+ {
+ tools::Rectangle aRect1(Point(), Size(0, 20));
+ CPPUNIT_ASSERT_EQUAL(true, aRect1.IsEmpty());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRect1.getOpenWidth());
+
+ tools::Rectangle aRect2{ Point(), Point(0, 20) };
+ CPPUNIT_ASSERT_EQUAL(false, aRect2.IsEmpty());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRect2.getOpenWidth());
+
+ tools::Rectangle aRect3(0, 0, 0, 20);
+ CPPUNIT_ASSERT_EQUAL(false, aRect3.IsEmpty());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRect3.getOpenWidth());
+ }
+ {
+ 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);
+
+ constexpr tools::Rectangle aRect3(Point(), Size(0, 0));
+ static_assert(aRect3.IsEmpty());
+ static_assert(aRect3.Right() == 0);
+ static_assert(aRect3.Bottom() == 0);
+
+ constexpr tools::Rectangle aRect4(Point(), Size(1, 1));
+ static_assert(!aRect4.IsEmpty());
+ static_assert(aRect4.Right() == 0);
+ static_assert(aRect4.Bottom() == 0);
+
+ constexpr tools::Rectangle aRect5(Point(), Size(-1, -1));
+ static_assert(!aRect5.IsEmpty());
+ static_assert(aRect5.Right() == 0);
+ static_assert(aRect5.Bottom() == 0);
+ }
+}
+
+void RectangleTest::testOpenClosedSize()
{
{
tools::Rectangle aRect(1, 1, 1, 1);
@@ -71,18 +119,10 @@ 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);
- }
-
+void RectangleTest::testUnitConvesion()
+{
{
constexpr tools::Rectangle aRectTwip(100, 100, 100, 100);
constexpr tools::Rectangle aRectMm100(
@@ -106,24 +146,25 @@ void Test::test_rectangle()
static_assert(aRectMm100.GetWidth() == 0);
static_assert(aRectMm100.GetHeight() == 0);
}
+}
- {
- constexpr tools::Rectangle rect(Point(0, 0), Size(20, 20));
- constexpr tools::Rectangle inside(Point(10, 10), Size(10, 10));
- constexpr tools::Rectangle overlap(Point(10, 10), Size(20, 20));
- constexpr tools::Rectangle outside(Point(20, 20), Size(10, 10));
- CPPUNIT_ASSERT(rect.Contains(inside));
- CPPUNIT_ASSERT(rect.Contains(rect));
- CPPUNIT_ASSERT(!rect.Contains(overlap));
- CPPUNIT_ASSERT(!rect.Contains(outside));
- CPPUNIT_ASSERT(rect.Overlaps(inside));
- CPPUNIT_ASSERT(rect.Overlaps(rect));
- CPPUNIT_ASSERT(rect.Overlaps(overlap));
- CPPUNIT_ASSERT(!rect.Overlaps(outside));
- }
+void RectangleTest::testSetOperators()
+{
+ constexpr tools::Rectangle rect(Point(0, 0), Size(20, 20));
+ constexpr tools::Rectangle inside(Point(10, 10), Size(10, 10));
+ constexpr tools::Rectangle overlap(Point(10, 10), Size(20, 20));
+ constexpr tools::Rectangle outside(Point(20, 20), Size(10, 10));
+ CPPUNIT_ASSERT(rect.Contains(inside));
+ CPPUNIT_ASSERT(rect.Contains(rect));
+ CPPUNIT_ASSERT(!rect.Contains(overlap));
+ CPPUNIT_ASSERT(!rect.Contains(outside));
+ CPPUNIT_ASSERT(rect.Overlaps(inside));
+ CPPUNIT_ASSERT(rect.Overlaps(rect));
+ CPPUNIT_ASSERT(rect.Overlaps(overlap));
+ CPPUNIT_ASSERT(!rect.Overlaps(outside));
}
-void Test::test_rectnormalize_alreadynormal()
+void RectangleTest::test_rectnormalize_alreadynormal()
{
Point aTopLeft(0, 0);
Point aBottomRight(1, 1);
@@ -135,7 +176,7 @@ void Test::test_rectnormalize_alreadynormal()
CPPUNIT_ASSERT_EQUAL(aRect.BottomRight(), aBottomRight);
}
-void Test::test_rectnormalize_zerorect()
+void RectangleTest::test_rectnormalize_zerorect()
{
Point aTopLeft(53, 53);
Point aBottomRight(53, 53);
@@ -147,7 +188,7 @@ void Test::test_rectnormalize_zerorect()
CPPUNIT_ASSERT_EQUAL(aRect.BottomRight(), aBottomRight);
}
-void Test::test_rectnormalize_reverse_topleft_bottomright()
+void RectangleTest::test_rectnormalize_reverse_topleft_bottomright()
{
Point aPoint1(1, 1);
Point aPoint2(0, 0);
@@ -159,7 +200,7 @@ void Test::test_rectnormalize_reverse_topleft_bottomright()
CPPUNIT_ASSERT_EQUAL_MESSAGE("BottomRight() is wrong", Point(1, 1),
aRect.BottomRight());
}
-void Test::test_rectnormalize_topright_bottomleft()
+void RectangleTest::test_rectnormalize_topright_bottomleft()
{
Point aPoint1(1, 0);
Point aPoint2(0, 1);
@@ -171,7 +212,7 @@ void Test::test_rectnormalize_topright_bottomleft()
CPPUNIT_ASSERT_EQUAL_MESSAGE("BottomRight() is wrong", Point(1, 1),
aRect.BottomRight());
}
-void Test::test_rectnormalize_bottomleft_topright()
+void RectangleTest::test_rectnormalize_bottomleft_topright()
{
Point aPoint1(0, 1);
Point aPoint2(1, 0);
@@ -183,7 +224,7 @@ void Test::test_rectnormalize_bottomleft_topright()
CPPUNIT_ASSERT_EQUAL_MESSAGE("BottomRight() is wrong", Point(1, 1),
aRect.BottomRight());
}
-void Test::test_rectnormalize_zerowidth_top_bottom_reversed()
+void RectangleTest::test_rectnormalize_zerowidth_top_bottom_reversed()
{
Point aPoint1(0, 1);
Point aPoint2(0, 0);
@@ -195,7 +236,7 @@ void
Test::test_rectnormalize_zerowidth_top_bottom_reversed()
CPPUNIT_ASSERT_EQUAL_MESSAGE("BottomRight() is wrong", Point(0, 1),
aRect.BottomRight());
}
-void Test::test_rectnormalize_zeroheight_left_right_reversed()
+void RectangleTest::test_rectnormalize_zeroheight_left_right_reversed()
{
Point aPoint1(1, 0);
Point aPoint2(0, 0);
@@ -207,7 +248,7 @@ void
Test::test_rectnormalize_zeroheight_left_right_reversed()
CPPUNIT_ASSERT_EQUAL_MESSAGE("BottomRight() is wrong", Point(1, 0),
aRect.BottomRight());
}
-CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+CPPUNIT_TEST_SUITE_REGISTRATION(RectangleTest);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 0e21724794324eec13746cacd4f98c1a175fb701
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Fri Nov 18 16:37:33 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sat Jan 28 21:12:57 2023 +0900
basegfx: add setSize, setPosition to range classes, add tests
Change-Id: Idf01d1254e7327f1816e7b58d882bcc5ec9efae2
diff --git a/basegfx/test/B1DRangeTest.cxx b/basegfx/test/B1DRangeTest.cxx
index 22cf662defe5..9c3c12e37684 100644
--- a/basegfx/test/B1DRangeTest.cxx
+++ b/basegfx/test/B1DRangeTest.cxx
@@ -25,72 +25,115 @@
namespace basegfx
{
-class b1Xrange : public CppUnit::TestFixture
+class B1DRangeTest : public CppUnit::TestFixture
{
public:
- template <class Type> void implCheck()
+ void checkIntervalAxioms()
{
// test interval axioms
// (http://en.wikipedia.org/wiki/Interval_%28mathematics%29)
- Type aRange;
+ B1DRange aRange;
CPPUNIT_ASSERT_MESSAGE("default ctor - empty range", aRange.isEmpty());
- CPPUNIT_ASSERT_MESSAGE("center - get cop-out value since range is
empty",
- aRange.getCenter() == 0);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("center - get cop-out value since range
is empty", 0.0,
+ aRange.getCenter());
// degenerate interval
aRange.expand(1);
+ CPPUNIT_ASSERT_EQUAL(B1DRange(1.0, 1.0), aRange);
CPPUNIT_ASSERT_MESSAGE("degenerate range - still, not empty!",
!aRange.isEmpty());
- CPPUNIT_ASSERT_MESSAGE("degenerate range - size of 0",
aRange.getRange() == 0);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("degenerate range - size of 0", 0.0,
aRange.getRange());
CPPUNIT_ASSERT_MESSAGE("same value as degenerate range - is inside
range",
- aRange.isInside(1));
- CPPUNIT_ASSERT_MESSAGE("center - must be the single range value",
aRange.getCenter() == 1);
+ aRange.isInside(1.0));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("center - must be the single range
value", 1.0,
+ aRange.getCenter());
// proper interval
- aRange.expand(2);
- CPPUNIT_ASSERT_MESSAGE("proper range - size of 1", aRange.getRange()
== 1);
+ aRange.expand(2.0);
+ CPPUNIT_ASSERT_EQUAL(B1DRange(1.0, 2.0), aRange);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("proper range - size of 1", 1.0,
aRange.getRange());
CPPUNIT_ASSERT_MESSAGE("smaller value of range - is inside *closed*
range",
aRange.isInside(1));
CPPUNIT_ASSERT_MESSAGE("larger value of range - is inside *closed*
range",
aRange.isInside(2));
// center for proper interval that works for ints, too
- aRange.expand(3);
- CPPUNIT_ASSERT_MESSAGE("center - must be half of the range",
aRange.getCenter() == 2);
+ aRange.expand(3.0);
+ CPPUNIT_ASSERT_EQUAL(B1DRange(1.0, 3.0), aRange);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("center - must be half of the range",
2.0, aRange.getCenter());
+ }
+
+ void checkOverlap()
+ {
+ B1DRange aRange(1.0, 3.0);
+ B1DRange aRange2(0.0, 1.0);
- // check overlap
- Type aRange2(0, 1);
CPPUNIT_ASSERT_MESSAGE("range overlapping *includes* upper bound",
aRange.overlaps(aRange2));
CPPUNIT_ASSERT_MESSAGE("range overlapping *includes* upper bound, but
only barely",
!aRange.overlapsMore(aRange2));
- Type aRange3(0, 2);
+ B1DRange aRange3(0.0, 2.0);
CPPUNIT_ASSERT_MESSAGE("range overlapping is fully overlapping now",
aRange.overlapsMore(aRange3));
+ }
- // check intersect
- Type aRange4(3, 4);
- aRange.intersect(aRange4);
+ void checkIntersect()
+ {
+ B1DRange aRange(1.0, 3.0);
+ B1DRange aRange2(3.0, 4.0);
+ aRange.intersect(aRange2);
CPPUNIT_ASSERT_MESSAGE("range intersection is yielding empty range!",
!aRange.isEmpty());
- Type aRange5(5, 6);
- aRange.intersect(aRange5);
+ B1DRange aRange3(5.0, 6.0);
+ aRange.intersect(aRange3);
CPPUNIT_ASSERT_MESSAGE("range intersection is yielding nonempty
range!", aRange.isEmpty());
}
- void check() { implCheck<B1DRange>(); }
+ void checkShift()
+ {
+ B1DRange aRange(1.0, 3.0);
+ aRange.shift(2.0);
+ CPPUNIT_ASSERT_EQUAL(B1DRange(3.0, 5.0), aRange);
+
+ B1DRange aRange2(-1.0, -3.0);
+ aRange2.shift(2.0);
+ CPPUNIT_ASSERT_EQUAL(B1DRange(1.0, -1.0), aRange2);
+ }
+
+ void checkSetSize()
+ {
+ B1DRange aRange(1.0, 3.0);
+ aRange.setSize(5.0);
+ CPPUNIT_ASSERT_EQUAL(B1DRange(1.0, 6.0), aRange);
+
+ B1DRange aRange2(-1.0, -3.0);
+ aRange2.setSize(3.0);
+ CPPUNIT_ASSERT_EQUAL(B1DRange(-3.0, 0.0), aRange2);
+ }
+
+ void checkSetPosition()
+ {
+ B1DRange aRange(1.0, 3.0);
+ aRange.setPosition(7.0);
+ CPPUNIT_ASSERT_EQUAL(B1DRange(7.0, 9.0), aRange);
- // 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.
+ B1DRange aRange2(-1.0, -3.0);
+ aRange2.setPosition(-1.0);
+ CPPUNIT_ASSERT_EQUAL(B1DRange(-1.0, 1.0), aRange2);
+ }
- CPPUNIT_TEST_SUITE(b1Xrange);
- CPPUNIT_TEST(check);
+ CPPUNIT_TEST_SUITE(B1DRangeTest);
+ CPPUNIT_TEST(checkIntervalAxioms);
+ CPPUNIT_TEST(checkOverlap);
+ CPPUNIT_TEST(checkIntersect);
+ CPPUNIT_TEST(checkShift);
+ CPPUNIT_TEST(checkSetSize);
+ CPPUNIT_TEST(checkSetPosition);
CPPUNIT_TEST_SUITE_END();
-}; // class b1Xrange
+};
} // namespace basegfx
-CPPUNIT_TEST_SUITE_REGISTRATION(basegfx::b1Xrange);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx::B1DRangeTest);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basegfx/test/B2DRangeTest.cxx b/basegfx/test/B2DRangeTest.cxx
index 5b8b271000ea..047ad67a116e 100644
--- a/basegfx/test/B2DRangeTest.cxx
+++ b/basegfx/test/B2DRangeTest.cxx
@@ -91,9 +91,35 @@ class B2DRangeTest : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL(basegfx::B2DRange(1.0, 1.0, 4.0, 4.0), aRange);
}
- // 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.
+ void testSetSize()
+ {
+ basegfx::B2DRange aRange(1.0, 1.0, 4.0, 4.0);
+ aRange.setSize(0.0, 0.0);
+ CPPUNIT_ASSERT_EQUAL(basegfx::B2DRange(1.0, 1.0, 1.0, 1.0), aRange);
+ aRange.setSize(1.0, 2.0);
+ CPPUNIT_ASSERT_EQUAL(basegfx::B2DRange(1.0, 1.0, 2.0, 3.0), aRange);
+ aRange.setSize(-1.0, -2.0);
+ CPPUNIT_ASSERT_EQUAL(basegfx::B2DRange(), aRange);
+ }
+
+ void testSetPosition()
+ {
+ basegfx::B2DRange aRange(1.0, 1.0, 4.0, 3.0);
+ aRange.setPosition(4.0, 2.0);
+ CPPUNIT_ASSERT_EQUAL(basegfx::B2DRange(4.0, 2.0, 7.0, 4.0), aRange);
+ CPPUNIT_ASSERT_EQUAL(3.0, aRange.getWidth());
+ CPPUNIT_ASSERT_EQUAL(2.0, aRange.getHeight());
+
+ aRange.setPosition(1.0, 2.0);
+ CPPUNIT_ASSERT_EQUAL(basegfx::B2DRange(1.0, 2.0, 4.0, 4.0), aRange);
+ CPPUNIT_ASSERT_EQUAL(3.0, aRange.getWidth());
+ CPPUNIT_ASSERT_EQUAL(2.0, aRange.getHeight());
+
+ aRange.setPosition(-1.0, -3.0);
+ CPPUNIT_ASSERT_EQUAL(basegfx::B2DRange(-1.0, -3.0, 2.0, -1.0), aRange);
+ CPPUNIT_ASSERT_EQUAL(3.0, aRange.getWidth());
+ CPPUNIT_ASSERT_EQUAL(2.0, aRange.getHeight());
+ }
CPPUNIT_TEST_SUITE(B2DRangeTest);
CPPUNIT_TEST(testCreation);
@@ -101,6 +127,8 @@ class B2DRangeTest : public CppUnit::TestFixture
CPPUNIT_TEST(testCenter);
CPPUNIT_TEST(testIntersect);
CPPUNIT_TEST(testShift);
+ CPPUNIT_TEST(testSetSize);
+ CPPUNIT_TEST(testSetPosition);
CPPUNIT_TEST_SUITE_END();
};
diff --git a/include/basegfx/range/Range2D.hxx
b/include/basegfx/range/Range2D.hxx
index 15951f6e4888..4e47e0a29655 100644
--- a/include/basegfx/range/Range2D.hxx
+++ b/include/basegfx/range/Range2D.hxx
@@ -173,6 +173,20 @@ public:
maRangeY.shift(fDeltaY);
}
+ /// set size
+ void setSize(TYPE nWidth, TYPE nHeight)
+ {
+ maRangeX.setSize(nWidth);
+ maRangeY.setSize(nHeight);
+ }
+
+ /// set position
+ void setPosition(TYPE nX, TYPE nY)
+ {
+ maRangeX.setPosition(nX);
+ maRangeY.setPosition(nY);
+ }
+
/// clamp value on range
Tuple2D<TYPE> clamp(const Tuple2D<TYPE>& rTuple) const
{
diff --git a/include/basegfx/range/b1drange.hxx
b/include/basegfx/range/b1drange.hxx
index 0db585558a79..d9e8e71fbb44 100644
--- a/include/basegfx/range/b1drange.hxx
+++ b/include/basegfx/range/b1drange.hxx
@@ -144,8 +144,31 @@ namespace basegfx
{
return maRange.clamp(fValue);
}
+
+ void shift(double fDeltaX)
+ {
+ maRange.shift(fDeltaX);
+ }
+
+ void setSize(double fSize)
+ {
+ maRange.setSize(fSize);
+ }
+
+ void setPosition(double fPosition)
+ {
+ maRange.setPosition(fPosition);
+ }
};
+ /** Write to char stream */
+ template<typename charT, typename traits>
+ inline std::basic_ostream<charT, traits>& operator<<(
+ std::basic_ostream<charT, traits>& stream, const B1DRange& range)
+ {
+ return stream << "[" << range.getMinimum() << ", " <<
range.getMaximum() << "]";
+ }
+
} // end of namespace basegfx
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/basegfx/range/basicrange.hxx
b/include/basegfx/range/basicrange.hxx
index a7935f3069d9..31986998c7d2 100644
--- a/include/basegfx/range/basicrange.hxx
+++ b/include/basegfx/range/basicrange.hxx
@@ -278,6 +278,34 @@ namespace basegfx
}
}
+ void setSize(T nSize)
+ {
+ if (isEmpty())
+ return;
+
+ if (nSize >= Traits::neutral())
+ mnMaximum = mnMinimum + nSize;
+ else
+ reset();
+ }
+
+ void setPosition(T nPosition)
+ {
+ if (isEmpty())
+ return;
+
+ if (mnMinimum == mnMaximum)
+ {
+ mnMinimum = nPosition;
+ mnMaximum = nPosition;
+ }
+ else
+ {
+ mnMaximum = nPosition + (mnMaximum - mnMinimum);
+ mnMinimum = nPosition;
+ }
+ }
+
#if defined _MSC_VER && defined(_M_ARM64)
#pragma warning(push)
#pragma warning(disable: 4723) /* ignore: warning for C4723 on windows arm64
build */
commit 7c53b894948a0727153b7bb6965b159995406fbb
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Wed Oct 26 20:21:37 2022 +0200
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sat Jan 28 21:12:57 2023 +0900
svx: change PaperInfo to return gfx::Length paper sizes
Change-Id: Ie99a748ab9282893a852278be9793f7379522541
diff --git a/editeng/source/items/paperinf.cxx
b/editeng/source/items/paperinf.cxx
index 86401e63f387..130e7c020a41 100644
--- a/editeng/source/items/paperinf.cxx
+++ b/editeng/source/items/paperinf.cxx
@@ -39,6 +39,12 @@ Size SvxPaperInfo::GetPaperSize( Paper ePaper, MapUnit eUnit
)
: OutputDevice::LogicToLogic(aRet, MapMode(MapUnit::Map100thMM),
MapMode(eUnit));
}
+gfx::Size2DL SvxPaperInfo::getPaperSize(Paper ePaper)
+{
+ PaperInfo aInfo(ePaper);
+ return { gfx::Length::hmm(aInfo.getWidth()),
gfx::Length::hmm(aInfo.getHeight()) };
+}
+
/*------------------------------------------------------------------------
Description: Return the paper size of the printer, aligned to our
own sizes. If no Printer is set in the system, A4 portrait
@@ -108,6 +114,12 @@ Size SvxPaperInfo::GetDefaultPaperSize( MapUnit eUnit )
: OutputDevice::LogicToLogic(aRet, MapMode(MapUnit::Map100thMM),
MapMode(eUnit));
}
+gfx::Size2DL SvxPaperInfo::getDefaultPaperSize()
+{
+ PaperInfo aInfo(PaperInfo::getSystemDefaultPaper());
+ return { gfx::Length::hmm(aInfo.getWidth()),
gfx::Length::hmm(aInfo.getHeight()) };
+}
+
/*------------------------------------------------------------------------
Description: String representation for the SV-defines of paper size
------------------------------------------------------------------------*/
diff --git a/include/editeng/paperinf.hxx b/include/editeng/paperinf.hxx
index 2ccc8fbf96fa..20bc1441ba74 100644
--- a/include/editeng/paperinf.hxx
+++ b/include/editeng/paperinf.hxx
@@ -25,6 +25,7 @@
#include <tools/mapunit.hxx>
#include <i18nutil/paper.hxx>
#include <tools/gen.hxx>
+#include <basegfx/units/Length.hxx>
#include <editeng/editengdllapi.h>
// forward ---------------------------------------------------------------
@@ -42,6 +43,9 @@ public:
static Paper GetSvxPaper( const Size &rSize, MapUnit eUnit );
static tools::Long GetSloppyPaperDimension( tools::Long nSize );
static OUString GetName( Paper ePaper );
+
+ static gfx::Size2DL getPaperSize(Paper ePaper);
+ static gfx::Size2DL getDefaultPaperSize();
};
// INLINE -----------------------------------------------------------------
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index 5f6854a4ce1d..0772aff4d5b4 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -371,6 +371,13 @@ public:
, maLower(0_emu)
{}
+ Border(gfx::Length const& nLeft, gfx::Length const& nUpper, gfx::Length
const& nRight, gfx::Length const& nLower)
+ : maLeft(nLeft)
+ , maRight(nRight)
+ , maUpper(nUpper)
+ , maLower(nLower)
+ {}
+
gfx::Length const& getLeft() const { return maLeft; }
gfx::Length const& getRight() const { return maRight; }
gfx::Length const& getUpper() const { return maUpper; }
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index a14e4382a8e0..4b8f8360e6ac 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -499,7 +499,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const
* pRefDocument /* =
return;
// #i57181# Paper size depends on Language, like in Writer
- Size aDefSize = SvxPaperInfo::GetDefaultPaperSize( MapUnit::Map100thMM );
+ gfx::Size2DL aDefaultSize = SvxPaperInfo::getDefaultPaperSize();
// Insert handout page
rtl::Reference<SdPage> pHandoutPage = AllocSdPage(false);
@@ -516,8 +516,8 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const
* pRefDocument /* =
}
else
{
- pHandoutPage->setSize(gfx::length::fromSizeHmm(aDefSize));
- pHandoutPage->SetBorder(0, 0, 0, 0);
+ pHandoutPage->setSize(aDefaultSize);
+ pHandoutPage->setBorder(svx::Border());
}
pHandoutPage->SetPageKind(PageKind::Handout);
@@ -553,7 +553,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const
* pRefDocument /* =
else if (meDocType == DocumentType::Draw)
{
// Draw: always use default size with margins
- pPage->setSize(gfx::length::fromSizeHmm(aDefSize));
+ pPage->setSize(aDefaultSize);
SfxPrinter* pPrinter = mpDocSh->GetPrinter(false);
if (pPrinter && pPrinter->IsValid())
@@ -563,12 +563,12 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument
const * pRefDocument /* =
aPageOffset -= pPrinter->PixelToLogic( Point() );
::tools::Long nOffset = !aPageOffset.X() && !aPageOffset.Y() ?
0 : PRINT_OFFSET;
- sal_uLong nTop = aPageOffset.Y();
- sal_uLong nLeft = aPageOffset.X();
- sal_uLong nBottom = std::max(::tools::Long(aDefSize.Height() -
aOutSize.Height() - nTop + nOffset), ::tools::Long(0));
- sal_uLong nRight = std::max(::tools::Long(aDefSize.Width() -
aOutSize.Width() - nLeft + nOffset), ::tools::Long(0));
+ gfx::Length nTop = gfx::Length::hmm(aPageOffset.Y());
+ gfx::Length nLeft = gfx::Length::hmm(aPageOffset.X());
+ gfx::Length nBottom =
gfx::Length::hmm(std::max(::tools::Long(aDefaultSize.getHeight().as_hmm() -
aOutSize.Height() - aPageOffset.Y() + nOffset), tools::Long(0)));
+ gfx::Length nRight =
gfx::Length::hmm(std::max(::tools::Long(aDefaultSize.getWidth().as_hmm() -
aOutSize.Width() - aPageOffset.X() + nOffset), tools::Long(0)));
- pPage->SetBorder(nLeft, nTop, nRight, nBottom);
+ pPage->setBorder(svx::Border(nLeft, nTop, nRight, nBottom));
}
else
{
@@ -577,14 +577,14 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument
const * pRefDocument /* =
// This has to be kept synchronized with the border
// width set in the
// SvxPageDescPage::PaperSizeSelect_Impl callback.
- pPage->SetBorder(1000, 1000, 1000, 1000);
+ pPage->setBorder(svx::Border(1000_hmm, 1000_hmm, 1000_hmm,
1000_hmm));
}
}
else
{
// Impress: always use screen format, landscape.
- Size aSz( SvxPaperInfo::GetPaperSize(PAPER_SCREEN_16_9,
MapUnit::Map100thMM) );
- pPage->setSize({ gfx::Length::hmm(aSz.Height()),
gfx::Length::hmm(aSz.Width()) });
+ gfx::Size2DL aSize = SvxPaperInfo::getPaperSize(PAPER_SCREEN_16_9);
+ pPage->setSize({ aSize.getHeight(), aSize.getWidth() });
pPage->setBorder(svx::Border());
}
@@ -619,13 +619,13 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument
const * pRefDocument /* =
else
{
// Always use portrait format
- if (aDefSize.Height() >= aDefSize.Width())
+ if (aDefaultSize.getHeight() >= aDefaultSize.getWidth())
{
- pNotesPage->setSize(gfx::length::fromSizeHmm(aDefSize));
+ pNotesPage->setSize(aDefaultSize);
}
else
{
- pNotesPage->setSize({ gfx::Length::hmm(aDefSize.Height()),
gfx::Length::hmm(aDefSize.Width()) });
+ pNotesPage->setSize({ aDefaultSize.getHeight(),
aDefaultSize.getWidth() });
}
pNotesPage->SetBorder(0, 0, 0, 0);
commit 03291333a486bacf809be6dd47096abd02ea7a33
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Tue Oct 25 21:04:27 2022 +0200
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sat Jan 28 21:12:57 2023 +0900
svx: SdrTextObj maRect - use getter and add funcs. for manipulation
Change-Id: I0a416fa2ac470650c2ef430dbb91bf8d5a8013cd
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index a2574765ade7..a1cccb0804a4 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -165,7 +165,32 @@ protected:
// The "aRect" is also the rect of RectObj and CircObj.
// When mbTextFrame=true the text will be formatted into this rect
// When mbTextFrame=false the text will be centered around its middle
- tools::Rectangle maRect;
+ tools::Rectangle maRectangle;
+
+ tools::Rectangle const& getRectangle() const
+ {
+ return maRectangle;
+ }
+
+ void setRectangle(tools::Rectangle const& rRectangle)
+ {
+ maRectangle = rRectangle;
+ }
+
+ void setRectangleSize(sal_Int32 nWidth, sal_Int32 nHeight)
+ {
+ maRectangle.SetSize(Size(nWidth, nHeight));
+ }
+
+ void moveRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta)
+ {
+ maRectangle.Move(nXDelta, nYDelta);
+ }
+
+ void moveRectanglePosition(sal_Int32 nX, sal_Int32 nY)
+ {
+ maRectangle.SetPos(Point(nX, nY));
+ }
// The GeoStat contains the rotation and shear angles
GeoStat maGeo;
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 44ecb8fefded..a6a56f417e6d 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -1397,7 +1397,7 @@ void SdrObjCustomShape::AdaptTextMinSize()
// check if we need to change anything before creating an SfxItemSet,
because that is expensive
const bool
bResizeShapeToFitText(GetObjectItem(SDRATTR_TEXT_AUTOGROWHEIGHT).GetValue());
- tools::Rectangle aTextBound(maRect);
+ tools::Rectangle aTextBound(getRectangle());
bool bChanged(false);
if(bResizeShapeToFitText)
bChanged = true;
@@ -1432,10 +1432,11 @@ void SdrObjCustomShape::AdaptTextMinSize()
SetObjectItemSet(aSet);
}
-void SdrObjCustomShape::NbcSetSnapRect( const tools::Rectangle& rRect )
+void SdrObjCustomShape::NbcSetSnapRect(const tools::Rectangle& rRectangle)
{
- maRect = rRect;
- ImpJustifyRect(maRect);
+ tools::Rectangle aRectangle(rRectangle);
+ ImpJustifyRect(aRectangle);
+ setRectangle(aRectangle);
InvalidateRenderGeometry();
AdaptTextMinSize();
@@ -1455,10 +1456,11 @@ void SdrObjCustomShape::SetSnapRect( const
tools::Rectangle& rRect )
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
}
-void SdrObjCustomShape::NbcSetLogicRect( const tools::Rectangle& rRect )
+void SdrObjCustomShape::NbcSetLogicRect(const tools::Rectangle& rRectangle)
{
- maRect = rRect;
- ImpJustifyRect(maRect);
+ tools::Rectangle aRectangle(rRectangle);
+ ImpJustifyRect(aRectangle);
+ setRectangle(aRectangle);
InvalidateRenderGeometry();
AdaptTextMinSize();
@@ -1515,7 +1517,7 @@ void SdrObjCustomShape::NbcMove( const Size& rSiz )
void SdrObjCustomShape::NbcResize( const Point& rRef, const Fraction& rxFact,
const Fraction& ryFact )
{
// taking care of handles that should not been changed
- tools::Rectangle aOld( maRect );
+ tools::Rectangle aOld(getRectangle());
std::vector< SdrCustomShapeInteraction > aInteractionHandles(
GetInteractionHandles() );
SdrTextObj::NbcResize( rRef, rxFact, ryFact );
@@ -1543,17 +1545,17 @@ void SdrObjCustomShape::NbcResize( const Point& rRef,
const Fraction& rxFact, co
rInteraction.xInteraction->setControllerPosition(
rInteraction.aPosition );
if ( rInteraction.nMode &
CustomShapeHandleModes::RESIZE_ABSOLUTE_X )
{
- sal_Int32 nX = ( rInteraction.aPosition.X - aOld.Left() ) +
maRect.Left();
+ sal_Int32 nX = ( rInteraction.aPosition.X - aOld.Left() ) +
getRectangle().Left();
rInteraction.xInteraction->setControllerPosition(awt::Point(nX,
rInteraction.xInteraction->getPosition().Y));
}
else if ( rInteraction.nMode &
CustomShapeHandleModes::RESIZE_ABSOLUTE_NEGX )
{
- sal_Int32 nX = maRect.Right() - (aOld.Right() -
rInteraction.aPosition.X);
+ sal_Int32 nX = getRectangle().Right() - (aOld.Right() -
rInteraction.aPosition.X);
rInteraction.xInteraction->setControllerPosition(awt::Point(nX,
rInteraction.xInteraction->getPosition().Y));
}
if ( rInteraction.nMode &
CustomShapeHandleModes::RESIZE_ABSOLUTE_Y )
{
- sal_Int32 nY = ( rInteraction.aPosition.Y - aOld.Top() ) +
maRect.Top();
+ sal_Int32 nY = ( rInteraction.aPosition.Y - aOld.Top() ) +
getRectangle().Top();
rInteraction.xInteraction->setControllerPosition(awt::Point(rInteraction.xInteraction->getPosition().X,
nY));
}
}
@@ -1598,7 +1600,7 @@ void SdrObjCustomShape::NbcRotate( const Point& rRef,
Degree100 nAngle, double s
// the rotation angle for ashapes is stored in fObjectRotation, this
rotation
// has to be applied to the text object (which is internally using
maGeo.nAngle).
- SdrTextObj::NbcRotate( maRect.TopLeft(), -maGeo.nRotationAngle, //
retrieving the unrotated text object
+ SdrTextObj::NbcRotate( getRectangle().TopLeft(), -maGeo.nRotationAngle,
// retrieving the unrotated text object
-maGeo.mfSinRotationAngle,
maGeo.mfCosRotationAngle );
maGeo.nRotationAngle = 0_deg100;
// resetting aGeo data
@@ -1612,7 +1614,7 @@ void SdrObjCustomShape::NbcRotate( const Point& rRef,
Degree100 nAngle, double s
nW = nW % 36000_deg100;
if ( nW < 0_deg100 )
nW = 36000_deg100 + nW;
- SdrTextObj::NbcRotate( maRect.TopLeft(), nW, //
applying text rotation
+ SdrTextObj::NbcRotate( getRectangle().TopLeft(), nW,
// applying text rotation
sin( toRadians(nW) ),
cos( toRadians(nW) ) );
@@ -1723,14 +1725,18 @@ SdrGluePoint
SdrObjCustomShape::GetVertexGluePoint(sal_uInt16 nPosNum) const
}
Point aPt;
- switch (nPosNum) {
- case 0: aPt=maRect.TopCenter(); aPt.AdjustY( -nWdt ); break;
- case 1: aPt=maRect.RightCenter(); aPt.AdjustX(nWdt ); break;
- case 2: aPt=maRect.BottomCenter(); aPt.AdjustY(nWdt ); break;
- case 3: aPt=maRect.LeftCenter(); aPt.AdjustX( -nWdt ); break;
- }
- if (maGeo.nShearAngle != 0_deg100) ShearPoint(aPt, maRect.TopLeft(),
maGeo.mfTanShearAngle);
- if (maGeo.nRotationAngle != 0_deg100) RotatePoint(aPt, maRect.TopLeft(),
maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle);
+ auto aRectangle = getRectangle();
+ switch (nPosNum)
+ {
+ case 0: aPt = aRectangle.TopCenter(); aPt.AdjustY( -nWdt ); break;
+ case 1: aPt = aRectangle.RightCenter(); aPt.AdjustX(nWdt ); break;
+ case 2: aPt = aRectangle.BottomCenter(); aPt.AdjustY(nWdt ); break;
+ case 3: aPt = aRectangle.LeftCenter(); aPt.AdjustX( -nWdt ); break;
+ }
+ if (maGeo.nShearAngle != 0_deg100)
+ ShearPoint(aPt, aRectangle.TopLeft(), maGeo.mfTanShearAngle);
+ if (maGeo.nRotationAngle != 0_deg100)
+ RotatePoint(aPt, aRectangle.TopLeft(), maGeo.mfSinRotationAngle,
maGeo.mfCosRotationAngle);
aPt-=GetSnapRect().Center();
SdrGluePoint aGP(aPt);
aGP.SetPercent(false);
@@ -1779,19 +1785,19 @@ void
SdrObjCustomShape::ImpCheckCustomGluePointsAreAdded()
if (maGeo.nRotationAngle || nShearAngle || bMirroredX || bMirroredY)
{
- tools::Polygon aPoly( maRect );
+ tools::Polygon aPoly(getRectangle());
if( nShearAngle )
{
sal_uInt16 nPointCount=aPoly.GetSize();
for (sal_uInt16 i=0; i<nPointCount; i++)
- ShearPoint(aPoly[i],maRect.Center(), fTan );
+ ShearPoint(aPoly[i], getRectangle().Center(), fTan );
}
if (maGeo.nRotationAngle)
- aPoly.Rotate( maRect.Center(), to<Degree10>(maGeo.nRotationAngle)
);
+ aPoly.Rotate( getRectangle().Center(),
to<Degree10>(maGeo.nRotationAngle) );
tools::Rectangle aBoundRect( aPoly.GetBoundRect() );
- sal_Int32 nXDiff = aBoundRect.Left() - maRect.Left();
- sal_Int32 nYDiff = aBoundRect.Top() - maRect.Top();
+ sal_Int32 nXDiff = aBoundRect.Left() - getRectangle().Left();
+ sal_Int32 nYDiff = aBoundRect.Top() - getRectangle().Top();
if (nShearAngle && bMirroredX != bMirroredY)
{
@@ -1799,7 +1805,7 @@ void SdrObjCustomShape::ImpCheckCustomGluePointsAreAdded()
fTan = -fTan;
}
- Point aRef( maRect.GetWidth() / 2, maRect.GetHeight() / 2 );
+ Point aRef( getRectangle().GetWidth() / 2, getRectangle().GetHeight()
/ 2 );
for ( a = 0; a < aNewList.GetCount(); a++ )
{
SdrGluePoint& rPoint = aNewList[ a ];
@@ -1810,9 +1816,9 @@ void SdrObjCustomShape::ImpCheckCustomGluePointsAreAdded()
RotatePoint(aGlue, aRef, sin(basegfx::deg2rad(fObjectRotation)),
cos(basegfx::deg2rad(fObjectRotation)));
if ( bMirroredX )
- aGlue.setX( maRect.GetWidth() - aGlue.X() );
+ aGlue.setX( getRectangle().GetWidth() - aGlue.X() );
if ( bMirroredY )
- aGlue.setY( maRect.GetHeight() - aGlue.Y() );
+ aGlue.setY( getRectangle().GetHeight() - aGlue.Y() );
aGlue.AdjustX( -nXDiff );
aGlue.AdjustY( -nYDiff );
rPoint.SetPos( aGlue );
@@ -1937,7 +1943,7 @@ bool SdrObjCustomShape::beginSpecialDrag(SdrDragStat&
rDrag) const
void SdrObjCustomShape::DragResizeCustomShape( const tools::Rectangle&
rNewRect )
{
- tools::Rectangle aOld( maRect );
+ tools::Rectangle aOld(getRectangle());
bool bOldMirroredX( IsMirroredX() );
bool bOldMirroredY( IsMirroredY() );
@@ -1947,7 +1953,7 @@ void SdrObjCustomShape::DragResizeCustomShape( const
tools::Rectangle& rNewRect
std::vector< SdrCustomShapeInteraction > aInteractionHandles(
GetInteractionHandles() );
GeoStat aGeoStat( GetGeoStat() );
- if ( aNewRect.TopLeft()!= maRect.TopLeft() &&
+ if ( aNewRect.TopLeft() != getRectangle().TopLeft() &&
( maGeo.nRotationAngle || maGeo.nShearAngle ) )
{
Point aNewPos( aNewRect.TopLeft() );
@@ -1955,7 +1961,7 @@ void SdrObjCustomShape::DragResizeCustomShape( const
tools::Rectangle& rNewRect
if ( maGeo.nRotationAngle ) RotatePoint(aNewPos, aOld.TopLeft(),
aGeoStat.mfSinRotationAngle, aGeoStat.mfCosRotationAngle );
aNewRect.SetPos( aNewPos );
}
- if ( aNewRect == maRect )
+ if (aNewRect == getRectangle())
return;
SetLogicRect( aNewRect );
@@ -1991,17 +1997,17 @@ void SdrObjCustomShape::DragResizeCustomShape( const
tools::Rectangle& rNewRect
{
nX = ( rInteraction.aPosition.X - aOld.Right() );
if ( rNewRect.Left() > rNewRect.Right() )
- nX = maRect.Left() - nX;
+ nX = getRectangle().Left() - nX;
else
- nX += maRect.Right();
+ nX += getRectangle().Right();
}
else
{
nX = ( rInteraction.aPosition.X - aOld.Left() );
if ( rNewRect.Left() > rNewRect.Right() )
- nX = maRect.Right() - nX;
+ nX = getRectangle().Right() - nX;
else
- nX += maRect.Left();
+ nX += getRectangle().Left();
}
rInteraction.xInteraction->setControllerPosition(awt::Point(nX,
rInteraction.xInteraction->getPosition().Y));
}
@@ -2012,17 +2018,17 @@ void SdrObjCustomShape::DragResizeCustomShape( const
tools::Rectangle& rNewRect
{
nY = ( rInteraction.aPosition.Y - aOld.Bottom() );
if ( rNewRect.Top() > rNewRect.Bottom() )
- nY = maRect.Top() - nY;
+ nY = getRectangle().Top() - nY;
else
- nY += maRect.Bottom();
+ nY += getRectangle().Bottom();
}
else
{
nY = ( rInteraction.aPosition.Y - aOld.Top() );
if ( rNewRect.Top() > rNewRect.Bottom() )
- nY = maRect.Bottom() - nY;
+ nY = getRectangle().Bottom() - nY;
else
- nY += maRect.Top();
+ nY += getRectangle().Top();
}
rInteraction.xInteraction->setControllerPosition(awt::Point(rInteraction.xInteraction->getPosition().X,
nY));
}
@@ -2052,7 +2058,7 @@ void SdrObjCustomShape::DragMoveCustomShapeHdl( const
Point& rDestination,
sal_Int32 nXDiff = aPt.X - aInteractionHandle.aPosition.X;
sal_Int32 nYDiff = aPt.Y - aInteractionHandle.aPosition.Y;
- maRect.Move( nXDiff, nYDiff );
+ moveRectangle(nXDiff, nYDiff);
moveOutRectangle(nXDiff, nYDiff);
maSnapRect.Move( nXDiff, nYDiff );
SetBoundAndSnapRectsDirty(/*bNotMyself*/true);
@@ -2134,12 +2140,12 @@ void SdrObjCustomShape::DragCreateObject( SdrDragStat&
rStat )
if ( !aInteractionHandles.empty() )
{
sal_Int32 nHandlePos = aInteractionHandles[
aInteractionHandles.size() - 1 ].xInteraction->getPosition().X;
- aRect1.Move( maRect.Left() - nHandlePos, 0 );
+ aRect1.Move(getRectangle().Left() - nHandlePos, 0);
}
}
ImpJustifyRect( aRect1 );
rStat.SetActionRect( aRect1 );
- maRect = aRect1;
+ setRectangle(aRect1);
SetBoundAndSnapRectsDirty();
for (const auto& rInteraction : aInteractionHandles)
@@ -2446,9 +2452,9 @@ tools::Rectangle
SdrObjCustomShape::ImpCalculateTextFrame( const bool bHgt, cons
{
tools::Rectangle aReturnValue;
- tools::Rectangle aOldTextRect( maRect ); // <- initial text
rectangle
+ tools::Rectangle aOldTextRect(getRectangle()); // <- initial text
rectangle
- tools::Rectangle aNewTextRect( maRect ); // <- new text rectangle
returned from the custom shape renderer,
+ tools::Rectangle aNewTextRect(getRectangle()); // <- new text
rectangle returned from the custom shape renderer,
GetTextBounds( aNewTextRect ); // it depends to the current
logical shape size
tools::Rectangle aAdjustedTextRect( aNewTextRect );
// <- new text rectangle is being tested by AdjustTextFrameWidthAndHeight
to ensure
@@ -2457,7 +2463,7 @@ tools::Rectangle
SdrObjCustomShape::ImpCalculateTextFrame( const bool bHgt, cons
if (aAdjustedTextRect != aNewTextRect && aOldTextRect !=
aAdjustedTextRect &&
aNewTextRect.GetWidth() && aNewTextRect.GetHeight())
{
- aReturnValue = maRect;
+ aReturnValue = getRectangle();
double fXScale = static_cast<double>(aOldTextRect.GetWidth()) /
static_cast<double>(aNewTextRect.GetWidth());
double fYScale = static_cast<double>(aOldTextRect.GetHeight()) /
static_cast<double>(aNewTextRect.GetHeight());
double fRightDiff = static_cast<double>( aAdjustedTextRect.Right()
- aNewTextRect.Right() ) * fXScale;
@@ -2476,7 +2482,7 @@ tools::Rectangle
SdrObjCustomShape::ImpCalculateTextFrame( const bool bHgt, cons
bool SdrObjCustomShape::NbcAdjustTextFrameWidthAndHeight(bool bHgt, bool bWdt)
{
tools::Rectangle aNewTextRect = ImpCalculateTextFrame(bHgt, bWdt);
- const bool bRet = !aNewTextRect.IsEmpty() && aNewTextRect != maRect;
+ const bool bRet = !aNewTextRect.IsEmpty() && aNewTextRect !=
getRectangle();
if (bRet && !mbAdjustingTextFrameWidthAndHeight)
{
mbAdjustingTextFrameWidthAndHeight = true;
@@ -2484,7 +2490,7 @@ bool
SdrObjCustomShape::NbcAdjustTextFrameWidthAndHeight(bool bHgt, bool bWdt)
// taking care of handles that should not been changed
std::vector< SdrCustomShapeInteraction > aInteractionHandles(
GetInteractionHandles() );
- maRect = aNewTextRect;
+ setRectangle(aNewTextRect);
SetBoundAndSnapRectsDirty();
SetChanged();
@@ -2509,7 +2515,7 @@ bool
SdrObjCustomShape::NbcAdjustTextFrameWidthAndHeight(bool bHgt, bool bWdt)
bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight()
{
tools::Rectangle aNewTextRect = ImpCalculateTextFrame( true/*bHgt*/,
true/*bWdt*/ );
- bool bRet = !aNewTextRect.IsEmpty() && ( aNewTextRect != maRect );
+ bool bRet = !aNewTextRect.IsEmpty() && ( aNewTextRect != getRectangle());
if ( bRet )
{
tools::Rectangle aBoundRect0;
@@ -2519,7 +2525,7 @@ bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight()
// taking care of handles that should not been changed
std::vector< SdrCustomShapeInteraction > aInteractionHandles(
GetInteractionHandles() );
- maRect = aNewTextRect;
+ setRectangle(aNewTextRect);
SetBoundAndSnapRectsDirty();
for (const auto& rInteraction : aInteractionHandles)
@@ -2887,8 +2893,8 @@ void SdrObjCustomShape::handlePageChange(SdrPage*
pOldPage, SdrPage* pNewPage)
// invalidating rectangles by SetRectsDirty is not sufficient,
// AdjustTextFrameWidthAndHeight() also has to be made, both
// actions are done by NbcSetSnapRect
- tools::Rectangle aTmp( maRect ); //creating temporary rectangle
#i61108#
- NbcSetSnapRect( aTmp );
+ tools::Rectangle aRectangle(getRectangle()); //creating temporary
rectangle #i61108#
+ NbcSetSnapRect(aRectangle);
}
}
@@ -3109,8 +3115,8 @@ bool
SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegf
double fRotate = basegfx::deg2rad(fObjectRotation);
double fShearX = toRadians(maGeo.nShearAngle);
- // get aRect, this is the unrotated snaprect
- tools::Rectangle aRectangle(maRect);
+ // get aRectangle, this is the unrotated snaprect
+ tools::Rectangle aRectangle(getRectangle());
bool bMirroredX = IsMirroredX();
bool bMirroredY = IsMirroredY();
@@ -3122,7 +3128,7 @@ bool
SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegf
if ( bMirroredX )
{
fShearX = -fShearX;
- tools::Polygon aPol = Rect2Poly(maRect, aNewGeo);
+ tools::Polygon aPol = Rect2Poly(getRectangle(), aNewGeo);
tools::Rectangle aBoundRect( aPol.GetBoundRect() );
Point aRef1( ( aBoundRect.Left() + aBoundRect.Right() ) >> 1,
aBoundRect.Top() );
@@ -3163,7 +3169,7 @@ bool
SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegf
aPol[2]=aPol0[3]; // it was *not* wrong even when the reordering
aPol[3]=aPol0[2]; // *seems* to be specific for X-Mirrorings. Oh
aPol[4]=aPol0[1]; // will I be happy when this old stuff is |gone|
with aw080 (!)
- Poly2Rect(aPol,aRectangle,aNewGeo);
+ Poly2Rect(aPol, aRectangle, aNewGeo);
}
}
diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx
index 6a886272bad1..14e7678499c7 100644
--- a/svx/source/svdraw/svdocapt.cxx
+++ b/svx/source/svdraw/svdocapt.cxx
@@ -308,7 +308,7 @@ bool SdrCaptionObj::beginSpecialDrag(SdrDragStat& rDrag)
const
return false;
rDrag.SetNoSnap();
- rDrag.SetActionRect(maRect);
+ rDrag.SetActionRect(getRectangle());
Point aHit(rDrag.GetStart());
@@ -341,15 +341,15 @@ bool SdrCaptionObj::applySpecialDrag(SdrDragStat& rDrag)
}
else
{
- Point aDelt(rDrag.GetNow()-rDrag.GetStart());
+ Point aDelta(rDrag.GetNow()-rDrag.GetStart());
if(!pHdl)
{
- maRect.Move(aDelt.X(),aDelt.Y());
+ moveRectangle(aDelta.X(), aDelta.Y());
}
else
{
- aTailPoly[0] += aDelt;
+ aTailPoly[0] += aDelta;
}
ImpRecalcTail();
@@ -408,7 +408,7 @@ void SdrCaptionObj::ImpRecalcTail()
{
ImpCaptParams aPara;
ImpGetCaptParams(aPara);
- ImpCalcTail(aPara, aTailPoly, maRect);
+ ImpCalcTail(aPara, aTailPoly, getRectangle());
SetBoundAndSnapRectsDirty();
SetXPolyDirty();
}
@@ -511,14 +511,15 @@ void SdrCaptionObj::ImpCalcTail(const ImpCaptParams&
rPara, tools::Polygon& rPol
bool SdrCaptionObj::BegCreate(SdrDragStat& rStat)
{
- if (maRect.IsEmpty()) return false; // Create currently only works with
the given Rect
+ if (getRectangle().IsEmpty())
+ return false; // Create currently only works with the given Rect
ImpCaptParams aPara;
ImpGetCaptParams(aPara);
- maRect.SetPos(rStat.GetNow());
+ moveRectanglePosition(rStat.GetNow().X(), rStat.GetNow().Y());
aTailPoly[0]=rStat.GetStart();
- ImpCalcTail(aPara,aTailPoly,maRect);
- rStat.SetActionRect(maRect);
+ ImpCalcTail(aPara,aTailPoly, getRectangle());
+ rStat.SetActionRect(getRectangle());
return true;
}
@@ -526,9 +527,9 @@ bool SdrCaptionObj::MovCreate(SdrDragStat& rStat)
{
ImpCaptParams aPara;
ImpGetCaptParams(aPara);
- maRect.SetPos(rStat.GetNow());
- ImpCalcTail(aPara,aTailPoly,maRect);
- rStat.SetActionRect(maRect);
+ moveRectanglePosition(rStat.GetNow().X(), rStat.GetNow().Y());
+ ImpCalcTail(aPara,aTailPoly, getRectangle());
+ rStat.SetActionRect(getRectangle());
SetBoundRectDirty();
m_bSnapRectDirty=true;
return true;
@@ -538,8 +539,8 @@ bool SdrCaptionObj::EndCreate(SdrDragStat& rStat,
SdrCreateCmd eCmd)
{
ImpCaptParams aPara;
ImpGetCaptParams(aPara);
- maRect.SetPos(rStat.GetNow());
- ImpCalcTail(aPara,aTailPoly,maRect);
+ moveRectanglePosition(rStat.GetNow().X(), rStat.GetNow().Y());
+ ImpCalcTail(aPara,aTailPoly, getRectangle());
SetBoundAndSnapRectsDirty();
return (eCmd==SdrCreateCmd::ForceEnd || rStat.GetPointCount()>=2);
}
@@ -556,7 +557,7 @@ void SdrCaptionObj::BrkCreate(SdrDragStat& /*rStat*/)
basegfx::B2DPolyPolygon SdrCaptionObj::TakeCreatePoly(const SdrDragStat&
/*rDrag*/) const
{
basegfx::B2DPolyPolygon aRetval;
- const basegfx::B2DRange aRange
=vcl::unotools::b2DRectangleFromRectangle(maRect);
+ const basegfx::B2DRange aRange
=vcl::unotools::b2DRectangleFromRectangle(getRectangle());
aRetval.append(basegfx::utils::createPolygonFromRect(aRange));
aRetval.append(aTailPoly.getB2DPolygon());
return aRetval;
@@ -598,7 +599,7 @@ Point SdrCaptionObj::GetRelativePos() const
const tools::Rectangle& SdrCaptionObj::GetLogicRect() const
{
- return maRect;
+ return getRectangle();
}
void SdrCaptionObj::NbcSetLogicRect(const tools::Rectangle& rRect)
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index 1207548114bf..ab8bc58ddf85 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -312,14 +312,14 @@ basegfx::B2DPolygon SdrCircObj::ImpCalcXPolyCirc(const
SdrCircKind eCircleKind,
void SdrCircObj::RecalcXPoly()
{
- basegfx::B2DPolygon aPolyCirc(ImpCalcXPolyCirc(meCircleKind, maRect,
nStartAngle, nEndAngle));
+ basegfx::B2DPolygon aPolyCirc(ImpCalcXPolyCirc(meCircleKind,
getRectangle(), nStartAngle, nEndAngle));
mpXPoly = XPolygon(aPolyCirc);
}
OUString SdrCircObj::TakeObjNameSingul() const
{
TranslateId pID=STR_ObjNameSingulCIRC;
- if (maRect.GetWidth() == maRect.GetHeight() && maGeo.nShearAngle==0_deg100)
+ if (getRectangle().GetWidth() == getRectangle().GetHeight() &&
maGeo.nShearAngle == 0_deg100)
{
switch (meCircleKind) {
case SdrCircKind::Full: pID=STR_ObjNameSingulCIRC; break;
@@ -348,7 +348,7 @@ OUString SdrCircObj::TakeObjNameSingul() const
OUString SdrCircObj::TakeObjNamePlural() const
{
TranslateId pID=STR_ObjNamePluralCIRC;
- if (maRect.GetWidth() == maRect.GetHeight() && maGeo.nShearAngle==0_deg100)
+ if (getRectangle().GetWidth() == getRectangle().GetHeight() &&
maGeo.nShearAngle == 0_deg100)
{
switch (meCircleKind) {
case SdrCircKind::Full: pID=STR_ObjNamePluralCIRC; break;
@@ -376,7 +376,7 @@ rtl::Reference<SdrObject>
SdrCircObj::CloneSdrObject(SdrModel& rTargetModel) con
basegfx::B2DPolyPolygon SdrCircObj::TakeXorPoly() const
{
- const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind,
maRect, nStartAngle, nEndAngle));
+ const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind,
getRectangle(), nStartAngle, nEndAngle));
return basegfx::B2DPolyPolygon(aCircPolygon);
}
@@ -423,61 +423,61 @@ void SdrCircObj::AddToHdlList(SdrHdlList& rHdlList) const
Point aPnt;
SdrHdlKind eLocalKind(SdrHdlKind::Move);
sal_uInt32 nPNum(0);
-
+ tools::Rectangle aRectangle = getRectangle();
switch (nHdlNum)
{
case 0:
- aPnt = GetAnglePnt(maRect,nStartAngle);
+ aPnt = GetAnglePnt(aRectangle, nStartAngle);
eLocalKind = SdrHdlKind::Circle;
nPNum = 1;
break;
case 1:
- aPnt = GetAnglePnt(maRect,nEndAngle);
+ aPnt = GetAnglePnt(aRectangle, nEndAngle);
eLocalKind = SdrHdlKind::Circle;
nPNum = 2;
break;
case 2:
- aPnt = maRect.TopLeft();
+ aPnt = aRectangle.TopLeft();
eLocalKind = SdrHdlKind::UpperLeft;
break;
case 3:
- aPnt = maRect.TopCenter();
+ aPnt = aRectangle.TopCenter();
eLocalKind = SdrHdlKind::Upper;
break;
case 4:
- aPnt = maRect.TopRight();
+ aPnt = aRectangle.TopRight();
eLocalKind = SdrHdlKind::UpperRight;
break;
case 5:
- aPnt = maRect.LeftCenter();
+ aPnt = aRectangle.LeftCenter();
eLocalKind = SdrHdlKind::Left;
break;
case 6:
- aPnt = maRect.RightCenter();
+ aPnt = aRectangle.RightCenter();
eLocalKind = SdrHdlKind::Right;
break;
case 7:
- aPnt = maRect.BottomLeft();
+ aPnt = aRectangle.BottomLeft();
eLocalKind = SdrHdlKind::LowerLeft;
break;
case 8:
- aPnt = maRect.BottomCenter();
+ aPnt = aRectangle.BottomCenter();
eLocalKind = SdrHdlKind::Lower;
break;
case 9:
- aPnt = maRect.BottomRight();
+ aPnt = aRectangle.BottomRight();
eLocalKind = SdrHdlKind::LowerRight;
break;
}
if (maGeo.nShearAngle)
{
- ShearPoint(aPnt, maRect.TopLeft(), maGeo.mfTanShearAngle);
+ ShearPoint(aPnt, aRectangle.TopLeft(), maGeo.mfTanShearAngle);
}
if (maGeo.nRotationAngle)
{
- RotatePoint(aPnt, maRect.TopLeft(), maGeo.mfSinRotationAngle,
maGeo.mfCosRotationAngle);
+ RotatePoint(aPnt, aRectangle.TopLeft(), maGeo.mfSinRotationAngle,
maGeo.mfCosRotationAngle);
}
std::unique_ptr<SdrHdl> pH(new SdrHdl(aPnt,eLocalKind));
@@ -520,15 +520,15 @@ bool SdrCircObj::applySpecialDrag(SdrDragStat& rDrag)
Point aPt(rDrag.GetNow());
if (maGeo.nRotationAngle)
- RotatePoint(aPt,maRect.TopLeft(), -maGeo.mfSinRotationAngle,
maGeo.mfCosRotationAngle);
+ RotatePoint(aPt, getRectangle().TopLeft(),
-maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle);
if (maGeo.nShearAngle)
- ShearPoint(aPt,maRect.TopLeft(), -maGeo.mfTanShearAngle);
+ ShearPoint(aPt, getRectangle().TopLeft(), -maGeo.mfTanShearAngle);
- aPt -= maRect.Center();
+ aPt -= getRectangle().Center();
- tools::Long nWdt = maRect.Right() - maRect.Left();
- tools::Long nHgt = maRect.Bottom() - maRect.Top();
+ tools::Long nWdt = getRectangle().Right() - getRectangle().Left();
+ tools::Long nHgt = getRectangle().Bottom() - getRectangle().Top();
if(nWdt>=nHgt)
{
@@ -696,7 +696,7 @@ bool SdrCircObj::BegCreate(SdrDragStat& rStat)
tools::Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
aRect1.Normalize();
rStat.SetActionRect(aRect1);
- maRect = aRect1;
+ setRectangle(aRect1);
ImpSetCreateParams(rStat);
return true;
}
@@ -706,8 +706,8 @@ bool SdrCircObj::MovCreate(SdrDragStat& rStat)
ImpSetCreateParams(rStat);
ImpCircUser* pU=static_cast<ImpCircUser*>(rStat.GetUser());
rStat.SetActionRect(pU->aR);
- maRect = pU->aR; // for ObjName
- ImpJustifyRect(maRect);
+ setRectangle(pU->aR); // for ObjName
+ ImpJustifyRect(maRectangle);
nStartAngle=pU->nStart;
nEndAngle=pU->nEnd;
SetBoundRectDirty();
@@ -733,16 +733,18 @@ bool SdrCircObj::EndCreate(SdrDragStat& rStat,
SdrCreateCmd eCmd)
if (meCircleKind==SdrCircKind::Full) {
bRet=rStat.GetPointCount()>=2;
if (bRet) {
- maRect = pU->aR;
- ImpJustifyRect(maRect);
+ tools::Rectangle aRectangle(pU->aR);
+ ImpJustifyRect(aRectangle);
+ setRectangle(aRectangle);
}
} else {
rStat.SetNoSnap(rStat.GetPointCount()>=2);
rStat.SetOrtho4Possible(rStat.GetPointCount()<2);
bRet=rStat.GetPointCount()>=4;
if (bRet) {
- maRect = pU->aR;
- ImpJustifyRect(maRect);
+ tools::Rectangle aRectangle(pU->aR);
+ ImpJustifyRect(aRectangle);
+ setRectangle(aRectangle);
nStartAngle=pU->nStart;
nEndAngle=pU->nEnd;
}
@@ -809,7 +811,7 @@ PointerStyle SdrCircObj::GetCreatePointer() const
void SdrCircObj::NbcMove(const Size& aSize)
{
- maRect.Move(aSize);
+ moveRectangle(aSize.Width(), aSize.Height());
moveOutRectangle(aSize.Width(), aSize.Height());
maSnapRect.Move(aSize);
SetXPolyDirty();
@@ -880,9 +882,9 @@ void SdrCircObj::NbcMirror(const Point& rRef1, const Point&
rRef2)
Point aTmpPt1;
Point aTmpPt2;
if (bFreeMirr) { // some preparations for using an arbitrary axis of
reflection
- Point aCenter(maRect.Center());
- tools::Long nWdt=maRect.GetWidth()-1;
- tools::Long nHgt=maRect.GetHeight()-1;
+ Point aCenter(getRectangle().Center());
+ tools::Long nWdt = getRectangle().GetWidth() - 1;
+ tools::Long nHgt = getRectangle().GetHeight() - 1;
tools::Long nMaxRad=(std::max(nWdt,nHgt)+1) /2;
// starting point
double a = toRadians(nStartAngle);
@@ -898,13 +900,13 @@ void SdrCircObj::NbcMirror(const Point& rRef1, const
Point& rRef2)
aTmpPt2+=aCenter;
if (maGeo.nRotationAngle)
{
- RotatePoint(aTmpPt1, maRect.TopLeft(), maGeo.mfSinRotationAngle,
maGeo.mfCosRotationAngle);
- RotatePoint(aTmpPt2, maRect.TopLeft(), maGeo.mfSinRotationAngle,
maGeo.mfCosRotationAngle);
+ RotatePoint(aTmpPt1, getRectangle().TopLeft(),
maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle);
+ RotatePoint(aTmpPt2, getRectangle().TopLeft(),
maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle);
}
if (maGeo.nShearAngle)
{
- ShearPoint(aTmpPt1, maRect.TopLeft(), maGeo.mfTanShearAngle);
- ShearPoint(aTmpPt2, maRect.TopLeft(), maGeo.mfTanShearAngle);
+ ShearPoint(aTmpPt1, getRectangle().TopLeft(),
maGeo.mfTanShearAngle);
+ ShearPoint(aTmpPt2, getRectangle().TopLeft(),
maGeo.mfTanShearAngle);
}
}
SdrTextObj::NbcMirror(rRef1,rRef2);
@@ -914,16 +916,16 @@ void SdrCircObj::NbcMirror(const Point& rRef1, const
Point& rRef2)
// unrotate:
if (maGeo.nRotationAngle)
{
- RotatePoint(aTmpPt1, maRect.TopLeft(), -maGeo.mfSinRotationAngle,
maGeo.mfCosRotationAngle); // -sin for reversion
- RotatePoint(aTmpPt2, maRect.TopLeft(), -maGeo.mfSinRotationAngle,
maGeo.mfCosRotationAngle); // -sin for reversion
+ RotatePoint(aTmpPt1, getRectangle().TopLeft(),
-maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); // -sin for reversion
+ RotatePoint(aTmpPt2, getRectangle().TopLeft(),
-maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle); // -sin for reversion
}
// unshear:
if (maGeo.nShearAngle)
{
- ShearPoint(aTmpPt1, maRect.TopLeft(), -maGeo.mfTanShearAngle); //
-tan for reversion
- ShearPoint(aTmpPt2, maRect.TopLeft(), -maGeo.mfTanShearAngle); //
-tan for reversion
+ ShearPoint(aTmpPt1, getRectangle().TopLeft(),
-maGeo.mfTanShearAngle); // -tan for reversion
+ ShearPoint(aTmpPt2, getRectangle().TopLeft(),
-maGeo.mfTanShearAngle); // -tan for reversion
}
- Point aCenter(maRect.Center());
+ Point aCenter(getRectangle().Center());
aTmpPt1-=aCenter;
aTmpPt2-=aCenter;
// because it's mirrored, the angles are swapped, too
@@ -971,37 +973,37 @@ static void Union(tools::Rectangle& rR, const Point& rP)
void SdrCircObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const
{
- rRect = maRect;
+ rRect = getRectangle();
if (meCircleKind!=SdrCircKind::Full) {
- const Point aPntStart(GetAnglePnt(maRect,nStartAngle));
- const Point aPntEnd(GetAnglePnt(maRect,nEndAngle));
+ const Point aPntStart(GetAnglePnt(getRectangle(), nStartAngle));
+ const Point aPntEnd(GetAnglePnt(getRectangle(), nEndAngle));
Degree100 a=nStartAngle;
Degree100 e=nEndAngle;
- rRect.SetLeft(maRect.Right() );
- rRect.SetRight(maRect.Left() );
- rRect.SetTop(maRect.Bottom() );
- rRect.SetBottom(maRect.Top() );
+ rRect.SetLeft(getRectangle().Right() );
+ rRect.SetRight(getRectangle().Left() );
+ rRect.SetTop(getRectangle().Bottom() );
+ rRect.SetBottom(getRectangle().Top() );
Union(rRect,aPntStart);
Union(rRect,aPntEnd);
if ((a<=18000_deg100 && e>=18000_deg100) || (a>e && (a<=18000_deg100
|| e>=18000_deg100))) {
- Union(rRect,maRect.LeftCenter());
+ Union(rRect, getRectangle().LeftCenter());
}
if ((a<=27000_deg100 && e>=27000_deg100) || (a>e && (a<=27000_deg100
|| e>=27000_deg100))) {
- Union(rRect,maRect.BottomCenter());
+ Union(rRect, getRectangle().BottomCenter());
}
if (a>e) {
- Union(rRect,maRect.RightCenter());
+ Union(rRect, getRectangle().RightCenter());
}
if ((a<=9000_deg100 && e>=9000_deg100) || (a>e && (a<=9000_deg100 ||
e>=9000_deg100))) {
- Union(rRect,maRect.TopCenter());
+ Union(rRect, getRectangle().TopCenter());
}
if (meCircleKind==SdrCircKind::Section) {
- Union(rRect,maRect.Center());
+ Union(rRect, getRectangle().Center());
}
if (maGeo.nRotationAngle)
{
Point aDst(rRect.TopLeft());
- aDst-=maRect.TopLeft();
+ aDst -= getRectangle().TopLeft();
Point aDst0(aDst);
RotatePoint(aDst,Point(), maGeo.mfSinRotationAngle,
maGeo.mfCosRotationAngle);
aDst-=aDst0;
@@ -1046,8 +1048,8 @@ void SdrCircObj::NbcSetSnapRect(const tools::Rectangle&
rRect)
NbcResize(maSnapRect.TopLeft(),Fraction(nWdt1,nWdt0),Fraction(nHgt1,nHgt0));
NbcMove(Size(rRect.Left()-aSR0.Left(),rRect.Top()-aSR0.Top()));
} else {
- maRect=rRect;
- ImpJustifyRect(maRect);
+ setRectangle(rRect);
+ ImpJustifyRect(maRectangle);
}
SetBoundAndSnapRectsDirty();
SetXPolyDirty();
@@ -1065,10 +1067,11 @@ sal_uInt32 SdrCircObj::GetSnapPointCount() const
Point SdrCircObj::GetSnapPoint(sal_uInt32 i) const
{
- switch (i) {
- case 1 : return GetAnglePnt(maRect,nStartAngle);
- case 2 : return GetAnglePnt(maRect,nEndAngle);
- default: return maRect.Center();
+ switch (i)
+ {
+ case 1 : return GetAnglePnt(getRectangle(), nStartAngle);
+ case 2 : return GetAnglePnt(getRectangle(), nEndAngle);
+ default: return getRectangle().Center();
}
}
@@ -1140,7 +1143,7 @@ void SdrCircObj::ImpSetCircInfoToAttr()
rtl::Reference<SdrObject> SdrCircObj::DoConvertToPolyObj(bool bBezier, bool
bAddText) const
{
const bool bFill(meCircleKind != SdrCircKind::Arc);
- const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind,
maRect, nStartAngle, nEndAngle));
+ const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind,
getRectangle(), nStartAngle, nEndAngle));
rtl::Reference<SdrObject> pRet =
ImpConvertMakeObj(basegfx::B2DPolyPolygon(aCircPolygon), bFill, bBezier);
if(bAddText)
diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx
index f84ee128a6e0..81bb8bdf79af 100644
--- a/svx/source/svdraw/svdoedge.cxx
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -1718,7 +1718,7 @@ void SdrEdgeObj::SetEdgeTrackPath( const
basegfx::B2DPolyPolygon& rPoly )
// #i110629# also set aRect and maSnapeRect depending on pEdgeTrack
const tools::Rectangle aPolygonBounds(pEdgeTrack->GetBoundRect());
- maRect = aPolygonBounds;
+ setRectangle(aPolygonBounds);
maSnapRect = aPolygonBounds;
}
}
@@ -2273,11 +2273,11 @@ void SdrEdgeObj::NbcSetSnapRect(const tools::Rectangle&
rRect)
if(aOld == rRect)
return;
- if (maRect.IsEmpty() && 0 == pEdgeTrack->GetPointCount())
+ if (getRectangle().IsEmpty() && 0 == pEdgeTrack->GetPointCount())
{
// #i110629# When initializing, do not scale on empty Rectangle; this
// will mirror the underlying text object (!)
- maRect = rRect;
+ setRectangle(rRect);
maSnapRect = rRect;
}
else
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 1c1be8a7a69a..00981a355e84 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -921,7 +921,7 @@ rtl::Reference<SdrObject>
SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAdd
ImpSdrGDIMetaFileImport aFilter(
getSdrModelFromSdrObject(),
GetLayer(),
- maRect);
+ getRectangle());
rtl::Reference<SdrObjGroup> pGrp = new
SdrObjGroup(getSdrModelFromSdrObject());
if(aFilter.DoImport(aMtf, *pGrp->GetSubList(), 0))
@@ -933,13 +933,13 @@ rtl::Reference<SdrObject>
SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAdd
if(aGeoStat.nShearAngle)
{
aGeoStat.RecalcTan();
- pGrp->NbcShear(maRect.TopLeft(), aGeoStat.nShearAngle,
aGeoStat.mfTanShearAngle, false);
+ pGrp->NbcShear(getRectangle().TopLeft(),
aGeoStat.nShearAngle, aGeoStat.mfTanShearAngle, false);
}
if(aGeoStat.nRotationAngle)
{
aGeoStat.RecalcSinCos();
- pGrp->NbcRotate(maRect.TopLeft(),
aGeoStat.nRotationAngle, aGeoStat.mfSinRotationAngle,
aGeoStat.mfCosRotationAngle);
+ pGrp->NbcRotate(getRectangle().TopLeft(),
aGeoStat.nRotationAngle, aGeoStat.mfSinRotationAngle,
aGeoStat.mfCosRotationAngle);
}
}
@@ -1105,7 +1105,7 @@ void SdrGrafObj::AdjustToMaxRect( const tools::Rectangle&
rMaxRect, bool bShrink
}
if( bShrinkOnly )
- aPos = maRect.TopLeft();
+ aPos = getRectangle().TopLeft();
aPos.AdjustX( -(aSize.Width() / 2) );
aPos.AdjustY( -(aSize.Height() / 2) );
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index 5e402646ef66..ee53dc085b32 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -698,7 +698,7 @@ void SdrMeasureObj::TakeUnrotatedSnapRect(tools::Rectangle&
rRect) const
aTextSize2.AdjustWidth( 1 ); aTextSize2.AdjustHeight( 1 ); // because of
the Rect-Ctor's odd behavior
rRect=tools::Rectangle(aTextPos,aTextSize2);
rRect.Normalize();
- const_cast<SdrMeasureObj*>(this)->maRect=rRect;
+ const_cast<SdrMeasureObj*>(this)->setRectangle(rRect);
if (aMPol.nTextAngle != maGeo.nRotationAngle) {
const_cast<SdrMeasureObj*>(this)->maGeo.nRotationAngle=aMPol.nTextAngle;
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
index 9b17b7bf278a..e6c179812eae 100644
--- a/svx/source/svdraw/svdomedia.cxx
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -245,7 +245,7 @@ void SdrMediaObj::AdjustToMaxRect( const tools::Rectangle&
rMaxRect, bool bShrin
}
if( bShrinkOnly )
- aPos = maRect.TopLeft();
+ aPos = getRectangle().TopLeft();
aPos.AdjustX( -(aSize.Width() / 2) );
aPos.AdjustY( -(aSize.Height() / 2) );
@@ -483,7 +483,7 @@ void SdrMediaObj::notifyPropertiesForLOKit()
json.put("id", mediaId);
json.put("url", m_xImpl->m_MediaProperties.getTempURL());
- const tools::Rectangle aRect = o3tl::convert(maRect,
o3tl::Length::mm100, o3tl::Length::twip);
+ const tools::Rectangle aRect = o3tl::convert(getRectangle(),
o3tl::Length::mm100, o3tl::Length::twip);
json.put("x", aRect.getX());
json.put("y", aRect.getY());
json.put("w", aRect.getOpenWidth());
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index a5ebed7ce7ce..3661aa260d14 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -1476,8 +1476,8 @@ void SdrOle2Obj::ImpSetVisAreaSize()
MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit(
mpImpl->mxObjRef->getMapUnit( GetAspect() ) );
Size aVisSize;
if (sal_Int32(aScaleWidth) != 0 && sal_Int32(aScaleHeight) != 0)
// avoid div by zero
- aVisSize = Size( static_cast<tools::Long>( Fraction(
maRect.GetWidth() ) / aScaleWidth ),
- static_cast<tools::Long>( Fraction(
maRect.GetHeight() ) / aScaleHeight ) );
+ aVisSize = Size( static_cast<tools::Long>( Fraction(
getRectangle().GetWidth() ) / aScaleWidth ),
+ static_cast<tools::Long>( Fraction(
getRectangle().GetHeight() ) / aScaleHeight ) );
aVisSize = OutputDevice::LogicToLogic(
aVisSize,
@@ -1503,18 +1503,15 @@ void SdrOle2Obj::ImpSetVisAreaSize()
// server changed VisArea to its liking and the VisArea is
different than the suggested one
// store the new value as given by the object
MapUnit aNewMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit(
mpImpl->mxObjRef->getMapUnit( GetAspect() ) );
- maRect.SetSize(
- OutputDevice::LogicToLogic(
- aAcceptedVisArea.GetSize(),
- MapMode(aNewMapUnit),
- MapMode(getSdrModelFromSdrObject().GetScaleUnit())));
+ auto aSize =
OutputDevice::LogicToLogic(aAcceptedVisArea.GetSize(), MapMode(aNewMapUnit),
MapMode(getSdrModelFromSdrObject().GetScaleUnit()));
+ setRectangleSize(aSize.Width(), aSize.Height());
}
// make the new object area known to the client
// compared to the "else" branch aRect might have been changed by
the object and no additional scaling was applied
// WHY this -> OSL_ASSERT( pClient );
if( pClient )
- pClient->SetObjArea(maRect);
+ pClient->SetObjArea(getRectangle());
// we need a new replacement image as the object has resized itself
@@ -1535,7 +1532,7 @@ void SdrOle2Obj::ImpSetVisAreaSize()
{
if ( pClient )
{
- tools::Rectangle aScaleRect(maRect.TopLeft(),
aObjAreaSize);
+ tools::Rectangle aScaleRect(getRectangle().TopLeft(),
aObjAreaSize);
pClient->SetObjAreaAndScale( aScaleRect, aScaleWidth,
aScaleHeight);
}
else
@@ -1556,8 +1553,8 @@ void SdrOle2Obj::ImpSetVisAreaSize()
const MapUnit aMapUnit(
VCLUnoHelper::UnoEmbed2VCLMapUnit(
mpImpl->mxObjRef->getMapUnit(GetAspect())));
- const Point aTL( maRect.TopLeft() );
- const Point aBR( maRect.BottomRight() );
+ const Point aTL( getRectangle().TopLeft() );
+ const Point aBR( getRectangle().BottomRight() );
const Point aTL2(
OutputDevice::LogicToLogic(
aTL,
@@ -1868,7 +1865,7 @@ bool SdrOle2Obj::CalculateNewScaling( Fraction&
aScaleWidth, Fraction& aScaleHei
MapMode aMapMode(getSdrModelFromSdrObject().GetScaleUnit());
aObjAreaSize = mpImpl->mxObjRef.GetSize( &aMapMode );
- Size aSize = maRect.GetSize();
+ Size aSize = getRectangle().GetSize();
aScaleWidth = Fraction(aSize.Width(), aObjAreaSize.Width() );
aScaleHeight = Fraction(aSize.Height(), aObjAreaSize.Height() );
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index a4998647c835..78012451b2bd 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -1682,7 +1682,7 @@ void SdrPathObj::ImpForceLineAngle()
maGeo.RecalcTan();
// for SdrTextObj, keep aRect up to date
- maRect = tools::Rectangle::Normalize(aPoint0, aPoint1);
+ setRectangle(tools::Rectangle::Normalize(aPoint0, aPoint1));
}
void SdrPathObj::ImpForceKind()
@@ -1746,7 +1746,7 @@ void SdrPathObj::ImpForceKind()
// #i10659# for SdrTextObj, keep aRect up to date
if(GetPathPoly().count())
{
- maRect = lcl_ImpGetBoundRect(GetPathPoly());
+ setRectangle(lcl_ImpGetBoundRect(GetPathPoly()));
}
}
@@ -2469,7 +2469,7 @@ void SdrPathObj::NbcSetPoint(const Point& rPnt,
sal_uInt32 nHdlNum)
if(GetPathPoly().count())
{
// #i10659# for SdrTextObj, keep aRect up to date
- maRect = lcl_ImpGetBoundRect(GetPathPoly());
+ setRectangle(lcl_ImpGetBoundRect(GetPathPoly()));
}
}
diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx
index 989fe0685e6b..a11151fb280d 100644
--- a/svx/source/svdraw/svdorect.cxx
+++ b/svx/source/svdraw/svdorect.cxx
@@ -122,14 +122,14 @@ XPolygon SdrRectObj::ImpCalcXPoly(const tools::Rectangle&
rRect1, tools::Long nR
aXPoly=aNewPoly;
// these angles always relate to the top left corner of aRect
- if (maGeo.nShearAngle)
ShearXPoly(aXPoly,maRect.TopLeft(),maGeo.mfTanShearAngle);
- if (maGeo.nRotationAngle)
RotateXPoly(aXPoly,maRect.TopLeft(),maGeo.mfSinRotationAngle,maGeo.mfCosRotationAngle);
+ if (maGeo.nShearAngle) ShearXPoly(aXPoly, getRectangle().TopLeft(),
maGeo.mfTanShearAngle);
+ if (maGeo.nRotationAngle) RotateXPoly(aXPoly, getRectangle().TopLeft(),
maGeo.mfSinRotationAngle, maGeo.mfCosRotationAngle);
return aXPoly;
}
void SdrRectObj::RecalcXPoly()
{
- mpXPoly = ImpCalcXPoly(maRect,GetEckenradius());
+ mpXPoly = ImpCalcXPoly(getRectangle(), GetEckenradius());
}
const XPolygon& SdrRectObj::GetXPoly() const
@@ -177,11 +177,11 @@ SdrObjKind SdrRectObj::GetObjIdentifier() const
void SdrRectObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const
{
- rRect = maRect;
+ rRect = getRectangle();
if (maGeo.nShearAngle==0_deg100)
return;
- tools::Long nDst=FRound((maRect.Bottom()-maRect.Top()) *
maGeo.mfTanShearAngle);
+ tools::Long nDst=FRound((getRectangle().Bottom()-getRectangle().Top()) *
maGeo.mfTanShearAngle);
if (maGeo.nShearAngle>0_deg100)
{
Point aRef(rRect.TopLeft());
@@ -210,7 +210,7 @@ OUString SdrRectObj::TakeObjNameSingul() const
{
pResId = bRounded ? STR_ObjNameSingulPARALRND :
STR_ObjNameSingulPARAL; // parallelogram or, maybe, rhombus
}
- else if (maRect.GetWidth() == maRect.GetHeight())
+ else if (getRectangle().GetWidth() == getRectangle().GetHeight())
{
pResId = bRounded ? STR_ObjNameSingulQUADRND : STR_ObjNameSingulQUAD;
// square
}
@@ -236,7 +236,7 @@ OUString SdrRectObj::TakeObjNamePlural() const
{
pResId = bRounded ? STR_ObjNamePluralPARALRND :
STR_ObjNamePluralPARAL; // parallelogram or rhombus
}
- else if (maRect.GetWidth() == maRect.GetHeight())
+ else if (getRectangle().GetWidth() == getRectangle().GetHeight())
{
pResId = bRounded ? STR_ObjNamePluralQUADRND : STR_ObjNamePluralQUAD;
// square
}
... etc. - the rest is truncated