include/svx/svdotext.hxx | 26 ++++++++++++++++++++------ svx/source/svdraw/svdocirc.cxx | 10 ++++++---- svx/source/svdraw/svdotext.cxx | 4 +--- svx/source/svdraw/svdotxtr.cxx | 33 ++++++++++++++++----------------- svx/source/table/svdotable.cxx | 2 +- 5 files changed, 44 insertions(+), 31 deletions(-)
New commits: commit 760a1f5d9fe762399950e7468fc8418e2c88e588 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Feb 9 10:03:43 2023 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Sat May 31 09:49:44 2025 +0200 use Range2DLWrap for the main rectangle in SdrTextObject Change-Id: I0d8ac090f9442fe561b4f87aa767185a987874c4 diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index dea64305df03..5296dbc01ccc 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -29,6 +29,7 @@ #include <tools/datetime.hxx> #include <svl/style.hxx> #include <svx/svdtext.hxx> +#include <svx/svdmodel.hxx> #include <svx/svxdllapi.h> #include <drawinglayer/primitive2d/Primitive2DContainer.hxx> #include <memory> @@ -177,31 +178,44 @@ 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::Range2DLWrap maRectangleRange; tools::Rectangle const& getRectangle() const { - return maRectangle; + return maRectangleRange.toToolsRect(); } void setRectangle(tools::Rectangle const& rRectangle) { - maRectangle = rRectangle; + auto eUnit = getSdrModelFromSdrObject().getUnit(); + maRectangleRange = gfx::Range2DLWrap::create(rRectangle, eUnit); } void setRectangleSize(sal_Int32 nWidth, sal_Int32 nHeight) { - maRectangle.SetSize(Size(nWidth, nHeight)); + auto eUnit = getSdrModelFromSdrObject().getUnit(); + auto width = gfx::Length::from(eUnit, nWidth); + auto height = gfx::Length::from(eUnit, nHeight); + maRectangleRange.setSize(width, height); } void moveRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta) { - maRectangle.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); + maRectangleRange.shift(xDelta, yDelta); } void moveRectanglePosition(sal_Int32 nX, sal_Int32 nY) { - maRectangle.SetPos(Point(nX, nY)); + auto eUnit = getSdrModelFromSdrObject().getUnit(); + auto x = gfx::Length::from(eUnit, nX); + auto y = gfx::Length::from(eUnit, nY); + maRectangleRange.setPosition(x, y); } // The GeoStat contains the rotation and shear angles diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx index eed36dbc71c1..f88a53e989c9 100644 --- a/svx/source/svdraw/svdocirc.cxx +++ b/svx/source/svdraw/svdocirc.cxx @@ -707,8 +707,9 @@ bool SdrCircObj::MovCreate(SdrDragStat& rStat) ImpSetCreateParams(rStat); ImpCircUser* pU=static_cast<ImpCircUser*>(rStat.GetUser()); rStat.SetActionRect(pU->aR); - setRectangle(pU->aR); // for ObjName - ImpJustifyRect(maRectangle); + auto aRectangle = pU->aR; + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); // for ObjName m_nStartAngle=pU->nStart; m_nEndAngle=pU->nEnd; SetBoundRectDirty(); @@ -1051,8 +1052,9 @@ 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 { - setRectangle(rRect); - ImpJustifyRect(maRectangle); + tools::Rectangle aRectangle(rRect); + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); } SetBoundAndSnapRectsDirty(); SetXPolyDirty(); diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 50f283cfb944..4a1e578bb65b 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -104,7 +104,7 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrTextObj const & rSource) // #i25616# mbSupportTextIndentingOnLineWidthChange = true; - maRectangle = rSource.maRectangle; + maRectangleRange = rSource.maRectangleRange; maGeo = rSource.maGeo; maTextSize = rSource.maTextSize; @@ -204,8 +204,6 @@ SdrTextObj::~SdrTextObj() void SdrTextObj::FitFrameToTextSize() { - ImpJustifyRect(maRectangle); - SdrText* pText = getActiveText(); if(pText==nullptr || !pText->GetOutlinerParaObject()) return; diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx index 0380a691cbe0..30e3d7264e35 100644 --- a/svx/source/svdraw/svdotxtr.cxx +++ b/svx/source/svdraw/svdotxtr.cxx @@ -56,9 +56,9 @@ void SdrTextObj::NbcSetSnapRect(const tools::Rectangle& rRect) else { // No rotation or shear. - - setRectangle(rRect); - ImpJustifyRect(maRectangle); + tools::Rectangle aRectangle(rRect); + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); AdaptTextMinSize(); @@ -74,8 +74,9 @@ const tools::Rectangle& SdrTextObj::GetLogicRect() const void SdrTextObj::NbcSetLogicRect(const tools::Rectangle& rRect, bool bAdaptTextMinSize) { - setRectangle(rRect); - ImpJustifyRect(maRectangle); + tools::Rectangle aRectangle(rRect); + ImpJustifyRect(aRectangle); + setRectangle(aRectangle); if (bAdaptTextMinSize) AdaptTextMinSize(); @@ -127,7 +128,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.m_nRotationAngle=18000_deg100; maGeo.RecalcSinCos(); @@ -175,8 +175,6 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract } } - ImpJustifyRect(maRectangle); - AdaptTextMinSize(); if(mbTextFrame && !getSdrModelFromSdrObject().IsPasteResize()) @@ -191,12 +189,13 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract void SdrTextObj::NbcRotate(const Point& rRef, Degree100 nAngle, double sn, double cs) { SetGlueReallyAbsolute(true); - tools::Long dx = getRectangle().Right() - getRectangle().Left(); - tools::Long dy = getRectangle().Bottom() - getRectangle().Top(); - Point aPoint1(getRectangle().TopLeft()); + tools::Rectangle aRectangle = getRectangle(); + tools::Long dx = aRectangle.Right() - aRectangle.Left(); + tools::Long dy = aRectangle.Bottom() - aRectangle.Top(); + Point aPoint1(aRectangle.TopLeft()); RotatePoint(aPoint1, rRef, sn, cs); Point aPoint2(aPoint1.X() + dx, aPoint1.Y() + dy); - tools::Rectangle aRectangle(aPoint1, aPoint2); + aRectangle = tools::Rectangle(aPoint1, aPoint2); setRectangle(aRectangle); if (maGeo.m_nRotationAngle==0_deg100) { @@ -216,16 +215,17 @@ void SdrTextObj::NbcShear(const Point& rRef, Degree100 /*nAngle*/, double tn, bo { SetGlueReallyAbsolute(true); + auto aRectangle = getRectangle(); // when this is a SdrPathObj, aRect may be uninitialized - tools::Polygon aPol(Rect2Poly(getRectangle().IsEmpty() ? GetSnapRect() : getRectangle(), maGeo)); + tools::Polygon aPol(Rect2Poly(aRectangle.IsEmpty() ? GetSnapRect() : aRectangle, maGeo)); sal_uInt16 nPointCount=aPol.GetSize(); for (sal_uInt16 i=0; i<nPointCount; i++) { ShearPoint(aPol[i],rRef,tn,bVShear); } - tools::Rectangle aRectangle = svx::polygonToRectangle(aPol, maGeo); + aRectangle = svx::polygonToRectangle(aPol, maGeo); + ImpJustifyRect(aRectangle); setRectangle(aRectangle); - ImpJustifyRect(maRectangle); if (mbTextFrame) { NbcAdjustTextFrameWidthAndHeight(); @@ -246,7 +246,7 @@ void SdrTextObj::NbcMirror(const Point& rRef1, const Point& rRef2) std::abs(rRef1.X()-rRef2.X())==std::abs(rRef1.Y()-rRef2.Y()))) { bRotate90=maGeo.m_nRotationAngle.get() % 9000 ==0; } - tools::Polygon aPol(Rect2Poly(getRectangle(),maGeo)); + tools::Polygon aPol(Rect2Poly(getRectangle(), maGeo)); sal_uInt16 i; sal_uInt16 nPointCount=aPol.GetSize(); for (i=0; i<nPointCount; i++) { @@ -281,7 +281,6 @@ void SdrTextObj::NbcMirror(const Point& rRef1, const Point& rRef2) maGeo.RecalcTan(); } - ImpJustifyRect(maRectangle); if (mbTextFrame) { NbcAdjustTextFrameWidthAndHeight(); } diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 974b06c30219..e07dfc66f998 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -842,7 +842,7 @@ SdrTableObj::SdrTableObj(SdrModel& rSdrModel, SdrTableObj const & rSource) TableModelNotifyGuard aGuard( mpImpl.is() ? mpImpl->mxTable.get() : nullptr ); maLogicRect = rSource.maLogicRect; - maRectangle = rSource.maRectangle; + maRectangleRange = rSource.maRectangleRange; maGeo = rSource.maGeo; meTextKind = rSource.meTextKind; mbTextFrame = rSource.mbTextFrame;