Rebased ref, commits from common ancestor:
commit ff64c2acebdabc78483953d4f5734ed4c3ad1848
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: Tue May 27 08:44:19 2025 +0900

    svx: change SdrPage size and border to use gfx::Length
    
    Change-Id: I382cfba6189eab02581057ab5af437cd1d163138

diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index 8550bf6805f4..69ebc5f8defc 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -218,12 +218,13 @@ DlgEditor::DlgEditor (
     aMarkIdle.SetInvokeHandler( LINK( this, DlgEditor, MarkTimeout ) );
 
     rWindow.SetMapMode( MapMode( MapUnit::Map100thMM ) );
-    pDlgEdPage->SetSize( rWindow.PixelToLogic( Size(DLGED_PAGE_WIDTH_MIN, 
DLGED_PAGE_HEIGHT_MIN) ) );
+    Size aPageSize = rWindow.PixelToLogic(Size(DLGED_PAGE_WIDTH_MIN, 
DLGED_PAGE_HEIGHT_MIN));
+    pDlgEdPage->setToolsSize(aPageSize);
 
     pDlgEdView->ShowSdrPage(pDlgEdView->GetModel().GetPage(0));
     pDlgEdView->SetLayerVisible( u"HiddenLayer"_ustr, false );
     pDlgEdView->SetMoveSnapOnlyTopLeft(true);
-    pDlgEdView->SetWorkArea( tools::Rectangle( Point( 0, 0 ), 
pDlgEdPage->GetSize() ) );
+    pDlgEdView->SetWorkArea(pDlgEdPage->getRectangle().toToolsRect());
 
     Size aGridSize( 100, 100 );  // 100TH_MM
     pDlgEdView->SetGridCoarse( aGridSize );
@@ -269,7 +270,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() ));
@@ -1202,11 +1203,11 @@ bool DlgEditor::AdjustPageSize()
 
             if ( pDlgEdPage )
             {
-                Size aPageSize = pDlgEdPage->GetSize();
+                Size aPageSize = pDlgEdPage->getSize().toToolsSize();
                 if ( nNewPageWidth != aPageSize.Width() || nNewPageHeight != 
aPageSize.Height() )
                 {
                     Size aNewPageSize( nNewPageWidth, nNewPageHeight );
-                    pDlgEdPage->SetSize( aNewPageSize );
+                    pDlgEdPage->setToolsSize(aNewPageSize);
                     pDlgEdView->SetWorkArea( tools::Rectangle( Point( 0, 0 ), 
aNewPageSize ) );
                     bAdjustedPageSize = true;
                 }
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
index bc714d51c768..c545fdd37faa 100644
--- a/basctl/source/dlged/dlgedobj.cxx
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -419,7 +419,7 @@ void DlgEdObj::PositionAndSizeChange( const 
beans::PropertyChangeEvent& evt )
     DBG_ASSERT( pDlgEdForm, "DlgEdObj::PositionAndSizeChange: no form!" );
     DlgEdPage& rPage = pDlgEdForm->GetDlgEditor().GetPage();
     {
-        Size aPageSize = rPage.GetSize();
+        Size aPageSize = rPage.getSize().toToolsSize();
         sal_Int32 nPageWidthIn = aPageSize.Width();
         sal_Int32 nPageHeightIn = aPageSize.Height();
         sal_Int32 nPageX, nPageY, nPageWidth, nPageHeight;
@@ -1294,7 +1294,7 @@ void DlgEdForm::PositionAndSizeChange( const 
beans::PropertyChangeEvent& evt )
 
     sal_Int32 nPageXIn = 0;
     sal_Int32 nPageYIn = 0;
-    Size aPageSize = rPage.GetSize();
+    Size aPageSize = rPage.getSize().toToolsSize();
     sal_Int32 nPageWidthIn = aPageSize.Width();
     sal_Int32 nPageHeightIn = aPageSize.Height();
     sal_Int32 nPageX, nPageY, nPageWidth, nPageHeight;
@@ -1344,7 +1344,7 @@ void DlgEdForm::PositionAndSizeChange( const 
beans::PropertyChangeEvent& evt )
     if ( bAdjustedPageSize )
     {
         rEditor.InitScrollBars();
-        aPageSize = rPage.GetSize();
+        aPageSize = rPage.getSize().toToolsSize();
         nPageWidthIn = aPageSize.Width();
         nPageHeightIn = aPageSize.Height();
         if ( TransformSdrToControlCoordinates( nPageXIn, nPageYIn, 
nPageWidthIn, nPageHeightIn, nPageX, nPageY, nPageWidth, nPageHeight ) )
diff --git a/basctl/source/dlged/dlgedview.cxx 
b/basctl/source/dlged/dlgedview.cxx
index 5ffe5185a2fb..4a3c0281b46e 100644
--- a/basctl/source/dlged/dlgedview.cxx
+++ b/basctl/source/dlged/dlgedview.cxx
@@ -90,7 +90,7 @@ void DlgEdView::MakeVisible( const tools::Rectangle& rRect, 
vcl::Window& rWin )
         nScrollY -= nDeltaY;
 
     // don't scroll beyond the page size
-    Size aPageSize = rDlgEditor.GetPage().GetSize();
+    Size aPageSize = rDlgEditor.GetPage().getSize().toToolsSize();
     sal_Int32 nPageWidth  = aPageSize.Width();
     sal_Int32 nPageHeight = aPageSize.Height();
 
diff --git a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx 
b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
index 51b163d1fccd..c468e7ee87c4 100644
--- a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
+++ b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx
@@ -147,7 +147,7 @@ Graphic ViewElementListProvider::GetSymbolGraphic( 
sal_Int32 nStandardSymbol, co
         new SdrModel());
 
     rtl::Reference<SdrPage> pPage = new SdrPage( *pModel, false );
-    pPage->SetSize(Size(1000,1000));
+    pPage->setSize({ 1000_hmm, 1000_hmm });
     pModel->InsertPage( pPage.get(), 0 );
     SdrView aView(*pModel, pVDev);
     aView.hideMarkHandles();
diff --git a/chart2/source/controller/main/DrawCommandDispatch.cxx 
b/chart2/source/controller/main/DrawCommandDispatch.cxx
index 2065e123ebcd..434070ad990c 100644
--- a/chart2/source/controller/main/DrawCommandDispatch.cxx
+++ b/chart2/source/controller/main/DrawCommandDispatch.cxx
@@ -416,7 +416,7 @@ rtl::Reference<SdrObject> 
DrawCommandDispatch::createDefaultObject( const ChartC
             if ( pObj )
             {
                 Size aObjectSize( 4000, 2500 );
-                tools::Rectangle aPageRect( tools::Rectangle( Point( 0, 0 ), 
pPage->GetSize() ) );
+                tools::Rectangle 
aPageRect(pPage->getRectangle().toToolsRect());
                 Point aObjectPos = aPageRect.Center();
                 aObjectPos.AdjustX( -(aObjectSize.Width() / 2) );
                 aObjectPos.AdjustY( -(aObjectSize.Height() / 2) );
diff --git a/chart2/source/view/main/ChartView.cxx 
b/chart2/source/view/main/ChartView.cxx
index 60192c88fdef..88ed9ec50363 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -1397,7 +1397,7 @@ void ChartView::createShapes()
 
     if (pPage) //it is necessary to use the implementation here as the uno 
page does not provide a propertyset
     {
-        pPage->SetSize(Size(aPageSize.Width,aPageSize.Height));
+        pPage->setSize({ gfx::Length::hmm(aPageSize.Width), 
gfx::Length::hmm(aPageSize.Height) });
     }
     else
     {
diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx
index 8a55cbf12870..a5fe8ca1ffed 100644
--- a/cui/source/tabpages/tpline.cxx
+++ b/cui/source/tabpages/tpline.cxx
@@ -820,7 +820,7 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs )
         std::unique_ptr<SdrModel> pModel(
             new SdrModel(nullptr, nullptr, true));
         rtl::Reference<SdrPage> pPage = new SdrPage( *pModel, false );
-        pPage->SetSize(Size(1000,1000));
+        pPage->setSize({ 1_cm, 1_cm });
         pModel->InsertPage( pPage.get(), 0 );
         {
         SdrView aView( *pModel, pVDev );
@@ -1446,7 +1446,7 @@ void SvxLineTabPage::PopulateMenus()
         new SdrModel(nullptr, nullptr, true));
     // Page
     rtl::Reference<SdrPage> pPage = new SdrPage( *pModel, false );
-    pPage->SetSize(Size(1000,1000));
+    pPage->setSize({ 1_cm, 1_cm });
     pModel->InsertPage( pPage.get(), 0 );
     {
         // 3D View
diff --git a/filter/source/msfilter/svdfppt.cxx 
b/filter/source/msfilter/svdfppt.cxx
index 20d3e5d9bc96..3f69def9cf52 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -1247,7 +1247,7 @@ rtl::Reference<SdrObject> SdrEscherImport::ProcessObj( 
SvStream& rSt, DffObjData
     {
         if ( rObjData.nSpFlags & ShapeFlag::Background )
         {
-            pRet->NbcSetSnapRect( tools::Rectangle( Point(), 
rData.pPage.page->GetSize() ) );   // set size
+            
pRet->NbcSetSnapRect(rData.pPage.page->getRectangle().toToolsRect()); // set 
size
         }
         if (rPersistEntry.xSolverContainer)
         {
@@ -2663,7 +2663,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;
 }
@@ -2805,7 +2806,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 ) )
@@ -3053,15 +3054,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 04514f029425..ed2495a2ede1 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -389,12 +389,12 @@ bool SVGFilter::filterImpressOrDraw( const Sequence< 
PropertyValue >& rDescripto
             // in comparison. Use a common scaling factor for hor/ver to not 
get
             // asynchronous border distances, though. All in all this will 
adapt borders
             // nicely and is based on office-defaults for 
standard-page-border-sizes.
-            const Size aPageSize(pTargetSdrPage->GetSize());
+            const gfx::Size2DL aPageSize = pTargetSdrPage->getSize();
             const double fBorderRelation((
-                static_cast< double >(pTargetSdrPage->GetLeftBorder()) / 
aPageSize.Width() +
-                static_cast< double >(pTargetSdrPage->GetRightBorder()) / 
aPageSize.Width() +
-                static_cast< double >(pTargetSdrPage->GetUpperBorder()) / 
aPageSize.Height() +
-                static_cast< double >(pTargetSdrPage->GetLowerBorder()) / 
aPageSize.Height()) / 4.0);
+                pTargetSdrPage->getBorder().getLeft()  / aPageSize.getWidth() +
+                pTargetSdrPage->getBorder().getRight() / aPageSize.getWidth() +
+                pTargetSdrPage->getBorder().getUpper() / aPageSize.getHeight() 
+
+                pTargetSdrPage->getBorder().getLower() / 
aPageSize.getHeight()) / 4.0);
             const tools::Long 
nAllBorder(basegfx::fround<tools::Long>((aGraphicSize.Width() + 
aGraphicSize.Height()) * fBorderRelation * 0.5));
 
             // Adapt PageSize and Border stuff. To get all MasterPages and 
PresObjs
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index 15b756b1c9e1..0d1e6098d70b 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -39,6 +39,7 @@
 
 #include <svx/svdtypes.hxx>
 #include <svx/svxdllapi.h>
+#include <basegfx/units/Length.hxx>
 
 #include <rtl/ref.hxx>
 #include <deque>
@@ -362,6 +363,13 @@ public:
     MapUnit          GetScaleUnit() const                       { return 
m_eObjUnit; }
     void             SetScaleUnit(MapUnit eMap);
 
+    gfx::LengthUnit getUnit() const
+    {
+        return m_eObjUnit == MapUnit::MapTwip
+                ? gfx::LengthUnit::twip
+                : gfx::LengthUnit::hmm;
+    }
+
     // maximal size e.g. for auto growing texts
     const Size&      GetMaxObjSize() const                      { return 
m_aMaxObjSize; }
     void             SetMaxObjSize(const Size& rSiz)            { 
m_aMaxObjSize=rSiz; }
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index 3d9c60401544..ea3131367a6b 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -24,6 +24,7 @@
 #include <vcl/prntypes.hxx>
 #include <svl/itemset.hxx>
 #include <svx/sdrpageuser.hxx>
+#include <svx/svdmodel.hxx>
 #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
 #include <svx/sdrmasterpagedescriptor.hxx>
 #include <svx/svxdllapi.h>
@@ -31,11 +32,14 @@
 #include <com/sun/star/drawing/XDrawPage.hpp>
 #include <svx/svdobj.hxx>
 #include <unotools/weakref.hxx>
+#include <basegfx/units/Length.hxx>
 #include <memory>
 #include <optional>
 #include <vector>
 #include <deque>
 #include <tools/UniqueID.hxx>
+#include <basegfx/units/Size2DLWrap.hxx>
+#include <basegfx/units/Range2DLWrap.hxx>
 
 // predefines
 namespace model { class Theme; }
@@ -359,6 +363,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
@@ -425,12 +500,8 @@ protected:
     std::vector<rtl::Reference<sdr::annotation::Annotation>> maAnnotations;
 
 private:
-    tools::Long mnWidth;       // page size
-    tools::Long mnHeight;      // page size
-    sal_Int32 mnBorderLeft;  // left page margin
-    sal_Int32 mnBorderUpper; // top page margin
-    sal_Int32 mnBorderRight; // right page margin
-    sal_Int32 mnBorderLower; // bottom page margin
+    gfx::Size2DLWrap maSize;
+    svx::Border maBorder;
     UniqueID maUniqueID;
     bool mbBackgroundFullSize = false; ///< Background object to represent the 
whole page.
 
@@ -488,21 +559,50 @@ public:
     void setPageBorderOnlyLeftRight(bool bNew) { mbPageBorderOnlyLeftRight = 
bNew; }
     bool getPageBorderOnlyLeftRight() const { return 
mbPageBorderOnlyLeftRight; }
 
-    virtual void SetSize(const Size& aSiz);
-    Size GetSize() const;
+    gfx::LengthUnit getUnit() const { return 
getSdrModelFromSdrPage().getUnit(); }
+    virtual void setSize(gfx::Size2DLWrap const& rSize);
+
+    void setToolsSize(Size const rSize)
+    {
+        setSize(gfx::Size2DLWrap::create(rSize, getUnit()));
+    }
+
+    const gfx::Size2DLWrap& getSize() const
+    {
+        return maSize;
+    }
+
+    gfx::Range2DLWrap getRectangle() const
+    {
+        return gfx::Range2DLWrap(0_emu, 0_emu, maSize.getWidth(), 
maSize.getHeight(), getUnit());
+    }
+
+    gfx::Range2DLWrap getInnerRectangle() const
+    {
+        return gfx::Range2DLWrap(maBorder.getLeft(), maBorder.getUpper(),
+                                 maSize.getWidth() - maBorder.getRight(),
+                                 maSize.getHeight() - maBorder.getLower(),
+                                 getUnit());
+    }
+
     virtual void SetOrientation(Orientation eOri);
     virtual Orientation GetOrientation() const;
-    tools::Long GetWidth() const;
-    tools::Long GetHeight() const;
-    virtual void  SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, 
sal_Int32 Lwr);
+
+    virtual svx::Border const& getBorder() const
+    {
+        return maBorder;
+    }
+
+    virtual void setBorder(svx::Border const& rBorder)
+    {
+        maBorder = rBorder;
+    }
+
+    virtual void  SetBorder(sal_Int32 nLeft, sal_Int32 nUpper, sal_Int32 
nRight, sal_Int32 Lower);
     virtual void  SetLeftBorder(sal_Int32 nBorder);
     virtual void  SetUpperBorder(sal_Int32 nBorder);
     virtual void  SetRightBorder(sal_Int32 nBorder);
     virtual void  SetLowerBorder(sal_Int32 nBorder);
-    sal_Int32 GetLeftBorder() const;
-    sal_Int32 GetUpperBorder() const;
-    sal_Int32 GetRightBorder() const;
-    sal_Int32 GetLowerBorder() const;
     sal_uInt64 GetUniqueID() const { return maUniqueID.getID(); }
     void    SetBackgroundFullSize(bool bIn);
     bool    IsBackgroundFullSize() const;
diff --git a/reportdesign/source/ui/report/ReportSection.cxx 
b/reportdesign/source/ui/report/ReportSection.cxx
index de7f0ef69be4..e3072be03ac4 100644
--- a/reportdesign/source/ui/report/ReportSection.cxx
+++ b/reportdesign/source/ui/report/ReportSection.cxx
@@ -221,9 +221,10 @@ void OReportSection::fill()
 //  m_pPage->SetUpperBorder(-10000);
 
     m_pView->SetDesignMode();
-
-    m_pPage->SetSize( Size( 
getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width,5*m_xSection->getHeight())
 );
-    const Size aPageSize = m_pPage->GetSize();
+    auto aWidth = getStyleProperty<awt::Size>(xReportDefinition, 
PROPERTY_PAPERSIZE).Width;
+    auto aHeight = 5 * m_xSection->getHeight();
+    m_pPage->setToolsSize(Size(aWidth, aHeight));
+    const Size aPageSize = m_pPage->getSize().toToolsSize();
     m_pView->SetWorkArea( tools::Rectangle( Point( nLeftMargin, 0), 
Size(aPageSize.Width() - nLeftMargin - nRightMargin,aPageSize.Height()) ) );
 }
 
@@ -482,12 +483,12 @@ void OReportSection::_propertyChanged(const 
beans::PropertyChangeEvent& _rEvent)
         {
             m_pPage->SetRightBorder(nRightMargin);
         }
-        const Size aOldPageSize = m_pPage->GetSize();
+        const Size aOldPageSize = m_pPage->getSize().toToolsSize();
         sal_Int32 nNewHeight = 5*m_xSection->getHeight();
         if ( aOldPageSize.Height() != nNewHeight || nPaperWidth != 
aOldPageSize.Width() )
         {
-            m_pPage->SetSize( Size( nPaperWidth,nNewHeight) );
-            const Size aPageSize = m_pPage->GetSize();
+            m_pPage->setToolsSize(Size(nPaperWidth, nNewHeight));
+            const Size aPageSize = m_pPage->getSize().toToolsSize();
             m_pView->SetWorkArea( tools::Rectangle( Point( nLeftMargin, 0), 
Size(aPageSize.Width() - nLeftMargin - nRightMargin,aPageSize.Height()) ) );
         }
         impl_adjustObjectSizePosition(nPaperWidth,nLeftMargin,nRightMargin);
diff --git a/reportdesign/source/ui/report/SectionView.cxx 
b/reportdesign/source/ui/report/SectionView.cxx
index 4a4bf32ad1b4..72619bd82393 100644
--- a/reportdesign/source/ui/report/SectionView.cxx
+++ b/reportdesign/source/ui/report/SectionView.cxx
@@ -85,7 +85,7 @@ void OSectionView::MakeVisible( const tools::Rectangle& 
rRect, vcl::Window& rWin
         const sal_Int32 nVisBottom = aVisRect.Bottom();
 
         // don't scroll beyond the page size
-        Size aPageSize = m_pSectionWindow->getPage()->GetSize();
+        Size aPageSize = m_pSectionWindow->getPage()->getSize().toToolsSize();
         const sal_Int32 nPageWidth  = aPageSize.Width();
         const sal_Int32 nPageHeight = aPageSize.Height();
 
diff --git a/sc/source/core/data/drawpage.cxx b/sc/source/core/data/drawpage.cxx
index 9baa9be3ca6a..43034dde81f5 100644
--- a/sc/source/core/data/drawpage.cxx
+++ b/sc/source/core/data/drawpage.cxx
@@ -24,8 +24,8 @@
 ScDrawPage::ScDrawPage(ScDrawLayer& rNewModel, bool bMasterPage)
 :   FmFormPage(rNewModel, bMasterPage)
 {
-    SetSize( Size( SAL_MAX_INT32, SAL_MAX_INT32 ) );
-        // largest size supported by sal_Int32 SdrPage::mnWidth/Height
+    setToolsSize(Size(SAL_MAX_INT32, SAL_MAX_INT32));
+    // largest size supported by sal_Int32 SdrPage::mnWidth/Height
 }
 
 ScDrawPage::~ScDrawPage()
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index d41f21e86d71..4d09f4a662bb 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -644,9 +644,9 @@ void ScDrawLayer::SetPageSize(sal_uInt16 nPageNo, const 
Size& rSize, bool bUpdat
     if (!pPage)
         return;
 
-    if ( rSize != pPage->GetSize() )
+    if (rSize != pPage->getSize().toToolsSize())
     {
-        pPage->SetSize( rSize );
+        pPage->setToolsSize(rSize);
         Broadcast( ScTabSizeChangedHint( static_cast<SCTAB>(nPageNo) ) );   // 
SetWorkArea() on the views
     }
 
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 817c33566ba3..8ea866c1a0e5 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -353,7 +353,7 @@ void ScCaptionCreator::Initialize()
     mbNegPage = mrDoc.IsNegativePage( maPos.Tab() );
     if( SdrPage* pDrawPage = GetDrawPage() )
     {
-        maPageRect = tools::Rectangle( Point( 0, 0 ), pDrawPage->GetSize() );
+        maPageRect = pDrawPage->getRectangle().toToolsRect();
         /*  #i98141# SdrPage::GetSize() returns negative width in RTL mode.
             The call to Rectangle::Adjust() orders left/right coordinate
             accordingly. */
diff --git a/sc/source/filter/rtf/eeimpars.cxx 
b/sc/source/filter/rtf/eeimpars.cxx
index f2f50c276beb..f97c60574db1 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -604,7 +604,7 @@ void ScEEImport::InsertGraphic( SCCOL nCol, SCROW nRow, 
SCTAB nTab,
         aLogicSize = pDefaultDev->PixelToLogic( aSizePix, MapMode( 
MapUnit::Map100thMM ) );
 
         // Limit size
-        ::ScLimitSizeOnDrawPage( aLogicSize, aInsertPos, pPage->GetSize() );
+        ::ScLimitSizeOnDrawPage(aLogicSize, aInsertPos, 
pPage->getSize().toToolsSize());
 
         if ( pI->oGraphic )
         {
diff --git a/sc/source/ui/app/client.cxx b/sc/source/ui/app/client.cxx
index 5c44bc077e83..5960a9239c37 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 728865a43f4d..a506bc8207a3 100644
--- a/sc/source/ui/drawfunc/fuins1.cxx
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -183,7 +183,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() );
+    ScLimitSizeOnDrawPage(aLogicSize, aInsertPos, 
pPage->getSize().toToolsSize());
 
     tools::Rectangle aRect ( aInsertPos, aLogicSize );
 
@@ -237,7 +237,7 @@ static void lcl_InsertMedia( const OUString& rMediaURL, 
bool bApi,
     else
         aSize = Size( 5000, 5000 );
 
-    ScLimitSizeOnDrawPage( aSize, aInsertPos, pPage->GetSize() );
+    ScLimitSizeOnDrawPage(aSize, aInsertPos, pPage->getSize().toToolsSize());
 
     if( rData.GetDocument().IsNegativePage( rData.GetTabNo() ) )
         aInsertPos.AdjustX( -(aSize.Width()) );
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
index 8794d3f89521..6a4299967e5b 100644
--- a/sc/source/ui/view/drawview.cxx
+++ b/sc/source/ui/view/drawview.cxx
@@ -258,9 +258,9 @@ void ScDrawView::UpdateWorkArea()
     SdrPage* pPage = GetModel().GetPage(static_cast<sal_uInt16>(nTab));
     if (pPage)
     {
-        Size aPageSize( pPage->GetSize() );
+        Size aPageSize(pPage->getSize().toToolsSize());
         tools::Rectangle aNewArea( Point(), aPageSize );
-        if ( aPageSize.Width() < 0 )
+        if (aPageSize.Width() < 0)
         {
             //  RTL: from max.negative (left) to zero (right)
             aNewArea.SetRight( 0 );
diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx
index 87b25b9dc8eb..d832d7f78187 100644
--- a/sc/source/ui/view/viewfun7.cxx
+++ b/sc/source/ui/view/viewfun7.cxx
@@ -57,7 +57,7 @@ static void lcl_AdjustInsertPos( ScViewData& rData, Point& 
rPos, const Size& rSi
 {
     SdrPage* pPage = rData.GetScDrawView()->GetModel().GetPage( 
static_cast<sal_uInt16>(rData.GetTabNo()) );
     assert(pPage && "pPage ???");
-    Size aPgSize( pPage->GetSize() );
+    Size aPgSize(pPage->getSize().toToolsSize());
     if (aPgSize.Width() < 0)
         aPgSize.setWidth( -aPgSize.Width() );
     tools::Long x = aPgSize.Width() - rPos.X() - rSize.Width();
diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx
index 37bd5aa91a8a..8c8a784d68cb 100644
--- a/sd/inc/drawdoc.hxx
+++ b/sd/inc/drawdoc.hxx
@@ -22,9 +22,11 @@
 #include <com/sun/star/text/WritingMode.hpp>
 #include <svl/style.hxx>
 #include <svx/fmmodel.hxx>
+#include <svx/svdpage.hxx>
 #include <unotools/charclass.hxx>
 #include <vcl/prntypes.hxx>
 #include <xmloff/autolayout.hxx>
+#include <basegfx/units/Size2DLWrap.hxx>
 
 #include <vector>
 #include <memory>
@@ -267,11 +269,8 @@ struct InsertBookmarkOptions
  */
 struct PageProperties
 {
-    Size         size;        // Page size dimensions
-    sal_Int32    left;        // Left margin
-    sal_Int32    right;       // Right margin
-    sal_Int32    upper;       // Upper (top) margin
-    sal_Int32    lower;       // Lower (bottom) margin
+    gfx::Size2DLWrap size;        // Page size dimensions
+    svx::Border border;
     Orientation  orientation; // Page orientation (portrait/landscape)
     SdPage*      pPage;       // Pointer to the page object
 };
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index f5245ddecc1c..c0a55dc59b5f 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -153,7 +153,8 @@ public:
 
     virtual rtl::Reference<SdrPage> CloneSdrPage(SdrModel& rTargetModel) const 
override;
 
-    virtual void    SetSize(const Size& aSize) override;
+    virtual void setSize(gfx::Size2DLWrap const& rSize) override;
+
     virtual void    SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, 
sal_Int32 Lwr) override;
     virtual void    SetLeftBorder(sal_Int32 nBorder) override;
     virtual void    SetRightBorder(sal_Int32 nBorder) override;
diff --git a/sd/source/core/CustomAnimationEffect.cxx 
b/sd/source/core/CustomAnimationEffect.cxx
index 009cdbdb910c..858a7109ea37 100644
--- a/sd/source/core/CustomAnimationEffect.cxx
+++ b/sd/source/core/CustomAnimationEffect.cxx
@@ -1584,8 +1584,8 @@ void CustomAnimationEffect::updateSdrPathObjFromPath( 
SdrPathObj& rPathObj )
             SdrPage* pPage = pObj->getSdrPageFromSdrObject();
             if( pPage )
             {
-                const Size aPageSize( pPage->GetSize() );
-                
aPolyPoly.transform(basegfx::utils::createScaleB2DHomMatrix(static_cast<double>(aPageSize.Width()),
 static_cast<double>(aPageSize.Height())));
+                const auto aPageSize = pPage->getSize().toB2DSize();
+                
aPolyPoly.transform(basegfx::utils::createScaleB2DHomMatrix(aPageSize.getWidth(),
 aPageSize.getHeight()));
             }
 
             const ::tools::Rectangle aBoundRect( pObj->GetCurrentBoundRect() );
@@ -1625,9 +1625,10 @@ void CustomAnimationEffect::updatePathFromSdrPathObj( 
const SdrPathObj& rPathObj
         SdrPage* pPage = pObj->getSdrPageFromSdrObject();
         if( pPage )
         {
-            const Size aPageSize( pPage->GetSize() );
+            const auto aPageSize = pPage->getSize().toB2DSize();
             aPolyPoly.transform(basegfx::utils::createScaleB2DHomMatrix(
-                1.0 / static_cast<double>(aPageSize.Width()), 1.0 / 
static_cast<double>(aPageSize.Height())));
+                1.0 / aPageSize.getWidth(),
+                1.0 / aPageSize.getHeight()));
         }
     }
 
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index a07d24e4ffcb..7f6d5b1a5ab3 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -461,9 +461,11 @@ void SdDrawDocument::AdaptPageSizeForAllPages(
                 new SdPageFormatUndoAction(
                     this,
                     pPage,
-                    pPage->GetSize(),
-                    pPage->GetLeftBorder(), pPage->GetRightBorder(),
-                    pPage->GetUpperBorder(), pPage->GetLowerBorder(),
+                    pPage->getSize().toToolsSize(),
+                    pPage->getBorder().leftUnit(),
+                    pPage->getBorder().rightUnit(),
+                    pPage->getBorder().upperUnit(),
+                    pPage->getBorder().lowerUnit(),
                     pPage->GetOrientation(),
                     pPage->GetPaperBin(),
                     pPage->IsBackgroundFullSize(),
@@ -484,7 +486,7 @@ void SdDrawDocument::AdaptPageSizeForAllPages(
 
             if (rNewSize.Width() > 0)
             {
-                pPage->SetSize(rNewSize);
+                pPage->setToolsSize(rNewSize);
             }
         }
 
@@ -516,9 +518,11 @@ void SdDrawDocument::AdaptPageSizeForAllPages(
                 new SdPageFormatUndoAction(
                     this,
                     pPage,
-                    pPage->GetSize(),
-                    pPage->GetLeftBorder(), pPage->GetRightBorder(),
-                    pPage->GetUpperBorder(), pPage->GetLowerBorder(),
+                    pPage->getSize().toToolsSize(),
+                    pPage->getBorder().leftUnit(),
+                    pPage->getBorder().rightUnit(),
+                    pPage->getBorder().upperUnit(),
+                    pPage->getBorder().lowerUnit(),
                     pPage->GetOrientation(),
                     pPage->GetPaperBin(),
                     pPage->IsBackgroundFullSize(),
@@ -539,7 +543,7 @@ void SdDrawDocument::AdaptPageSizeForAllPages(
 
             if (rNewSize.Width() > 0)
             {
-                pPage->SetSize(rNewSize);
+                pPage->setToolsSize(rNewSize);
             }
         }
 
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index c89b605a90e3..f865737eed67 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -578,12 +578,12 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument 
const * pRefDocument /* =
 
     if( pRefPage )
     {
-        pHandoutPage->SetSize(pRefPage->GetSize());
-        pHandoutPage->SetBorder( pRefPage->GetLeftBorder(), 
pRefPage->GetUpperBorder(), pRefPage->GetRightBorder(), 
pRefPage->GetLowerBorder() );
+        pHandoutPage->setSize(pRefPage->getSize());
+        pHandoutPage->setBorder(pRefPage->getBorder());
     }
     else
     {
-        pHandoutPage->SetSize(aDefSize);
+        pHandoutPage->setToolsSize(aDefSize);
         pHandoutPage->SetBorder(0, 0, 0, 0);
     }
 
@@ -593,12 +593,9 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument 
const * pRefDocument /* =
 
     // Insert master page and register this with the handout page
     rtl::Reference<SdPage> pHandoutMPage = AllocSdPage(true);
-    pHandoutMPage->SetSize( pHandoutPage->GetSize() );
+    pHandoutMPage->setSize(pHandoutPage->getSize());
     pHandoutMPage->SetPageKind(PageKind::Handout);
-    pHandoutMPage->SetBorder( pHandoutPage->GetLeftBorder(),
-                              pHandoutPage->GetUpperBorder(),
-                              pHandoutPage->GetRightBorder(),
-                              pHandoutPage->GetLowerBorder() );
+    pHandoutMPage->setBorder(pHandoutPage->getBorder());
     InsertMasterPage(pHandoutMPage.get(), 0);
     pHandoutPage->TRG_SetMasterPage( *pHandoutMPage );
 
@@ -617,13 +614,13 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument 
const * pRefDocument /* =
 
         if( pRefPage )
         {
-            pPage->SetSize( pRefPage->GetSize() );
-            pPage->SetBorder( pRefPage->GetLeftBorder(), 
pRefPage->GetUpperBorder(), pRefPage->GetRightBorder(), 
pRefPage->GetLowerBorder() );
+            pPage->setSize(pRefPage->getSize());
+            pPage->setBorder(pRefPage->getBorder());
         }
         else if (meDocType == DocumentType::Draw)
         {
             // Draw: always use default size with margins
-            pPage->SetSize(aDefSize);
+            pPage->setToolsSize(aDefSize);
 
             SfxPrinter* pPrinter = mpDocSh->GetPrinter(false);
             if (pPrinter && pPrinter->IsValid())
@@ -653,9 +650,9 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const 
* pRefDocument /* =
         else
         {
             // Impress: always use screen format, landscape.
-            Size aSz( SvxPaperInfo::GetPaperSize(PAPER_SCREEN_16_9, 
MapUnit::Map100thMM) );
-            pPage->SetSize( Size( aSz.Height(), aSz.Width() ) );
-            pPage->SetBorder(0, 0, 0, 0);
+            Size aSize = SvxPaperInfo::GetPaperSize(PAPER_SCREEN_16_9, 
MapUnit::Map100thMM);
+            pPage->setToolsSize(Size(aSize.Height(), aSize.Width()));
+            pPage->setBorder(svx::Border());
         }
 
         InsertPage(pPage.get(), 1);
@@ -668,11 +665,8 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument 
const * pRefDocument /* =
 
     // Insert master page, then register this with the page
     rtl::Reference<SdPage> pMPage = AllocSdPage(true);
-    pMPage->SetSize( pPage->GetSize() );
-    pMPage->SetBorder( pPage->GetLeftBorder(),
-                       pPage->GetUpperBorder(),
-                       pPage->GetRightBorder(),
-                       pPage->GetLowerBorder() );
+    pMPage->setSize(pPage->getSize());
+    pMPage->setBorder(pPage->getBorder());
     InsertMasterPage(pMPage.get(), 1);
     pPage->TRG_SetMasterPage( *pMPage );
     if( bClipboard )
@@ -686,19 +680,19 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument 
const * pRefDocument /* =
 
     if( pRefPage )
     {
-        pNotesPage->SetSize( pRefPage->GetSize() );
-        pNotesPage->SetBorder( pRefPage->GetLeftBorder(), 
pRefPage->GetUpperBorder(), pRefPage->GetRightBorder(), 
pRefPage->GetLowerBorder() );
+        pNotesPage->setSize(pRefPage->getSize());
+        pNotesPage->setBorder(pRefPage->getBorder());
     }
     else
     {
         // Always use portrait format
         if (aDefSize.Height() >= aDefSize.Width())
         {
-            pNotesPage->SetSize(aDefSize);
+            pNotesPage->setToolsSize(aDefSize);
         }
         else
         {
-            pNotesPage->SetSize( Size(aDefSize.Height(), aDefSize.Width()) );
+            pNotesPage->setToolsSize(Size(aDefSize.Height(), 
aDefSize.Width()));
         }
 
         pNotesPage->SetBorder(0, 0, 0, 0);
@@ -710,12 +704,9 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument 
const * pRefDocument /* =
 
     // Insert master page, then register this with the notes page
     rtl::Reference<SdPage> pNotesMPage = AllocSdPage(true);
-    pNotesMPage->SetSize( pNotesPage->GetSize() );
+    pNotesMPage->setSize(pNotesPage->getSize());
     pNotesMPage->SetPageKind(PageKind::Notes);
-    pNotesMPage->SetBorder( pNotesPage->GetLeftBorder(),
-                            pNotesPage->GetUpperBorder(),
-                            pNotesPage->GetRightBorder(),
-                            pNotesPage->GetLowerBorder() );
+    pNotesMPage->setBorder(pNotesPage->getBorder());
     InsertMasterPage(pNotesMPage.get(), 2);
     pNotesPage->TRG_SetMasterPage( *pNotesMPage );
     if( bClipboard )
@@ -1163,11 +1154,8 @@ void SdDrawDocument::CheckMasterPages()
                 pNewNotesPage->SetPageKind(PageKind::Notes);
                 if( pRefNotesPage )
                 {
-                    pNewNotesPage->SetSize( pRefNotesPage->GetSize() );
-                    pNewNotesPage->SetBorder( pRefNotesPage->GetLeftBorder(),
-                                            pRefNotesPage->GetUpperBorder(),
-                                            pRefNotesPage->GetRightBorder(),
-                                            pRefNotesPage->GetLowerBorder() );
+                    pNewNotesPage->setSize(pRefNotesPage->getSize());
+                    pNewNotesPage->setBorder(pRefNotesPage->getBorder());
                 }
                 InsertMasterPage(pNewNotesPage.get(),  nPage );
                 pNewNotesPage->SetLayoutName( pPage->GetLayoutName() );
@@ -1233,11 +1221,8 @@ sal_uInt16 SdDrawDocument::CreatePage (
 
     // Set the size here since else the presobj autolayout
     // will be wrong.
-    pStandardPage->SetSize( pPreviousStandardPage->GetSize() );
-    pStandardPage->SetBorder( pPreviousStandardPage->GetLeftBorder(),
-                              pPreviousStandardPage->GetUpperBorder(),
-                              pPreviousStandardPage->GetRightBorder(),
-                              pPreviousStandardPage->GetLowerBorder() );
+    pStandardPage->setSize(pPreviousStandardPage->getSize());
+    pStandardPage->setBorder(pPreviousStandardPage->getBorder());
 
     // Use master page of current page.
     
pStandardPage->TRG_SetMasterPage(pPreviousStandardPage->TRG_GetMasterPage());
@@ -1422,11 +1407,8 @@ void SdDrawDocument::SetupNewPage (
 {
     if (pPreviousPage != nullptr)
     {
-        pPage->SetSize( pPreviousPage->GetSize() );
-        pPage->SetBorder( pPreviousPage->GetLeftBorder(),
-            pPreviousPage->GetUpperBorder(),
-            pPreviousPage->GetRightBorder(),
-            pPreviousPage->GetLowerBorder() );
+        pPage->setSize(pPreviousPage->getSize());
+        pPage->setBorder(pPreviousPage->getBorder());
     }
     pPage->SetName(sPageName);
 
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index 9d3c48404330..45a39d060db4 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -412,20 +412,14 @@ void SdDrawDocument::getPageProperties(PageProperties& 
mainProps, PageProperties
 {
     // Get the properties from the first Standard page.
     mainProps.pPage = GetSdPage(0, PageKind::Standard);
-    mainProps.size        = mainProps.pPage->GetSize();
-    mainProps.left        = mainProps.pPage->GetLeftBorder();
-    mainProps.right       = mainProps.pPage->GetRightBorder();
-    mainProps.upper       = mainProps.pPage->GetUpperBorder();
-    mainProps.lower       = mainProps.pPage->GetLowerBorder();
+    mainProps.size = mainProps.pPage->getSize();
+    mainProps.border = mainProps.pPage->getBorder();
     mainProps.orientation = mainProps.pPage->GetOrientation();
 
     // Similarly for the first Notes page.
     notesProps.pPage = GetSdPage(0, PageKind::Notes);
-    notesProps.size        = notesProps.pPage->GetSize();
-    notesProps.left        = notesProps.pPage->GetLeftBorder();
-    notesProps.right       = notesProps.pPage->GetRightBorder();
-    notesProps.upper       = notesProps.pPage->GetUpperBorder();
-    notesProps.lower       = notesProps.pPage->GetLowerBorder();
+    notesProps.size = notesProps.pPage->getSize();
+    notesProps.border = notesProps.pPage->getBorder();
     notesProps.orientation = notesProps.pPage->GetOrientation();
 
     // Adapt the main page properties using the last standard page.
@@ -458,11 +452,11 @@ bool SdDrawDocument::determineScaleObjects(bool 
bNoDialogs,
     {
         // If not dialog-less, compare the first bookmark page with our 
reference page.
         SdPage* pBMPage = rParams.pBookmarkDoc->GetSdPage(0, 
PageKind::Standard);
-        if (pBMPage->GetSize()      != rParams.mainProps.pPage->GetSize()      
 ||
-            pBMPage->GetLeftBorder()  != 
rParams.mainProps.pPage->GetLeftBorder()  ||
-            pBMPage->GetRightBorder() != 
rParams.mainProps.pPage->GetRightBorder() ||
-            pBMPage->GetUpperBorder() != 
rParams.mainProps.pPage->GetUpperBorder() ||
-            pBMPage->GetLowerBorder() != 
rParams.mainProps.pPage->GetLowerBorder())
+        if (pBMPage->getSize() != rParams.mainProps.pPage->getSize() ||
+            pBMPage->getBorder().getLeft()  != 
rParams.mainProps.pPage->getBorder().getLeft() ||
+            pBMPage->getBorder().getRight() != 
rParams.mainProps.pPage->getBorder().getRight() ||
+            pBMPage->getBorder().getUpper() != 
rParams.mainProps.pPage->getBorder().getUpper() ||
+            pBMPage->getBorder().getLower() != 
rParams.mainProps.pPage->getBorder().getLower())
         {
             OUString aStr(SdResId(STR_SCALE_OBJECTS));
             std::unique_ptr<weld::MessageDialog> 
xQueryBox(Application::CreateMessageDialog(nullptr,
@@ -936,11 +930,10 @@ void 
SdDrawDocument::updateInsertedPages(PageInsertionParams& rParams,
 
         if (rParams.bScaleObjects)
         {
-            ::tools::Rectangle aBorderRect(rParams.mainProps.left, 
rParams.mainProps.upper, rParams.mainProps.right, rParams.mainProps.lower);
-            rParams.mainProps.pPage->ScaleObjects(rParams.mainProps.size, 
aBorderRect, true);
+            
rParams.mainProps.pPage->ScaleObjects(rParams.mainProps.size.toToolsSize(), 
rParams.mainProps.border.toToolsRect(), true);
         }
-        rParams.mainProps.pPage->SetSize(rParams.mainProps.size);
-        rParams.mainProps.pPage->SetBorder(rParams.mainProps.left, 
rParams.mainProps.upper, rParams.mainProps.right, rParams.mainProps.lower);
+        rParams.mainProps.pPage->setSize(rParams.mainProps.size);
+        rParams.mainProps.pPage->setBorder(rParams.mainProps.border);
         rParams.mainProps.pPage->SetOrientation(rParams.mainProps.orientation);
 
         if (bRemoveEmptyPresObj)
@@ -955,12 +948,11 @@ void 
SdDrawDocument::updateInsertedPages(PageInsertionParams& rParams,
 
         if (rParams.bScaleObjects)
         {
-            ::tools::Rectangle aBorderRect(rParams.notesProps.left, 
rParams.notesProps.upper, rParams.notesProps.right, rParams.notesProps.lower);
-            rParams.notesProps.pPage->ScaleObjects(rParams.notesProps.size, 
aBorderRect, true);
+            
rParams.notesProps.pPage->ScaleObjects(rParams.notesProps.size.toToolsSize(), 
rParams.notesProps.border.toToolsRect(), true);
         }
 
-        rParams.notesProps.pPage->SetSize(rParams.notesProps.size);
-        rParams.notesProps.pPage->SetBorder(rParams.notesProps.left, 
rParams.notesProps.upper, rParams.notesProps.right, rParams.notesProps.lower);
+        rParams.notesProps.pPage->setSize(rParams.notesProps.size);
+        rParams.notesProps.pPage->setBorder(rParams.notesProps.border);
         
rParams.notesProps.pPage->SetOrientation(rParams.notesProps.orientation);
 
         if (bRemoveEmptyPresObj)
@@ -977,11 +969,10 @@ void 
SdDrawDocument::updateInsertedPages(PageInsertionParams& rParams,
         {
             if (rParams.bScaleObjects)
             {
-                ::tools::Rectangle aBorderRect(rParams.mainProps.left, 
rParams.mainProps.upper, rParams.mainProps.right, rParams.mainProps.lower);
-                rParams.mainProps.pPage->ScaleObjects(rParams.mainProps.size, 
aBorderRect, true);
+                
rParams.mainProps.pPage->ScaleObjects(rParams.mainProps.size.toToolsSize(), 
rParams.mainProps.border.toToolsRect(), true);
             }
-            rParams.mainProps.pPage->SetSize(rParams.mainProps.size);
-            rParams.mainProps.pPage->SetBorder(rParams.mainProps.left, 
rParams.mainProps.upper, rParams.mainProps.right, rParams.mainProps.lower);
+            rParams.mainProps.pPage->setSize(rParams.mainProps.size);
+            rParams.mainProps.pPage->setBorder(rParams.mainProps.border);
             
rParams.mainProps.pPage->SetOrientation(rParams.mainProps.orientation);
 
             uno::Reference<drawing::XDrawPage> 
xNewPage(GetMasterPage(nPage)->getUnoPage(), uno::UNO_QUERY_THROW);
@@ -1012,11 +1003,10 @@ void 
SdDrawDocument::updateInsertedPages(PageInsertionParams& rParams,
         {
             if (rParams.bScaleObjects)
             {
-                ::tools::Rectangle aBorderRect(rParams.notesProps.left, 
rParams.notesProps.upper, rParams.notesProps.right, rParams.notesProps.lower);
-                
rParams.notesProps.pPage->ScaleObjects(rParams.notesProps.size, aBorderRect, 
true);
+                
rParams.notesProps.pPage->ScaleObjects(rParams.notesProps.size.toToolsSize(), 
rParams.notesProps.border.toToolsRect(), true);
             }
-            rParams.notesProps.pPage->SetSize(rParams.notesProps.size);
-            rParams.notesProps.pPage->SetBorder(rParams.notesProps.left, 
rParams.notesProps.upper, rParams.notesProps.right, rParams.notesProps.lower);
+            rParams.notesProps.pPage->setSize(rParams.notesProps.size);
+            rParams.notesProps.pPage->setBorder(rParams.notesProps.border);
             
rParams.notesProps.pPage->SetOrientation(rParams.notesProps.orientation);
         }
 
@@ -1188,7 +1178,7 @@ bool SdDrawDocument::InsertBookmarkAsObject(
         }
         else
         {
-            aObjPos = ::tools::Rectangle(Point(), pPage->GetSize()).Center();
+            aObjPos = ::tools::Rectangle(Point(), 
pPage->getSize().toToolsSize()).Center();
         }
 
         size_t nCountBefore = 0;
@@ -1873,31 +1863,21 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 
nSdPageNum,
         // Adapt new master pages
         if (pSourceDoc != this)
         {
-            Size aSize(rOldMaster.GetSize());
-            ::tools::Rectangle aBorderRect(rOldMaster.GetLeftBorder(),
-                                  rOldMaster.GetUpperBorder(),
-                                  rOldMaster.GetRightBorder(),
-                                  rOldMaster.GetLowerBorder());
+            Size aSize = rOldMaster.getSize().toToolsSize();
+
+            tools::Rectangle aBorderRect(rOldMaster.getBorder().toToolsRect());
+
             pMaster->ScaleObjects(aSize, aBorderRect, true);
-            pMaster->SetSize(aSize);
-            pMaster->SetBorder(rOldMaster.GetLeftBorder(),
-                               rOldMaster.GetUpperBorder(),
-                               rOldMaster.GetRightBorder(),
-                               rOldMaster.GetLowerBorder());
+            pMaster->setSize(rOldMaster.getSize());
+            pMaster->setBorder(rOldMaster.getBorder());
             pMaster->SetOrientation( rOldMaster.GetOrientation() );
             pMaster->SetAutoLayout(pMaster->GetAutoLayout());
 
-            aSize = rOldNotesMaster.GetSize();
-            ::tools::Rectangle 
aNotesBorderRect(rOldNotesMaster.GetLeftBorder(),
-                                       rOldNotesMaster.GetUpperBorder(),
-                                       rOldNotesMaster.GetRightBorder(),
-                                       rOldNotesMaster.GetLowerBorder());
+            aSize = rOldNotesMaster.getSize().toToolsSize();
+            tools::Rectangle 
aNotesBorderRect(rOldNotesMaster.getBorder().toToolsRect());
             pNotesMaster->ScaleObjects(aSize, aNotesBorderRect, true);
-            pNotesMaster->SetSize(aSize);
-            pNotesMaster->SetBorder(rOldNotesMaster.GetLeftBorder(),
-                                    rOldNotesMaster.GetUpperBorder(),
-                                    rOldNotesMaster.GetRightBorder(),
-                                    rOldNotesMaster.GetLowerBorder());
+            pNotesMaster->setSize(rOldNotesMaster.getSize());
+            pNotesMaster->setBorder(rOldNotesMaster.getBorder());
             pNotesMaster->SetOrientation( rOldNotesMaster.GetOrientation() );
             pNotesMaster->SetAutoLayout(pNotesMaster->GetAutoLayout());
 
@@ -1932,11 +1912,8 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
         }
 
         pMaster = AllocSdPage(true);
-        pMaster->SetSize(pSelectedPage->GetSize());
-        pMaster->SetBorder(pSelectedPage->GetLeftBorder(),
-                           pSelectedPage->GetUpperBorder(),
-                           pSelectedPage->GetRightBorder(),
-                           pSelectedPage->GetLowerBorder() );
+        pMaster->setSize(pSelectedPage->getSize());
+        pMaster->setBorder(pSelectedPage->getBorder());
         pMaster->SetName(aName);
         pMaster->SetLayoutName(aPageLayoutName);
         InsertMasterPage(pMaster.get());
@@ -1948,11 +1925,8 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
 
         pNotesMaster = AllocSdPage(true);
         pNotesMaster->SetPageKind(PageKind::Notes);
-        pNotesMaster->SetSize(pNotes->GetSize());
-        pNotesMaster->SetBorder(pNotes->GetLeftBorder(),
-                                pNotes->GetUpperBorder(),
-                                pNotes->GetRightBorder(),
-                                pNotes->GetLowerBorder() );
+        pNotesMaster->setSize(pNotes->getSize());
+        pNotesMaster->setBorder(pNotes->getBorder());
         pNotesMaster->SetName(aName);
         pNotesMaster->SetLayoutName(aPageLayoutName);
         InsertMasterPage(pNotesMaster.get());
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index 501c2da5b8ed..5ae97e8bdf21 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -1000,18 +1000,14 @@ rtl::Reference<SdrObject> 
SdPage::CreateDefaultPresObj(PresObjKind eObjKind)
         // create footer objects for standard master page
         if( mePageKind == PageKind::Standard )
         {
-            const ::tools::Long nLftBorder = GetLeftBorder();
-            const ::tools::Long nUppBorder = GetUpperBorder();
-
-            Point aPos ( nLftBorder, nUppBorder );
-            Size aSize ( GetSize() );
-
-            aSize.AdjustWidth( -(nLftBorder + GetRightBorder()) );
-            aSize.AdjustHeight( -(nUppBorder + GetLowerBorder()) );
+            Point aPosition(getBorder().leftUnit(), getBorder().upperUnit());
+            Size aSize = getSize().toToolsSize();
+            aSize.AdjustWidth(-basegfx::fround(getBorder().leftUnit() + 
getBorder().rightUnit()));
+            aSize.AdjustHeight(-basegfx::fround(getBorder().upperUnit() + 
getBorder().lowerUnit()));
 
             getPresObjProp( *this, sObjKind, sPageKind, propvalue);
-            aPos.AdjustX(::tools::Long( aSize.Width() * propvalue[2] ) );
-            aPos.AdjustY(::tools::Long( aSize.Height() * propvalue[3] ) );
+            aPosition.AdjustX(::tools::Long( aSize.Width() * propvalue[2] ) );
+            aPosition.AdjustY(::tools::Long( aSize.Height() * propvalue[3] ) );
             aSize.setWidth( ::tools::Long( aSize.Width() * propvalue[1] ) );
             aSize.setHeight( ::tools::Long( aSize.Height() * propvalue[0] ) );
 
@@ -1022,18 +1018,17 @@ rtl::Reference<SdrObject> 
SdPage::CreateDefaultPresObj(PresObjKind eObjKind)
             }
             else
             {
-                ::tools::Rectangle aRect( aPos, aSize );
+                ::tools::Rectangle aRect( aPosition, aSize );
                 return CreatePresObj( eObjKind, false, aRect );
             }
         }
         else
         {
             // create header&footer objects for handout and notes master
-            Size aPageSize ( GetSize() );
-            aPageSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
-            aPageSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
-
-            Point aPosition ( GetLeftBorder(), GetUpperBorder() );
+            Point aPosition(getBorder().leftUnit(), getBorder().upperUnit());
+            Size aPageSize = getSize().toToolsSize();
+            aPageSize.AdjustWidth(-basegfx::fround(getBorder().leftUnit() + 
getBorder().rightUnit()));
+            aPageSize.AdjustHeight(-basegfx::fround(getBorder().upperUnit() + 
getBorder().lowerUnit()));
 
             getPresObjProp( *this, sObjKind, sPageKind, propvalue);
             int NOTES_HEADER_FOOTER_WIDTH = ::tools::Long(aPageSize.Width() * 
propvalue[1]);
@@ -1092,10 +1087,11 @@ void SdPage::DestroyDefaultPresObj(PresObjKind eObjKind)
         /******************************************************************
         * standard- or note page: title area
         ******************************************************************/
-        Point aTitlePos ( GetLeftBorder(), GetUpperBorder() );
-        Size aTitleSize ( GetSize() );
-        aTitleSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
-        aTitleSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
+        Point aTitlePos(getBorder().leftUnit(), getBorder().upperUnit());
+        Size aTitleSize = getSize().toToolsSize();
+        aTitleSize.AdjustWidth(-basegfx::fround(getBorder().leftUnit() + 
getBorder().rightUnit()));
+        aTitleSize.AdjustHeight(-basegfx::fround(getBorder().upperUnit() + 
getBorder().lowerUnit()));
+
         const char* sPageKind = PageKindVector[mePageKind];
 
         if (mePageKind == PageKind::Standard)
@@ -1136,15 +1132,15 @@ void SdPage::DestroyDefaultPresObj(PresObjKind eObjKind)
             if ( pRefPage )
             {
                 // scale actually page size into handout rectangle
-                double fH = pRefPage->GetWidth() == 0
-                    ? 0 : static_cast<double>(aPartArea.Width())  / 
pRefPage->GetWidth();
-                double fV = pRefPage->GetHeight() == 0
-                    ? 0 : static_cast<double>(aPartArea.Height()) / 
pRefPage->GetHeight();
+                double fH = pRefPage->getSize().toToolsSize().getWidth() == 0
+                    ? 0 : static_cast<double>(aPartArea.Width())  / 
pRefPage->getSize().toToolsSize().getWidth();
+                double fV = pRefPage->getSize().toToolsSize().getHeight() == 0
+                    ? 0 : static_cast<double>(aPartArea.Height()) / 
pRefPage->getSize().toToolsSize().getHeight();
 
                 if ( fH > fV )
                     fH = fV;
-                aSize.setWidth( static_cast<::tools::Long>(fH * 
pRefPage->GetWidth()) );
-                aSize.setHeight( static_cast<::tools::Long>(fH * 
pRefPage->GetHeight()) );
+                aSize.setWidth( static_cast<::tools::Long>(fH * 
pRefPage->getSize().toToolsSize().getWidth()) );
+                aSize.setHeight( static_cast<::tools::Long>(fH * 
pRefPage->getSize().toToolsSize().getHeight()) );
 
                 aPos.AdjustX((aPartArea.Width() - aSize.Width()) / 2 );
                 aPos.AdjustY((aPartArea.Height()- aSize.Height())/ 2 );
@@ -1175,10 +1171,10 @@ void SdPage::DestroyDefaultPresObj(PresObjKind eObjKind)
     {
         double propvalue[] = {0,0,0,0};
 
-        Point aLayoutPos ( GetLeftBorder(), GetUpperBorder() );
-        Size aLayoutSize ( GetSize() );
-        aLayoutSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
-        aLayoutSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
+        Point aLayoutPos(getBorder().leftUnit(), getBorder().upperUnit());
+        Size aLayoutSize = getSize().toToolsSize();
+        aLayoutSize.AdjustWidth(-basegfx::fround(getBorder().leftUnit() + 
getBorder().rightUnit()));
+        aLayoutSize.AdjustHeight(-basegfx::fround(getBorder().upperUnit() + 
getBorder().lowerUnit()));
         const char* sPageKind = PageKindVector[mePageKind];
 
         if (mePageKind == PageKind::Standard)
@@ -1777,12 +1773,12 @@ void SdPage::GetPageInfo(::tools::JsonWriter& 
jsonWriter)
 {
     jsonWriter.put("visible", static_cast<unsigned int>(!this->IsExcluded()));
     jsonWriter.put("selected", static_cast<unsigned int>(this->IsSelected()));
-    jsonWriter.put("width", GetWidth());
-    jsonWriter.put("height", GetHeight());
-    jsonWriter.put("leftBorder", GetLeftBorder());
-    jsonWriter.put("rightBorder", GetRightBorder());
-    jsonWriter.put("upperBorder", GetUpperBorder());
-    jsonWriter.put("lowerBorder", GetLowerBorder());
+    jsonWriter.put("width", getSize().toToolsSize().getWidth());
+    jsonWriter.put("height", getSize().toToolsSize().getHeight());
+    jsonWriter.put("leftBorder", getBorder().leftUnit());
+    jsonWriter.put("rightBorder",getBorder().rightUnit());
+    jsonWriter.put("upperBorder", getBorder().upperUnit());
+    jsonWriter.put("lowerBorder", getBorder().lowerUnit());
     jsonWriter.put("name", GetName());
     jsonWriter.put("hash", GetUniqueID());
 }
@@ -1802,26 +1798,25 @@ void SdPage::NotifyPagePropertyChanges()
     }
 }
 
-void SdPage::SetSize(const Size& aSize)
+void SdPage::setSize(gfx::Size2DLWrap const& rSize)
 {
-    Size aOldSize = GetSize();
+    auto const& rOldSize = getSize();
 
-    if (aSize != aOldSize)
+    if (rSize != rOldSize)
     {
-        FmFormPage::SetSize(aSize);
-
+        FmFormPage::setSize(rSize);
         if (comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current())
             NotifyPagePropertyChanges();
     }
 }
 
-void SdPage::SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, 
sal_Int32 nLwr)
+void SdPage::SetBorder(sal_Int32 nLeft, sal_Int32 nUpper, sal_Int32 nRight, 
sal_Int32 nLower)
 {
-    if (nLft != GetLeftBorder() || nUpp != GetUpperBorder() ||
-        nRgt != GetRightBorder() || nLwr != GetLowerBorder() )
+    auto eUnit = getUnit();
+    if (gfx::Length::from(eUnit, nLeft) != getBorder().getLeft() || 
gfx::Length::from(eUnit, nUpper) != getBorder().getUpper() ||
+        gfx::Length::from(eUnit, nRight) != getBorder().getRight() || 
gfx::Length::from(eUnit, nLower) != getBorder().getLower())
     {
-        FmFormPage::SetBorder(nLft, nUpp, nRgt, nLwr);
-
+        FmFormPage::SetBorder(nLeft, nUpper, nRight, nLower);
         if (comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current())
             NotifyPagePropertyChanges();
     }
@@ -1829,7 +1824,7 @@ void SdPage::SetBorder(sal_Int32 nLft, sal_Int32 nUpp, 
sal_Int32 nRgt, sal_Int32
 
 void SdPage::SetLeftBorder(sal_Int32 nBorder)
 {
-    if (nBorder != GetLeftBorder() )
+    if (gfx::Length::from(getUnit(), nBorder) != getBorder().getLeft())
     {
         FmFormPage::SetLeftBorder(nBorder);
     }
@@ -1837,7 +1832,7 @@ void SdPage::SetLeftBorder(sal_Int32 nBorder)
 
 void SdPage::SetRightBorder(sal_Int32 nBorder)
 {
-    if (nBorder != GetRightBorder() )
+    if (gfx::Length::from(getUnit(), nBorder) != getBorder().getRight())
     {
         FmFormPage::SetRightBorder(nBorder);
     }
@@ -1845,7 +1840,7 @@ void SdPage::SetRightBorder(sal_Int32 nBorder)
 
 void SdPage::SetUpperBorder(sal_Int32 nBorder)
 {
-    if (nBorder != GetUpperBorder() )
+    if (gfx::Length::from(getUnit(), nBorder) != getBorder().getUpper())
     {
         FmFormPage::SetUpperBorder(nBorder);
     }
@@ -1853,7 +1848,7 @@ void SdPage::SetUpperBorder(sal_Int32 nBorder)
 
 void SdPage::SetLowerBorder(sal_Int32 nBorder)
 {
-    if (nBorder != GetLowerBorder() )
+    if (gfx::Length::from(getUnit(), nBorder) != getBorder().getLower())
     {
         FmFormPage::SetLowerBorder(nBorder);
     }
@@ -1885,27 +1880,27 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, 
const ::tools::Rectangle& rN
     // -> use up to date values
     if (aNewPageSize.Width() < 0)
     {
-        aNewPageSize.setWidth( GetWidth() );
+        aNewPageSize.setWidth(getSize().toToolsSize().getWidth());
     }
     if (aNewPageSize.Height() < 0)
     {
-        aNewPageSize.setHeight( GetHeight() );
+        aNewPageSize.setHeight(getSize().toToolsSize().getHeight());
     }
     if (nLeft < 0)
     {
-        nLeft = GetLeftBorder();
+        nLeft = getBorder().leftUnit();
     }
     if (nRight < 0)
     {
-        nRight = GetRightBorder();
+        nRight = getBorder().rightUnit();
     }
     if (nUpper < 0)
     {
-        nUpper = GetUpperBorder();
+        nUpper = getBorder().upperUnit();
     }
     if (nLower < 0)
     {
-        nLower = GetLowerBorder();
+        nLower = getBorder().lowerUnit();
     }
 
     Size aBackgroundSize(aNewPageSize);
@@ -1917,8 +1912,8 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const 
::tools::Rectangle& rN
         aNewPageSize = aBackgroundSize;
     }
 
-    ::tools::Long nOldWidth  = GetWidth() - GetLeftBorder() - GetRightBorder();
-    ::tools::Long nOldHeight = GetHeight() - GetUpperBorder() - 
GetLowerBorder();
+    ::tools::Long nOldWidth  = (getSize().getWidth() - getBorder().getLeft() - 
getBorder().getRight()).as(getUnit());
+    ::tools::Long nOldHeight = (getSize().getHeight() - getBorder().getUpper() 
- getBorder().getLower()).as(getUnit());
 
     Fraction aFractX(aNewPageSize.Width(), nOldWidth);
     Fraction aFractY(aNewPageSize.Height(), nOldHeight);
@@ -2107,8 +2102,8 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const 
::tools::Rectangle& rN
 
                 // corrected scaling; only distances may be scaled
                 // use aTopLeft as original TopLeft
-                aNewPos.setX( ::tools::Long((aTopLeft.X() - GetLeftBorder()) * 
static_cast<double>(aFractX)) + nLeft );
-                aNewPos.setY( ::tools::Long((aTopLeft.Y() - GetUpperBorder()) 
* static_cast<double>(aFractY)) + nUpper );
+                aNewPos.setX( ::tools::Long((aTopLeft.X() - 
getBorder().leftUnit()) * double(aFractX)) + nLeft );
+                aNewPos.setY( ::tools::Long((aTopLeft.Y() - 
getBorder().upperUnit()) * double(aFractY)) + nUpper );
 
                 Size aVec(aNewPos.X() - aTopLeft.X(), aNewPos.Y() - 
aTopLeft.Y());
 
@@ -2626,15 +2621,10 @@ void SdPage::SetOrientation( Orientation /*eOrient*/)
 
 Orientation SdPage::GetOrientation() const
 {
-    Size aSize = GetSize();
-    if ( aSize.getWidth() > aSize.getHeight() )
-    {
+    auto aSize = getSize();
+    if (aSize.getWidth() > aSize.getHeight())
         return Orientation::Landscape;
-    }
-    else
-    {
-        return Orientation::Portrait;
-    }
+    return Orientation::Portrait;
 }
 
 /*************************************************************************
@@ -2994,7 +2984,7 @@ void SdPage::CalculateHandoutAreas(SdDrawDocument& 
rModel, AutoLayout eLayout, b
 
     const sal_uInt16* pOffsets = aOffsets[0];
 
-    Size aArea = rHandoutMaster.GetSize();
+    Size aArea = rHandoutMaster.getSize().toToolsSize();
     const bool bLandscape = aArea.Width() > aArea.Height() || eOrient == 
Orientation::Landscape;
 
     if ((eOrient == Orientation::Landscape && aArea.Width() < aArea.Height())
@@ -3011,10 +3001,10 @@ void SdPage::CalculateHandoutAreas(SdDrawDocument& 
rModel, AutoLayout eLayout, b
     const ::tools::Long nGapW = 1000; // gap is 1cm
     const ::tools::Long nGapH = 1000;
 
-    ::tools::Long nLeftBorder = rHandoutMaster.GetLeftBorder();
-    ::tools::Long nRightBorder = rHandoutMaster.GetRightBorder();
-    ::tools::Long nTopBorder = rHandoutMaster.GetUpperBorder();
-    ::tools::Long nBottomBorder = rHandoutMaster.GetLowerBorder();
+    ::tools::Long nLeftBorder = rHandoutMaster.getBorder().leftUnit();
+    ::tools::Long nRightBorder = rHandoutMaster.getBorder().rightUnit();
+    ::tools::Long nTopBorder = rHandoutMaster.getBorder().upperUnit();
+    ::tools::Long nBottomBorder = rHandoutMaster.getBorder().lowerUnit();
 
     const ::tools::Long nHeaderFooterHeight = static_cast< ::tools::Long >( 
(aArea.Height() - nTopBorder - nLeftBorder) * 0.05  );
 
@@ -3091,17 +3081,18 @@ void SdPage::CalculateHandoutAreas(SdDrawDocument& 
rModel, AutoLayout eLayout, b
     aPartArea.setHeight( (aArea.Height() - ((nRowCnt-1) * nGapH) ) / nRowCnt );
 
     SdrPage* pFirstPage = rModel.GetMasterSdPage(0, PageKind::Standard);
-    if (pFirstPage && pFirstPage->GetWidth() && pFirstPage->GetHeight())
+    Size aFirstPageSize = pFirstPage->getSize().toToolsSize();
+    if (pFirstPage && aFirstPageSize.Width() && aFirstPageSize.Height())
     {
        // scale actual size into handout rect
-       double fScale = static_cast<double>(aPartArea.Width()) / 
static_cast<double>(pFirstPage->GetWidth());
+       double fScale = static_cast<double>(aPartArea.Width()) / 
static_cast<double>(aFirstPageSize.Width());
 
-       aSize.setHeight( static_cast<::tools::Long>(fScale * 
pFirstPage->GetHeight() ) );
+       aSize.setHeight( static_cast<::tools::Long>(fScale * 
aFirstPageSize.Height() ) );
        if( aSize.Height() > aPartArea.Height() )
        {
-           fScale = static_cast<double>(aPartArea.Height()) / 
static_cast<double>(pFirstPage->GetHeight());
+           fScale = static_cast<double>(aPartArea.Height()) / 
static_cast<double>(aFirstPageSize.Height());
            aSize.setHeight( aPartArea.Height() );
-           aSize.setWidth( static_cast<::tools::Long>(fScale * 
pFirstPage->GetWidth()) );
+           aSize.setWidth( static_cast<::tools::Long>(fScale * 
aFirstPageSize.Width()) );
        }
        else
        {
diff --git a/sd/source/filter/grf/sdgrffilter.cxx 
b/sd/source/filter/grf/sdgrffilter.cxx
index ad544150da93..f2aee40fb7d3 100644
--- a/sd/source/filter/grf/sdgrffilter.cxx
+++ b/sd/source/filter/grf/sdgrffilter.cxx
@@ -185,12 +185,12 @@ bool SdGRFFilter::Import()
 void SdGRFFilter::InsertSdrGrafObj(const Graphic& rGraphic, SdPage* pPage)
 {
     Point aPos;
-    Size aPagSize(pPage->GetSize());
+    Size aPagSize(pPage->getSize().toToolsSize());
     Size aGrfSize(OutputDevice::LogicToLogic(rGraphic.GetPrefSize(), 
rGraphic.GetPrefMapMode(),
                                              MapMode(MapUnit::Map100thMM)));
 
-    aPagSize.AdjustWidth(-(pPage->GetLeftBorder() + pPage->GetRightBorder()));
-    aPagSize.AdjustHeight(-(pPage->GetUpperBorder() + 
pPage->GetLowerBorder()));
+    aPagSize.AdjustWidth(-basegfx::fround((pPage->getBorder().getLeft() + 
pPage->getBorder().getRight()).as(pPage->getUnit())));
+    aPagSize.AdjustHeight(-basegfx::fround((pPage->getBorder().getUpper() + 
pPage->getBorder().getLower()).as(pPage->getUnit())));
 
     // scale to fit page
     if (((aGrfSize.Height() > aPagSize.Height()) || (aGrfSize.Width() > 
aPagSize.Width()))
@@ -213,8 +213,8 @@ void SdGRFFilter::InsertSdrGrafObj(const Graphic& rGraphic, 
SdPage* pPage)
     }
 
     // set output rectangle for graphic
-    aPos.setX(((aPagSize.Width() - aGrfSize.Width()) >> 1) + 
pPage->GetLeftBorder());
-    aPos.setY(((aPagSize.Height() - aGrfSize.Height()) >> 1) + 
pPage->GetUpperBorder());
+    aPos.setX(((aPagSize.Width() - aGrfSize.Width()) / 2.0) + 
pPage->getBorder().leftUnit());
+    aPos.setY(((aPagSize.Height() - aGrfSize.Height()) / 2.0) + 
pPage->getBorder().upperUnit());
 
     pPage->InsertObject(new SdrGrafObj(pPage->getSdrModelFromSdrPage(), 
rGraphic,
                                        ::tools::Rectangle(aPos, aGrfSize)));
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx 
b/sd/source/filter/pdf/sdpdffilter.cxx
index 068aca1fcce9..127ef0f4c65c 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -86,7 +86,7 @@ bool SdPdfFilter::Import()
             return false;
 
         // Make the page size match the rendered image.
-        pPage->SetSize(aSizeHMM);
+        pPage->setToolsSize(aSizeHMM);
 
         rtl::Reference<SdrGrafObj> pSdrGrafObj
             = new SdrGrafObj(rModel, rGraphic, tools::Rectangle(Point(), 
aSizeHMM));
diff --git a/sd/source/ui/annotations/annotationmanager.cxx 
b/sd/source/ui/annotations/annotationmanager.cxx
index 504bbe63adef..f480487a4786 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -488,7 +488,7 @@ void AnnotationManagerImpl::InsertAnnotation(const 
OUString& rText)
     sdr::annotation::AnnotationVector aAnnotations(pPage->getAnnotations());
     if (!aAnnotations.empty())
     {
-        const int fPageWidth = pPage->GetSize().Width();
+        const int fPageWidth = pPage->getSize().toToolsSize().Width();
         const int fWidth = 1000;
         const int fHeight = 800;
 
diff --git a/sd/source/ui/app/sdmod2.cxx b/sd/source/ui/app/sdmod2.cxx
index 52ebc7b33c5e..caa64b368ccd 100644
--- a/sd/source/ui/app/sdmod2.cxx
+++ b/sd/source/ui/app/sdmod2.cxx
@@ -523,7 +523,7 @@ std::optional<SfxItemSet> SdModule::CreateItemSet( 
sal_uInt16 nSlot )
     {
         assert(pDoc);
         SdrPage* pPage = pDoc->GetSdPage(0, PageKind::Standard);
-        Size aSize(pPage->GetSize());
+        Size aSize(pPage->getSize().toToolsSize());
         nW = aSize.Width();
         nH = aSize.Height();
     }
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index 31d61b6b9b19..dca8289403a0 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -286,7 +286,7 @@ void SdTransferable::CreateData()
         SdPage*             pPage = mpSdDrawDocumentIntern->GetSdPage( 0, 
PageKind::Standard );
         OUString            aOldLayoutName( pOldPage->GetLayoutName() );
 
-        pPage->SetSize( pOldPage->GetSize() );
+        pPage->setSize(pOldPage->getSize());
         pPage->SetLayoutName( aOldLayoutName );
         pNewStylePool->CopyGraphicSheets( *pOldStylePool );
         pNewStylePool->CopyCellSheets( *pOldStylePool );
@@ -318,7 +318,7 @@ void SdTransferable::CreateData()
             pObj->NbcMove( aVector );
     }
     else
-        maVisArea.SetSize( pPage->GetSize() );
+        maVisArea.SetSize(pPage->getSize().toToolsSize());
 
     // output is at the zero point
     maVisArea.SetPos( Point() );
diff --git a/sd/source/ui/dlg/copydlg.cxx b/sd/source/ui/dlg/copydlg.cxx
index 6b8fe8c7e302..5451841bd7b8 100644
--- a/sd/source/ui/dlg/copydlg.cxx
+++ b/sd/source/ui/dlg/copydlg.cxx
@@ -91,7 +91,7 @@ void CopyDlg::Reset()
 {
     // Set Min/Max values
     ::tools::Rectangle aRect = mpView->GetAllMarkedRect();
-    Size aPageSize = mpView->GetSdrPageView()->GetPage()->GetSize();
+    Size aPageSize = 
mpView->GetSdrPageView()->GetPage()->getSize().toToolsSize();
 
     // tdf#125011 draw/impress sizes are in mm_100th already, "normalize" to
     // decimal shift by number of decimal places the widgets are using (2) then
diff --git a/sd/source/ui/dlg/headerfooterdlg.cxx 
b/sd/source/ui/dlg/headerfooterdlg.cxx
index 95f8249699bc..b60546bf7781 100644
--- a/sd/source/ui/dlg/headerfooterdlg.cxx
+++ b/sd/source/ui/dlg/headerfooterdlg.cxx
@@ -645,7 +645,7 @@ void PresLayoutPreview::SetDrawingArea(weld::DrawingArea* 
pDrawingArea)
 void PresLayoutPreview::init( SdPage *pMaster )
 {
     mpMaster = pMaster;
-    maPageSize = pMaster->GetSize();
+    maPageSize = pMaster->getSize().toToolsSize();
 }
 
 void PresLayoutPreview::update( HeaderFooterSettings const & rSettings )
diff --git a/sd/source/ui/docshell/docshel2.cxx 
b/sd/source/ui/docshell/docshel2.cxx
index f5489f20392d..1acf07cdb80c 100644
--- a/sd/source/ui/docshell/docshel2.cxx
+++ b/sd/source/ui/docshell/docshel2.cxx
@@ -129,7 +129,7 @@ void DrawDocShell::Draw(OutputDevice* pOut, const 
JobSetup&, sal_uInt16 nAspect,
     if( ( ASPECT_THUMBNAIL == nAspect ) || ( ASPECT_DOCPRINT == nAspect ) )
     {
         // provide size of first page
-        aVisArea.SetSize(mpDoc->GetSdPage(0, PageKind::Standard)->GetSize());
+        aVisArea.SetSize(mpDoc->GetSdPage(0, 
PageKind::Standard)->getSize().toToolsSize());
     }
     else
     {
@@ -181,7 +181,7 @@ BitmapEx DrawDocShell::GetPagePreviewBitmap(SdPage* pPage)
 {
     const sal_uInt16 nMaxEdgePixel = 90;
     MapMode         aMapMode( MapUnit::Map100thMM );
-    const Size      aSize( pPage->GetSize() );
+    const Size aSize = pPage->getSize().toToolsSize();
     const Point     aNullPt;
     ScopedVclPtrInstance< VirtualDevice > pVDev( 
*Application::GetDefaultDevice() );
 
diff --git a/sd/source/ui/func/fuexpand.cxx b/sd/source/ui/func/fuexpand.cxx
index 74625c53eff3..5cb0529b428b 100644
--- a/sd/source/ui/func/fuexpand.cxx
+++ b/sd/source/ui/func/fuexpand.cxx
@@ -134,11 +134,8 @@ void FuExpandPage::DoExecute( SfxRequest& )
             {
                 // page with title & structuring!
                 rtl::Reference<SdPage> pPage = mpDoc->AllocSdPage(false);
-                pPage->SetSize(pActualPage->GetSize() );
-                pPage->SetBorder(pActualPage->GetLeftBorder(),
-                                 pActualPage->GetUpperBorder(),
-                                 pActualPage->GetRightBorder(),
-                                 pActualPage->GetLowerBorder() );
+                pPage->setSize(pActualPage->getSize() );
+                pPage->setBorder(pActualPage->getBorder());
                 pPage->SetName(OUString());
 
                 // insert page after current page
@@ -156,11 +153,8 @@ void FuExpandPage::DoExecute( SfxRequest& )
 
                 // notes-page
                 rtl::Reference<SdPage> pNotesPage = mpDoc->AllocSdPage(false);
-                pNotesPage->SetSize(pActualNotesPage->GetSize());
-                pNotesPage->SetBorder(pActualNotesPage->GetLeftBorder(),
-                                      pActualNotesPage->GetUpperBorder(),
-                                      pActualNotesPage->GetRightBorder(),
-                                      pActualNotesPage->GetLowerBorder() );
+                pNotesPage->setSize(pActualNotesPage->getSize());
+                pNotesPage->setBorder(pActualNotesPage->getBorder());
                 pNotesPage->SetPageKind(PageKind::Notes);
                 pNotesPage->SetName(OUString());
 
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index 44470c09b4d4..7af3497b68a8 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -594,7 +594,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
                 {
                     // we create a new OLE object
                     SdrPageView* pPV = mpView->GetSdrPageView();
-                    Size aPageSize = pPV->GetPage()->GetSize();
+                    Size aPageSize = pPV->GetPage()->getSize().toToolsSize();
 
                     // get the size from the iconified object
                     ::svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx
index e9fc1eee39b0..aa26cb8609f9 100644
--- a/sd/source/ui/func/fuinsfil.cxx
+++ b/sd/source/ui/func/fuinsfil.cxx
@@ -432,7 +432,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
     if( nIndex != -1 )
         aLayoutName = aLayoutName.copy(0, nIndex);
 
-    aOutliner.SetPaperSize(pPage->GetSize());
+    aOutliner.SetPaperSize(pPage->getSize().toToolsSize());
 
     SvStream* pStream = pMedium->GetInStream();
     assert(pStream && "No InStream!");
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index ee97cd1694fa..11ba720b3f11 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -229,7 +229,7 @@ void FuPage::ExecuteAsyncDialog(weld::Window* pParent, 
const SfxRequest& rReq)
     aNewAttr->Put( aPageItem );
 
     // size
-    maSize = mpPage->GetSize();
+    maSize = mpPage->getSize().toToolsSize();
     SvxSizeItem aSizeItem( SID_ATTR_PAGE_SIZE, maSize );
     aNewAttr->Put( aSizeItem );
 
@@ -241,13 +241,15 @@ void FuPage::ExecuteAsyncDialog(weld::Window* pParent, 
const SfxRequest& rReq)
     SvxPaperBinItem aPaperBinItem( SID_ATTR_PAGE_PAPERBIN, 
static_cast<sal_uInt8>(mpPage->GetPaperBin()) );
     aNewAttr->Put( aPaperBinItem );
 
-    SvxLRSpaceItem aLRSpaceItem(SvxIndentValue::twips(mpPage->GetLeftBorder()),
-                                
SvxIndentValue::twips(mpPage->GetRightBorder()),
+    SvxLRSpaceItem 
aLRSpaceItem(SvxIndentValue::twips(mpPage->getBorder().leftUnit()),
+                                
SvxIndentValue::twips(mpPage->getBorder().rightUnit()),
                                 SvxIndentValue::zero(),
                                 
mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_LRSPACE));
     aNewAttr->Put( aLRSpaceItem );
 
-    SvxULSpaceItem aULSpaceItem( 
static_cast<sal_uInt16>(mpPage->GetUpperBorder()), 
static_cast<sal_uInt16>(mpPage->GetLowerBorder()), 
mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_ULSPACE));
+    SvxULSpaceItem 
aULSpaceItem(static_cast<sal_uInt16>(mpPage->getBorder().upperUnit()),
+                                
static_cast<sal_uInt16>(mpPage->getBorder().lowerUnit()),
+                                
mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_ULSPACE));
     aNewAttr->Put( aULSpaceItem );
 
     // Application
@@ -516,7 +518,7 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
     {
         aNewSize = static_cast<const SvxSizeItem*>(pPoolItem)->GetSize();
 
-        if( mpPage->GetSize() != aNewSize )
+        if (mpPage->getSize().toToolsSize() != aNewSize)
             bSetPageSizeAndBorder = true;
     }
 
@@ -526,9 +528,11 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
         nLeft = static_cast<const SvxLRSpaceItem*>(pPoolItem)->ResolveLeft({});
         nRight = static_cast<const 
SvxLRSpaceItem*>(pPoolItem)->ResolveRight({});
 
-        if( mpPage->GetLeftBorder() != nLeft || mpPage->GetRightBorder() != 
nRight )
+        if (mpPage->getBorder().leftUnit() != nLeft
+         || mpPage->getBorder().rightUnit() != nRight)
+        {
             bSetPageSizeAndBorder = true;
-
+        }
     }
 
     if( 
pArgs->GetItemState(mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_ULSPACE),
@@ -537,8 +541,11 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
         nUpper = static_cast<const SvxULSpaceItem*>(pPoolItem)->GetUpper();
         nLower = static_cast<const SvxULSpaceItem*>(pPoolItem)->GetLower();
 
-        if( mpPage->GetUpperBorder() != nUpper || mpPage->GetLowerBorder() != 
nLower )
+        if (mpPage->getBorder().upperUnit() != nUpper
+         || mpPage->getBorder().lowerUnit() != nLower)
+        {
             bSetPageSizeAndBorder = true;
+        }
     }
 
     if( 
pArgs->GetItemState(mpDoc->GetPool().GetWhichIDFromSlotID(SID_ATTR_PAGE_EXT1), 
true, &pPoolItem) == SfxItemState::SET )
@@ -573,14 +580,14 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
     if (nLeft == -1 && nUpper != -1)
     {
         bSetPageSizeAndBorder = true;
-        nLeft  = mpPage->GetLeftBorder();
-        nRight = mpPage->GetRightBorder();
+        nLeft  = mpPage->getBorder().leftUnit();
+        nRight = mpPage->getBorder().rightUnit();
     }
     else if (nLeft != -1 && nUpper == -1)
     {
         bSetPageSizeAndBorder = true;
-        nUpper = mpPage->GetUpperBorder();
-        nLower = mpPage->GetLowerBorder();
+        nUpper = mpPage->getBorder().upperUnit();
+        nLower = mpPage->getBorder().lowerUnit();
     }
 
     if( bSetPageSizeAndBorder || !mbMasterPage )
@@ -613,7 +620,7 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
     }
 
     // Objects can not be bigger than ViewSize
-    Size aPageSize = mpDoc->GetSdPage(0, ePageKind)->GetSize();
+    Size aPageSize = mpDoc->GetSdPage(0, ePageKind)->getSize().toToolsSize();
     Size aViewSize(aPageSize.Width() * 3, aPageSize.Height() * 2);
     mpDoc->SetMaxObjSize(aViewSize);
 
diff --git a/sd/source/ui/func/fusumry.cxx b/sd/source/ui/func/fusumry.cxx
index bf63c84485c1..0ff7f5a8e4eb 100644
--- a/sd/source/ui/func/fusumry.cxx
+++ b/sd/source/ui/func/fusumry.cxx
@@ -119,11 +119,8 @@ void FuSummaryPage::DoExecute( SfxRequest& )
 
                     // page with title & structuring!
                     pSummaryPage = mpDoc->AllocSdPage(false);
-                    pSummaryPage->SetSize(pActualPage->GetSize() );
-                    pSummaryPage->SetBorder(pActualPage->GetLeftBorder(),
-                                     pActualPage->GetUpperBorder(),
-                                     pActualPage->GetRightBorder(),
-                                     pActualPage->GetLowerBorder() );
+                    pSummaryPage->setSize(pActualPage->getSize());
+                    pSummaryPage->setBorder(pActualPage->getBorder());
 
                     // insert page at the back
                     mpDoc->InsertPage(pSummaryPage.get(), nCount * 2 + 1);
@@ -139,11 +136,8 @@ void FuSummaryPage::DoExecute( SfxRequest& )
 
                     // notes-page
                     rtl::Reference<SdPage> pNotesPage = 
mpDoc->AllocSdPage(false);
-                    pNotesPage->SetSize(pActualNotesPage->GetSize());
-                    pNotesPage->SetBorder(pActualNotesPage->GetLeftBorder(),
-                                          pActualNotesPage->GetUpperBorder(),
-                                          pActualNotesPage->GetRightBorder(),
-                                          pActualNotesPage->GetLowerBorder() );
+                    pNotesPage->setSize(pActualNotesPage->getSize());
+                    pNotesPage->setBorder(pActualNotesPage->getBorder());
                     pNotesPage->SetPageKind(PageKind::Notes);
 
                     // insert page at the back
diff --git a/sd/source/ui/func/fuzoom.cxx b/sd/source/ui/func/fuzoom.cxx
index ec0fec3bf49e..f03907820e62 100644
--- a/sd/source/ui/func/fuzoom.cxx
+++ b/sd/source/ui/func/fuzoom.cxx
@@ -116,7 +116,7 @@ bool FuZoom::MouseMove(const MouseEvent& rMEvt)
             if (aScroll.X() != 0 || aScroll.Y() != 0)
             {
                 Size aWorkSize = mpView->GetWorkArea().GetSize();
-                Size aPageSize = 
mpView->GetSdrPageView()->GetPage()->GetSize();
+                Size aPageSize = 
mpView->GetSdrPageView()->GetPage()->getSize().toToolsSize();
                 if (aWorkSize.Width() != 0 && aWorkSize.Height() != 0 &&
                         aPageSize.Width() != 0 && aPageSize.Height() != 0)
                 {
diff --git a/sd/source/ui/func/undopage.cxx b/sd/source/ui/func/undopage.cxx
index 174747bf6c5d..26dcc17f4587 100644
--- a/sd/source/ui/func/undopage.cxx
+++ b/sd/source/ui/func/undopage.cxx
@@ -29,7 +29,7 @@ void SdPageFormatUndoAction::Undo()
 {
     ::tools::Rectangle aOldBorderRect(mnOldLeft, mnOldUpper, mnOldRight, 
mnOldLower);
     mpPage->ScaleObjects(maOldSize, aOldBorderRect, mbNewScale);
-    mpPage->SetSize(maOldSize);
+    mpPage->setToolsSize(maOldSize);
     mpPage->SetLeftBorder(mnOldLeft);
     mpPage->SetRightBorder(mnOldRight);
     mpPage->SetUpperBorder(mnOldUpper);
@@ -47,7 +47,7 @@ void SdPageFormatUndoAction::Redo()
 {
     ::tools::Rectangle aNewBorderRect(mnNewLeft, mnNewUpper, mnNewRight, 
mnNewLower);
     mpPage->ScaleObjects(maNewSize, aNewBorderRect, mbNewScale);
-    mpPage->SetSize(maNewSize);
+    mpPage->setToolsSize(maNewSize);
     mpPage->SetLeftBorder(mnNewLeft);
     mpPage->SetRightBorder(mnNewRight);
     mpPage->SetUpperBorder(mnNewUpper);
diff --git a/sd/source/ui/presenter/SlideRenderer.cxx 
b/sd/source/ui/presenter/SlideRenderer.cxx
index 707b50b90fe4..db96694fdfec 100644
--- a/sd/source/ui/presenter/SlideRenderer.cxx
+++ b/sd/source/ui/presenter/SlideRenderer.cxx
@@ -134,7 +134,7 @@ BitmapEx SlideRenderer::CreatePreview (
             0);
 
     // Determine the size of the current slide and its aspect ratio.
-    Size aPageSize = pPage->GetSize();
+    Size aPageSize = pPage->getSize().toToolsSize();
     if (aPageSize.Height() <= 0)
         throw lang::IllegalArgumentException(u"SlideRenderer::createPreview() 
called with invalid size"_ustr,
             static_cast<XWeak*>(this),
diff --git a/sd/source/ui/sidebar/DocumentHelper.cxx 
b/sd/source/ui/sidebar/DocumentHelper.cxx
index 303ceb58850b..29fdc34d7238 100644
--- a/sd/source/ui/sidebar/DocumentHelper.cxx
+++ b/sd/source/ui/sidebar/DocumentHelper.cxx
@@ -359,14 +359,15 @@ SdPage* DocumentHelper::AddMasterPage (
 
         // Adapt the size of the new master page to that of the pages in
         // the document.
-        Size aNewSize (rTargetDocument.GetSdPage(0, 
pMasterPage->GetPageKind())->GetSize());
-        ::tools::Rectangle aBorders (
-            pClonedMasterPage->GetLeftBorder(),
-            pClonedMasterPage->GetUpperBorder(),
-            pClonedMasterPage->GetRightBorder(),
-            pClonedMasterPage->GetLowerBorder());
+        auto pPage = rTargetDocument.GetSdPage(0, pMasterPage->GetPageKind());
+        Size aNewSize = pPage->getSize().toToolsSize();
+        ::tools::Rectangle aBorders(
+            pClonedMasterPage->getBorder().leftUnit(),
+            pClonedMasterPage->getBorder().upperUnit(),
+            pClonedMasterPage->getBorder().rightUnit(),
+            pClonedMasterPage->getBorder().lowerUnit());
         pClonedMasterPage->ScaleObjects(aNewSize, aBorders, true);
-        pClonedMasterPage->SetSize(aNewSize);
+        pClonedMasterPage->setSize(pPage->getSize());
         pClonedMasterPage->CreateTitleAndLayout(true);
     }
 
diff --git a/sd/source/ui/sidebar/MasterPageContainer.cxx 
b/sd/source/ui/sidebar/MasterPageContainer.cxx
index fb404b765200..19d30107d09d 100644
--- a/sd/source/ui/sidebar/MasterPageContainer.cxx
+++ b/sd/source/ui/sidebar/MasterPageContainer.cxx
@@ -555,7 +555,7 @@ void 
MasterPageContainer::Implementation::UpdatePreviewSizePixel()
         });
     if (iDescriptor != maContainer.end())
     {
-        Size aPageSize ((*iDescriptor)->mpMasterPage->GetSize());
+        Size aPageSize ((*iDescriptor)->mpMasterPage->getSize().toToolsSize());
         OSL_ASSERT(!aPageSize.IsEmpty());
         if (aPageSize.Width() > 0)
             nWidth = aPageSize.Width();
diff --git a/sd/source/ui/slideshow/slideshowviewimpl.cxx 
b/sd/source/ui/slideshow/slideshowviewimpl.cxx
index 7db8594e4e08..5b937d390f90 100644
--- a/sd/source/ui/slideshow/slideshowviewimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowviewimpl.cxx
@@ -286,7 +286,7 @@ geometry::AffineMatrix2D SAL_CALL 
SlideShowView::getTransformation(  )
     }
 
     SdPage* pP = mpDoc->GetSdPage( 0, PageKind::Standard );
-    Size aPageSize( pP->GetSize() );
+    Size aPageSize(pP->getSize().toToolsSize());
 
     const double page_ratio = static_cast<double>(aPageSize.Width()) / 
static_cast<double>(aPageSize.Height());
     const double output_ratio = static_cast<double>(aOutputSize.Width()) / 
static_cast<double>(aOutputSize.Height());
diff --git a/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx 
b/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx
index ec8c7d9dcd0c..1200128f6471 100644
--- a/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsScrollBarManager.cxx
@@ -340,7 +340,7 @@ bool ScrollBarManager::TestScrollBarVisibilities (
     bool bRearrangeSuccess (mrSlideSorter.GetView().GetLayouter().Rearrange (
         mrSlideSorter.GetView().GetOrientation(),
         aBrowserSize,
-        rModel.GetPageDescriptor(0)->GetPage()->GetSize(),
+        rModel.GetPageDescriptor(0)->GetPage()->getSize().toToolsSize(),
         rModel.GetPageCount()));
 
     if (bRearrangeSuccess)
diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx 
b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
index 9c056f39f033..179f22fc828f 100644
--- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx
+++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
@@ -293,7 +293,7 @@ void SlideSorterView::Rearrange()
         mpLayouter->Rearrange (
             meOrientation,
             aWindowSize,
-            mrModel.GetPageDescriptor(0)->GetPage()->GetSize(),
+            mrModel.GetPageDescriptor(0)->GetPage()->getSize().toToolsSize(),
             mrModel.GetPageCount()));
     if (bRearrangeSuccess)
     {
diff --git a/sd/source/ui/table/tablefunction.cxx 
b/sd/source/ui/table/tablefunction.cxx
index 943744da15dc..bd38c6281ab5 100644
--- a/sd/source/ui/table/tablefunction.cxx
+++ b/sd/source/ui/table/tablefunction.cxx
@@ -105,7 +105,7 @@ static void InsertTableImpl(const DrawViewShell* pShell,
 
         // make sure that the default size of the table fits on the paper and 
is inside the viewing area.
         // if zoomed in close, don't make the table bigger than the viewing 
window.
-        Size aMaxSize = pShell->getCurrentPage()->GetSize();
+        Size aMaxSize = pShell->getCurrentPage()->getSize().toToolsSize();
 
         if (comphelper::LibreOfficeKit::isActive())
         {
diff --git a/sd/source/ui/tools/PreviewRenderer.cxx 
b/sd/source/ui/tools/PreviewRenderer.cxx
index 9425f0b16791..409f26650614 100644
--- a/sd/source/ui/tools/PreviewRenderer.cxx
+++ b/sd/source/ui/tools/PreviewRenderer.cxx
@@ -87,7 +87,7 @@ Image PreviewRenderer::RenderPage (
 {
     if (pPage != nullptr)
     {
-        const Size aPageModelSize (pPage->GetSize());
+        const Size aPageModelSize(pPage->getSize().toToolsSize());
         const double nAspectRatio (
             double(aPageModelSize.Width()) / double(aPageModelSize.Height()));
         const sal_Int32 nFrameWidth (mbHasFrame ? snFrameWidth : 0);
@@ -272,7 +272,7 @@ void PreviewRenderer::PaintPage (
     const bool bDisplayPresentationObjects)
 {
     // Paint the page.
-    ::tools::Rectangle aPaintRectangle (Point(0,0), pPage->GetSize());
+    ::tools::Rectangle aPaintRectangle = pPage->getRectangle().toToolsRect();
     vcl::Region aRegion (aPaintRectangle);
 
     // Turn off online spelling and redlining.
@@ -358,7 +358,7 @@ void PreviewRenderer::SetupOutputSize (
     aMapMode.SetMapUnit(MapUnit::MapPixel);
 
     // Adapt it to the desired width.
-    const Size aPageModelSize (rPage.GetSize());
+    const Size aPageModelSize = rPage.getSize().toToolsSize();
     if (!aPageModelSize.IsEmpty())
     {
         const sal_Int32 nFrameWidth (mbHasFrame ? snFrameWidth : 0);
diff --git a/sd/source/ui/tools/SlideshowLayerRenderer.cxx 
b/sd/source/ui/tools/SlideshowLayerRenderer.cxx
index 90d7170561ed..d04d3f6efbba 100644
--- a/sd/source/ui/tools/SlideshowLayerRenderer.cxx
+++ b/sd/source/ui/tools/SlideshowLayerRenderer.cxx
@@ -116,7 +116,7 @@ public:
 
         maVirtualDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(rSlideSize, 
rScale, Point(),
                                                                    pBuffer);
-        Size aPageSize(rPage.GetSize());
+        Size aPageSize(rPage.getSize().toToolsSize());
 
         MapMode aMapMode(MapUnit::Map100thMM);
         const Fraction aFracX(rSlideSize.Width(),
@@ -821,7 +821,8 @@ void SlideshowLayerRenderer::setupMasterPageFields()
 
 Size SlideshowLayerRenderer::calculateAndSetSizePixel(Size const& 
rDesiredSizePixel)
 {
-    double fRatio = double(mrPage.GetHeight()) / mrPage.GetWidth();
+    double fRatio
+        = double(mrPage.getSize().getHeight().as_hmm()) / 
mrPage.getSize().getWidth().as_hmm();
     Size aSize(rDesiredSizePixel.Width(), 
::tools::Long(rDesiredSizePixel.Width() * fRatio));
     maSlideSize = aSize;
 
@@ -842,7 +843,7 @@ void SlideshowLayerRenderer::createViewAndDraw(
     aView.setHideBackground(!(mbRenderBackground && 
maRenderState.includeBackground()));
     aView.ShowSdrPage(&mrPage);
 
-    Size aPageSize(mrPage.GetSize());
+    Size aPageSize = mrPage.getSize().toToolsSize();
     Point aPoint;
 
     vcl::Region aRegion(::tools::Rectangle(aPoint, aPageSize));
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index e569fa25c077..390f21b37097 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2065,8 +2065,8 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 
nPage, bool bDuplicate )
         // this is only used for clipboard where we only have one page
         pStandardPage = mpDoc->AllocSdPage(false);
 
-        Size aDefSize(21000, 29700);   // A4 portrait orientation
-        pStandardPage->SetSize( aDefSize );
+        gfx::Size2DLWrap aDefSize(210_mm, 297_mm);   // A4 portrait orientation
+        pStandardPage->setSize(aDefSize);
         mpDoc->InsertPage(pStandardPage.get(), 0);
     }
     else
@@ -2096,11 +2096,8 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 
nPage, bool bDuplicate )
         else
             pStandardPage = mpDoc->AllocSdPage(false);
 
-        pStandardPage->SetSize( pPreviousStandardPage->GetSize() );
-        pStandardPage->SetBorder( pPreviousStandardPage->GetLeftBorder(),
-                                    pPreviousStandardPage->GetUpperBorder(),
-                                    pPreviousStandardPage->GetRightBorder(),
-                                    pPreviousStandardPage->GetLowerBorder() );
+        pStandardPage->setSize(pPreviousStandardPage->getSize());
+        pStandardPage->setBorder(pPreviousStandardPage->getBorder());
         pStandardPage->SetOrientation( pPreviousStandardPage->GetOrientation() 
);
         pStandardPage->SetName(OUString());
 
@@ -2131,11 +2128,8 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 
nPage, bool bDuplicate )
         else
             pNotesPage = mpDoc->AllocSdPage(false);
 
-        pNotesPage->SetSize( pPreviousNotesPage->GetSize() );
-        pNotesPage->SetBorder( pPreviousNotesPage->GetLeftBorder(),
-                                pPreviousNotesPage->GetUpperBorder(),
-                                pPreviousNotesPage->GetRightBorder(),
-                                pPreviousNotesPage->GetLowerBorder() );
+        pNotesPage->setSize(pPreviousNotesPage->getSize());
+        pNotesPage->setBorder(pPreviousNotesPage->getBorder());
         pNotesPage->SetOrientation( pPreviousNotesPage->GetOrientation() );
         pNotesPage->SetName(OUString());
         pNotesPage->SetPageKind(PageKind::Notes);
@@ -3119,7 +3113,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL 
SdXImpressDocument::getRenderer(
         awt::Size aPageSize;
         if ( bExportNotesPages )
         {
-            Size aNotesPageSize = mpDoc->GetSdPage( 0, PageKind::Notes 
)->GetSize();
+            Size aNotesPageSize = mpDoc->GetSdPage(0, PageKind::Notes 
)->getSize().toToolsSize();
             aPageSize = awt::Size( aNotesPageSize.Width(), 
aNotesPageSize.Height() );
         }
         else
@@ -3273,7 +3267,7 @@ static void ImplPDFExportShapeInteraction( const 
uno::Reference< drawing::XShape
         uno::Reference< beans::XPropertySet > xShapePropSet( xShape, 
uno::UNO_QUERY );
         if( xShapePropSet.is() )
         {
-            Size        aPageSize( rDoc.GetSdPage( 0, PageKind::Standard 
)->GetSize() );
+            Size aPageSize(rDoc.GetSdPage(0, 
PageKind::Standard)->getSize().toToolsSize());
             Point aPoint( 0, 0 );
             ::tools::Rectangle   aPageRect( aPoint, aPageSize );
 
@@ -3528,7 +3522,7 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 
nRenderer, const uno::Any& r
     }
 
     ::sd::ClientView aView( mpDocShell, pOut );
-    ::tools::Rectangle aVisArea( Point(), mpDoc->GetSdPage( 
static_cast<sal_uInt16>(nPageNumber) - 1, ePageKind )->GetSize() );
+    ::tools::Rectangle aVisArea( Point(), mpDoc->GetSdPage( 
static_cast<sal_uInt16>(nPageNumber) - 1, ePageKind )->getSize().toToolsSize() 
);
     vcl::Region                       aRegion( aVisArea );
 
     ::sd::ViewShell* pOldViewSh = mpDocShell->GetViewShell();
@@ -3746,7 +3740,7 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 
nRenderer, const uno::Any& r
         {
             try
             {
-                Size        aPageSize( mpDoc->GetSdPage( 0, PageKind::Standard 
)->GetSize() );
+                Size aPageSize(mpDoc->GetSdPage(0, 
PageKind::Standard)->getSize().toToolsSize());
                 Point aPoint( 0, 0 );
                 ::tools::Rectangle   aPageRect( aPoint, aPageSize );
 
@@ -4259,7 +4253,7 @@ void 
SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<cs
         {
             // get the full page size in pixels
             pWindow->EnableMapMode();
-            Size 
aSize(pWindow->LogicToPixel(pDrawView->GetSdrPageView()->GetPage()->GetSize()));
+            Size 
aSize(pWindow->LogicToPixel(pDrawView->GetSdrPageView()->GetPage()->getSize().toToolsSize()));
             // Disable map mode, so that it's possible to send mouse event
             // coordinates in logic units
             pWindow->EnableMapMode(false);
@@ -5375,11 +5369,8 @@ uno::Reference< drawing::XDrawPage > 
SdMasterPagesAccess::insertNewImpl( sal_Int
 
         // create and insert new draw masterpage
         rtl::Reference<SdPage> pMPage = mpModel->mpDoc->AllocSdPage(true);
-        pMPage->SetSize( pPage->GetSize() );
-        pMPage->SetBorder( pPage->GetLeftBorder(),
-                           pPage->GetUpperBorder(),
-                           pPage->GetRightBorder(),
-                           pPage->GetLowerBorder() );
+        pMPage->setSize(pPage->getSize());
+        pMPage->setBorder(pPage->getBorder());
         if (oPageName)
             // no need to update the page URLs on a brand new page
             pMPage->SetName(*oPageName, /*bUpdatePageRelativeURLs*/false);
@@ -5395,12 +5386,9 @@ uno::Reference< drawing::XDrawPage > 
SdMasterPagesAccess::insertNewImpl( sal_Int
 
         // create and insert new notes masterpage
         rtl::Reference<SdPage> pMNotesPage = mpModel->mpDoc->AllocSdPage(true);
-        pMNotesPage->SetSize( pRefNotesPage->GetSize() );
+        pMNotesPage->setSize(pRefNotesPage->getSize());
         pMNotesPage->SetPageKind(PageKind::Notes);
-        pMNotesPage->SetBorder( pRefNotesPage->GetLeftBorder(),
-                                pRefNotesPage->GetUpperBorder(),
-                                pRefNotesPage->GetRightBorder(),
-                                pRefNotesPage->GetLowerBorder() );
+        pMNotesPage->setBorder(pRefNotesPage->getBorder());
         pMNotesPage->SetLayoutName( aLayoutName );
         pDoc->InsertMasterPage(pMNotesPage.get(),  
static_cast<sal_uInt16>(nInsertPos) + 1);
         pMNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, true, true);
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index 8279858b20df..e39f1af8c603 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -1030,22 +1030,22 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const 
OUString& PropertyName )
         aAny = getNavigationOrder();
         break;
     case WID_PAGE_LEFT:
-        aAny <<= GetPage()->GetLeftBorder();
+        aAny <<= basegfx::fround(GetPage()->getBorder().leftUnit());
         break;
     case WID_PAGE_RIGHT:
-        aAny <<= GetPage()->GetRightBorder();
+        aAny <<= basegfx::fround(GetPage()->getBorder().rightUnit());
         break;
     case WID_PAGE_TOP:
-        aAny <<= GetPage()->GetUpperBorder();
+        aAny <<= basegfx::fround(GetPage()->getBorder().upperUnit());
         break;
     case WID_PAGE_BOTTOM:
-        aAny <<= GetPage()->GetLowerBorder();
+        aAny <<= basegfx::fround(GetPage()->getBorder().lowerUnit());
         break;
     case WID_PAGE_WIDTH:
-        aAny <<= static_cast<sal_Int32>( GetPage()->GetSize().getWidth() );
+        aAny <<= static_cast<sal_Int32>( 
GetPage()->getSize().toToolsSize().getWidth() );
         break;
     case WID_PAGE_HEIGHT:
-e 
... etc. - the rest is truncated

Reply via email to