diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2022-07-28 15:18:15 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2022-07-29 20:48:49 +0200 |
commit | ce2003a672c410e9cd47bb6580688eee57165d7c (patch) | |
tree | 02a3125a65f4d5d1c1449e4e70f6fe3e288a8b61 /svx | |
parent | f1436b235c02a4bfda001208cbe712c2b457acfa (diff) |
svx: manipulate SdrObject::m_aOutRect indirectly
Change-Id: I0d8a8e4df06595250c07a61181fbd76fe1da5662
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137571
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdoashp.cxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdobj.cxx | 160 | ||||
-rw-r--r-- | svx/source/svdraw/svdocirc.cxx | 8 | ||||
-rw-r--r-- | svx/source/svdraw/svdoedge.cxx | 19 | ||||
-rw-r--r-- | svx/source/svdraw/svdogrp.cxx | 24 | ||||
-rw-r--r-- | svx/source/svdraw/svdopage.cxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdotxtr.cxx | 8 | ||||
-rw-r--r-- | svx/source/svdraw/svdovirt.cxx | 15 |
8 files changed, 153 insertions, 85 deletions
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 640b8abf547c..7cd102252b60 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -2034,7 +2034,7 @@ void SdrObjCustomShape::DragMoveCustomShapeHdl( const Point& rDestination, sal_Int32 nYDiff = aPt.Y - aInteractionHandle.aPosition.Y; maRect.Move( nXDiff, nYDiff ); - m_aOutRect.Move( nXDiff, nYDiff ); + moveOutRectangle(nXDiff, nYDiff); maSnapRect.Move( nXDiff, nYDiff ); SetBoundAndSnapRectsDirty(/*bNotMyself*/true); InvalidateRenderGeometry(); diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index d503d68009ef..585988077edc 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -1382,23 +1382,26 @@ bool SdrObject::BegCreate(SdrDragStat& rStat) tools::Rectangle aRect1(rStat.GetStart(), rStat.GetNow()); aRect1.Justify(); rStat.SetActionRect(aRect1); - m_aOutRect = aRect1; + setOutRectangle(aRect1); return true; } bool SdrObject::MovCreate(SdrDragStat& rStat) { - rStat.TakeCreateRect(m_aOutRect); - rStat.SetActionRect(m_aOutRect); - m_aOutRect.Justify(); - + tools::Rectangle aRectangle; + rStat.TakeCreateRect(aRectangle); + rStat.SetActionRect(aRectangle); + aRectangle.Justify(); + setOutRectangle(aRectangle); return true; } bool SdrObject::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) { - rStat.TakeCreateRect(m_aOutRect); - m_aOutRect.Justify(); + tools::Rectangle aRectangle; + rStat.TakeCreateRect(aRectangle); + aRectangle.Justify(); + setOutRectangle(aRectangle); return (eCmd==SdrCreateCmd::ForceEnd || rStat.GetPointCount()>=2); } @@ -1429,9 +1432,9 @@ PointerStyle SdrObject::GetCreatePointer() const } // transformations -void SdrObject::NbcMove(const Size& rSiz) +void SdrObject::NbcMove(const Size& rSize) { - m_aOutRect.Move(rSiz); + moveOutRectangle(rSize.Width(), rSize.Height()); SetBoundAndSnapRectsDirty(); } @@ -1452,7 +1455,10 @@ void SdrObject::NbcResize(const Point& rRef, const Fraction& xFact, const Fracti NbcMirrorGluePoints(aRef1,aRef2); } } - ResizeRect(m_aOutRect,rRef,xFact,yFact); + auto aRectangle = getOutRectangle(); + ResizeRect(aRectangle, rRef, xFact, yFact); + setOutRectangle(aRectangle); + SetBoundAndSnapRectsDirty(); } @@ -1465,60 +1471,85 @@ void SdrObject::NbcRotate(const Point& rRef, Degree100 nAngle) } } -void SdrObject::NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) +namespace { - SetGlueReallyAbsolute(true); - m_aOutRect.Move(-rRef.X(),-rRef.Y()); - tools::Rectangle R(m_aOutRect); + +tools::Rectangle lclRotateRectangle(tools::Rectangle const& rRectangle, Point const& rRef, double sn, double cs) +{ + tools::Rectangle aRectangle(rRectangle); + aRectangle.Move(-rRef.X(),-rRef.Y()); + tools::Rectangle R(aRectangle); if (sn==1.0 && cs==0.0) { // 90deg - m_aOutRect.SetLeft(-R.Bottom() ); - m_aOutRect.SetRight(-R.Top() ); - m_aOutRect.SetTop(R.Left() ); - m_aOutRect.SetBottom(R.Right() ); + aRectangle.SetLeft(-R.Bottom() ); + aRectangle.SetRight(-R.Top() ); + aRectangle.SetTop(R.Left() ); + aRectangle.SetBottom(R.Right() ); } else if (sn==0.0 && cs==-1.0) { // 180deg - m_aOutRect.SetLeft(-R.Right() ); - m_aOutRect.SetRight(-R.Left() ); - m_aOutRect.SetTop(-R.Bottom() ); - m_aOutRect.SetBottom(-R.Top() ); + aRectangle.SetLeft(-R.Right() ); + aRectangle.SetRight(-R.Left() ); + aRectangle.SetTop(-R.Bottom() ); + aRectangle.SetBottom(-R.Top() ); } else if (sn==-1.0 && cs==0.0) { // 270deg - m_aOutRect.SetLeft(R.Top() ); - m_aOutRect.SetRight(R.Bottom() ); - m_aOutRect.SetTop(-R.Right() ); - m_aOutRect.SetBottom(-R.Left() ); + aRectangle.SetLeft(R.Top() ); + aRectangle.SetRight(R.Bottom() ); + aRectangle.SetTop(-R.Right() ); + aRectangle.SetBottom(-R.Left() ); } - m_aOutRect.Move(rRef.X(),rRef.Y()); - m_aOutRect.Justify(); // just in case - SetBoundAndSnapRectsDirty(); - NbcRotateGluePoints(rRef,nAngle,sn,cs); - SetGlueReallyAbsolute(false); + aRectangle.Move(rRef.X(),rRef.Y()); + aRectangle.Justify(); // just in case + return aRectangle; } -void SdrObject::NbcMirror(const Point& rRef1, const Point& rRef2) +tools::Rectangle lclMirrorRectangle(tools::Rectangle const& rRectangle, Point const& rRef1, Point const& rRef2) { - SetGlueReallyAbsolute(true); - m_aOutRect.Move(-rRef1.X(),-rRef1.Y()); - tools::Rectangle R(m_aOutRect); + tools::Rectangle aRectangle(rRectangle); + aRectangle.Move(-rRef1.X(),-rRef1.Y()); + tools::Rectangle R(aRectangle); tools::Long dx=rRef2.X()-rRef1.X(); tools::Long dy=rRef2.Y()-rRef1.Y(); if (dx==0) { // vertical axis - m_aOutRect.SetLeft(-R.Right() ); - m_aOutRect.SetRight(-R.Left() ); + aRectangle.SetLeft(-R.Right() ); + aRectangle.SetRight(-R.Left() ); } else if (dy==0) { // horizontal axis - m_aOutRect.SetTop(-R.Bottom() ); - m_aOutRect.SetBottom(-R.Top() ); + aRectangle.SetTop(-R.Bottom() ); + aRectangle.SetBottom(-R.Top() ); } else if (dx==dy) { // 45deg axis - m_aOutRect.SetLeft(R.Top() ); - m_aOutRect.SetRight(R.Bottom() ); - m_aOutRect.SetTop(R.Left() ); - m_aOutRect.SetBottom(R.Right() ); + aRectangle.SetLeft(R.Top() ); + aRectangle.SetRight(R.Bottom() ); + aRectangle.SetTop(R.Left() ); + aRectangle.SetBottom(R.Right() ); } else if (dx==-dy) { // 45deg axis - m_aOutRect.SetLeft(-R.Bottom() ); - m_aOutRect.SetRight(-R.Top() ); - m_aOutRect.SetTop(-R.Right() ); - m_aOutRect.SetBottom(-R.Left() ); + aRectangle.SetLeft(-R.Bottom() ); + aRectangle.SetRight(-R.Top() ); + aRectangle.SetTop(-R.Right() ); + aRectangle.SetBottom(-R.Left() ); } - m_aOutRect.Move(rRef1.X(),rRef1.Y()); - m_aOutRect.Justify(); // just in case + aRectangle.Move(rRef1.X(),rRef1.Y()); + aRectangle.Justify(); // just in case + return aRectangle; +} + +} // end anonymous namespace + +void SdrObject::NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) +{ + SetGlueReallyAbsolute(true); + tools::Rectangle aRectangle = getOutRectangle(); + aRectangle = lclRotateRectangle(aRectangle, rRef, sn, cs); + setOutRectangle(aRectangle); + SetBoundAndSnapRectsDirty(); + NbcRotateGluePoints(rRef, nAngle, sn, cs); + SetGlueReallyAbsolute(false); +} + +void SdrObject::NbcMirror(const Point& rRef1, const Point& rRef2) +{ + SetGlueReallyAbsolute(true); + + tools::Rectangle aRectangle = getOutRectangle(); + aRectangle = lclMirrorRectangle(aRectangle, rRef1, rRef2); + setOutRectangle(aRectangle); + SetBoundAndSnapRectsDirty(); NbcMirrorGluePoints(rRef1,rRef2); SetGlueReallyAbsolute(false); @@ -1669,7 +1700,7 @@ const tools::Rectangle& SdrObject::GetSnapRect() const void SdrObject::NbcSetSnapRect(const tools::Rectangle& rRect) { - m_aOutRect=rRect; + setOutRectangle(rRect); } const tools::Rectangle& SdrObject::GetLogicRect() const @@ -1780,7 +1811,7 @@ void SdrObject::dumpAsXml(xmlTextWriterPtr pWriter) const (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("title"), "%s", BAD_CAST(GetTitle().toUtf8().getStr())); (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("description"), "%s", BAD_CAST(GetDescription().toUtf8().getStr())); (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("nOrdNum"), "%" SAL_PRIuUINT32, GetOrdNumDirect()); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("aOutRect"), BAD_CAST(m_aOutRect.toString().getStr())); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("aOutRect"), BAD_CAST(getOutRectangle().toString().getStr())); if (m_pGrabBagItem) { @@ -1926,7 +1957,7 @@ void SdrObject::SaveGeoData(SdrObjGeoData& rGeo) const void SdrObject::RestoreGeoData(const SdrObjGeoData& rGeo) { SetBoundAndSnapRectsDirty(); - m_aOutRect =rGeo.aBoundRect ; + setOutRectangle(rGeo.aBoundRect); m_aAnchor =rGeo.aAnchor ; m_bMovProt =rGeo.bMovProt ; m_bSizProt =rGeo.bSizProt ; @@ -3191,6 +3222,31 @@ void SdrObject::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygo } } +tools::Rectangle SdrObject::getOutRectangle() const +{ + return m_aOutRect; +} + +void SdrObject::setOutRectangleConst(tools::Rectangle const& rRectangle) const +{ + m_aOutRect = rRectangle; +} + +void SdrObject::setOutRectangle(tools::Rectangle const& rRectangle) +{ + m_aOutRect = rRectangle; +} + +void SdrObject::resetOutRectangle() +{ + m_aOutRect = tools::Rectangle(); +} + +void SdrObject::moveOutRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta) +{ + m_aOutRect.Move(nXDelta, nYDelta); +} + SdrObject* SdrObjFactory::CreateObjectFromFactory(SdrModel& rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier) { SdrObjCreatorParams aParams { nInventor, nObjIdentifier, rSdrModel }; diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx index 0204b2c2effe..bf253ceeee39 100644 --- a/svx/source/svdraw/svdocirc.cxx +++ b/svx/source/svdraw/svdocirc.cxx @@ -807,11 +807,11 @@ PointerStyle SdrCircObj::GetCreatePointer() const return PointerStyle::Cross; } -void SdrCircObj::NbcMove(const Size& aSiz) +void SdrCircObj::NbcMove(const Size& aSize) { - maRect.Move(aSiz); - m_aOutRect.Move(aSiz); - maSnapRect.Move(aSiz); + maRect.Move(aSize); + moveOutRectangle(aSize.Width(), aSize.Height()); + maSnapRect.Move(aSize); SetXPolyDirty(); SetBoundAndSnapRectsDirty(true); } diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx index 769a720c3339..92a5829af2c0 100644 --- a/svx/source/svdraw/svdoedge.cxx +++ b/svx/source/svdraw/svdoedge.cxx @@ -729,10 +729,13 @@ XPolygon SdrEdgeObj::ImpCalcEdgeTrack(const XPolygon& rTrack0, SdrObjConnection& sal_uInt16 nSiz=rTrack0.GetPointCount(); nSiz--; aPt2=rTrack0[nSiz]; - } else { - if (!m_aOutRect.IsEmpty()) { - aPt1=m_aOutRect.TopLeft(); - aPt2=m_aOutRect.BottomRight(); + } + else + { + auto aRectangle = getOutRectangle(); + if (!aRectangle.IsEmpty()) { + aPt1 = aRectangle.TopLeft(); + aPt2 = aRectangle.BottomRight(); } } @@ -746,7 +749,7 @@ XPolygon SdrEdgeObj::ImpCalcEdgeTrack(const XPolygon& rTrack0, SdrObjConnection& if (rCon1.pObj==static_cast<SdrObject const *>(this)) { // check, just in case - aBoundRect1=m_aOutRect; + aBoundRect1 = getOutRectangle(); } else { @@ -773,7 +776,7 @@ XPolygon SdrEdgeObj::ImpCalcEdgeTrack(const XPolygon& rTrack0, SdrObjConnection& { if (rCon2.pObj==static_cast<SdrObject const *>(this)) { // check, just in case - aBoundRect2=m_aOutRect; + aBoundRect2 = getOutRectangle(); } else { @@ -2539,9 +2542,9 @@ Point SdrEdgeObj::GetTailPoint( bool bTail ) const else { if(bTail) - return m_aOutRect.TopLeft(); + return getOutRectangle().TopLeft(); else - return m_aOutRect.BottomRight(); + return getOutRectangle().BottomRight(); } } diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx index 7fc8e0b12f80..d71ff03e1051 100644 --- a/svx/source/svdraw/svdogrp.cxx +++ b/svx/source/svdraw/svdogrp.cxx @@ -247,7 +247,7 @@ const tools::Rectangle& SdrObjGroup::GetCurrentBoundRect() const // <aOutRect> has to contain the bounding rectangle if(0 != GetObjCount()) { - m_aOutRect = GetAllObjBoundRect(); + setOutRectangleConst(GetAllObjBoundRect()); } return m_aOutRect; @@ -324,7 +324,7 @@ basegfx::B2DPolyPolygon SdrObjGroup::TakeXorPoly() const if(!aRetval.count()) { - const basegfx::B2DRange aRange = vcl::unotools::b2DRectangleFromRectangle(m_aOutRect); + const basegfx::B2DRange aRange = vcl::unotools::b2DRectangleFromRectangle(getOutRectangle()); aRetval.append(basegfx::utils::createPolygonFromRect(aRange)); } @@ -399,9 +399,9 @@ void SdrObjGroup::NbcSetLogicRect(const tools::Rectangle& rRect) } -void SdrObjGroup::NbcMove(const Size& rSiz) +void SdrObjGroup::NbcMove(const Size& rSize) { - maRefPoint.Move(rSiz); + maRefPoint.Move(rSize); const size_t nObjCount(GetObjCount()); if(0 != nObjCount) @@ -409,12 +409,12 @@ void SdrObjGroup::NbcMove(const Size& rSiz) for (size_t i=0; i<nObjCount; ++i) { SdrObject* pObj(GetObj(i)); - pObj->NbcMove(rSiz); + pObj->NbcMove(rSize); } } else { - m_aOutRect.Move(rSiz); + moveOutRectangle(rSize.Width(), rSize.Height()); SetBoundAndSnapRectsDirty(); } } @@ -451,7 +451,10 @@ void SdrObjGroup::NbcResize(const Point& rRef, const Fraction& xFact, const Frac } else { - ResizeRect(m_aOutRect,rRef,xFact,yFact); + auto aRectangle = getOutRectangle(); + ResizeRect(aRectangle, rRef, xFact, yFact); + setOutRectangle(aRectangle); + SetBoundAndSnapRectsDirty(); } } @@ -591,7 +594,7 @@ void SdrObjGroup::Move(const Size& rSiz) } else { - m_aOutRect.Move(rSiz); + moveOutRectangle(rSiz.Width(), rSiz.Height()); SetBoundAndSnapRectsDirty(); } @@ -644,7 +647,10 @@ void SdrObjGroup::Resize(const Point& rRef, const Fraction& xFact, const Fractio } else { - ResizeRect(m_aOutRect,rRef,xFact,yFact); + auto aRectangle = getOutRectangle(); + ResizeRect(aRectangle, rRef, xFact, yFact); + setOutRectangle(aRectangle); + SetBoundAndSnapRectsDirty(); } diff --git a/svx/source/svdraw/svdopage.cxx b/svx/source/svdraw/svdopage.cxx index 67c7a104e2f5..800102aba2c9 100644 --- a/svx/source/svdraw/svdopage.cxx +++ b/svx/source/svdraw/svdopage.cxx @@ -89,7 +89,7 @@ SdrPageObj::SdrPageObj( mpShownPage->AddPageUser(*this); } - m_aOutRect = rRect; + setOutRectangle(rRect); } SdrPageObj::~SdrPageObj() diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx index a9b2a6dbf476..7d1a54433dad 100644 --- a/svx/source/svdraw/svdotxtr.cxx +++ b/svx/source/svdraw/svdotxtr.cxx @@ -91,11 +91,11 @@ Degree100 SdrTextObj::GetShearAngle(bool /*bVertical*/) const return maGeo.nShearAngle; } -void SdrTextObj::NbcMove(const Size& rSiz) +void SdrTextObj::NbcMove(const Size& rSize) { - maRect.Move(rSiz); - m_aOutRect.Move(rSiz); - maSnapRect.Move(rSiz); + maRect.Move(rSize); + moveOutRectangle(rSize.Width(), rSize.Height()); + maSnapRect.Move(rSize); SetBoundAndSnapRectsDirty(true); } diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx index 7d68e4840ff9..f43e1d554be8 100644 --- a/svx/source/svdraw/svdovirt.cxx +++ b/svx/source/svdraw/svdovirt.cxx @@ -113,22 +113,25 @@ SdrObjList* SdrVirtObj::GetSubList() const const tools::Rectangle& SdrVirtObj::GetCurrentBoundRect() const { - m_aOutRect = rRefObj.GetCurrentBoundRect(); // TODO: Optimize this. - m_aOutRect += m_aAnchor; + auto aRectangle = rRefObj.GetCurrentBoundRect(); // TODO: Optimize this. + aRectangle += m_aAnchor; + setOutRectangleConst(aRectangle); return m_aOutRect; } const tools::Rectangle& SdrVirtObj::GetLastBoundRect() const { - m_aOutRect = rRefObj.GetLastBoundRect(); // TODO: Optimize this. - m_aOutRect += m_aAnchor; + auto aRectangle = rRefObj.GetLastBoundRect(); // TODO: Optimize this. + aRectangle += m_aAnchor; + setOutRectangleConst(aRectangle); return m_aOutRect; } void SdrVirtObj::RecalcBoundRect() { - m_aOutRect=rRefObj.GetCurrentBoundRect(); - m_aOutRect+=m_aAnchor; + tools::Rectangle aRectangle = rRefObj.GetCurrentBoundRect(); + aRectangle += m_aAnchor; + setOutRectangle(aRectangle); } SdrVirtObj* SdrVirtObj::CloneSdrObject(SdrModel& rTargetModel) const |