Rebased ref, commits from common ancestor:
commit 624b1929804446c5da04a27dd668d82325422c8b
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Wed Jun 11 21:26:18 2025 +0200
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sun Nov 2 14:37:10 2025 +0900
svx: convert SnapRect to SnapRange which uses gfx::Range2DLWrap
Change-Id: Ib84b6a95847742e14f2b35b3b77e3731f0187542
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 1680321e5ca5..43cd25e39839 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -551,6 +551,12 @@ public:
/// SetSnapRect() tries to size the Object so that it fits into the
/// passed Rect (without stroke width, ...)
virtual void RecalcSnapRect();
+
+ virtual const gfx::Range2DL& getSnapRange() const
+ {
+ return m_aOutterRange;
+ }
+
virtual const tools::Rectangle& GetSnapRect() const;
virtual void SetSnapRect(const tools::Rectangle& rRect);
virtual void NbcSetSnapRect(const tools::Rectangle& rRect);
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 5203c18d8272..1734dde6a289 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -33,6 +33,7 @@
#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <basegfx/units/Range2DLWrap.hxx>
+#include <basegfx/units/Tuple2DLWrap.hxx>
#include <basegfx/units/LengthTypes.hxx>
#include <basegfx/range/b2drange.hxx>
#include <drawinglayer/processor2d/contourextractor2d.hxx>
@@ -2348,16 +2349,40 @@ SdrGluePoint SdrObject::GetVertexGluePoint(sal_uInt16
nPosNum) const
SdrGluePoint SdrObject::GetCornerGluePoint(sal_uInt16 nPosNum) const
{
- tools::Rectangle aR(GetCurrentBoundRect());
- Point aPt;
- switch (nPosNum) {
- case 0 : aPt=aR.TopLeft(); break;
- case 1 : aPt=aR.TopRight(); break;
- case 2 : aPt=aR.BottomRight(); break;
- case 3 : aPt=aR.BottomLeft(); break;
+ auto const& rCurrentBoundRange = getCurrentBoundRange();
+
+ gfx::Length x;
+ gfx::Length y;
+
+ switch (nPosNum)
+ {
+ case 0:
+ x = rCurrentBoundRange.getMinX();
+ y = rCurrentBoundRange.getMinY();
+ break;
+
+ case 1:
+ x = rCurrentBoundRange.getMaxX();
+ y = rCurrentBoundRange.getMinY();
+ break;
+ case 2:
+ x = rCurrentBoundRange.getMaxX();
+ y = rCurrentBoundRange.getMaxY();
+ break;
+ case 3:
+ x = rCurrentBoundRange.getMinX();
+ y = rCurrentBoundRange.getMaxY();
+ break;
}
- aPt-=GetSnapRect().Center();
- SdrGluePoint aGP(aPt);
+
+ x -= getSnapRange().getCenterX();
+ y -= getSnapRange().getCenterY();
+
+ auto eUnit = getSdrModelFromSdrObject().getUnit();
+ gfx::Tuple2DLWrap aTuple2D(x, y, eUnit);
+
+ // TODO
+ SdrGluePoint aGP(aTuple2D.toPoint());
aGP.SetPercent(false);
return aGP;
}
commit 3c47d566c0fa6461dba21a584291550d2e68cb80
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Sun Jun 8 23:02:06 2025 +0200
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sun Nov 2 14:37:10 2025 +0900
basegfx: change getCenter{X,Y} use type defined in Traits
BaseRange, Range2D should use the type for center defined in
Traits, so we can make center using the type we want. In case of
integers and doubles this can just be double, but for gfx::Length
it should keep being gfx::Length.
Change-Id: I13edbcc745e46304c4a0742b2addaf87cf4183a2
diff --git a/basegfx/test/LengthUnitTest.cxx b/basegfx/test/LengthUnitTest.cxx
index b8e0c10a0999..f7ea153a810e 100644
--- a/basegfx/test/LengthUnitTest.cxx
+++ b/basegfx/test/LengthUnitTest.cxx
@@ -498,8 +498,28 @@ class Range2DLTest : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL(2_cm, aRange.getMaxY());
}
+ void testCenter()
+ {
+ {
+ gfx::Range2DL aRange(1_cm, 2_cm, 1_cm, 2_cm);
+ CPPUNIT_ASSERT_EQUAL(1_cm, aRange.getCenterX());
+ CPPUNIT_ASSERT_EQUAL(2_cm, aRange.getCenterY());
+ }
+ {
+ gfx::Range2DL aRange(-1_cm, -2_cm, 1_cm, 2_cm);
+ CPPUNIT_ASSERT_EQUAL(0_cm, aRange.getCenterX());
+ CPPUNIT_ASSERT_EQUAL(0_cm, aRange.getCenterY());
+ }
+ {
+ gfx::Range2DL aRange(1_cm, 1_cm, 2_cm, 5_cm);
+ CPPUNIT_ASSERT_EQUAL(15_mm, aRange.getCenterX()); // center
between 1cm and 2cm
+ CPPUNIT_ASSERT_EQUAL(3_cm, aRange.getCenterY()); // center between
1cm and 5cm
+ }
+ }
+
CPPUNIT_TEST_SUITE(Range2DLTest);
CPPUNIT_TEST(testInRange);
+ CPPUNIT_TEST(testCenter);
CPPUNIT_TEST_SUITE_END();
};
diff --git a/include/basegfx/range/Range2D.hxx
b/include/basegfx/range/Range2D.hxx
index 478a69dd8d01..c1a7804d3887 100644
--- a/include/basegfx/range/Range2D.hxx
+++ b/include/basegfx/range/Range2D.hxx
@@ -108,10 +108,10 @@ public:
TYPE getHeight() const { return maRangeY.getRange(); }
/// return center X value of set. returns 0 for empty sets.
- double getCenterX() const { return maRangeX.getCenter(); }
+ TRAITS::CenterType getCenterX() const { return maRangeX.getCenter(); }
/// return center Y value of set. returns 0 for empty sets.
- double getCenterY() const { return maRangeY.getCenter(); }
+ TRAITS::CenterType getCenterY() const { return maRangeY.getCenter(); }
/// yields true if given point is contained in set
bool isInside(const Tuple2D<TYPE>& rTuple) const
diff --git a/include/basegfx/range/basicrange.hxx
b/include/basegfx/range/basicrange.hxx
index 30595f431741..6b68e6185cf5 100644
--- a/include/basegfx/range/basicrange.hxx
+++ b/include/basegfx/range/basicrange.hxx
@@ -22,7 +22,7 @@
#include <sal/types.h>
#include <float.h>
#include <basegfx/numeric/ftools.hxx>
-
+#include <o3tl/concepts.hxx>
namespace basegfx
{
@@ -62,16 +62,12 @@ namespace basegfx
T getMinimum() const { return mnMinimum; }
T getMaximum() const { return mnMaximum; }
- double getCenter() const
+ Traits::CenterType getCenter() const
{
- if(isEmpty())
- {
- return 0.0;
- }
- else
- {
- return ((mnMaximum + mnMinimum) / 2.0);
- }
+ if (isEmpty())
+ return Traits::neutral();
+
+ return (mnMaximum + mnMinimum) / 2.0;
}
bool isInside(T nValue) const
@@ -334,6 +330,7 @@ namespace basegfx
static constexpr double neutral() { return 0.0; };
typedef double DifferenceType;
+ typedef double CenterType;
};
struct Int32Traits
@@ -343,6 +340,7 @@ namespace basegfx
static constexpr sal_Int32 neutral() { return 0; };
typedef sal_Int64 DifferenceType;
+ typedef double CenterType;
};
} // end of namespace basegfx
diff --git a/include/basegfx/units/Length.hxx b/include/basegfx/units/Length.hxx
index a61787762caf..828e9ec24d79 100644
--- a/include/basegfx/units/Length.hxx
+++ b/include/basegfx/units/Length.hxx
@@ -33,6 +33,7 @@ struct LengthTraits
static constexpr Length neutral() { return Length(); }
typedef Length DifferenceType;
+ typedef Length CenterType;
};
} // end namespace gfx
commit 1e5b68755f5ea5b21ff11901452d364b341e17ba
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Sun Jun 8 12:08:10 2025 +0200
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sun Nov 2 14:37:10 2025 +0900
svx: change SdrTextObj::maTextSize to gfx::Size2DLWrap
Change-Id: I382da7fc4f09f1df21a66ecb36e5930cc9d56d4e
diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx
index fdff7e43d87a..f8b336f163fe 100644
--- a/include/svx/svdomeas.hxx
+++ b/include/svx/svdomeas.hxx
@@ -131,7 +131,7 @@ public:
SAL_DLLPRIVATE virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool
bBezier, bool bAddText) const override;
SAL_DLLPRIVATE virtual bool BegTextEdit(SdrOutliner& rOutl) override;
- SAL_DLLPRIVATE virtual const Size& GetTextSize() const override;
+ SAL_DLLPRIVATE virtual Size GetTextSize() const override;
SAL_DLLPRIVATE virtual void TakeTextRect( SdrOutliner& rOutliner,
tools::Rectangle& rTextRect, bool bNoEditText,
tools::Rectangle* pAnchorRect, bool bLineWidth = true ) const override;
SAL_DLLPRIVATE virtual void TakeTextAnchorRect(tools::Rectangle&
rAnchorRect) const override;
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index ca29164153a3..033e2c4e2eae 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -34,6 +34,7 @@
#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
#include <memory>
#include <vector>
+#include <basegfx/units/Size2DLWrap.hxx>
#include <com/sun/star/drawing/TextFitToSizeType.hpp>
@@ -212,7 +213,12 @@ protected:
rtl::Reference<SdrText> mxText;
// This contains the dimensions of the text
- Size maTextSize;
+ gfx::Size2DLWrap maTextSize;
+ void setTextSize(Size const& rSize)
+ {
+ auto eUnit = getSdrModelFromSdrObject().getUnit();
+ maTextSize = gfx::Size2DLWrap::create(rSize, eUnit);
+ }
// an Outliner*, so that
// 1. the TextObj won't be edited simultaneously by multiple views, and
@@ -405,7 +411,7 @@ public:
void SetText(SvStream& rInput, const OUString& rBaseURL, EETextFormat
eFormat);
// FitToSize and Fontwork are not taken into account in GetTextSize()!
- virtual const Size& GetTextSize() const;
+ virtual Size GetTextSize() const;
void FitFrameToTextSize();
double GetFontScale() const;
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index 218c2ee9985b..38d392d59955 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -603,12 +603,13 @@ void SdrMeasureObj::UndirtyText() const
rOutliner.SetUpdateLayout(true);
rOutliner.UpdateFields();
- Size aSiz(rOutliner.CalcTextSize());
+ Size aSize = rOutliner.CalcTextSize();
rOutliner.Clear();
// cast to nonconst three times
- const_cast<SdrMeasureObj*>(this)->maTextSize = aSiz;
- const_cast<SdrMeasureObj*>(this)->mbTextSizeDirty = false;
- const_cast<SdrMeasureObj*>(this)->m_bTextDirty = false;
+ auto* pThis = const_cast<SdrMeasureObj*>(this);
+ pThis->setTextSize(aSize);
+ pThis->mbTextSizeDirty = false;
+ pThis->m_bTextDirty = false;
}
void SdrMeasureObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const
@@ -1266,9 +1267,10 @@ bool SdrMeasureObj::BegTextEdit(SdrOutliner& rOutl)
return SdrTextObj::BegTextEdit(rOutl);
}
-const Size& SdrMeasureObj::GetTextSize() const
+Size SdrMeasureObj::GetTextSize() const
{
- if (m_bTextDirty) UndirtyText();
+ if (m_bTextDirty)
+ UndirtyText();
return SdrTextObj::GetTextSize();
}
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 49c0799aec72..f3e2abc362b5 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -206,7 +206,7 @@ void SdrTextObj::NbcSetText(SvStream& rInput, const
OUString& rBaseURL, EETextFo
Size aSize(rOutliner.CalcTextSize());
rOutliner.Clear();
NbcSetOutlinerParaObject(std::move(pNewText));
- maTextSize=aSize;
+ setTextSize(aSize);
mbTextSizeDirty=false;
}
@@ -219,25 +219,26 @@ void SdrTextObj::SetText(SvStream& rInput, const
OUString& rBaseURL, EETextForma
SendUserCall(SdrUserCallType::Resize,aBoundRect0);
}
-const Size& SdrTextObj::GetTextSize() const
+Size SdrTextObj::GetTextSize() const
{
if (mbTextSizeDirty)
{
- Size aSiz;
+ Size aSize;
SdrText* pText = getActiveText();
if( pText && pText->GetOutlinerParaObject ())
{
SdrOutliner& rOutliner=ImpGetDrawOutliner();
rOutliner.SetText(*pText->GetOutlinerParaObject());
rOutliner.SetUpdateLayout(true);
- aSiz=rOutliner.CalcTextSize();
+ aSize = rOutliner.CalcTextSize();
rOutliner.Clear();
}
// casting to nonconst twice
- const_cast<SdrTextObj*>(this)->maTextSize = aSiz;
- const_cast<SdrTextObj*>(this)->mbTextSizeDirty = false;
+ auto pThis = const_cast<SdrTextObj*>(this);
+ pThis->setTextSize(aSize);
+ pThis->mbTextSizeDirty = false;
}
- return maTextSize;
+ return maTextSize.toToolsSize();
}
bool SdrTextObj::IsAutoGrowHeight() const
commit 801d00953a335837c3b8d17b72b6b037ebd1faa5
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Tue Feb 21 22:05:02 2023 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sun Nov 2 14:37:10 2025 +0900
svx: change SdrObjGeoData aBoundRectangle using gfx::Range2DLWrap
Change-Id: I13213ea2bdbfc5badb87d1bbd836192b8ae45e72
diff --git a/include/svx/svdgeodata.hxx b/include/svx/svdgeodata.hxx
index 7f5a8b9713a4..c87dacab99a6 100644
--- a/include/svx/svdgeodata.hxx
+++ b/include/svx/svdgeodata.hxx
@@ -23,14 +23,27 @@
#include <svx/svdglue.hxx>
#include <tools/gen.hxx>
#include <optional>
+#include <basegfx/units/Range2DLWrap.hxx>
/**
* All geometrical data of an arbitrary object for use in undo/redo
*/
class SVXCORE_DLLPUBLIC SdrObjGeoData
{
+private:
+ gfx::Range2DLWrap maBoundRange;
+
public:
- tools::Rectangle aBoundRect;
+ gfx::Range2DLWrap const& getBoundRange() const
+ {
+ return maBoundRange;
+ }
+
+ void setBoundRange(gfx::Range2DLWrap const& rRange)
+ {
+ maBoundRange = rRange;
+ }
+
Point aAnchor;
std::optional<SdrGluePointList> moGluePoints;
bool bMovProt;
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 3a47b8ae02c0..1680321e5ca5 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -396,6 +396,7 @@ public:
// non-useful BoundRects sometimes) i rename that method from
GetBoundRect() to
// GetCurrentBoundRect().
virtual const tools::Rectangle& GetCurrentBoundRect() const;
+ virtual const gfx::Range2DLWrap& getCurrentBoundRange() const;
// To have a possibility to get the last calculated BoundRect e.g for
producing
// the first rectangle for repaints (old and new need to be used) without
forcing
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 52351872f28e..5203c18d8272 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -962,6 +962,13 @@ const tools::Rectangle& SdrObject::GetCurrentBoundRect()
const
return getOutRectangle();
}
+const gfx::Range2DLWrap& SdrObject::getCurrentBoundRange() const
+{
+ if (m_aOutterRange.isEmpty())
+ const_cast<SdrObject*>(this)->RecalcBoundRect();
+ return m_aOutterRange;
+}
+
// To have a possibility to get the last calculated BoundRect e.g for producing
// the first rectangle for repaints (old and new need to be used) without
forcing
// a RecalcBoundRect (which may be problematical and expensive sometimes) I
add here
@@ -1949,7 +1956,7 @@ std::unique_ptr<SdrObjGeoData> SdrObject::NewGeoData()
const
void SdrObject::SaveGeoData(SdrObjGeoData& rGeo) const
{
- rGeo.aBoundRect =GetCurrentBoundRect();
+ rGeo.setBoundRange(getCurrentBoundRange());
rGeo.aAnchor =m_aAnchor ;
rGeo.bMovProt =m_bMovProt ;
rGeo.bSizProt =m_bSizProt ;
@@ -1969,7 +1976,7 @@ void SdrObject::SaveGeoData(SdrObjGeoData& rGeo) const
void SdrObject::RestoreGeoData(const SdrObjGeoData& rGeo)
{
SetBoundAndSnapRectsDirty();
- setOutRectangle(rGeo.aBoundRect);
+ m_aOutterRange = rGeo.getBoundRange();
m_aAnchor =rGeo.aAnchor ;
m_bMovProt =rGeo.bMovProt ;
m_bSizProt =rGeo.bSizProt ;
commit 6f7de0978c815b02157b1b6925a7a42ff4955c66
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Sun Mar 5 18:48:23 2023 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sun Nov 2 14:37:10 2025 +0900
svx: use gfx::Length based types directly in SdrTextObj::NbcResize
Change-Id: I839430b30685994e1767998b353c63b97f461284
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 0c6183f8ceac..45d2c55e127d 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -123,80 +123,102 @@ void SdrTextObj::NbcMove(const Size& rSize)
void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const
Fraction& yFact)
{
- bool bNotSheared=maGeo.m_nShearAngle==0_deg100;
- bool bRotate90=bNotSheared && maGeo.m_nRotationAngle.get() % 9000 ==0;
- bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
- bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
- if (bXMirr || bYMirr) {
+ bool bNotSheared = maGeo.m_nShearAngle == 0_deg100;
+ bool bRotate90 = bNotSheared && maGeo.m_nRotationAngle.get() % 9000 == 0;
+
+ bool bXMirrored = (xFact.GetNumerator() < 0) != (xFact.GetDenominator() <
0);
+ bool bYMirrored = (yFact.GetNumerator() < 0) != (yFact.GetDenominator() <
0);
+
+ double fFactorX = xFact.IsValid() ? double(xFact) : 1.0;
+ double fFactorY = yFact.IsValid() ? double(yFact) : 1.0;
+
+ if (bXMirrored || bYMirrored)
+ {
Point aRef1(GetSnapRect().Center());
- if (bXMirr) {
+ if (bXMirrored)
+ {
Point aRef2(aRef1);
aRef2.AdjustY( 1 );
NbcMirrorGluePoints(aRef1,aRef2);
}
- if (bYMirr) {
+ if (bYMirrored)
+ {
Point aRef2(aRef1);
aRef2.AdjustX( 1 );
NbcMirrorGluePoints(aRef1,aRef2);
}
}
- if (maGeo.m_nRotationAngle==0_deg100 && maGeo.m_nShearAngle==0_deg100) {
- auto aRectangle = getRectangle();
- ResizeRect(aRectangle, rRef, xFact, yFact);
- setRectangle(aRectangle);
- if (bYMirr)
+ if (maGeo.m_nRotationAngle == 0_deg100 && maGeo.m_nShearAngle == 0_deg100)
+ {
+ auto eUnit = getSdrModelFromSdrObject().getUnit();
+ gfx::Tuple2DL aReference = createTupleFromPoint(rRef, eUnit);
+ svx::resizeRange(maRectangleRange, aReference, fFactorX, fFactorY);
+
+ if (bYMirrored)
{
- moveRectangle(aRectangle.Right() - aRectangle.Left(),
aRectangle.Bottom() - aRectangle.Top());
- maGeo.m_nRotationAngle=18000_deg100;
+ maRectangleRange.shift(maRectangleRange.getWidth(),
maRectangleRange.getHeight());
+ maGeo.m_nRotationAngle = 18000_deg100;
maGeo.RecalcSinCos();
}
}
else
{
- tools::Polygon aPol(Rect2Poly(getRectangle(), maGeo));
+ tools::Polygon aPolygon(Rect2Poly(getRectangle(), maGeo));
- for(sal_uInt16 a(0); a < aPol.GetSize(); a++)
+ for (sal_uInt16 a(0); a < aPolygon.GetSize(); a++)
{
- ResizePoint(aPol[a], rRef, xFact, yFact);
+ ResizePoint(aPolygon[a], rRef, xFact, yFact);
}
- if(bXMirr != bYMirr)
+ if (bXMirrored != bYMirrored)
{
// turn polygon and move it a little
- tools::Polygon aPol0(aPol);
+ tools::Polygon aPol0(aPolygon);
- aPol[0] = aPol0[1];
- aPol[1] = aPol0[0];
- aPol[2] = aPol0[3];
- aPol[3] = aPol0[2];
- aPol[4] = aPol0[1];
+ aPolygon[0] = aPol0[1];
+ aPolygon[1] = aPol0[0];
+ aPolygon[2] = aPol0[3];
+ aPolygon[3] = aPol0[2];
+ aPolygon[4] = aPol0[1];
}
- tools::Rectangle aRectangle = svx::polygonToRectangle(aPol, maGeo);
+ tools::Rectangle aRectangle = svx::polygonToRectangle(aPolygon, maGeo);
setRectangle(aRectangle);
}
- if (bRotate90) {
- bool bRota90=maGeo.m_nRotationAngle.get() % 9000 ==0;
- if (!bRota90) { // there's seems to be a rounding error occurring:
correct it
- Degree100 a=NormAngle36000(maGeo.m_nRotationAngle);
- if (a<4500_deg100) a=0_deg100;
- else if (a<13500_deg100) a=9000_deg100;
- else if (a<22500_deg100) a=18000_deg100;
- else if (a<31500_deg100) a=27000_deg100;
- else a=0_deg100;
- maGeo.m_nRotationAngle=a;
+ if (bRotate90)
+ {
+ bool bRota90 = maGeo.m_nRotationAngle.get() % 9000 == 0;
+ if (!bRota90)
+ {
+ // there's seems to be a rounding error occurring: correct it
+
+ Degree100 angle = NormAngle36000(maGeo.m_nRotationAngle);
+ if (angle < 4500_deg100)
+ angle = 0_deg100;
+ else if (angle < 13500_deg100)
+ angle = 9000_deg100;
+ else if (angle < 22500_deg100)
+ angle = 18000_deg100;
+ else if (angle < 31500_deg100)
+ angle = 27000_deg100;
+ else
+ angle = 0_deg100;
+
+ maGeo.m_nRotationAngle = angle;
maGeo.RecalcSinCos();
}
- if (bNotSheared!=(maGeo.m_nShearAngle==0_deg100)) { // correct a
rounding error occurring with Shear
- maGeo.m_nShearAngle=0_deg100;
+ if (bNotSheared != (maGeo.m_nShearAngle == 0_deg100))
+ {
+ // correct a rounding error occurring with Shear
+ maGeo.m_nShearAngle = 0_deg100;
maGeo.RecalcTan();
}
}
AdaptTextMinSize();
- if(mbTextFrame && !getSdrModelFromSdrObject().IsPasteResize())
+ if (mbTextFrame && !getSdrModelFromSdrObject().IsPasteResize())
{
NbcAdjustTextFrameWidthAndHeight();
}
commit f37cabf08cc03c93ae087885ee4baea5c063d10d
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Sun Mar 5 14:46:10 2023 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sun Nov 2 14:37:10 2025 +0900
svx: use gfx::Length based types directly in SdrTextObj::NbcMove
Change-Id: Ib0d4a9f60a2ae7f64d914c7a39aa146fef6a9f74
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 4d6c4014e4c8..0c6183f8ceac 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -40,6 +40,18 @@
using namespace com::sun::star;
+namespace
+{
+
+gfx::Tuple2DL createTupleFromPoint(Point const& rPoint, gfx::LengthUnit eUnit
= gfx::LengthUnit::hmm)
+{
+ auto x = gfx::Length::from(eUnit, rPoint.X());
+ auto y = gfx::Length::from(eUnit, rPoint.Y());
+ return gfx::Tuple2DL(x, y);
+}
+
+} // end anonymous
+
void SdrTextObj::NbcSetSnapRect(const tools::Rectangle& rRect)
{
if (maGeo.m_nRotationAngle || maGeo.m_nShearAngle)
@@ -96,8 +108,15 @@ Degree100 SdrTextObj::GetShearAngle(bool /*bVertical*/)
const
void SdrTextObj::NbcMove(const Size& rSize)
{
- moveRectangle(rSize.Width(), rSize.Height());
- moveOutRectangle(rSize.Width(), rSize.Height());
+ gfx::Tuple2DL aDelta = createTupleFromPoint(Point(rSize.Width(),
rSize.Height()), getSdrModelFromSdrObject().getUnit());
+ gfx::Length xDelta = aDelta.getX();
+ gfx::Length yDelta = aDelta.getY();
+
+ if (xDelta == 0_emu && yDelta == 0_emu)
+ return;
+
+ maRectangleRange.shift(xDelta, yDelta);
+ m_aOutterRange.shift(xDelta, yDelta);
maSnapRect.Move(rSize);
SetBoundAndSnapRectsDirty(true);
}
@@ -186,19 +205,6 @@ void SdrTextObj::NbcResize(const Point& rRef, const
Fraction& xFact, const Fract
SetBoundAndSnapRectsDirty();
}
-namespace
-{
-
-gfx::Tuple2DL createTupleFromPoint(Point const& rPoint, gfx::LengthUnit eUnit
= gfx::LengthUnit::hmm)
-{
- auto x = gfx::Length::from(eUnit, rPoint.X());
- auto y = gfx::Length::from(eUnit, rPoint.Y());
- return gfx::Tuple2DL(x, y);
-}
-
-} // end anonymous
-
-
void SdrTextObj::NbcRotate(const Point& rRef, Degree100 nAngle, double sn,
double cs)
{
SetGlueReallyAbsolute(true);
commit 322390f5a790e1da6902d0024408d643be011457
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Sat Mar 4 22:12:51 2023 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sun Nov 2 14:37:09 2025 +0900
svx: use gfx::Length based types directly in SdrTextObj::NbcRotate
Change-Id: Ic5ee712fa7507e016441595f8847649fd18b50ee
diff --git a/include/svx/svdtrans.hxx b/include/svx/svdtrans.hxx
index e0677e55f48b..1dab54c7603d 100644
--- a/include/svx/svdtrans.hxx
+++ b/include/svx/svdtrans.hxx
@@ -46,13 +46,15 @@ SVXCORE_DLLPUBLIC void ResizeRect(tools::Rectangle& rRect,
const Point& rRef, co
namespace svx
{
SVXCORE_DLLPUBLIC void resizeRange(gfx::Range2DLWrap& rRange, gfx::Tuple2DL
const& rReference, double fFactorX, double fFactorY);
+SVXCORE_DLLPUBLIC gfx::Tuple2DL rotatePoint(gfx::Tuple2DL const& rPoint,
gfx::Tuple2DL const& rReference, double sinAngle, double cosAngle);
}
inline void ResizePoint(Point& rPnt, const Point& rRef, const Fraction&
xFract, const Fraction& yFract);
void ResizePoly(tools::Polygon& rPoly, const Point& rRef, const Fraction&
xFact, const Fraction& yFact);
void ResizeXPoly(XPolygon& rPoly, const Point& rRef, const Fraction& xFact,
const Fraction& yFact);
-inline void RotatePoint(Point& rPnt, const Point& rRef, double sn, double cs);
+SVXCORE_DLLPUBLIC void RotatePoint(Point& rPnt, const Point& rRef, double sn,
double cs);
+
SVXCORE_DLLPUBLIC void RotatePoly(tools::Polygon& rPoly, const Point& rRef,
double sn, double cs);
void RotateXPoly(XPolygon& rPoly, const Point& rRef, double sn, double cs);
void RotateXPoly(XPolyPolygon& rPoly, const Point& rRef, double sn, double cs);
@@ -107,14 +109,6 @@ inline void ResizePoint(Point& rPnt, const Point& rRef,
const Fraction& xFract,
rPnt.setY(rRef.Y() + basegfx::fround<tools::Long>((rPnt.Y() - rRef.Y()) *
nyFract));
}
-inline void RotatePoint(Point& rPnt, const Point& rRef, double sn, double cs)
-{
- tools::Long dx=rPnt.X()-rRef.X();
- tools::Long dy=rPnt.Y()-rRef.Y();
- rPnt.setX(basegfx::fround<tools::Long>(rRef.X() + dx * cs + dy * sn));
- rPnt.setY(basegfx::fround<tools::Long>(rRef.Y() + dy * cs - dx * sn));
-}
-
inline void ShearPoint(Point& rPnt, const Point& rRef, double tn, bool bVShear)
{
if (!bVShear) { // Horizontal
diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx
index 38b76827d117..33a66fda57f3 100644
--- a/svx/qa/unit/svdraw.cxx
+++ b/svx/qa/unit/svdraw.cxx
@@ -957,6 +957,46 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testResizeRect)
CPPUNIT_ASSERT_EQUAL(tools::Rectangle(6, 6, 10, 10), aRectangle);
}
}
+
+CPPUNIT_TEST_FIXTURE(SvdrawTest, testRotatePoint2D)
+{
+ {
+ auto angle = 18000_deg100;
+ double angleRadians = toRadians(angle);
+ gfx::Tuple2DL aPoint(2_cm, 1_cm);
+ gfx::Tuple2DL aReference(1_cm, 1_cm);
+ aPoint
+ = svx::rotatePoint(aPoint, aReference, std::sin(angleRadians),
std::cos(angleRadians));
+
+ CPPUNIT_ASSERT_EQUAL(0_cm, aPoint.getX());
+ CPPUNIT_ASSERT_EQUAL(1_cm, aPoint.getY());
+ }
+
+ {
+ auto angle = 9000_deg100;
+ double angleRadians = toRadians(angle);
+ gfx::Tuple2DL aPoint(2_cm, 1_cm);
+ gfx::Tuple2DL aReference(1_cm, 1_cm);
+ aPoint
+ = svx::rotatePoint(aPoint, aReference, std::sin(angleRadians),
std::cos(angleRadians));
+
+ CPPUNIT_ASSERT_EQUAL(1_cm, aPoint.getX());
+ CPPUNIT_ASSERT_EQUAL(0_cm, aPoint.getY());
+ }
+
+ {
+ auto angle = 18000_deg100;
+ double angleRadians = toRadians(angle);
+ gfx::Tuple2DL aPoint(1_cm, 1_cm);
+ gfx::Tuple2DL aReference(2_cm, 2_cm);
+ aPoint
+ = svx::rotatePoint(aPoint, aReference, std::sin(angleRadians),
std::cos(angleRadians));
+
+ CPPUNIT_ASSERT_EQUAL(3_cm, aPoint.getX());
+ CPPUNIT_ASSERT_EQUAL(3_cm, aPoint.getY());
+ }
+}
+
} // end anonymous namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 30e3d7264e35..4d6c4014e4c8 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -186,28 +186,50 @@ void SdrTextObj::NbcResize(const Point& rRef, const
Fraction& xFact, const Fract
SetBoundAndSnapRectsDirty();
}
+namespace
+{
+
+gfx::Tuple2DL createTupleFromPoint(Point const& rPoint, gfx::LengthUnit eUnit
= gfx::LengthUnit::hmm)
+{
+ auto x = gfx::Length::from(eUnit, rPoint.X());
+ auto y = gfx::Length::from(eUnit, rPoint.Y());
+ return gfx::Tuple2DL(x, y);
+}
+
+} // end anonymous
+
+
void SdrTextObj::NbcRotate(const Point& rRef, Degree100 nAngle, double sn,
double cs)
{
SetGlueReallyAbsolute(true);
- 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);
- aRectangle = tools::Rectangle(aPoint1, aPoint2);
- setRectangle(aRectangle);
+ gfx::Tuple2DL aReference = createTupleFromPoint(rRef,
getSdrModelFromSdrObject().getUnit());
- if (maGeo.m_nRotationAngle==0_deg100) {
- maGeo.m_nRotationAngle=NormAngle36000(nAngle);
- maGeo.mfSinRotationAngle=sn;
- maGeo.mfCosRotationAngle=cs;
- } else {
- maGeo.m_nRotationAngle=NormAngle36000(maGeo.m_nRotationAngle+nAngle);
+ gfx::Length aWidth = maRectangleRange.getWidth();
+ gfx::Length aHeight = maRectangleRange.getHeight();
+
+ gfx::Tuple2DL aPoint(maRectangleRange.getMinX(),
maRectangleRange.getMinY());
+ gfx::Tuple2DL aRotated = svx::rotatePoint(aPoint, aReference, sn, cs);
+
+ maRectangleRange = gfx::Range2DLWrap(
+ aRotated.getX(),
+ aRotated.getY(),
+ aRotated.getX() + aWidth,
+ aRotated.getY() + aHeight);
+
+ if (maGeo.m_nRotationAngle == 0_deg100)
+ {
+ maGeo.m_nRotationAngle = NormAngle36000(nAngle);
+ maGeo.mfSinRotationAngle = sn;
+ maGeo.mfCosRotationAngle = cs;
+ }
+ else
+ {
+ maGeo.m_nRotationAngle = NormAngle36000(maGeo.m_nRotationAngle +
nAngle);
maGeo.RecalcSinCos();
}
+
SetBoundAndSnapRectsDirty();
- NbcRotateGluePoints(rRef,nAngle,sn,cs);
+ NbcRotateGluePoints(rRef, nAngle, sn, cs);
SetGlueReallyAbsolute(false);
}
diff --git a/svx/source/svdraw/svdtrans.cxx b/svx/source/svdraw/svdtrans.cxx
index 4df9f3075555..3c6d006a6295 100644
--- a/svx/source/svdraw/svdtrans.cxx
+++ b/svx/source/svdraw/svdtrans.cxx
@@ -75,8 +75,24 @@ void resizeRange(gfx::Range2DLWrap& rRange, gfx::Tuple2DL
const& rReference, dou
rRange = gfx::Range2DLWrap(left, top, right, bottom, rRange.getUnit());
}
+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();
+ gfx::Length x = rReference.getX() + dx * cosAngle + dy * sinAngle;
+ gfx::Length y = rReference.getY() + dy * cosAngle - dx * sinAngle;
+ return {x, y};
+}
+
} // end svx namespace
+void RotatePoint(Point& rPoint, const Point& rRef, double sn, double cs)
+{
+ tools::Long dx = rPoint.X() - rRef.X();
+ tools::Long dy = rPoint.Y() - rRef.Y();
+ rPoint.setX(basegfx::fround(rRef.X() + dx * cs + dy * sn));
+ rPoint.setY(basegfx::fround(rRef.Y() + dy * cs - dx * sn));
+}
void ResizePoly(tools::Polygon& rPoly, const Point& rRef, const Fraction&
xFact, const Fraction& yFact)
{
commit 1cf22ca36ea6fadf658f5f6b9c4f2bc08678ba8e
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Fri Feb 10 18:10:33 2023 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sun Nov 2 14:37:09 2025 +0900
svx: refactor SdrObject resize to use m_aOutterRange directly
Change-Id: I77aad10b32a53545c7f7bbf8fd87b914395a5bad
diff --git a/include/svx/svdtrans.hxx b/include/svx/svdtrans.hxx
index 1d490b1e1158..e0677e55f48b 100644
--- a/include/svx/svdtrans.hxx
+++ b/include/svx/svdtrans.hxx
@@ -29,6 +29,9 @@
#include <tools/mapunit.hxx>
#include <tools/poly.hxx>
+#include <basegfx/units/Range2DLWrap.hxx>
+#include <basegfx/units/LengthTypes.hxx>
+
// That maximum shear angle
inline constexpr Degree100 SDRMAXSHEAR(8900);
@@ -39,6 +42,12 @@ inline void MovePoly(tools::Polygon& rPoly, const Size& S)
{ rPoly.Move(S.W
void MoveXPoly(XPolygon& rPoly, const Size& S);
SVXCORE_DLLPUBLIC void ResizeRect(tools::Rectangle& rRect, const Point& rRef,
const Fraction& xFact, const Fraction& yFact);
+
+namespace svx
+{
+SVXCORE_DLLPUBLIC void resizeRange(gfx::Range2DLWrap& rRange, gfx::Tuple2DL
const& rReference, double fFactorX, double fFactorY);
+}
+
inline void ResizePoint(Point& rPnt, const Point& rRef, const Fraction&
xFract, const Fraction& yFract);
void ResizePoly(tools::Polygon& rPoly, const Point& rRef, const Fraction&
xFact, const Fraction& yFact);
void ResizeXPoly(XPolygon& rPoly, const Point& rRef, const Fraction& xFact,
const Fraction& yFact);
diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx
index 080316f8e59b..38b76827d117 100644
--- a/svx/qa/unit/svdraw.cxx
+++ b/svx/qa/unit/svdraw.cxx
@@ -9,6 +9,7 @@
#include <config_poppler.h>
#include <test/unoapixml_test.hxx>
+#include <basegfx/units/Length.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
@@ -46,6 +47,8 @@
#include <sdr/contact/objectcontactofobjlistpainter.hxx>
+#include <test/unoapixml_test.hxx>
+
using namespace ::com::sun::star;
namespace
@@ -891,6 +894,69 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testVisualSignResize)
CPPUNIT_ASSERT_LESS(static_cast<sal_Int32>(10000),
xShape->getSize().Height);
#endif
}
+
+CPPUNIT_TEST_FIXTURE(SvdrawTest, testResizeRect)
+{
+ {
+ tools::Rectangle aRectangle(1, 1, 10, 10);
+ Point aReference(1, 1);
+ ResizeRect(aRectangle, aReference, Fraction(1, 2), Fraction(1, 2));
+
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(1, 1, 6, 6), aRectangle);
+ }
+
+ {
+ tools::Rectangle aRectangle(1, 1, 10, 10);
+ Point aReference(10, 10);
+ ResizeRect(aRectangle, aReference, Fraction(1, 2), Fraction(1, 2));
+
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(5, 5, 10, 10), aRectangle);
+ }
+
+ {
+ gfx::Range2DLWrap aRange(1_hmm, 1_hmm, 10_hmm, 10_hmm);
+ CPPUNIT_ASSERT_EQUAL(9_hmm, aRange.getWidth());
+ CPPUNIT_ASSERT_EQUAL(9_hmm, aRange.getHeight());
+
+ gfx::Tuple2DL aReference(1_hmm, 1_hmm);
+ svx::resizeRange(aRange, aReference, 0.5, 0.5);
+
+ CPPUNIT_ASSERT_EQUAL(false, aRange.isEmpty());
+
+ CPPUNIT_ASSERT_EQUAL(1_hmm, aRange.getMinX());
+ CPPUNIT_ASSERT_EQUAL(5.5_hmm, aRange.getMaxX());
+ CPPUNIT_ASSERT_EQUAL(1_hmm, aRange.getMinY());
+ CPPUNIT_ASSERT_EQUAL(5.5_hmm, aRange.getMaxY());
+
+ CPPUNIT_ASSERT_EQUAL(4.5_hmm, aRange.getWidth());
+ CPPUNIT_ASSERT_EQUAL(4.5_hmm, aRange.getHeight());
+
+ auto aRectangle = aRange.toToolsRect();
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(1, 1, 6, 6), aRectangle);
+ }
+
+ {
+ gfx::Range2DLWrap aRange(1_hmm, 1_hmm, 10_hmm, 10_hmm);
+ CPPUNIT_ASSERT_EQUAL(9_hmm, aRange.getWidth());
+ CPPUNIT_ASSERT_EQUAL(9_hmm, aRange.getHeight());
+
+ gfx::Tuple2DL aReference(10_hmm, 10_hmm);
+ svx::resizeRange(aRange, aReference, 0.5, 0.5);
+
+ CPPUNIT_ASSERT_EQUAL(false, aRange.isEmpty());
+
+ CPPUNIT_ASSERT_EQUAL(5.5_hmm, aRange.getMinX());
+ CPPUNIT_ASSERT_EQUAL(10_hmm, aRange.getMaxX());
+ CPPUNIT_ASSERT_EQUAL(5.5_hmm, aRange.getMinY());
+ CPPUNIT_ASSERT_EQUAL(10_hmm, aRange.getMaxY());
+
+ CPPUNIT_ASSERT_EQUAL(4.5_hmm, aRange.getWidth());
+ CPPUNIT_ASSERT_EQUAL(4.5_hmm, aRange.getHeight());
+
+ auto aRectangle = aRange.toToolsRect();
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(6, 6, 10, 10), aRectangle);
+ }
+}
} // end anonymous namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index fb31de09e521..52351872f28e 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -33,6 +33,7 @@
#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <basegfx/units/Range2DLWrap.hxx>
+#include <basegfx/units/LengthTypes.hxx>
#include <basegfx/range/b2drange.hxx>
#include <drawinglayer/processor2d/contourextractor2d.hxx>
#include <drawinglayer/processor2d/linegeometryextractor2d.hxx>
@@ -977,9 +978,8 @@ void SdrObject::RecalcBoundRect()
return;
- auto const& rRectangle = getOutRectangle();
// central new method which will calculate the BoundRect using primitive
geometry
- if (!rRectangle.IsEmpty())
+ if (!isOutRectangleEmpty())
return;
// Use view-independent data - we do not want any connections
@@ -1464,24 +1464,32 @@ void SdrObject::NbcMove(const Size& rSize)
void SdrObject::NbcResize(const Point& rRef, const Fraction& xFact, const
Fraction& yFact)
{
- bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
- bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
- if (bXMirr || bYMirr) {
+ bool bXMirror = (xFact.GetNumerator() < 0) != (xFact.GetDenominator() < 0);
+ bool bYMirror = (yFact.GetNumerator() < 0) != (yFact.GetDenominator() < 0);
+ if (bXMirror || bYMirror)
+ {
Point aRef1(GetSnapRect().Center());
- if (bXMirr) {
+ if (bXMirror)
+ {
Point aRef2(aRef1);
aRef2.AdjustY( 1 );
- NbcMirrorGluePoints(aRef1,aRef2);
+ NbcMirrorGluePoints(aRef1, aRef2);
}
- if (bYMirr) {
+ if (bYMirror)
+ {
Point aRef2(aRef1);
aRef2.AdjustX( 1 );
- NbcMirrorGluePoints(aRef1,aRef2);
+ NbcMirrorGluePoints(aRef1, aRef2);
}
}
- auto aRectangle = getOutRectangle();
- ResizeRect(aRectangle, rRef, xFact, yFact);
- setOutRectangle(aRectangle);
+
+ auto eUnit = getSdrModelFromSdrObject().getUnit();
+ gfx::Tuple2DL aReference{
+ gfx::Length::from(eUnit, rRef.X()),
+ gfx::Length::from(eUnit, rRef.Y())};
+ double fFactorX = xFact.IsValid() ? double(xFact) : 1.0;
+ double fFactorY = yFact.IsValid() ? double(yFact) : 1.0;
+ svx::resizeRange(m_aOutterRange, aReference, fFactorX, fFactorY);
SetBoundAndSnapRectsDirty();
}
diff --git a/svx/source/svdraw/svdtrans.cxx b/svx/source/svdraw/svdtrans.cxx
index eb2964dec823..4df9f3075555 100644
--- a/svx/source/svdraw/svdtrans.cxx
+++ b/svx/source/svdraw/svdtrans.cxx
@@ -61,6 +61,22 @@ void ResizeRect(tools::Rectangle& rRect, const Point& rRef,
const Fraction& rxFa
rRect.Normalize();
}
+namespace svx
+{
+
+void resizeRange(gfx::Range2DLWrap& rRange, gfx::Tuple2DL const& rReference,
double fFactorX, double fFactorY)
+{
+ auto left = rReference.getX() + ((rRange.getMinX() - rReference.getX()) *
fFactorX);
+ auto right = rReference.getX() + ((rRange.getMaxX() - rReference.getX()) *
fFactorX);
+
+ auto top = rReference.getY() + ((rRange.getMinY() - rReference.getY()) *
fFactorY);
+ auto bottom = rReference.getY() + ((rRange.getMaxY() - rReference.getY())
* fFactorY);
+
+ rRange = gfx::Range2DLWrap(left, top, right, bottom, rRange.getUnit());
+}
+
+} // end svx namespace
+
void ResizePoly(tools::Polygon& rPoly, const Point& rRef, const Fraction&
xFact, const Fraction& yFact)
{
commit 88cccf08a78f87f3ad47c561a5c8bb697ebde17d
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Thu Feb 9 10:03:43 2023 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sun Nov 2 14:37:09 2025 +0900
use Range2DLWrap for the main rectangle in SdrTextObject
Change-Id: I0d8ac090f9442fe561b4f87aa767185a987874c4
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index 872474fc0cef..ca29164153a3 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>
@@ -164,31 +165,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 31fe9103a92d..49c0799aec72 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -116,7 +116,7 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrTextObj
const & rSource)
// #i25616#
mbSupportTextIndentingOnLineWidthChange = true;
- maRectangle = rSource.maRectangle;
+ maRectangleRange = rSource.maRectangleRange;
maGeo = rSource.maGeo;
maTextSize = rSource.maTextSize;
@@ -156,8 +156,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 f39b33662b00..aaa1ac9248e5 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;
commit c109cbb50a5ddae4feb10e9425d682dc3b9d8d4b
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Wed Feb 8 10:42:19 2023 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sun Nov 2 14:37:09 2025 +0900
use Range2DLWrap for "OutRectangle" in SdrObject
Change-Id: I243b44a84bc09991744009ae24ac7657d493c5cf
diff --git a/include/svx/Border.hxx b/include/svx/Border.hxx
index 2c6b251c4c62..cbf697c59f6e 100644
--- a/include/svx/Border.hxx
+++ b/include/svx/Border.hxx
@@ -67,6 +67,12 @@ 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());
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 7917d988cd20..3a47b8ae02c0 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -35,6 +35,7 @@
#include <tools/link.hxx>
#include <tools/gen.hxx>
#include <unotools/resmgr.hxx>
+#include <basegfx/units/Range2DLWrap.hxx>
#include <unordered_set>
@@ -874,13 +875,14 @@ public:
protected:
const tools::Rectangle& getOutRectangle() const;
bool isOutRectangleSet() const { return m_bOutRectangleSet; }
+ 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 bool m_bOutRectangleSet; // empty is a valid
rectangle, so we need a separate flag to know when the cached value is not yet
set
+ mutable gfx::Range2DLWrap m_aOutterRange; // surrounding rectangle for
Paint (incl. LineWidth, ...)
+ mutable bool m_bOutRectangleSet; // empty is a valid rectangle, so we need
a separate flag to know when the cached value is not yet set
Point m_aAnchor; // anchor position (Writer)
SdrObjUserCall* m_pUserCall;
std::unique_ptr<SdrObjPlusData>
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index bb0e80fa8825..cfd506cfd9fd 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -522,10 +522,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 107be17e2fbd..fb31de09e521 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -32,6 +32,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>
@@ -955,9 +956,7 @@ void SdrObject::SetNavigationPosition (const sal_uInt32
nNewPosition)
const tools::Rectangle& SdrObject::GetCurrentBoundRect() const
{
if (!isOutRectangleSet())
- {
const_cast< SdrObject* >(this)->RecalcBoundRect();
- }
return getOutRectangle();
}
@@ -1004,12 +1003,12 @@ void SdrObject::RecalcBoundRect()
return;
}
- 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);
+ 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());
}
void SdrObject::BroadcastObjectChange() const
@@ -3216,30 +3215,44 @@ 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);
m_bOutRectangleSet = true;
}
void SdrObject::setOutRectangle(tools::Rectangle const& rRectangle)
{
- m_aOutRect = rRectangle;
+ auto eUnit = getSdrModelFromSdrObject().getUnit();
+ m_aOutterRange = gfx::Range2DLWrap::create(rRectangle, eUnit);
m_bOutRectangleSet = true;
}
void SdrObject::resetOutRectangle()
{
- m_aOutRect = tools::Rectangle();
+ m_aOutterRange.reset();
m_bOutRectangleSet = false;
}
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 d53242011da7..b968c8b0d1a9 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 1f1566453ce4..f6839b2126c8 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -2464,10 +2464,8 @@ void SwDrawVirtObj::NbcSetAnchorPos(const Point& rPnt)
const tools::Rectangle& SwDrawVirtObj::GetCurrentBoundRect() const
{
- if (getOutRectangle().IsEmpty())
- {
+ if (isOutRectangleEmpty())
const_cast<SwDrawVirtObj*>(this)->RecalcBoundRect();
- }
return getOutRectangle();
}
commit 74ff4af31006f10046a8f8981b118c1f29426e20
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Wed Oct 26 20:21:37 2022 +0200
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sun Nov 2 14:37:09 2025 +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..47dd992b4f02 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::Size2DLWrap 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::Size2DLWrap 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..0d12100e5903 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/Size2DLWrap.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::Size2DLWrap getPaperSize(Paper ePaper);
+ static gfx::Size2DLWrap getDefaultPaperSize();
};
// INLINE -----------------------------------------------------------------
diff --git a/include/svx/Border.hxx b/include/svx/Border.hxx
index abf93e6013f4..2c6b251c4c62 100644
--- a/include/svx/Border.hxx
+++ b/include/svx/Border.hxx
@@ -43,6 +43,15 @@ public:
{
}
+ 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& left() const { return maLeft; }
gfx::Length const& right() const { return maRight; }
gfx::Length const& upper() const { return maUpper; }
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index f865737eed67..518ecf02aa18 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -566,7 +566,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const
* pRefDocument /* =
return;
// #i57181# Paper size depends on Language, like in Writer
- Size aDefSize = SvxPaperInfo::GetDefaultPaperSize( MapUnit::Map100thMM );
+ gfx::Size2DLWrap aDefaultSize = SvxPaperInfo::getDefaultPaperSize();
// Insert handout page
rtl::Reference<SdPage> pHandoutPage = AllocSdPage(false);
@@ -583,8 +583,8 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const
* pRefDocument /* =
}
else
{
- pHandoutPage->setToolsSize(aDefSize);
- pHandoutPage->SetBorder(0, 0, 0, 0);
+ pHandoutPage->setSize(aDefaultSize);
+ pHandoutPage->setBorder(svx::Border());
}
pHandoutPage->SetPageKind(PageKind::Handout);
@@ -620,7 +620,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const
* pRefDocument /* =
else if (meDocType == DocumentType::Draw)
{
// Draw: always use default size with margins
- pPage->setToolsSize(aDefSize);
+ pPage->setSize(aDefaultSize);
SfxPrinter* pPrinter = mpDocSh->GetPrinter(false);
if (pPrinter && pPrinter->IsValid())
@@ -630,12 +630,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
{
@@ -644,14 +644,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 aSize = SvxPaperInfo::GetPaperSize(PAPER_SCREEN_16_9,
MapUnit::Map100thMM);
- pPage->setToolsSize(Size(aSize.Height(), aSize.Width()));
+ gfx::Size2DLWrap aSize =
SvxPaperInfo::getPaperSize(PAPER_SCREEN_16_9);
+ pPage->setSize({ aSize.getHeight(), aSize.getWidth() });
pPage->setBorder(svx::Border());
}
@@ -686,16 +686,16 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument
const * pRefDocument /* =
else
{
// Always use portrait format
- if (aDefSize.Height() >= aDefSize.Width())
+ if (aDefaultSize.getHeight() >= aDefaultSize.getWidth())
{
- pNotesPage->setToolsSize(aDefSize);
+ pNotesPage->setSize(aDefaultSize);
}
else
{
- pNotesPage->setToolsSize(Size(aDefSize.Height(),
aDefSize.Width()));
+ pNotesPage->setSize({ aDefaultSize.getHeight(),
aDefaultSize.getWidth() });
}
- pNotesPage->SetBorder(0, 0, 0, 0);
+ pNotesPage->setBorder(svx::Border());
}
pNotesPage->SetPageKind(PageKind::Notes);
InsertPage(pNotesPage.get(), 2);
commit de8a98536c718b8eed9c0abb6ce2c89cae3788c2
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Thu Feb 2 19:22:23 2023 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Sun Nov 2 14:37:04 2025 +0900
svx: change SdrPage size and border to use gfx::Length
Change-Id: I382cfba6189eab02581057ab5af437cd1d163138
diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index a799d85bc49b..a45ee04b6828 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -217,12 +217,13 @@ DlgEditor::DlgEditor (
aMarkIdle.SetInvokeHandler( LINK( this, DlgEditor, MarkTimeout ) );
rWindow.SetMapMode( MapMode( MapUnit::Map100thMM ) );
- pDlgEdPage->SetSize( rWindow.PixelToLogic( Size(DLGED_PAGE_WIDTH_MIN,
DLGED_PAGE_HEIGHT_MIN) ) );
+ Size aPageSize = rWindow.PixelToLogic(Size(DLGED_PAGE_WIDTH_MIN,
DLGED_PAGE_HEIGHT_MIN));
+ pDlgEdPage->setToolsSize(aPageSize);
pDlgEdView->ShowSdrPage(pDlgEdView->GetModel().GetPage(0));
pDlgEdView->SetLayerVisible( u"HiddenLayer"_ustr, false );
pDlgEdView->SetMoveSnapOnlyTopLeft(true);
- pDlgEdView->SetWorkArea( tools::Rectangle( Point( 0, 0 ),
pDlgEdPage->GetSize() ) );
+ pDlgEdView->SetWorkArea(pDlgEdPage->getRectangle().toToolsRect());
Size aGridSize( 100, 100 ); // 100TH_MM
pDlgEdView->SetGridCoarse( aGridSize );
@@ -268,7 +269,7 @@ void DlgEditor::InitScrollBars()
return;
Size aOutSize = rWindow.GetOutDev()->GetOutputSize();
- Size aPgSize = pDlgEdPage->GetSize();
+ Size aPgSize = pDlgEdPage->getSize().toToolsSize();
pHScroll->SetRange( Range( 0, aPgSize.Width() ));
pVScroll->SetRange( Range( 0, aPgSize.Height() ));
@@ -1199,11 +1200,11 @@ bool DlgEditor::AdjustPageSize()
if ( pDlgEdPage )
{
- Size aPageSize = pDlgEdPage->GetSize();
+ Size aPageSize = pDlgEdPage->getSize().toToolsSize();
if ( nNewPageWidth != aPageSize.Width() || nNewPageHeight !=
aPageSize.Height() )
{
Size aNewPageSize( nNewPageWidth, nNewPageHeight );
- pDlgEdPage->SetSize( aNewPageSize );
+ pDlgEdPage->setToolsSize(aNewPageSize);
pDlgEdView->SetWorkArea( tools::Rectangle( Point( 0, 0 ),
aNewPageSize ) );
bAdjustedPageSize = true;
}
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
index bc714d51c768..c545fdd37faa 100644
--- a/basctl/source/dlged/dlgedobj.cxx
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -419,7 +419,7 @@ void DlgEdObj::PositionAndSizeChange( const
beans::PropertyChangeEvent& evt )
DBG_ASSERT( pDlgEdForm, "DlgEdObj::PositionAndSizeChange: no form!" );
DlgEdPage& rPage = pDlgEdForm->GetDlgEditor().GetPage();
{
- Size aPageSize = rPage.GetSize();
+ Size aPageSize = rPage.getSize().toToolsSize();
sal_Int32 nPageWidthIn = aPageSize.Width();
sal_Int32 nPageHeightIn = aPageSize.Height();
sal_Int32 nPageX, nPageY, nPageWidth, nPageHeight;
@@ -1294,7 +1294,7 @@ void DlgEdForm::PositionAndSizeChange( const
beans::PropertyChangeEvent& evt )
sal_Int32 nPageXIn = 0;
sal_Int32 nPageYIn = 0;
- Size aPageSize = rPage.GetSize();
+ Size aPageSize = rPage.getSize().toToolsSize();
sal_Int32 nPageWidthIn = aPageSize.Width();
sal_Int32 nPageHeightIn = aPageSize.Height();
sal_Int32 nPageX, nPageY, nPageWidth, nPageHeight;
@@ -1344,7 +1344,7 @@ void DlgEdForm::PositionAndSizeChange( const
beans::PropertyChangeEvent& evt )
if ( bAdjustedPageSize )
{
rEditor.InitScrollBars();
- aPageSize = rPage.GetSize();
+ aPageSize = rPage.getSize().toToolsSize();
nPageWidthIn = aPageSize.Width();
nPageHeightIn = aPageSize.Height();
if ( TransformSdrToControlCoordinates( nPageXIn, nPageYIn,
nPageWidthIn, nPageHeightIn, nPageX, nPageY, nPageWidth, nPageHeight ) )
diff --git a/basctl/source/dlged/dlgedview.cxx
b/basctl/source/dlged/dlgedview.cxx
index 5ffe5185a2fb..4a3c0281b46e 100644
--- a/basctl/source/dlged/dlgedview.cxx
+++ b/basctl/source/dlged/dlgedview.cxx
@@ -90,7 +90,7 @@ void DlgEdView::MakeVisible( const tools::Rectangle& rRect,
vcl::Window& rWin )
nScrollY -= nDeltaY;
// don't scroll beyond the page size
- Size aPageSize = rDlgEditor.GetPage().GetSize();
+ Size aPageSize = rDlgEditor.GetPage().getSize().toToolsSize();
sal_Int32 nPageWidth = aPageSize.Width();
sal_Int32 nPageHeight = aPageSize.Height();
diff --git a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
index 51b163d1fccd..c468e7ee87c4 100644
--- a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
+++ b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
@@ -147,7 +147,7 @@ Graphic ViewElementListProvider::GetSymbolGraphic(
sal_Int32 nStandardSymbol, co
new SdrModel());
rtl::Reference<SdrPage> pPage = new SdrPage( *pModel, false );
- pPage->SetSize(Size(1000,1000));
+ pPage->setSize({ 1000_hmm, 1000_hmm });
pModel->InsertPage( pPage.get(), 0 );
SdrView aView(*pModel, pVDev);
aView.hideMarkHandles();
diff --git a/chart2/source/controller/main/DrawCommandDispatch.cxx
b/chart2/source/controller/main/DrawCommandDispatch.cxx
index c7a3d9837ce8..be3d514cb2b9 100644
--- a/chart2/source/controller/main/DrawCommandDispatch.cxx
+++ b/chart2/source/controller/main/DrawCommandDispatch.cxx
@@ -416,7 +416,7 @@ rtl::Reference<SdrObject>
DrawCommandDispatch::createDefaultObject( const ChartC
if ( pObj )
{
Size aObjectSize( 4000, 2500 );
- tools::Rectangle aPageRect( tools::Rectangle( Point( 0, 0 ),
pPage->GetSize() ) );
+ tools::Rectangle
aPageRect(pPage->getRectangle().toToolsRect());
Point aObjectPos = aPageRect.Center();
aObjectPos.AdjustX( -(aObjectSize.Width() / 2) );
aObjectPos.AdjustY( -(aObjectSize.Height() / 2) );
diff --git a/chart2/source/view/main/ChartView.cxx
b/chart2/source/view/main/ChartView.cxx
index 1b20e34939ad..63d0152d7f75 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1397,7 +1397,7 @@ void ChartView::createShapes()
if (pPage) //it is necessary to use the implementation here as the uno
page does not provide a propertyset
{
- pPage->SetSize(Size(aPageSize.Width,aPageSize.Height));
+ pPage->setSize({ gfx::Length::hmm(aPageSize.Width),
gfx::Length::hmm(aPageSize.Height) });
}
else
{
diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx
index 81a4a713887f..580c078922c4 100644
--- a/cui/source/tabpages/tpline.cxx
+++ b/cui/source/tabpages/tpline.cxx
@@ -819,7 +819,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs )
std::unique_ptr<SdrModel> pModel(
new SdrModel(nullptr, nullptr, true));
rtl::Reference<SdrPage> pPage = new SdrPage( *pModel, false );
- pPage->SetSize(Size(1000,1000));
+ pPage->setSize({ 1_cm, 1_cm });
pModel->InsertPage( pPage.get(), 0 );
{
SdrView aView( *pModel, pVDev );
@@ -1445,7 +1445,7 @@ void SvxLineTabPage::PopulateMenus()
new SdrModel(nullptr, nullptr, true));
// Page
rtl::Reference<SdrPage> pPage = new SdrPage( *pModel, false );
- pPage->SetSize(Size(1000,1000));
+ pPage->setSize({ 1_cm, 1_cm });
pModel->InsertPage( pPage.get(), 0 );
{
// 3D View
diff --git a/filter/source/msfilter/svdfppt.cxx
b/filter/source/msfilter/svdfppt.cxx
index e9928a85f1e5..c177390574e4 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -1247,7 +1247,7 @@ rtl::Reference<SdrObject> SdrEscherImport::ProcessObj(
SvStream& rSt, DffObjData
{
if ( rObjData.nSpFlags & ShapeFlag::Background )
{
- pRet->NbcSetSnapRect( tools::Rectangle( Point(),
rData.pPage.page->GetSize() ) ); // set size
+
pRet->NbcSetSnapRect(rData.pPage.page->getRectangle().toToolsRect()); // set
size
}
if (rPersistEntry.xSolverContainer)
{
@@ -2669,7 +2669,8 @@ bool SdrPowerPointImport::SeekToShape( SvStream& rSt,
SvxMSDffClientData* pClien
rtl::Reference<SdrPage> SdrPowerPointImport::MakeBlankPage( bool bMaster )
const
{
rtl::Reference<SdrPage> pRet = pSdrModel->AllocPage( bMaster );
- pRet->SetSize( GetPageSize() );
+ Size const& rSize = GetPageSize();
+ pRet->setSize({ gfx::Length::hmm(rSize.Width()),
gfx::Length::hmm(rSize.Height()) });
return pRet;
}
@@ -2811,7 +2812,7 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet,
const PptSlidePersistEntry*
{
case DFF_msofbtSpContainer :
{
- tools::Rectangle aPageSize( Point(),
pRet->GetSize() );
+ tools::Rectangle aPageSize =
pRet->getRectangle().toToolsRect();
if ( rSlidePersist.aSlideAtom.nFlags & 4 )
// follow master background?
{
if ( HasMasterPage( m_nCurrentPageNum,
m_eCurrentPageKind ) )
@@ -3059,15 +3060,8 @@ rtl::Reference<SdrObject>
SdrPowerPointImport::ImportPageBackgroundObject( const
pSet->Put( XFillStyleItem( drawing::FillStyle_NONE ) );
}
pSet->Put( XLineStyleItem( drawing::LineStyle_NONE ) );
- tools::Rectangle aRect(
- rPage.GetLeftBorder(),
- rPage.GetUpperBorder(),
- rPage.GetWidth() - rPage.GetRightBorder(),
- rPage.GetHeight() - rPage.GetLowerBorder());
-
- pRet = new SdrRectObj(
- *pSdrModel,
- aRect);
+ tools::Rectangle aRect = rPage.getInnerRectangle().toToolsRect();
+ pRet = new SdrRectObj(*pSdrModel, aRect);
pRet->SetMergedItemSet(*pSet);
pRet->SetMarkProtect( true );
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index 7e129af41c92..3a248badea2b 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -373,12 +373,12 @@ bool SVGFilter::filterImpressOrDraw( const Sequence<
PropertyValue >& rDescripto
// in comparison. Use a common scaling factor for hor/ver to not
get
// asynchronous border distances, though. All in all this will
adapt borders
// nicely and is based on office-defaults for
standard-page-border-sizes.
- const Size aPageSize(pTargetSdrPage->GetSize());
+ const gfx::Size2DL aPageSize = pTargetSdrPage->getSize();
const double fBorderRelation((
- static_cast< double >(pTargetSdrPage->GetLeftBorder()) /
aPageSize.Width() +
- static_cast< double >(pTargetSdrPage->GetRightBorder()) /
aPageSize.Width() +
- static_cast< double >(pTargetSdrPage->GetUpperBorder()) /
aPageSize.Height() +
- static_cast< double >(pTargetSdrPage->GetLowerBorder()) /
aPageSize.Height()) / 4.0);
+ pTargetSdrPage->getBorder().getLeft() / aPageSize.getWidth() +
+ pTargetSdrPage->getBorder().getRight() / aPageSize.getWidth() +
+ pTargetSdrPage->getBorder().getUpper() / aPageSize.getHeight()
+
+ pTargetSdrPage->getBorder().getLower() /
aPageSize.getHeight()) / 4.0);
const tools::Long
nAllBorder(basegfx::fround<tools::Long>((aGraphicSize.Width() +
aGraphicSize.Height()) * fBorderRelation * 0.5));
// Adapt PageSize and Border stuff. To get all MasterPages and
PresObjs
diff --git a/include/svx/Border.hxx b/include/svx/Border.hxx
new file mode 100644
index 000000000000..abf93e6013f4
--- /dev/null
+++ b/include/svx/Border.hxx
@@ -0,0 +1,82 @@
+/* -*- 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 svx
+{
+/** Represents the borders or margins from the sides of a rectangular object.
+ *
+ * Values represent the length from the sides of a rectangular object.
+ * Used mainly to define the borders/margins for a page.
+ *
+ * Includes the base unit, which is used for conversion to tools::Rectangle,
+ * or for leftUnit, rightUnit, upperUnit, lowerUnit getters. These are needed
+ * for compatibility and will eventually go unused when the code is converted
+ * to use gfx::Length.
+ */
+class Border
+{
+private:
+ gfx::Length maLeft;
+ gfx::Length maRight;
+ gfx::Length maUpper;
+ gfx::Length maLower;
+ gfx::LengthUnit meUnit;
+
+public:
+ Border(gfx::LengthUnit eUnit = gfx::LengthUnit::hmm)
+ : maLeft(0_emu)
+ , maRight(0_emu)
+ , maUpper(0_emu)
+ , maLower(0_emu)
+ , meUnit(eUnit)
+ {
+ }
+
+ gfx::Length const& left() const { return maLeft; }
+ gfx::Length const& right() const { return maRight; }
+ gfx::Length const& upper() const { return maUpper; }
+ gfx::Length const& lower() const { return maLower; }
+
+ gfx::Length const& getLeft() const { return maLeft; }
+ gfx::Length const& getRight() const { return maRight; }
+ gfx::Length const& getUpper() const { return maUpper; }
+ gfx::Length const& getLower() const { return maLower; }
+
+ tools::Long leftUnit() const { return maLeft.as(meUnit); }
+ tools::Long rightUnit() const { return maRight.as(meUnit); }
+ tools::Long upperUnit() const { return maUpper.as(meUnit); }
+ tools::Long lowerUnit() const { return maLower.as(meUnit); }
+
+ tools::Rectangle toToolsRect() const
+ {
+ return tools::Rectangle(leftUnit(), upperUnit(), rightUnit(),
lowerUnit());
+ }
+
+ bool isEmpty() const
+ {
+ return maLeft == 0_emu && maRight == 0_emu && maUpper == 0_emu &&
maLower == 0_emu;
+ }
+
+ void setLeft(gfx::Length const& rLeft) { maLeft = rLeft; }
+
+ void setRight(gfx::Length const& rRight) { maRight = rRight; }
+
+ void setUpper(gfx::Length const& rUpper) { maUpper = rUpper; }
+
+ void setLower(gfx::Length const& rLower) { maLower = rLower; }
+};
+
+} // end svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index 15b756b1c9e1..0d1e6098d70b 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -39,6 +39,7 @@
#include <svx/svdtypes.hxx>
#include <svx/svxdllapi.h>
+#include <basegfx/units/Length.hxx>
#include <rtl/ref.hxx>
#include <deque>
@@ -362,6 +363,13 @@ public:
MapUnit GetScaleUnit() const { return
m_eObjUnit; }
void SetScaleUnit(MapUnit eMap);
+ gfx::LengthUnit getUnit() const
+ {
+ return m_eObjUnit == MapUnit::MapTwip
+ ? gfx::LengthUnit::twip
+ : gfx::LengthUnit::hmm;
+ }
+
// maximal size e.g. for auto growing texts
const Size& GetMaxObjSize() const { return
m_aMaxObjSize; }
void SetMaxObjSize(const Size& rSiz) {
m_aMaxObjSize=rSiz; }
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index ca05dfba74e2..bb0e80fa8825 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -24,6 +24,7 @@
#include <vcl/prntypes.hxx>
#include <svl/itemset.hxx>
#include <svx/sdrpageuser.hxx>
+#include <svx/svdmodel.hxx>
#include <svx/sdr/contact/viewobjectcontactredirector.hxx>
#include <svx/sdrmasterpagedescriptor.hxx>
#include <svx/svxdllapi.h>
@@ -31,6 +32,10 @@
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <svx/svdobj.hxx>
#include <unotools/weakref.hxx>
+#include <basegfx/units/Length.hxx>
+#include <basegfx/units/Size2DLWrap.hxx>
+#include <basegfx/units/Range2DLWrap.hxx>
+#include <svx/Border.hxx>
#include <memory>
#include <optional>
#include <vector>
@@ -359,7 +364,6 @@ public:
void dumpAsXml(xmlTextWriterPtr pWriter) const;
};
-
/**
A SdrPage contains exactly one SdrObjList and a description of the physical
page dimensions (size / margins). The latter is required to "catch" objects
@@ -425,12 +429,8 @@ protected:
std::vector<rtl::Reference<sdr::annotation::Annotation>> maAnnotations;
private:
- tools::Long mnWidth; // page size
- tools::Long mnHeight; // page size
- sal_Int32 mnBorderLeft; // left page margin
- sal_Int32 mnBorderUpper; // top page margin
- sal_Int32 mnBorderRight; // right page margin
- sal_Int32 mnBorderLower; // bottom page margin
+ gfx::Size2DLWrap maSize;
+ svx::Border maBorder;
UniqueID maUniqueID;
bool mbBackgroundFullSize = false; ///< Background object to represent the
whole page.
@@ -488,21 +488,50 @@ public:
void setPageBorderOnlyLeftRight(bool bNew) { mbPageBorderOnlyLeftRight =
bNew; }
bool getPageBorderOnlyLeftRight() const { return
mbPageBorderOnlyLeftRight; }
- virtual void SetSize(const Size& aSiz);
- Size GetSize() const;
+ gfx::LengthUnit getUnit() const { return
getSdrModelFromSdrPage().getUnit(); }
+ virtual void setSize(gfx::Size2DLWrap const& rSize);
+
+ void setToolsSize(Size const rSize)
+ {
+ setSize(gfx::Size2DLWrap::create(rSize, getUnit()));
+ }
+
+ const gfx::Size2DLWrap& getSize() const
+ {
+ return maSize;
+ }
+
+ gfx::Range2DLWrap getRectangle() const
+ {
+ return gfx::Range2DLWrap(0_emu, 0_emu, maSize.getWidth(),
maSize.getHeight(), getUnit());
+ }
+
+ gfx::Range2DLWrap getInnerRectangle() const
+ {
+ return gfx::Range2DLWrap(maBorder.getLeft(), maBorder.getUpper(),
+ maSize.getWidth() - maBorder.getRight(),
+ maSize.getHeight() - maBorder.getLower(),
+ getUnit());
+ }
+
virtual void SetOrientation(Orientation eOri);
virtual Orientation GetOrientation() const;
- tools::Long GetWidth() const;
- tools::Long GetHeight() const;
- virtual void SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt,
sal_Int32 Lwr);
+
+ virtual svx::Border const& getBorder() const
+ {
+ return maBorder;
+ }
+
+ virtual void setBorder(svx::Border const& rBorder)
+ {
+ maBorder = rBorder;
+ }
+
+ virtual void SetBorder(sal_Int32 nLeft, sal_Int32 nUpper, sal_Int32
nRight, sal_Int32 Lower);
virtual void SetLeftBorder(sal_Int32 nBorder);
virtual void SetUpperBorder(sal_Int32 nBorder);
virtual void SetRightBorder(sal_Int32 nBorder);
virtual void SetLowerBorder(sal_Int32 nBorder);
- sal_Int32 GetLeftBorder() const;
- sal_Int32 GetUpperBorder() const;
- sal_Int32 GetRightBorder() const;
- sal_Int32 GetLowerBorder() const;
sal_uInt64 GetUniqueID() const { return maUniqueID.getID(); }
void SetBackgroundFullSize(bool bIn);
bool IsBackgroundFullSize() const;
diff --git a/reportdesign/source/ui/report/ReportSection.cxx
b/reportdesign/source/ui/report/ReportSection.cxx
index 3947cb3c9630..aed0c2e329c5 100644
--- a/reportdesign/source/ui/report/ReportSection.cxx
+++ b/reportdesign/source/ui/report/ReportSection.cxx
@@ -221,9 +221,10 @@ void OReportSection::fill()
// m_pPage->SetUpperBorder(-10000);
m_pView->SetDesignMode();
-
- m_pPage->SetSize( Size(
getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width,5*m_xSection->getHeight())
);
- const Size aPageSize = m_pPage->GetSize();
+ auto aWidth = getStyleProperty<awt::Size>(xReportDefinition,
PROPERTY_PAPERSIZE).Width;
+ auto aHeight = 5 * m_xSection->getHeight();
+ m_pPage->setToolsSize(Size(aWidth, aHeight));
+ const Size aPageSize = m_pPage->getSize().toToolsSize();
m_pView->SetWorkArea( tools::Rectangle( Point( nLeftMargin, 0),
Size(aPageSize.Width() - nLeftMargin - nRightMargin,aPageSize.Height()) ) );
}
@@ -482,12 +483,12 @@ void OReportSection::_propertyChanged(const
beans::PropertyChangeEvent& _rEvent)
{
m_pPage->SetRightBorder(nRightMargin);
}
- const Size aOldPageSize = m_pPage->GetSize();
+ const Size aOldPageSize = m_pPage->getSize().toToolsSize();
sal_Int32 nNewHeight = 5*m_xSection->getHeight();
if ( aOldPageSize.Height() != nNewHeight || nPaperWidth !=
aOldPageSize.Width() )
{
- m_pPage->SetSize( Size( nPaperWidth,nNewHeight) );
- const Size aPageSize = m_pPage->GetSize();
+ m_pPage->setToolsSize(Size(nPaperWidth, nNewHeight));
+ const Size aPageSize = m_pPage->getSize().toToolsSize();
m_pView->SetWorkArea( tools::Rectangle( Point( nLeftMargin, 0),
Size(aPageSize.Width() - nLeftMargin - nRightMargin,aPageSize.Height()) ) );
}
impl_adjustObjectSizePosition(nPaperWidth,nLeftMargin,nRightMargin);
diff --git a/reportdesign/source/ui/report/SectionView.cxx
b/reportdesign/source/ui/report/SectionView.cxx
index 4a4bf32ad1b4..72619bd82393 100644
--- a/reportdesign/source/ui/report/SectionView.cxx
+++ b/reportdesign/source/ui/report/SectionView.cxx
@@ -85,7 +85,7 @@ void OSectionView::MakeVisible( const tools::Rectangle&
rRect, vcl::Window& rWin
const sal_Int32 nVisBottom = aVisRect.Bottom();
// don't scroll beyond the page size
- Size aPageSize = m_pSectionWindow->getPage()->GetSize();
+ Size aPageSize = m_pSectionWindow->getPage()->getSize().toToolsSize();
const sal_Int32 nPageWidth = aPageSize.Width();
const sal_Int32 nPageHeight = aPageSize.Height();
diff --git a/sc/source/core/data/drawpage.cxx b/sc/source/core/data/drawpage.cxx
index 9baa9be3ca6a..43034dde81f5 100644
--- a/sc/source/core/data/drawpage.cxx
+++ b/sc/source/core/data/drawpage.cxx
@@ -24,8 +24,8 @@
ScDrawPage::ScDrawPage(ScDrawLayer& rNewModel, bool bMasterPage)
: FmFormPage(rNewModel, bMasterPage)
{
- SetSize( Size( SAL_MAX_INT32, SAL_MAX_INT32 ) );
- // largest size supported by sal_Int32 SdrPage::mnWidth/Height
+ setToolsSize(Size(SAL_MAX_INT32, SAL_MAX_INT32));
+ // largest size supported by sal_Int32 SdrPage::mnWidth/Height
}
ScDrawPage::~ScDrawPage()
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 2867ec1c6e71..85871914368f 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -644,9 +644,9 @@ void ScDrawLayer::SetPageSize(sal_uInt16 nPageNo, const
Size& rSize, bool bUpdat
if (!pPage)
return;
- if ( rSize != pPage->GetSize() )
+ if (rSize != pPage->getSize().toToolsSize())
{
- pPage->SetSize( rSize );
+ pPage->setToolsSize(rSize);
Broadcast( ScTabSizeChangedHint( static_cast<SCTAB>(nPageNo) ) ); //
SetWorkArea() on the views
}
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 817c33566ba3..8ea866c1a0e5 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -353,7 +353,7 @@ void ScCaptionCreator::Initialize()
mbNegPage = mrDoc.IsNegativePage( maPos.Tab() );
if( SdrPage* pDrawPage = GetDrawPage() )
{
- maPageRect = tools::Rectangle( Point( 0, 0 ), pDrawPage->GetSize() );
+ maPageRect = pDrawPage->getRectangle().toToolsRect();
/* #i98141# SdrPage::GetSize() returns negative width in RTL mode.
The call to Rectangle::Adjust() orders left/right coordinate
accordingly. */
diff --git a/sc/source/filter/rtf/eeimpars.cxx
b/sc/source/filter/rtf/eeimpars.cxx
index 38122bfc6669..567fcb42a535 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -604,7 +604,7 @@ void ScEEImport::InsertGraphic( SCCOL nCol, SCROW nRow,
SCTAB nTab,
aLogicSize = pDefaultDev->PixelToLogic( aSizePix, MapMode(
MapUnit::Map100thMM ) );
// Limit size
- ::ScLimitSizeOnDrawPage( aLogicSize, aInsertPos, pPage->GetSize() );
+ ::ScLimitSizeOnDrawPage(aLogicSize, aInsertPos,
pPage->getSize().toToolsSize());
if ( pI->oGraphic )
{
diff --git a/sc/source/ui/app/client.cxx b/sc/source/ui/app/client.cxx
index c5f6400e39d7..b4c19ce8bd8a 100644
--- a/sc/source/ui/app/client.cxx
+++ b/sc/source/ui/app/client.cxx
@@ -99,7 +99,7 @@ void ScClient::RequestNewObjectArea( tools::Rectangle&
aLogicRect )
return;
Point aPos;
- Size aSize = pPage->GetSize();
+ Size aSize = pPage->getSize().toToolsSize();
if ( aSize.Width() < 0 )
{
aPos.setX( aSize.Width() + 1 ); // negative
diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx
index d9a1d83568c3..bb43a2cdc5af 100644
--- a/sc/source/ui/drawfunc/fuins1.cxx
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -171,7 +171,7 @@ static void lcl_InsertGraphic( const Graphic& rGraphic,
if ( rData.GetDocument().IsNegativePage( rData.CurrentTabForData() ) )
aInsertPos.AdjustX( -(aLogicSize.Width()) ); // move position to
left edge
- ScLimitSizeOnDrawPage( aLogicSize, aInsertPos, pPage->GetSize() );
+ ScLimitSizeOnDrawPage(aLogicSize, aInsertPos,
pPage->getSize().toToolsSize());
tools::Rectangle aRect ( aInsertPos, aLogicSize );
@@ -225,7 +225,7 @@ static void lcl_InsertMedia( const OUString& rMediaURL,
bool bApi,
else
aSize = Size( 5000, 5000 );
- ScLimitSizeOnDrawPage( aSize, aInsertPos, pPage->GetSize() );
+ ScLimitSizeOnDrawPage(aSize, aInsertPos, pPage->getSize().toToolsSize());
if( rData.GetDocument().IsNegativePage( rData.CurrentTabForData() ) )
aInsertPos.AdjustX( -(aSize.Width()) );
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
index c92e52d4e985..4bbd5ef00f3b 100644
--- a/sc/source/ui/view/drawview.cxx
+++ b/sc/source/ui/view/drawview.cxx
@@ -258,9 +258,9 @@ void ScDrawView::UpdateWorkArea()
SdrPage* pPage = GetModel().GetPage(static_cast<sal_uInt16>(nTab));
if (pPage)
{
- Size aPageSize( pPage->GetSize() );
+ Size aPageSize(pPage->getSize().toToolsSize());
tools::Rectangle aNewArea( Point(), aPageSize );
- if ( aPageSize.Width() < 0 )
+ if (aPageSize.Width() < 0)
{
// RTL: from max.negative (left) to zero (right)
aNewArea.SetRight( 0 );
diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx
index 84d6d5f9dcd9..a78994170538 100644
--- a/sc/source/ui/view/viewfun7.cxx
+++ b/sc/source/ui/view/viewfun7.cxx
@@ -57,7 +57,7 @@ static void lcl_AdjustInsertPos( ScViewData& rData, Point&
rPos, const Size& rSi
{
SdrPage* pPage = rData.GetScDrawView()->GetModel().GetPage(
static_cast<sal_uInt16>(rData.CurrentTabForData()) );
assert(pPage && "pPage ???");
- Size aPgSize( pPage->GetSize() );
+ Size aPgSize(pPage->getSize().toToolsSize());
if (aPgSize.Width() < 0)
aPgSize.setWidth( -aPgSize.Width() );
tools::Long x = aPgSize.Width() - rPos.X() - rSize.Width();
diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx
index cb44248ba7cd..c37b61ec0dc4 100644
--- a/sd/inc/drawdoc.hxx
+++ b/sd/inc/drawdoc.hxx
@@ -22,9 +22,11 @@
#include <com/sun/star/text/WritingMode.hpp>
#include <svl/style.hxx>
#include <svx/fmmodel.hxx>
+#include <svx/svdpage.hxx>
#include <unotools/charclass.hxx>
#include <vcl/prntypes.hxx>
#include <xmloff/autolayout.hxx>
+#include <basegfx/units/Size2DLWrap.hxx>
#include <vector>
#include <memory>
@@ -267,11 +269,8 @@ struct InsertBookmarkOptions
*/
struct PageProperties
{
- Size size; // Page size dimensions
- sal_Int32 left; // Left margin
- sal_Int32 right; // Right margin
- sal_Int32 upper; // Upper (top) margin
- sal_Int32 lower; // Lower (bottom) margin
+ gfx::Size2DLWrap size; // Page size dimensions
+ svx::Border border;
Orientation orientation; // Page orientation (portrait/landscape)
SdPage* pPage; // Pointer to the page object
};
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index 69dcca6dfd69..ebb4451427b7 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -156,7 +156,8 @@ public:
virtual rtl::Reference<SdrPage> CloneSdrPage(SdrModel& rTargetModel) const
override;
- virtual void SetSize(const Size& aSize) override;
+ virtual void setSize(gfx::Size2DLWrap const& rSize) override;
+
virtual void SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt,
sal_Int32 Lwr) override;
virtual void SetLeftBorder(sal_Int32 nBorder) override;
virtual void SetRightBorder(sal_Int32 nBorder) override;
diff --git a/sd/source/core/CustomAnimationEffect.cxx
b/sd/source/core/CustomAnimationEffect.cxx
index 2c6beb28b30a..fb2ea3c62f02 100644
--- a/sd/source/core/CustomAnimationEffect.cxx
+++ b/sd/source/core/CustomAnimationEffect.cxx
@@ -1584,8 +1584,8 @@ void CustomAnimationEffect::updateSdrPathObjFromPath(
SdrPathObj& rPathObj )
SdrPage* pPage = pObj->getSdrPageFromSdrObject();
if( pPage )
{
- const Size aPageSize( pPage->GetSize() );
-
aPolyPoly.transform(basegfx::utils::createScaleB2DHomMatrix(static_cast<double>(aPageSize.Width()),
static_cast<double>(aPageSize.Height())));
+ const auto aPageSize = pPage->getSize().toB2DSize();
+
aPolyPoly.transform(basegfx::utils::createScaleB2DHomMatrix(aPageSize.getWidth(),
aPageSize.getHeight()));
}
const ::tools::Rectangle aBoundRect( pObj->GetCurrentBoundRect() );
@@ -1625,9 +1625,10 @@ void CustomAnimationEffect::updatePathFromSdrPathObj(
const SdrPathObj& rPathObj
SdrPage* pPage = pObj->getSdrPageFromSdrObject();
if( pPage )
{
- const Size aPageSize( pPage->GetSize() );
+ const auto aPageSize = pPage->getSize().toB2DSize();
aPolyPoly.transform(basegfx::utils::createScaleB2DHomMatrix(
- 1.0 / static_cast<double>(aPageSize.Width()), 1.0 /
static_cast<double>(aPageSize.Height())));
+ 1.0 / aPageSize.getWidth(),
+ 1.0 / aPageSize.getHeight()));
}
}
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index 7cbf50613202..a2ba9efa8697 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -469,9 +469,11 @@ void SdDrawDocument::AdaptPageSizeForAllPages(
new SdPageFormatUndoAction(
*this,
pPage,
- pPage->GetSize(),
- pPage->GetLeftBorder(), pPage->GetRightBorder(),
- pPage->GetUpperBorder(), pPage->GetLowerBorder(),
+ pPage->getSize().toToolsSize(),
+ pPage->getBorder().leftUnit(),
+ pPage->getBorder().rightUnit(),
+ pPage->getBorder().upperUnit(),
+ pPage->getBorder().lowerUnit(),
pPage->GetOrientation(),
pPage->GetPaperBin(),
pPage->IsBackgroundFullSize(),
@@ -492,7 +494,7 @@ void SdDrawDocument::AdaptPageSizeForAllPages(
if (rNewSize.Width() > 0)
{
- pPage->SetSize(rNewSize);
+ pPage->setToolsSize(rNewSize);
}
}
@@ -524,9 +526,11 @@ void SdDrawDocument::AdaptPageSizeForAllPages(
new SdPageFormatUndoAction(
*this,
pPage,
- pPage->GetSize(),
- pPage->GetLeftBorder(), pPage->GetRightBorder(),
- pPage->GetUpperBorder(), pPage->GetLowerBorder(),
+ pPage->getSize().toToolsSize(),
+ pPage->getBorder().leftUnit(),
+ pPage->getBorder().rightUnit(),
+ pPage->getBorder().upperUnit(),
+ pPage->getBorder().lowerUnit(),
pPage->GetOrientation(),
pPage->GetPaperBin(),
pPage->IsBackgroundFullSize(),
@@ -547,7 +551,7 @@ void SdDrawDocument::AdaptPageSizeForAllPages(
if (rNewSize.Width() > 0)
{
- pPage->SetSize(rNewSize);
+ pPage->setToolsSize(rNewSize);
}
}
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index c89b605a90e3..f865737eed67 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -578,12 +578,12 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument
const * pRefDocument /* =
if( pRefPage )
{
- pHandoutPage->SetSize(pRefPage->GetSize());
- pHandoutPage->SetBorder( pRefPage->GetLeftBorder(),
pRefPage->GetUpperBorder(), pRefPage->GetRightBorder(),
pRefPage->GetLowerBorder() );
+ pHandoutPage->setSize(pRefPage->getSize());
+ pHandoutPage->setBorder(pRefPage->getBorder());
}
else
{
- pHandoutPage->SetSize(aDefSize);
+ pHandoutPage->setToolsSize(aDefSize);
pHandoutPage->SetBorder(0, 0, 0, 0);
}
@@ -593,12 +593,9 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument
const * pRefDocument /* =
// Insert master page and register this with the handout page
rtl::Reference<SdPage> pHandoutMPage = AllocSdPage(true);
- pHandoutMPage->SetSize( pHandoutPage->GetSize() );
+ pHandoutMPage->setSize(pHandoutPage->getSize());
pHandoutMPage->SetPageKind(PageKind::Handout);
- pHandoutMPage->SetBorder( pHandoutPage->GetLeftBorder(),
- pHandoutPage->GetUpperBorder(),
- pHandoutPage->GetRightBorder(),
- pHandoutPage->GetLowerBorder() );
+ pHandoutMPage->setBorder(pHandoutPage->getBorder());
InsertMasterPage(pHandoutMPage.get(), 0);
pHandoutPage->TRG_SetMasterPage( *pHandoutMPage );
@@ -617,13 +614,13 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument
const * pRefDocument /* =
if( pRefPage )
{
- pPage->SetSize( pRefPage->GetSize() );
- pPage->SetBorder( pRefPage->GetLeftBorder(),
pRefPage->GetUpperBorder(), pRefPage->GetRightBorder(),
pRefPage->GetLowerBorder() );
+ pPage->setSize(pRefPage->getSize());
+ pPage->setBorder(pRefPage->getBorder());
}
else if (meDocType == DocumentType::Draw)
{
// Draw: always use default size with margins
- pPage->SetSize(aDefSize);
+ pPage->setToolsSize(aDefSize);
SfxPrinter* pPrinter = mpDocSh->GetPrinter(false);
if (pPrinter && pPrinter->IsValid())
-e
... etc. - the rest is truncated