[Libreoffice-commits] core.git: Branch 'private/tvajngerl/staging' - 1056 commits - android/Bootstrap android/source animations/source basctl/sdi basctl/source basctl/uiconfig basegfx/CppunitTest_basegfx.mk basegfx/source basegfx/test basic/CppunitTest_basic_macros.mk basic/Library_sb.mk basic/qa basic/source bin/check-elf-dynamic-objects bin/create-dmg-from-merged-app-bundle bin/find-can-be-private-symbols.functions.results bin/list-dispatch-commands.py bin/lo-pack-sources bin/merge-app-bundles bridges/inc bridges/Library_cpp_uno.mk bridges/source canvas/inc canvas/qa canvas/source chart2/inc chart2/qa chart2/source cli_ure/source comphelper/JunitTest_comphelper_complex.mk comphelper/Library_comphelper.mk comphelper/Module_comphelper.mk comphelper/PythonTest_comphelper_python.mk comphelper/qa comphelper/source compilerplugins/clang config_host.mk.in configmgr/qa configmgr/source configure.ac connectivity/source cppcanvas/source cppu/source cui/inc cui/qa cui/source cui/uiconfig dbaccess/Executab le_odbcconfig.mk dbaccess/source dbaccess/win32 desktop/Library_sofficeapp.mk desktop/lokclipboard.component desktop/qa desktop/source desktop/uiconfig dictionaries distro-configs/Jenkins distro-configs/LibreOfficeFlatpak.conf docmodel/Library_docmodel.mk docmodel/source download.lst drawinglayer/inc drawinglayer/qa drawinglayer/source editeng/inc editeng/qa editeng/source emfio/qa emfio/source extensions/source external/cairo external/cppunit external/curl external/fontconfig external/freetype external/frozen external/hsqldb external/libjpeg-turbo external/liborcus external/Module_external.mk external/nss external/openssl external/postgresql external/python3 external/zxing extras/source filter/CppunitTest_filter_pdfimporter_test.mk filter/Library_pdfimporter.mk filter/Module_filter.mk filter/qa filter/source filter/uiconfig forms/source formula/source fpicker/source framework/inc framework/source g .git-hooks/README .gitignore helpcontent2 hwpfilter/source i18nlangtag/qa i18nlangta g/source i18npool/qa i18npool/source icon-themes/breeze icon-themes/breeze_dark icon-themes/breeze_dark_svg icon-themes/breeze_svg icon-themes/colibre icon-themes/colibre_dark icon-themes/colibre_dark_svg icon-themes/colibre_svg icon-themes/elementary icon-themes/elementary_svg icon-themes/karasa_jaga icon-themes/karasa_jaga_svg icon-themes/sifr icon-themes/sifr_dark icon-themes/sifr_dark_svg icon-themes/sifr_svg icon-themes/sukapura icon-themes/sukapura_svg idl/inc idl/source include/basegfx include/basic include/comphelper include/connectivity include/dbaccess include/docmodel include/drawinglayer include/editeng include/filter include/formula include/framework include/i18nlangtag include/LibreOfficeKit include/oox include/rtl include/sfx2 include/svl include/svtools include/svx include/systools include/test include/toolkit include/tools include/ucbhelper include/unotest include/unotools include/vbahelper include/vcl include/xmloff io/source jurt/source lingucomponent/source lingu istic/CppunitTest_linguistic_restprotocol.mk linguistic/Module_linguistic.mk linguistic/qa linguistic/source Makefile.fetch o3tl/qa odk/config odk/examples offapi/com offapi/type_reference offapi/UnoApi_offapi.mk officecfg/registry oovbaapi/ooo oox/inc oox/qa oox/source opencl/source package/source pyuno/source readlicense_oo/license README.md registry/inc reportdesign/source RepositoryExternal.mk Repository.mk ridljar/com sal/inc sal/Library_sal.mk sal/osl sal/qa sal/rtl sax/source sccomp/qa sc/CppunitTest_sc_bugfix_test.mk sc/CppunitTest_sc_subsequent_export_test3.mk sc/CppunitTest_sc_subsequent_export_test4.mk sc/CppunitTest_sc_subsequent_filters_test3.mk sc/CppunitTest_sc_subsequent_filters_test4.mk sc/CppunitTest_sc_tiledrendering.mk schema/libreoffice sc/inc sc/Library_scfilt.mk sc/Library_sc.mk sc/Module_sc.mk sc/qa scripting/source sc/sdi sc/source sc/uiconfig sdext/source sd/inc sd/qa sd/source sd/uiconfig sfx2/inc sfx2/Library_sfx.mk sfx2/sdi sfx2/source sfx2/uiconfig slid eshow/source solenv/bin solenv/clang-format solenv/flatpak-manifest.in solenv/gbuild sot/source starmath/inc starmath/qa starmath/source static/README.wasm.md stoc/source svgio/inc svgio/Library_svgio.mk svgio/source svl/qa svl/source svtools/inc svtools/source svx/inc svx/qa svx/sdi svx/source svx/uiconfig sw/CppunitTest_sw_a11y.mk sw/CppunitTest_sw_core_layout.mk sw/CppunitTest_sw_rtfexport6.mk sw/inc sw/IwyuFilter_sw.yaml sw/Library_msword.mk sw/Module_sw.mk sw/qa sw/sdi sw/source sw/uiconfig sw/UITest_sw_ui_frmdlg.mk sysui/desktop test/CppunitTest_test_a11y.mk test/Library_subsequenttest.mk test/Module_test.mk test/qa test/source test/user-template toolkit/qa toolkit/source tools/qa tools/source translations ucbhelper/source ucb/source udkapi/com udkapi/type_reference uitest/impress_tests uitest/math_tests uitest/uitest unotest/Library_unotest.mk unotest/source unotools/source uui/source vbahelper/source vcl/backendtest vcl/inc vcl/jsdialog vcl/Library_vcl.mk vcl/osx vcl/qa vcl/ qt5 vcl/qt6 vcl/skia vcl/source vcl/uiconfig vcl/unx vcl/win vcl/workben wizards/com wizards/Package_sfwidgets.mk wizards/source writerfilter/inc writerfilter/qa writerfilter/source writerperfect/qa xmlhelp/source xmloff/CppunitTest_xmloff_text.mk xmloff/inc xmloff/qa xmloff/source xmlscript/source xmlsecurity/source

Sat, 04 Mar 2023 05:17:59 -0800

Rebased ref, commits from common ancestor:
commit fcc270948df8174636be953e2e505e64c00311ea
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Mar 4 22:12:51 2023 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat Mar 4 22:12:51 2023 +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 e213d5f1ea61..549e84ed9d67 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() + FRound( (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(FRound(rRef.X()+dx*cs+dy*sn));
-    rPnt.setY(FRound(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 6a40dca7a081..966f001ff4e3 100644
--- a/svx/qa/unit/svdraw.cxx
+++ b/svx/qa/unit/svdraw.cxx
@@ -614,4 +614,162 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testResizeRect)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(SvdrawTest, testRotatePoint)
+{
+    {
+        auto angle = 18000_deg100;
+        double angleRadians = toRadians(angle);
+        Point aPoint(2000, 1000);
+        Point aReference(1000, 1000);
+        RotatePoint(aPoint, aReference, std::sin(angleRadians), 
std::cos(angleRadians));
+
+        CPPUNIT_ASSERT_EQUAL(Point(0, 1000), aPoint);
+    }
+
+    {
+        auto angle = 9000_deg100;
+        double angleRadians = toRadians(angle);
+        Point aPoint(2000, 1000);
+        Point aReference(1000, 1000);
+        RotatePoint(aPoint, aReference, std::sin(angleRadians), 
std::cos(angleRadians));
+
+        CPPUNIT_ASSERT_EQUAL(Point(1000, 0), aPoint);
+    }
+
+    {
+        auto angle = 18000_deg100;
+        double angleRadians = toRadians(angle);
+        Point aPoint(100, 100);
+        Point aReference(200, 200);
+        RotatePoint(aPoint, aReference, std::sin(angleRadians), 
std::cos(angleRadians));
+
+        CPPUNIT_ASSERT_EQUAL(Point(300, 300), aPoint);
+    }
+}
+
+CPPUNIT_TEST_FIXTURE(SvdrawTest, testRectangleObjectMove)
+{
+    std::unique_ptr<SdrModel> pModel(new SdrModel(nullptr, nullptr, true));
+    pModel->GetItemPool().FreezeIdRanges();
+
+    rtl::Reference<SdrPage> pPage(new SdrPage(*pModel, false));
+    pPage->setSize({ 50_cm, 50_cm });
+    pModel->InsertPage(pPage.get(), 0);
+
+    tools::Rectangle aRect(Point(), Size(100, 100));
+    rtl::Reference<SdrRectObj> pRectangleObject = new SdrRectObj(*pModel, 
aRect);
+    pPage->NbcInsertObject(pRectangleObject.get());
+
+    CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(), Size(100, 100)),
+                         pRectangleObject->GetLogicRect());
+    pRectangleObject->NbcMove({ 100, 100 });
+    CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(100, 100), Size(100, 100)),
+                         pRectangleObject->GetLogicRect());
+
+    pPage->RemoveObject(0);
+}
+
+CPPUNIT_TEST_FIXTURE(SvdrawTest, testRectangleObjectRotate)
+{
+    std::unique_ptr<SdrModel> pModel(new SdrModel(nullptr, nullptr, true));
+    pModel->GetItemPool().FreezeIdRanges();
+
+    rtl::Reference<SdrPage> pPage(new SdrPage(*pModel, false));
+    pPage->setSize({ 50_cm, 50_cm });
+    pModel->InsertPage(pPage.get(), 0);
+
+    {
+        tools::Rectangle aObjectSize(Point(), Size(100, 100));
+        rtl::Reference<SdrRectObj> pRectangleObject = new SdrRectObj(*pModel, 
aObjectSize);
+        pPage->NbcInsertObject(pRectangleObject.get());
+
+        CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, 0), Size(100, 100)),
+                             pRectangleObject->GetLogicRect());
+        CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, 0), Size(100, 100)),
+                             pRectangleObject->GetSnapRect());
+        CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(-1, -1), Size(102, 102)),
+                             pRectangleObject->GetCurrentBoundRect());
+
+        auto angle = 9000_deg100;
+        double angleRadians = toRadians(angle);
+        pRectangleObject->NbcRotate(aObjectSize.Center(), angle, 
std::sin(angleRadians),
+                                    std::cos(angleRadians));
+
+        CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, 98), Size(100, 100)),
+                             pRectangleObject->GetLogicRect());
+        CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, -1), Size(100, 100)),
+                             pRectangleObject->GetSnapRect());
+        CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(-1, -2), Size(102, 102)),
+                             pRectangleObject->GetCurrentBoundRect());
+
+        pPage->RemoveObject(0);
+    }
+
+    {
+        tools::Rectangle aObjectSize(Point(), Size(100, 100));
+        rtl::Reference<SdrRectObj> pRectangleObject = new SdrRectObj(*pModel, 
aObjectSize);
+        pPage->NbcInsertObject(pRectangleObject.get());
+
+        CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, 0), Size(100, 100)),
+                             pRectangleObject->GetLogicRect());
+        CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, 0), Size(100, 100)),
+                             pRectangleObject->GetSnapRect());
+        CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(-1, -1), Size(102, 102)),
+                             pRectangleObject->GetCurrentBoundRect());
+
+        auto angle = -4500_deg100;
+        double angleRadians = toRadians(angle);
+        pRectangleObject->NbcRotate(aObjectSize.Center(), angle, 
std::sin(angleRadians),
+                                    std::cos(angleRadians));
+
+        CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(49, -20), Size(100, 100)),
+                             pRectangleObject->GetLogicRect());
+        CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(-21, -20), Size(141, 141)),
+                             pRectangleObject->GetSnapRect());
+        CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(-22, -21), Size(143, 143)),
+                             pRectangleObject->GetCurrentBoundRect());
+
+        pPage->RemoveObject(0);
+    }
+}
+
+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());
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 1e3b0e35c638..56a9da693c6d 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -187,28 +187,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.nRotationAngle==0_deg100) {
-        maGeo.nRotationAngle=NormAngle36000(nAngle);
-        maGeo.mfSinRotationAngle=sn;
-        maGeo.mfCosRotationAngle=cs;
-    } else {
-        maGeo.nRotationAngle=NormAngle36000(maGeo.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.nRotationAngle == 0_deg100)
+    {
+        maGeo.nRotationAngle = NormAngle36000(nAngle);
+        maGeo.mfSinRotationAngle = sn;
+        maGeo.mfCosRotationAngle = cs;
+    }
+    else
+    {
+        maGeo.nRotationAngle = NormAngle36000(maGeo.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 04b02e9184c6..5afacc34dd9a 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& rPnt, const Point& rRef, double sn, double cs)
+{
+    tools::Long dx=rPnt.X()-rRef.X();
+    tools::Long dy=rPnt.Y()-rRef.Y();
+    rPnt.setX(FRound(rRef.X()+dx*cs+dy*sn));
+    rPnt.setY(FRound(rRef.Y()+dy*cs-dx*sn));
+}
 
 void ResizePoly(tools::Polygon& rPoly, const Point& rRef, const Fraction& 
xFact, const Fraction& yFact)
 {
commit 856501ff069d148062989d83729f8d343b607e49
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Mar 4 22:02:31 2023 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat Mar 4 22:02:31 2023 +0900

    superfluous aRectangle vars - svdotxtr
    
    Change-Id: I89067626841864461fa575f226a0ac8e69f32c18

diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 25248e5195ea..1e3b0e35c638 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -224,7 +224,6 @@ void SdrTextObj::NbcShear(const Point& rRef, Degree100 
/*nAngle*/, double tn, bo
     for (sal_uInt16 i=0; i<nPointCount; i++) {
          ShearPoint(aPol[i],rRef,tn,bVShear);
     }
-    auto aRectangle = getRectangle();
     aRectangle = svx::polygonToRectangle(aPol, maGeo);
     ImpJustifyRect(aRectangle);
     setRectangle(aRectangle);
@@ -262,7 +261,6 @@ void SdrTextObj::NbcMirror(const Point& rRef1, const Point& 
rRef2)
     aPol[2]=aPol0[3];
     aPol[3]=aPol0[2];
     aPol[4]=aPol0[1];
-    tools::Rectangle aRectangle = getRectangle();
     aRectangle = svx::polygonToRectangle(aPol, maGeo);
     setRectangle(aRectangle);
 
commit 51ea03737cde8c333303ff02a19d77cfb9a572b6
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Mar 4 22:00:54 2023 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat Mar 4 22:00:54 2023 +0900

    missing include Size2D - SdrPAge
    
    Change-Id: Ic890c85d5bd30036a276319613d7d27472d149cf

diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index 19dc68c5d2cc..ccb1e39a319c 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -38,6 +38,7 @@
 #include <optional>
 #include <vector>
 #include <deque>
+#include <basegfx/units/Size2DLWrap.hxx>
 
 
 // predefines
commit 99ce8f86b62029cf8046f9fe774577965788a40e
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Tue Feb 21 22:05:02 2023 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat Mar 4 19:08:08 2023 +0900

    svx: change SdrObjGeoData aBoundRectangle using gfx::Range2DLWrap
    
    Change-Id: I13213ea2bdbfc5badb87d1bbd836192b8ae45e72

diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 55d800e9852d..9202bd575c3a 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -173,8 +173,20 @@ public:
  */
 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::unique_ptr<SdrGluePointList>
                                 pGPL;
@@ -185,7 +197,6 @@ public:
     bool                        mbVisible;
     SdrLayerID                  mnLayerID;
 
-public:
     SdrObjGeoData();
     virtual ~SdrObjGeoData();
 };
@@ -417,6 +428,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 791229023d79..5e7333e1afa3 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -932,6 +932,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
@@ -1866,7 +1873,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      ;
@@ -1890,7 +1897,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 e90a21de9f1549474fb07f4c29b7d900b8a124cd
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Feb 11 22:02:11 2023 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat Mar 4 19:08:08 2023 +0900

    make NbcRotate abstract as it's implementation is noop
    
    During testing the NbcRotate function on SdrObject it turned out
    the the function is essentially a noop, because it uses normal
    equality to test the values of a double, which are a product of
    sin and cos functions (to determine the 90 degree angles). So
    because of this the input rectangle was never modified - noop.
    
    Because of this we can just remove the impl. of the function and
    declare it abstract, so that the actual implementations define
    a valid function to rotate.
    
    There were some subclasses that didn't override the NbcRotate so
    they used the one implementation in SdrObject. These subclasses
    now override the function and in the implementation we call
    assert(false), which is never called during a test run. It seems
    we never rotate those objects.
    
    Change-Id: I1b1a45a8e96ed2d061f9b9f80c5fdaa5a84d4c05

diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index a22e62a61654..55d800e9852d 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -543,7 +543,7 @@ public:
     virtual void NbcMove  (const Size& rSiz);
     virtual void NbcResize(const Point& rRef, const Fraction& xFact, const 
Fraction& yFact);
     virtual void NbcCrop  (const basegfx::B2DPoint& rRef, double fxFact, 
double fyFact);
-    virtual void NbcRotate(const Point& rRef, Degree100 nAngle, double sn, 
double cs);
+    virtual void NbcRotate(const Point& rRef, Degree100 nAngle, double sn, 
double cs) = 0;
     // Utility for call sites that don't have sin and cos handy
     void NbcRotate(const Point& rRef, Degree100 nAngle);
     virtual void NbcMirror(const Point& rRef1, const Point& rRef2);
diff --git a/include/svx/svdopage.hxx b/include/svx/svdopage.hxx
index abb35d8239cd..279c75c758a6 100644
--- a/include/svx/svdopage.hxx
+++ b/include/svx/svdopage.hxx
@@ -64,6 +64,8 @@ public:
 
     virtual OUString TakeObjNameSingul() const override;
     virtual OUString TakeObjNamePlural() const override;
+
+    void NbcRotate(const Point& rRef, Degree100 nAngle, double sinAngle, 
double cosAngle) override;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index c2a266bb0a4d..791229023d79 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -1444,33 +1444,6 @@ void SdrObject::NbcRotate(const Point& rRef, Degree100 
nAngle)
 
 namespace
 {
-
-tools::Rectangle lclRotateRectangle(tools::Rectangle const& rRectangle, Point 
const& rRef, double sn, double cs)
-{
-    tools::Rectangle aRectangle(rRectangle);
-    aRectangle.Move(-rRef.X(),-rRef.Y());
-    tools::Rectangle R(aRectangle);
-    if (sn==1.0 && cs==0.0) { // 90deg
-        aRectangle.SetLeft(-R.Bottom() );
-        aRectangle.SetRight(-R.Top() );
-        aRectangle.SetTop(R.Left() );
-        aRectangle.SetBottom(R.Right() );
-    } else if (sn==0.0 && cs==-1.0) { // 180deg
-        aRectangle.SetLeft(-R.Right() );
-        aRectangle.SetRight(-R.Left() );
-        aRectangle.SetTop(-R.Bottom() );
-        aRectangle.SetBottom(-R.Top() );
-    } else if (sn==-1.0 && cs==0.0) { // 270deg
-        aRectangle.SetLeft(R.Top() );
-        aRectangle.SetRight(R.Bottom() );
-        aRectangle.SetTop(-R.Right() );
-        aRectangle.SetBottom(-R.Left() );
-    }
-    aRectangle.Move(rRef.X(),rRef.Y());
-    aRectangle.Normalize(); // just in case
-    return aRectangle;
-}
-
 tools::Rectangle lclMirrorRectangle(tools::Rectangle const& rRectangle, Point 
const& rRef1, Point const& rRef2)
 {
     tools::Rectangle aRectangle(rRectangle);
@@ -1502,17 +1475,6 @@ tools::Rectangle lclMirrorRectangle(tools::Rectangle 
const& rRectangle, Point co
 
 } // end anonymous namespace
 
-void SdrObject::NbcRotate(const Point& rRef,  Degree100 nAngle, double sn, 
double cs)
-{
-    SetGlueReallyAbsolute(true);
-    tools::Rectangle aRectangle = getOutRectangle();
-    aRectangle = lclRotateRectangle(aRectangle, rRef, sn, cs);
-    setOutRectangle(aRectangle);
-    SetBoundAndSnapRectsDirty();
-    NbcRotateGluePoints(rRef, nAngle, sn, cs);
-    SetGlueReallyAbsolute(false);
-}
-
 void SdrObject::NbcMirror(const Point& rRef1, const Point& rRef2)
 {
     SetGlueReallyAbsolute(true);
diff --git a/svx/source/svdraw/svdopage.cxx b/svx/source/svdraw/svdopage.cxx
index 8bd374fe6b45..448758646afe 100644
--- a/svx/source/svdraw/svdopage.cxx
+++ b/svx/source/svdraw/svdopage.cxx
@@ -172,4 +172,9 @@ OUString SdrPageObj::TakeObjNamePlural() const
     return SvxResId(STR_ObjNamePluralPAGE);
 }
 
+void SdrPageObj::NbcRotate(const Point& /*rRef*/, Degree100 /*nAngle*/, double 
/*sinAngle*/, double /*cosAngle*/)
+{
+    assert(false);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index 45068cf1fd89..31a193a45119 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -156,6 +156,11 @@ rtl::Reference<SdrObject> 
SwFlyDrawObj::CloneSdrObject(SdrModel& rTargetModel) c
     return new SwFlyDrawObj(rTargetModel);
 }
 
+void SwFlyDrawObj::NbcRotate(const Point& /*rRef*/, Degree100 /*nAngle*/, 
double /*sinAngle*/, double /*cosAngle*/)
+{
+    assert(false);
+}
+
 // TODO: Need own primitive to get the FlyFrame paint working
 namespace drawinglayer::primitive2d
 {
diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx
index a75499c9ee6a..809f2a542236 100644
--- a/sw/source/core/inc/dflyobj.hxx
+++ b/sw/source/core/inc/dflyobj.hxx
@@ -53,6 +53,8 @@ public:
     virtual SdrObjKind GetObjIdentifier()   const override;
     virtual bool IsTextBox() const override { return mbIsTextBox; }
     void SetTextBox(bool bIsTextBox) { mbIsTextBox = bIsTextBox; }
+
+    virtual void NbcRotate(const Point& rRef, Degree100 nAngle, double 
sinAnle, double cosAngle) override;
 };
 
 // virtual objects for Flys
@@ -121,6 +123,7 @@ public:
     virtual       void       addCropHandles(SdrHdlList& rTarget) const 
override;
     virtual       void       Rotate(const Point& rRef, Degree100 nAngle, 
double sn, double cs) override;
 
+
     // FullDrag support
     virtual rtl::Reference<SdrObject> getFullDragClone() const override;
 
commit 33619f2bce2dae83ca1ec1b0e0d209e8f6415ac6
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Sat Feb 11 17:08:54 2023 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat Mar 4 19:08:08 2023 +0900

    svx: make SdrObject abstract by making CloneSdrObject pure virtual
    
    This change makes SdrObject an abstract class that can't be as
    we don't want it to be instantiated. With this the ClonseSdrObject
    became a pure virtual function.
    
    With this change also the SwFlyDrawObj needs a implementation of
    the CloneSdrFunction, which was previously provided by SdrObject.
    
    Change-Id: I2efb8c1e6fac12b17ce497285067029d7da1c1fd

diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 55efe42267fe..a22e62a61654 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -443,7 +443,7 @@ public:
     virtual bool HasLimitedRotation() const;
 
     // Returns a copy of the object. Every inherited class must reimplement 
this.
-    virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) 
const;
+    virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) 
const = 0;
     // helper, since Clone always return the type of the current subclass
     template<class T>
     static rtl::Reference<T> Clone(T const & rObj, SdrModel& rTargetModel)
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 25da79240189..c2a266bb0a4d 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -1043,11 +1043,6 @@ bool SdrObject::HasLimitedRotation() const
     return false;
 }
 
-rtl::Reference<SdrObject> SdrObject::CloneSdrObject(SdrModel& rTargetModel) 
const
-{
-    return new SdrObject(rTargetModel, *this);
-}
-
 OUString SdrObject::TakeObjNameSingul() const
 {
     OUString sName(SvxResId(STR_ObjNameSingulNONE));
@@ -3346,7 +3341,7 @@ rtl::Reference<SdrObject> SdrObjFactory::MakeNewObject(
                 }
             }
             break;
-            case SdrObjKind::NONE       : pObj=new SdrObject(rSdrModel);       
            break;
+            case SdrObjKind::NONE       : pObj = nullptr; break;
             case SdrObjKind::Group       : pObj=new SdrObjGroup(rSdrModel);    
             break;
             case SdrObjKind::Polygon       : pObj=new SdrPathObj(rSdrModel, 
SdrObjKind::Polygon       ); break;
             case SdrObjKind::PolyLine       : pObj=new SdrPathObj(rSdrModel, 
SdrObjKind::PolyLine       ); break;
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index 3095d5a2a6f4..45068cf1fd89 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -130,6 +130,12 @@ SwFlyDrawObj::SwFlyDrawObj(SdrModel& rSdrModel)
 {
 }
 
+SwFlyDrawObj::SwFlyDrawObj(SdrModel& rSdrModel, SwFlyDrawObj const& rSource)
+    : SdrObject(rSdrModel, rSource)
+    , mbIsTextBox(false)
+{
+}
+
 SwFlyDrawObj::~SwFlyDrawObj()
 {
 }
@@ -145,6 +151,11 @@ SdrObjKind SwFlyDrawObj::GetObjIdentifier() const
     return SdrObjKind::SwFlyDrawObjIdentifier;
 }
 
+rtl::Reference<SdrObject> SwFlyDrawObj::CloneSdrObject(SdrModel& rTargetModel) 
const
+{
+    return new SwFlyDrawObj(rTargetModel);
+}
+
 // TODO: Need own primitive to get the FlyFrame paint working
 namespace drawinglayer::primitive2d
 {
diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx
index db853d2262b2..a75499c9ee6a 100644
--- a/sw/source/core/inc/dflyobj.hxx
+++ b/sw/source/core/inc/dflyobj.hxx
@@ -44,8 +44,11 @@ private:
 
 public:
     SwFlyDrawObj(SdrModel& rSdrModel);
+    SwFlyDrawObj(SdrModel& rSdrModel, SwFlyDrawObj const& rSource);
+
+    // for instantiation of this class while loading (via factory
+    virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) 
const;
 
-    // for instantiation of this class while loading (via factory)
     virtual SdrInventor GetObjInventor()     const override;
     virtual SdrObjKind GetObjIdentifier()   const override;
     virtual bool IsTextBox() const override { return mbIsTextBox; }
commit 25bfa737b89d15ab9df5b631349e6c8071e9b844
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Feb 10 18:10:33 2023 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat Mar 4 19:08:08 2023 +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 dea845a26bc1..e213d5f1ea61 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
 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 c491dddb00a1..6a40dca7a081 100644
--- a/svx/qa/unit/svdraw.cxx
+++ b/svx/qa/unit/svdraw.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include <test/unoapixml_test.hxx>
+#include <basegfx/units/Length.hxx>
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
@@ -24,6 +24,7 @@
 #include <svx/sdr/contact/displayinfo.hxx>
 #include <svx/sdr/contact/viewcontact.hxx>
 #include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/svdtrans.hxx>
 #include <svx/svdorect.hxx>
 #include <svx/unopage.hxx>
 #include <svx/svdview.hxx>
@@ -37,10 +38,10 @@
 
 #include <sdr/contact/objectcontactofobjlistpainter.hxx>
 
+#include <test/unoapixml_test.hxx>
+
 using namespace ::com::sun::star;
 
-namespace
-{
 /// Tests for svx/source/svdraw/ code.
 class SvdrawTest : public UnoApiXmlTest
 {
@@ -549,6 +550,68 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testPageViewDrawLayerClip)
     // i.e. the 2nd page had a line shape from the first page's footer.
     CPPUNIT_ASSERT_EQUAL(2, pPage2->getObjectCount());
 }
+
+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);
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 44a8c90cb1d2..25da79240189 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -35,6 +35,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>
@@ -946,10 +947,8 @@ void SdrObject::RecalcBoundRect()
     if ((getSdrModelFromSdrObject().isLocked()) || 
utl::ConfigManager::IsFuzzing())
         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
@@ -1409,24 +1408,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 ad44aa230e17..04b02e9184c6 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 5c185249c28ead10be0d19fa2848f029ee5c87c2
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Feb 10 00:28:22 2023 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat Mar 4 19:08:07 2023 +0900

    update length
    
    Change-Id: I0025f13c55382ab7d6b543c871db1b3f7bbaacf2

diff --git a/basegfx/test/LengthUnitTest.cxx b/basegfx/test/LengthUnitTest.cxx
index 2f597f0274d2..02da22fc17f5 100644
--- a/basegfx/test/LengthUnitTest.cxx
+++ b/basegfx/test/LengthUnitTest.cxx
@@ -18,25 +18,49 @@
 class LengthTest : public CppUnit::TestFixture
 {
 public:
-    void testBasic()
+    void testCreation()
     {
-        gfx::Length cm = 1_cm + 5_cm - 2_cm;
-        CPPUNIT_ASSERT_DOUBLES_EQUAL(4.0, cm.as_cm(), 1e-4);
-        CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04, cm.as_meter(), 1e-4);
-        CPPUNIT_ASSERT_DOUBLES_EQUAL(40.0, cm.as_mm(), 1e-4);
-        CPPUNIT_ASSERT_EQUAL(sal_Int64(1440000), cm.raw());
+        //  Creation from integer number
+        int number = 10;
+        auto asCm = gfx::Length::cm(number);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asCm.as_cm(), 1e-4);
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(3600000), asCm.raw());
 
-        gfx::Length cm2 = 5_cm * 2;
-        CPPUNIT_ASSERT_EQUAL(sal_Int64(3600000), cm2.raw());
-        CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, cm2.as_cm(), 1e-4);
+        auto asMm = gfx::Length::mm(number);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asMm.as_mm(), 1e-4);
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(360000), asMm.raw());
 
-        // 1 km - 50 m = 950 m = 95000 cm
-        gfx::Length cm3 = 100000_cm - 5000_cm;
-        CPPUNIT_ASSERT_EQUAL(sal_Int64(34200000000), cm3.raw());
-        CPPUNIT_ASSERT_DOUBLES_EQUAL(95000.0, cm3.as_cm(), 1e-4);
+        auto asInch = gfx::Length::in(number);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asInch.as_in(), 1e-4);
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(9144000), asInch.raw());
 
-        gfx::Length cm4 = -100_cm - 10_cm;
-        CPPUNIT_ASSERT_EQUAL(sal_Int64(-39600000), cm4.raw());
+        auto forceInteger = gfx::Length::hmm<sal_Int64>(10.1);
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(3600), forceInteger.raw());
+
+        auto forceDouble = gfx::Length::hmm<double>(10.1);
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(3636), forceDouble.raw());
+    }
+
+    void testUnitConversion()
+    {
+        // Big values
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(34200000000), (950_m).raw());
+        CPPUNIT_ASSERT_EQUAL(95000_cm, 950_m);
+        CPPUNIT_ASSERT_EQUAL(950000_mm, 950_m);
+        CPPUNIT_ASSERT_EQUAL(95000000_hmm, 950_m);
+        CPPUNIT_ASSERT_EQUAL(34200000000_emu, 950_m);
+
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(-34200000000), (-950_m).raw());
+        CPPUNIT_ASSERT_EQUAL(-95000_cm, -950_m);
+        CPPUNIT_ASSERT_EQUAL(-950000_mm, -950_m);
+        CPPUNIT_ASSERT_EQUAL(-95000000_hmm, -950_m);
+        CPPUNIT_ASSERT_EQUAL(-34200000000_emu, -950_m);
+
+        // To double value in chosen unit
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(4.0, (4_cm).as_cm(), 1e-4);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04, (4_cm).as_meter(), 1e-4);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(40.0, (4_cm).as_mm(), 1e-4);
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(1440000), (4_cm).raw());
 
         // (635 * 20) + 3 * (635 * 15) = 41275EMU
         gfx::Length pt = 1_pt + 3_px;
@@ -51,13 +75,10 @@ public:
         CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, inch.as_in(), 1e-4);
         CPPUNIT_ASSERT_DOUBLES_EQUAL(914400.0, inch.as_emu(), 1e-4);
         CPPUNIT_ASSERT_EQUAL(sal_Int64(914400), inch.raw());
+    }
 
-        // Conversion
-        sal_Int64 asNumber(17_pt);
-        asNumber += sal_Int64(1_pt);
-        gfx::Length asLength = gfx::Length::emu(asNumber);
-        CPPUNIT_ASSERT_EQUAL(sal_Int64(18 * 635 * 20), asLength.raw());
-
+    void testLimits()
+    {
         gfx::Length maximum = gfx::Length::emu(SAL_MAX_INT64);
         CPPUNIT_ASSERT_DOUBLES_EQUAL(256204778801.5, maximum.as_meter(), 1e-1);
         // 256204778 km
@@ -67,30 +88,62 @@ public:
         CPPUNIT_ASSERT_DOUBLES_EQUAL(-256204778801.5, minimum.as_meter(), 
1e-1);
         CPPUNIT_ASSERT_DOUBLES_EQUAL(double(SAL_MIN_INT64), minimum.as_emu(), 
1e-1);
         CPPUNIT_ASSERT_EQUAL(sal_Int64(SAL_MIN_INT64), minimum.raw());
+    }
+
+    void testAdditionAndSubstitution()
+    {
+        // results in zero
+        CPPUNIT_ASSERT_EQUAL(0_cm, 100_cm - 100_cm);
+        CPPUNIT_ASSERT_EQUAL(0_cm, -100_cm + 100_cm);
+
+        // + and - with zero
+        CPPUNIT_ASSERT_EQUAL(10_cm, 10_cm + 0_cm);
+        CPPUNIT_ASSERT_EQUAL(10_cm, 10_cm - 0_cm);
+        CPPUNIT_ASSERT_EQUAL(10_cm, 10_cm - 0_cm + 0_emu - 0_twip);
+
+        // common
+        CPPUNIT_ASSERT_EQUAL(6_cm, 1_cm + 5_cm);
+        CPPUNIT_ASSERT_EQUAL(-4_cm, 1_cm - 5_cm);
+        CPPUNIT_ASSERT_EQUAL(4_cm, -1_cm + 5_cm);
+        CPPUNIT_ASSERT_EQUAL(-6_cm, -1_cm - 5_cm);
+
+        // long chain
+        CPPUNIT_ASSERT_EQUAL(35129_hmm, 1_mm - 5_cm + 40_cm - 1_hmm + 30_hmm);
+
+        // floating point
+        CPPUNIT_ASSERT_EQUAL(1_mm, 0.5_mm + 0.5_mm);
+
+        // mixed units
+        CPPUNIT_ASSERT_EQUAL(180_emu + 635_emu, 0.5_hmm + 1_twip);
+        CPPUNIT_ASSERT_EQUAL(554400_emu, 1_in - 1_cm);
+
+        // Big values - 1km - 50m
+        CPPUNIT_ASSERT_EQUAL(95000_cm, 1000_m - 5000_cm);
 
         // 27 emu + 33 emu + 360 emu = 420
         gfx::Length emus = 27_emu + 33_emu + 1_hmm;
         CPPUNIT_ASSERT_EQUAL(sal_Int64(420), emus.raw());
+    }
 
-        //  Creation from number
-        int number = 10;
-        auto asCm = gfx::Length::cm(number);
-        CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asCm.as_cm(), 1e-4);
-        CPPUNIT_ASSERT_EQUAL(sal_Int64(3600000), asCm.raw());
+    void testMultiplication()
+    {
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(0), (1_hmm * 0).raw());
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(720), (1_hmm * 2).raw());
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(-720), (1_hmm * -2).raw());
 
-        auto asMm = gfx::Length::mm(number);
-        CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asMm.as_mm(), 1e-4);
-        CPPUNIT_ASSERT_EQUAL(sal_Int64(360000), asMm.raw());
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(0), (1_hmm * 0.0).raw());
 
-        auto asInch = gfx::Length::in(number);
-        CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asInch.as_in(), 1e-4);
-        CPPUNIT_ASSERT_EQUAL(sal_Int64(9144000), asInch.raw());
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(720), (1_hmm * 2.0).raw());
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(-720), (1_hmm * -2.0).raw());
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(-720), (-1_hmm * 2.0).raw());
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(720), (-1_hmm * -2.0).raw());
 
-        auto aa = gfx::Length::hmm<sal_Int64>(10.1);
-        CPPUNIT_ASSERT_EQUAL(sal_Int64(3600), aa.raw());
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(180), (1_hmm * 0.5).raw());
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(-180), (-1_hmm * 0.5).raw());
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(-180), (1_hmm * -0.5).raw());
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(180), (-1_hmm * -0.5).raw());
 
-        auto bb = gfx::Length::hmm<double>(10.1);
-        CPPUNIT_ASSERT_EQUAL(sal_Int64(3636), bb.raw());
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(90), (0.5_hmm * 0.5).raw());
     }
 
     void testDivision()
@@ -308,7 +361,11 @@ public:
     }
 
     CPPUNIT_TEST_SUITE(LengthTest);
-    CPPUNIT_TEST(testBasic);
+    CPPUNIT_TEST(testCreation);
+    CPPUNIT_TEST(testUnitConversion);
+    CPPUNIT_TEST(testLimits);
+    CPPUNIT_TEST(testAdditionAndSubstitution);
+    CPPUNIT_TEST(testMultiplication);
     CPPUNIT_TEST(testDivision);
     CPPUNIT_TEST(testGenericFrom);
     CPPUNIT_TEST(testGenericAs);
diff --git a/include/basegfx/units/LengthBase.hxx 
b/include/basegfx/units/LengthBase.hxx
index 8768d4abd8f9..7f9f48026820 100644
--- a/include/basegfx/units/LengthBase.hxx
+++ b/include/basegfx/units/LengthBase.hxx
@@ -160,13 +160,13 @@ public:
         return *this;
     }
 
-    constexpr LengthBase& operator*=(TYPE const& rhs)
+    template <typename INPUT> constexpr LengthBase& operator*=(INPUT const& 
rhs)
     {
         m_nValue *= rhs;
         return *this;
     }
 
-    constexpr LengthBase& operator/=(TYPE const& rhs)
+    template <typename INPUT> constexpr LengthBase& operator/=(INPUT const& 
rhs)
     {
         m_nValue /= rhs;
         return *this;
@@ -238,14 +238,16 @@ template <typename T> inline LengthBase<T> 
operator-(LengthBase<T> lhs, const Le
 
 /// Multiplication of a length unit with a scalar value.
 /// example 1cm * 2 = 2cm
-template <typename T> inline LengthBase<T> operator*(LengthBase<T> lhs, const 
long rhs)
+template <typename T, typename INPUT_TYPE>
+inline LengthBase<T> operator*(LengthBase<T> lhs, const INPUT_TYPE rhs)
 {
     return lhs *= rhs;
 }
 
 /// Division of a length unit with a scalar value.
 /// example 1cm / 2 = 0.5cm
-template <typename T> inline LengthBase<T> operator/(LengthBase<T> lhs, const 
long rhs)
+template <typename T, typename INPUT_TYPE>
+inline LengthBase<T> operator/(LengthBase<T> lhs, const INPUT_TYPE rhs)
 {
     return lhs /= rhs;
 }
commit c1fd74e091df08afc9cae513525f352485e1bc02
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Feb 9 21:16:55 2023 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat Mar 4 19:07:42 2023 +0900

    svx: minor fix
    
    Change-Id: I25e77c8abd12e2075939f55e06f40343ac23ca97

diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index a9cc15eebb11..25248e5195ea 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -154,7 +154,6 @@ void SdrTextObj::NbcResize(const Point& rRef, const 
Fraction& xFact, const Fract
             aPol[3] = aPol0[2];
             aPol[4] = aPol0[1];
         }
-        tools::Rectangle aRectangle(getRectangle());
         aRectangle = svx::polygonToRectangle(aPol, maGeo);
         setRectangle(aRectangle);
     }
@@ -227,6 +226,7 @@ void SdrTextObj::NbcShear(const Point& rRef, Degree100 
/*nAngle*/, double tn, bo
     }
     auto aRectangle = getRectangle();
     aRectangle = svx::polygonToRectangle(aPol, maGeo);
+    ImpJustifyRect(aRectangle);
     setRectangle(aRectangle);
 
     if (mbTextFrame) {
commit 27f8b9902293e8aee992bed1506519937621cd7f
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Feb 9 10:03:43 2023 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat Mar 4 19:04:28 2023 +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 a1cccb0804a4..4861eb3bf5ce 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -28,6 +28,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>
@@ -165,31 +166,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 ab8bc58ddf85..020551bcdf5e 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 20e54ca976ac..7b33092dfc48 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -101,7 +101,7 @@ SdrTextObj::SdrTextObj(SdrModel& rSdrModel, SdrTextObj 
const & rSource)
     // #i25616#
     mbSupportTextIndentingOnLineWidthChange = true;
 
-    maRectangle = rSource.maRectangle;
+    maRectangleRange = rSource.maRectangleRange;
     maGeo = rSource.maGeo;
     maTextSize = rSource.maTextSize;
 
@@ -201,8 +201,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 0834e6f3040d..a9cc15eebb11 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.nRotationAngle=18000_deg100;
             maGeo.RecalcSinCos();
@@ -134,7 +135,8 @@ void SdrTextObj::NbcResize(const Point& rRef, const 
Fraction& xFact, const Fract
     }
     else
     {
-        tools::Polygon aPol(Rect2Poly(getRectangle(), maGeo));
+        auto aRectangle = getRectangle();
+        tools::Polygon aPol(Rect2Poly(aRectangle, maGeo));
 
         for(sal_uInt16 a(0); a < aPol.GetSize(); a++)
         {
@@ -175,8 +177,6 @@ void SdrTextObj::NbcResize(const Point& rRef, const 
Fraction& xFact, const Fract
         }
     }
 
-    ImpJustifyRect(maRectangle);
-
     AdaptTextMinSize();
 
     if(mbTextFrame && !getSdrModelFromSdrObject().IsPasteResize())
@@ -191,12 +191,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.nRotationAngle==0_deg100) {
@@ -216,8 +217,9 @@ 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++) {
@@ -226,7 +228,6 @@ void SdrTextObj::NbcShear(const Point& rRef, Degree100 
/*nAngle*/, double tn, bo
     auto aRectangle = getRectangle();
     aRectangle = svx::polygonToRectangle(aPol, maGeo);
     setRectangle(aRectangle);
-    ImpJustifyRect(maRectangle);
 
     if (mbTextFrame) {
         NbcAdjustTextFrameWidthAndHeight();
@@ -247,7 +248,8 @@ void SdrTextObj::NbcMirror(const Point& rRef1, const Point& 
rRef2)
          std::abs(rRef1.X()-rRef2.X())==std::abs(rRef1.Y()-rRef2.Y()))) {
         bRotate90=maGeo.nRotationAngle.get() % 9000 ==0;
     }
-    tools::Polygon aPol(Rect2Poly(getRectangle(),maGeo));
+    tools::Rectangle aRectangle = getRectangle();
+    tools::Polygon aPol(Rect2Poly(aRectangle, maGeo));
     sal_uInt16 i;
     sal_uInt16 nPointCount=aPol.GetSize();
     for (i=0; i<nPointCount; i++) {
@@ -282,7 +284,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 25ab8715d307..b927bfbd2ebe 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 c4d41c49d13ce9279880938b7c9c61e3cc38794a
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Wed Feb 8 10:42:19 2023 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat Mar 4 19:01:20 2023 +0900

    use Range2DLWrap for "OutRectangle" in SdrObject
    
    Change-Id: I243b44a84bc09991744009ae24ac7657d493c5cf

diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 08ef71a168a8..55efe42267fe 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -34,6 +34,7 @@
 #include <tools/gen.hxx>
 #include <unotools/resmgr.hxx>
 #include <unotools/weakref.hxx>
+#include <basegfx/units/Range2DLWrap.hxx>
 #include <osl/diagnose.h>
 #include <typeinfo>
 
@@ -885,13 +886,15 @@ public:
     void ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) 
const noexcept;
 
 protected:
-    const tools::Rectangle& getOutRectangle() const;
+    tools::Rectangle const& getOutRectangle() const;
+    bool isOutRectangleEmpty() const;
     void setOutRectangleConst(tools::Rectangle const& rRectangle) const; // 
need to do something about this
     void setOutRectangle(tools::Rectangle const& rRectangle);
     void resetOutRectangle();
     void moveOutRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta);
 
-    mutable tools::Rectangle m_aOutRect;     // surrounding rectangle for 
Paint (incl. LineWidth, ...)
+    mutable gfx::Range2DLWrap m_aOutterRange; // surrounding rectangle for 
Paint (incl. LineWidth, ...)
+
     Point                       m_aAnchor;      // anchor position (Writer)
     SdrObjUserCall*             m_pUserCall;
     std::unique_ptr<SdrObjPlusData>
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index 3cf30db2ee84..19dc68c5d2cc 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -396,6 +396,14 @@ public:
     tools::Long upperUnit() const { return maUpper.as(meUnit); }
     tools::Long lowerUnit() const { return maLower.as(meUnit); }
 
+    bool operator==(Border const& other) const
+    {
+        return maLeft == other.maLeft
+        &&  maRight == other.maRight
+        &&  maUpper == other.maUpper
+        &&  maLower == other.maLower;
+    }
+
     tools::Rectangle toToolsRect() const
     {
         return tools::Rectangle(leftUnit(), upperUnit(), rightUnit(), 
lowerUnit());
@@ -586,10 +594,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 e733c2d83871..44a8c90cb1d2 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -34,6 +34,7 @@
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
 #include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/units/Range2DLWrap.hxx>
 #include <basegfx/range/b2drange.hxx>
 #include <drawinglayer/processor2d/contourextractor2d.hxx>
 #include <drawinglayer/processor2d/linegeometryextractor2d.hxx>
@@ -925,13 +926,9 @@ void SdrObject::SetNavigationPosition (const sal_uInt32 
nNewPosition)
 // GetCurrentBoundRect().
 const tools::Rectangle& SdrObject::GetCurrentBoundRect() const
 {
-    auto const& rRectangle = getOutRectangle();
-    if (rRectangle.IsEmpty())
-    {
-        const_cast< SdrObject* >(this)->RecalcBoundRect();
-    }
-
-    return rRectangle;
+    if (isOutRectangleEmpty())
+        const_cast<SdrObject*>(this)->RecalcBoundRect();
+    return getOutRectangle();
 }
 
 // To have a possibility to get the last calculated BoundRect e.g for producing
@@ -969,13 +966,12 @@ void SdrObject::RecalcBoundRect()
 
     if (!aRange.isEmpty())
     {
-        tools::Rectangle aNewRectangle(
-            tools::Long(floor(aRange.getMinX())),
-            tools::Long(floor(aRange.getMinY())),
-            tools::Long(ceil(aRange.getMaxX())),
-            tools::Long(ceil(aRange.getMaxY())));
-        setOutRectangle(aNewRectangle);
-        return;
+        const basegfx::B2DRange aRoundedRange(
+            std::floor(aRange.getMinX()),
+            std::floor(aRange.getMinY()),
+            std::ceil(aRange.getMaxX()),
+            std::ceil(aRange.getMaxY()));
+        m_aOutterRange = gfx::Range2DLWrap::create(aRoundedRange, 
getSdrModelFromSdrObject().getUnit());
     }
 }
 
@@ -3179,27 +3175,41 @@ void 
SdrObject::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygo
 
 const tools::Rectangle& SdrObject::getOutRectangle() const
 {
-    return m_aOutRect;
+    return m_aOutterRange.toToolsRect();
+}
+
+bool SdrObject::isOutRectangleEmpty() const
+{
+    return getOutRectangle().IsEmpty();
 }
 
 void SdrObject::setOutRectangleConst(tools::Rectangle const& rRectangle) const
 {
-    m_aOutRect = rRectangle;
+    auto eUnit = getSdrModelFromSdrObject().getUnit();
+    m_aOutterRange = gfx::Range2DLWrap::create(rRectangle, eUnit);
 }
 
 void SdrObject::setOutRectangle(tools::Rectangle const& rRectangle)
 {
-    m_aOutRect = rRectangle;
+    auto eUnit = getSdrModelFromSdrObject().getUnit();
+    m_aOutterRange = gfx::Range2DLWrap::create(rRectangle, eUnit);
 }
 
 void SdrObject::resetOutRectangle()
 {
-    m_aOutRect = tools::Rectangle();
+    m_aOutterRange.reset();
 }
 
 void SdrObject::moveOutRectangle(sal_Int32 nXDelta, sal_Int32 nYDelta)
 {
-    m_aOutRect.Move(nXDelta, nYDelta);
+    if (nXDelta == 0 && nYDelta == 0)
+        return;
+
+    auto eUnit = getSdrModelFromSdrObject().getUnit();
+    auto xDelta = gfx::Length::from(eUnit, nXDelta);
+    auto yDelta = gfx::Length::from(eUnit, nYDelta);
+
+    m_aOutterRange.shift(xDelta, yDelta);
 }
 
 E3dScene* DynCastE3dScene(SdrObject* pObj)
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index baf011520cbb..ea9b24089398 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -1444,16 +1444,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)
@@ -1477,6 +1472,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 a7c57ec0d609..52a45c6e95a4 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -2428,10 +2428,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 4f4cd7c070d87518c9b4443880221fefb2452f12
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Wed Feb 8 10:41:22 2023 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat Mar 4 19:00:18 2023 +0900

    gfx::Length updates
    
    Change-Id: I4c5936bb28456ababcfd4df4128e00b3d07d3b93

diff --git a/basegfx/test/LengthUnitTest.cxx b/basegfx/test/LengthUnitTest.cxx
index c3445b41b3ee..2f597f0274d2 100644
--- a/basegfx/test/LengthUnitTest.cxx
+++ b/basegfx/test/LengthUnitTest.cxx
@@ -288,6 +288,22 @@ public:
             CPPUNIT_ASSERT_EQUAL(100_hmm, aRange.getMaxY());
             CPPUNIT_ASSERT_EQUAL(0_hmm, aRange.getWidth());
             CPPUNIT_ASSERT_EQUAL(0_hmm, aRange.getHeight());
+
+            auto aRectFromRange = aRange.toToolsRect();
+            CPPUNIT_ASSERT_EQUAL(tools::Long(100), aRectFromRange.Left());
+            CPPUNIT_ASSERT_EQUAL(tools::Long(100), aRectFromRange.Top());
+            CPPUNIT_ASSERT_EQUAL(tools::Long(100), aRectFromRange.Right());
+            CPPUNIT_ASSERT_EQUAL(tools::Long(100), aRectFromRange.Bottom());
+            CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRectFromRange.GetWidth());
+            CPPUNIT_ASSERT_EQUAL(tools::Long(0), aRectFromRange.GetHeight());
+        }
+        {
+            basegfx::B2DRange aB2DRange(0.5, 0.5, 1.5, 1.5);
+            gfx::Range2DL aRange = gfx::Range2DLWrap::create(aB2DRange, 
gfx::LengthUnit::hmm);
+            CPPUNIT_ASSERT_EQUAL(180_emu, aRange.getMinX());
+            CPPUNIT_ASSERT_EQUAL(180_emu, aRange.getMinY());
+            CPPUNIT_ASSERT_EQUAL(540_emu, aRange.getMaxX());
+            CPPUNIT_ASSERT_EQUAL(540_emu, aRange.getMaxY());
         }
     }
 
diff --git a/include/basegfx/units/Range2DLWrap.hxx 
b/include/basegfx/units/Range2DLWrap.hxx
index cb15a20d5d4d..196e751ada9a 100644
--- a/include/basegfx/units/Range2DLWrap.hxx
+++ b/include/basegfx/units/Range2DLWrap.hxx
@@ -36,6 +36,20 @@ public:
         return Range2DLWrap(left, top, right, bottom, eUnit);
     }
 
+    static Range2DLWrap create(basegfx::B2DRange const& rRange2D,
+                               LengthUnit eUnit = LengthUnit::hmm)
+    {
+        if (rRange2D.isEmpty())
+            return Range2DLWrap(eUnit);
+
+        auto left = Length::from(eUnit, rRange2D.getMinX());
+        auto top = Length::from(eUnit, rRange2D.getMinY());
+        auto right = Length::from(eUnit, rRange2D.getMaxX());
+        auto bottom = Length::from(eUnit, rRange2D.getMaxY());
+
+        return Range2DLWrap(left, top, right, bottom, eUnit);
+    }
+
     Range2DLWrap(LengthUnit eUnit = LengthUnit::hmm)
         : Range2DL()
         , meUnit(eUnit)
@@ -61,8 +75,17 @@ public:
             auto top = getMinY().as(meUnit);
             auto right = getMaxX().as(meUnit);
             auto bottom = getMaxY().as(meUnit);
-            maRectangle = tools::Rectangle(basegfx::fround(left), 
basegfx::fround(top),
-                                           basegfx::fround(right), 
basegfx::fround(bottom));
+
+            if (left == right && top == bottom)
+            {
+                maRectangle = tools::Rectangle();
+                maRectangle.Move(basegfx::fround(left), basegfx::fround(top));
+            }
+            else
+            {
+                maRectangle = tools::Rectangle(basegfx::fround(left), 
basegfx::fround(top),
+                                               basegfx::fround(right), 
basegfx::fround(bottom));
+            }
         }
         return maRectangle;
     }
commit a687a2c553531dc75d4c658da0c14cf032c6ce8f
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Wed Oct 26 20:21:37 2022 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat Mar 4 18:58:51 2023 +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/svdpage.hxx b/include/svx/svdpage.hxx
index 644a7756bb71..3cf30db2ee84 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -374,6 +374,13 @@ public:
         , meUnit(eUnit)
     {}
 
+    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 924ed8474472..9ff7288e5be4 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -499,7 +499,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);
@@ -516,8 +516,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);
@@ -553,7 +553,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())
@@ -563,12 +563,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
             {
@@ -577,14 +577,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());
         }
 
@@ -619,16 +619,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 e42c4b68ee98942c343409e7adba636f279c0474
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Feb 2 19:22:23 2023 +0900
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Sat Mar 4 18:56:20 2023 +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 cede03ac4f41..96ea5679cb53 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -215,12 +215,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( "HiddenLayer", 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 );
@@ -266,7 +267,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() ));
@@ -1217,11 +1218,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 3e06307941da..3a7a5cc7dc76 100644
--- a/basctl/source/dlged/dlgedobj.cxx
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -418,7 +418,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;
@@ -1297,7 +1297,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;
@@ -1347,7 +1347,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 81271d38f8bd..a9a6c821e480 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 0b3df1aa22ad..f90c781ee84e 100644
--- a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
+++ b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
@@ -149,7 +149,7 @@ Graphic ViewElementListProvider::GetSymbolGraphic( 
sal_Int32 nStandardSymbol, co
 
     pModel->GetItemPool().FreezeIdRanges();
     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 935c0832d649..3a8be649e3cf 100644
--- a/chart2/source/controller/main/DrawCommandDispatch.cxx
+++ b/chart2/source/controller/main/DrawCommandDispatch.cxx
@@ -424,7 +424,7 @@ rtl::Reference<SdrObject> 
DrawCommandDispatch::createDefaultObject( const sal_uI
             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 c7e3d6d092a2..8ca821daca94 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1385,7 +1385,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 85efe01a1c2f..9aefabdd808f 100644
--- a/cui/source/tabpages/tpline.cxx
+++ b/cui/source/tabpages/tpline.cxx
@@ -816,7 +816,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs )
             new SdrModel(nullptr, nullptr, true));
         pModel->GetItemPool().FreezeIdRanges();
         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 @@ IMPL_LINK_NOARG(SvxLineTabPage, MenuCreateHdl_Impl, 
weld::Toggleable&, void)
     pModel->GetItemPool().FreezeIdRanges();
     // 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 cb6381fb6fd3..ba0b9b8f5449 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -1246,7 +1246,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)
         {
@@ -2672,7 +2672,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;
 }
@@ -2814,7 +2815,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 ) )
@@ -3083,15 +3084,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 963a9ae2c4d4..00c39751dfa9 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -321,12 +321,13 @@ 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((aGraphicSize.Width() 
+ aGraphicSize.Height()) * fBorderRelation * 0.5));
 
             // Adapt PageSize and Border stuff. To get all MasterPages and 
PresObjs
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index fe216d569919..86a27c65fd36 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -38,6 +38,7 @@
 
 #include <svx/svdtypes.hxx>
 #include <svx/svxdllapi.h>
+#include <basegfx/units/Length.hxx>
 
 #include <rtl/ref.hxx>
 #include <deque>
@@ -371,6 +372,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 fde15ccedcd9..644a7756bb71 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>
@@ -32,6 +33,7 @@
 #include <svx/svdobj.hxx>
 #include <docmodel/theme/Theme.hxx>
 #include <unotools/weakref.hxx>
+#include <basegfx/units/Length.hxx>
 #include <memory>
 #include <optional>
 #include <vector>
@@ -42,7 +44,6 @@
 namespace reportdesign { class OSection; }
 namespace sdr::contact { class ViewContact; }
 class SdrPage;
-class SdrModel;
 class SfxItemPool;
 class SdrPageView;
 class SdrLayerAdmin;
@@ -352,6 +353,77 @@ public:
     void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
 
+namespace svx
+{
+
+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
 
 /**
   A SdrPage contains exactly one SdrObjList and a description of the physical
@@ -414,12 +486,9 @@ private:
     SdrModel&                   mrSdrModelFromSdrPage;
 
 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;
+
     bool mbBackgroundFullSize = false; ///< Background object to represent the 
whole page.
 
     std::unique_ptr<SdrLayerAdmin> mpLayerAdmin;
@@ -476,21 +545,51 @@ 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;
+
     void    SetBackgroundFullSize(bool bIn);
     bool    IsBackgroundFullSize() const;
 
diff --git a/reportdesign/source/ui/report/ReportSection.cxx 
b/reportdesign/source/ui/report/ReportSection.cxx
index 09ccc044a3c4..30a463366ee7 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()) ) );
 }
 
@@ -481,12 +482,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 f3da3021e265..813a82d32caa 100644
--- a/reportdesign/source/ui/report/SectionView.cxx
+++ b/reportdesign/source/ui/report/SectionView.cxx
@@ -86,7 +86,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 6b6f029fb205..b7a87656f785 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 ec4fee275ed1..5b3ac622419b 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -575,9 +575,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 f33ed9dd6b68..6353c888bbf1 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -395,7 +395,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 e9ab9175ab8f..628904fe6cca 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -594,7 +594,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 ea9ffa9ade9c..fd650e96b4c9 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 72886789b448..6ccb532b60b4 100644
--- a/sc/source/ui/drawfunc/fuins1.cxx
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -175,7 +175,7 @@ static void lcl_InsertGraphic( const Graphic& rGraphic,
     if ( rData.GetDocument().IsNegativePage( rData.GetTabNo() ) )
         aInsertPos.AdjustX( -(aLogicSize.Width()) );       // move position to 
left edge
 
-    ScLimitSizeOnDrawPage( aLogicSize, aInsertPos, pPage->GetSize() );

... etc. - the rest is truncated

Reply via email to