summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-02-09 10:03:43 +0900
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2024-02-06 13:29:22 +0900
commit44a2ca44c7cfcd8f2a60f18d64b37bad4f28a124 (patch)
tree7c8334fe190277500515080392b13041aa1a1966
parentuse Range2DLWrap for "OutRectangle" in SdrObject (diff)
downloadcore-44a2ca44c7cfcd8f2a60f18d64b37bad4f28a124.tar.gz
core-44a2ca44c7cfcd8f2a60f18d64b37bad4f28a124.zip
use Range2DLWrap for the main rectangle in SdrTextObject
Change-Id: I0d8ac090f9442fe561b4f87aa767185a987874c4
-rw-r--r--include/svx/svdotext.hxx26
-rw-r--r--svx/source/svdraw/svdocirc.cxx10
-rw-r--r--svx/source/svdraw/svdotext.cxx4
-rw-r--r--svx/source/svdraw/svdotxtr.cxx34
-rw-r--r--svx/source/table/svdotable.cxx2
5 files changed, 45 insertions, 31 deletions
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index 84aea85fdeff..e6437198830d 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>
@@ -166,31 +167,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 becc496c76f1..deafa116328d 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -706,8 +706,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
nStartAngle=pU->nStart;
nEndAngle=pU->nEnd;
SetBoundRectDirty();
@@ -1048,8 +1049,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 cc8846504752..f6133f30464e 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 cde62097f490..1d1336e856d6 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)
{
- setRectangle(rRect);
- ImpJustifyRect(maRectangle);
+ tools::Rectangle aRectangle(rRect);
+ ImpJustifyRect(aRectangle);
+ setRectangle(aRectangle);
AdaptTextMinSize();
@@ -126,7 +127,7 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract
setRectangle(aRectangle);
if (bYMirr)
{
- maRectangle.Normalize();
+ //maRectangle.Normalize();
moveRectangle(aRectangle.Right() - aRectangle.Left(), aRectangle.Bottom() - aRectangle.Top());
maGeo.m_nRotationAngle=18000_deg100;
maGeo.RecalcSinCos();
@@ -174,8 +175,6 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract
}
}
- ImpJustifyRect(maRectangle);
-
AdaptTextMinSize();
if(mbTextFrame && !getSdrModelFromSdrObject().IsPasteResize())
@@ -190,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) {
@@ -215,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();
@@ -245,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++) {
@@ -279,7 +280,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 63eeeae7d037..50ea1652d6a6 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;