Rebased ref, commits from common ancestor:
commit d47feb759203542fb191a113bc53ee5cb88fea95
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Wed Feb 8 10:42:19 2023 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Wed Feb 8 22:38:57 2023 +0900
use Range2DLWrap for "OutRectangle" in SdrObject
Change-Id: I243b44a84bc09991744009ae24ac7657d493c5cf
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 6b779775bc3d..2d16d1ad33e7 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -34,6 +34,7 @@
#include <tools/gen.hxx>
#include <unotools/resmgr.hxx>
#include <unotools/weakref.hxx>
+#include <basegfx/units/Range2DLWrap.hxx>
#include <osl/diagnose.h>
#include <typeinfo>
@@ -893,13 +894,15 @@ public:
void ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon)
const noexcept;
protected:
- const tools::Rectangle& getOutRectangle() const;
+ tools::Rectangle const& getOutRectangle() const;
+ bool isOutRectangleEmpty() const;
void setOutRectangleConst(tools::Rectangle const& rRectangle) const; //
need to do something about this
void setOutRectangle(tools::Rectangle const& rRectangle);
void resetOutRectangle();
void moveOutRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta);
- mutable tools::Rectangle m_aOutRect; // surrounding rectangle for
Paint (incl. LineWidth, ...)
+ mutable gfx::Range2DLWrap m_aOutterRange; // surrounding rectangle for
Paint (incl. LineWidth, ...)
+
Point m_aAnchor; // anchor position (Writer)
SdrObjUserCall* m_pUserCall;
std::unique_ptr<SdrObjPlusData>
diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx
index cf0f06e3fb5b..7ddf4d7e3b62 100644
--- a/include/svx/svdomeas.hxx
+++ b/include/svx/svdomeas.hxx
@@ -65,7 +65,7 @@ private:
{
bTextDirty=true;
SetTextSizeDirty();
- if (!m_aOutRect.IsEmpty())
+ if (!getOutRectangle().IsEmpty())
{
SetBoundRectDirty();
SetBoundAndSnapRectsDirty(/*bNotMyself*/true);
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index c7a6115646b3..de6827173c47 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -398,6 +398,14 @@ public:
tools::Long upperUnit() const { return maUpper.as(meUnit); }
tools::Long lowerUnit() const { return maLower.as(meUnit); }
+ bool operator==(Border const& other) const
+ {
+ return maLeft == other.maLeft
+ && maRight == other.maRight
+ && maUpper == other.maUpper
+ && maLower == other.maLower;
+ }
+
tools::Rectangle toToolsRect() const
{
return tools::Rectangle(leftUnit(), upperUnit(), rightUnit(),
lowerUnit());
@@ -588,10 +596,7 @@ public:
return maBorder;
}
- virtual void setBorder(svx::Border const& rBorder)
- {
- maBorder = rBorder;
- }
+ virtual void setBorder(svx::Border const& rBorder);
virtual void SetBorder(sal_Int32 nLeft, sal_Int32 nUpper, sal_Int32
nRight, sal_Int32 Lower);
virtual void SetLeftBorder(sal_Int32 nBorder);
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index f9e061d59e17..f8ef26561a71 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -34,6 +34,7 @@
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/units/Range2DLWrap.hxx>
#include <basegfx/range/b2drange.hxx>
#include <drawinglayer/processor2d/contourextractor2d.hxx>
#include <drawinglayer/processor2d/linegeometryextractor2d.hxx>
@@ -925,13 +926,9 @@ void SdrObject::SetNavigationPosition (const sal_uInt32
nNewPosition)
// GetCurrentBoundRect().
const tools::Rectangle& SdrObject::GetCurrentBoundRect() const
{
- auto const& rRectangle = getOutRectangle();
- if (rRectangle.IsEmpty())
- {
- const_cast< SdrObject* >(this)->RecalcBoundRect();
- }
-
- return rRectangle;
+ if (isOutRectangleEmpty())
+ const_cast<SdrObject*>(this)->RecalcBoundRect();
+ return getOutRectangle();
}
// To have a possibility to get the last calculated BoundRect e.g for producing
@@ -969,13 +966,12 @@ void SdrObject::RecalcBoundRect()
if (!aRange.isEmpty())
{
- tools::Rectangle aNewRectangle(
- tools::Long(floor(aRange.getMinX())),
- tools::Long(floor(aRange.getMinY())),
- tools::Long(ceil(aRange.getMaxX())),
- tools::Long(ceil(aRange.getMaxY())));
- setOutRectangle(aNewRectangle);
- return;
+ const basegfx::B2DRange aRoundedRange(
+ std::floor(aRange.getMinX()),
+ std::floor(aRange.getMinY()),
+ std::ceil(aRange.getMaxX()),
+ std::ceil(aRange.getMaxY()));
+ m_aOutterRange = gfx::Range2DLWrap::create(aRoundedRange,
getSdrModelFromSdrObject().getUnit());
}
}
@@ -3181,27 +3177,41 @@ void
SdrObject::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygo
const tools::Rectangle& SdrObject::getOutRectangle() const
{
- return m_aOutRect;
+ return m_aOutterRange.toToolsRect();
+}
+
+bool SdrObject::isOutRectangleEmpty() const
+{
+ return getOutRectangle().IsEmpty();
}
void SdrObject::setOutRectangleConst(tools::Rectangle const& rRectangle) const
{
- m_aOutRect = rRectangle;
+ auto eUnit = getSdrModelFromSdrObject().getUnit();
+ m_aOutterRange = gfx::Range2DLWrap::create(rRectangle, eUnit);
}
void SdrObject::setOutRectangle(tools::Rectangle const& rRectangle)
{
- m_aOutRect = rRectangle;
+ auto eUnit = getSdrModelFromSdrObject().getUnit();
+ m_aOutterRange = gfx::Range2DLWrap::create(rRectangle, eUnit);
}
void SdrObject::resetOutRectangle()
{
- m_aOutRect = tools::Rectangle();
+ m_aOutterRange.reset();
}
void SdrObject::moveOutRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta)
{
- m_aOutRect.Move(nXDelta, nYDelta);
+ if (nXDelta == 0 && nYDelta == 0)
+ return;
+
+ auto eUnit = getSdrModelFromSdrObject().getUnit();
+ auto xDelta = gfx::Length::from(eUnit, nXDelta);
+ auto yDelta = gfx::Length::from(eUnit, nYDelta);
+
+ m_aOutterRange.shift(xDelta, yDelta);
}
E3dScene* DynCastE3dScene(SdrObject* pObj)
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index 5fe6ffcb4150..fdcd3ce4e94f 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -1429,16 +1429,11 @@ rtl::Reference<SdrPage> SdrPage::CloneSdrPage(SdrModel&
rTargetModel) const
void SdrPage::setSize(gfx::Size2DLWrap const& rSize)
{
- bool bChanged = false;
-
- if (maSize != rSize)
- {
- maSize = rSize;
- bChanged = true;
- }
+ if (maSize == rSize)
+ return;
- if (bChanged)
- SetChanged();
+ maSize = rSize;
+ SetChanged();
}
void SdrPage::SetOrientation(Orientation eOri)
@@ -1462,6 +1457,14 @@ Orientation SdrPage::GetOrientation() const
return Orientation::Portrait;
}
+void SdrPage::setBorder(svx::Border const& rBorder)
+{
+ if (maBorder == rBorder)
+ return;
+
+ maBorder = rBorder;
+ SetChanged();
+}
void SdrPage::SetBorder(sal_Int32 nLeft, sal_Int32 nUpper, sal_Int32 nRight,
sal_Int32 nLower)
{
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 156f73adc58a..52a45c6e95a4 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -2428,24 +2428,22 @@ void SwDrawVirtObj::NbcSetAnchorPos(const Point& rPnt)
const tools::Rectangle& SwDrawVirtObj::GetCurrentBoundRect() const
{
- if (m_aOutRect.IsEmpty())
- {
+ if (isOutRectangleEmpty())
const_cast<SwDrawVirtObj*>(this)->RecalcBoundRect();
- }
- return m_aOutRect;
+ return getOutRectangle();
}
const tools::Rectangle& SwDrawVirtObj::GetLastBoundRect() const
{
- return m_aOutRect;
+ return getOutRectangle();
}
Point SwDrawVirtObj::GetOffset() const
{
// do NOT use IsEmpty() here, there is already a useful offset
// in the position
- if (m_aOutRect == tools::Rectangle())
+ if (getOutRectangle() == tools::Rectangle())
{
return Point();
}
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index 9e2b96ce3118..3095d5a2a6f4 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -559,7 +559,7 @@ void SwVirtFlyDrawObj::SetRect() const
const tools::Rectangle& SwVirtFlyDrawObj::GetCurrentBoundRect() const
{
SetRect();
- return m_aOutRect;
+ return getOutRectangle();
}
const tools::Rectangle& SwVirtFlyDrawObj::GetLastBoundRect() const
@@ -580,7 +580,7 @@ void SwVirtFlyDrawObj::RecalcSnapRect()
const tools::Rectangle& SwVirtFlyDrawObj::GetSnapRect() const
{
SetRect();
- return m_aOutRect;
+ return getOutRectangle();
}
void SwVirtFlyDrawObj::SetSnapRect(const tools::Rectangle& )
@@ -601,7 +601,7 @@ void SwVirtFlyDrawObj::NbcSetSnapRect(const
tools::Rectangle& )
const tools::Rectangle& SwVirtFlyDrawObj::GetLogicRect() const
{
SetRect();
- return m_aOutRect;
+ return getOutRectangle();
}
void SwVirtFlyDrawObj::SetLogicRect(const tools::Rectangle& )