Rebased ref, commits from common ancestor:
commit e9cf86c73407b1200276fa447aff6bfaf5a95858
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Tue Oct 18 21:28:29 2022 +0200
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Tue Oct 18 21:34:29 2022 +0200

    editeng: fix rendering of text when "fit to frame" is enabbled
    
    This changes the nStretchX and nStretchY from sal_uInt16 to double
    so the text in text boxes is rendered correctly (text should be
    resized to the same size as the textbox).
    
    Change-Id: Ic92d03043af0abe86f1b67ae15522d0176ebbb51

diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index 88bc04a9efed..c8a66d0470a4 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -2266,12 +2266,12 @@ bool EditEngine::HasText( const SvxSearchItem& 
rSearchItem )
     return pImpEditEngine->HasText( rSearchItem );
 }
 
-void EditEngine::SetGlobalCharStretching( sal_uInt16 nX, sal_uInt16 nY )
+void EditEngine::SetGlobalCharStretching(double nX, double nY)
 {
     pImpEditEngine->SetCharStretching( nX, nY );
 }
 
-void EditEngine::GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) 
const
+void EditEngine::GetGlobalCharStretching(double& rX, double& rY) const
 {
     pImpEditEngine->GetCharStretching( rX, rY );
 }
diff --git a/editeng/source/editeng/editobj.cxx 
b/editeng/source/editeng/editobj.cxx
index 6d57c7497c2b..437754d70def 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -71,10 +71,10 @@ void XEditAttribute::SetItem(const SfxPoolItem& rNew)
 }
 
 XParaPortionList::XParaPortionList(
-    OutputDevice* pRefDev, sal_uInt32 nPW, sal_uInt16 _nStretchX, sal_uInt16 
_nStretchY)
+    OutputDevice* pRefDev, sal_uInt32 nPW, double nStretchX, double nStretchY)
     : pRefDevPtr(pRefDev)
-    , nStretchX(_nStretchX)
-    , nStretchY(_nStretchY)
+    , mnStretchX(nStretchX)
+    , mnStretchY(nStretchY)
     , nPaperWidth(nPW)
 {
 }
diff --git a/editeng/source/editeng/editobj2.hxx 
b/editeng/source/editeng/editobj2.hxx
index 250341fd4283..86a2e379be20 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -94,12 +94,12 @@ class XParaPortionList
     ListType maList;
 
     VclPtr<OutputDevice> pRefDevPtr;
-    sal_uInt16  nStretchX;
-    sal_uInt16  nStretchY;
+    double  mnStretchX;
+    double  mnStretchY;
     sal_uInt32  nPaperWidth;
 
 public:
-    XParaPortionList(OutputDevice* pRefDev, sal_uInt32 nPW, sal_uInt16 
_nStretchX, sal_uInt16 _nStretchY);
+    XParaPortionList(OutputDevice* pRefDev, sal_uInt32 nPW, double nStretchX, 
double nStretchY);
 
     void push_back(XParaPortion* p);
     const XParaPortion& operator[](size_t i) const;
@@ -108,8 +108,8 @@ public:
     sal_uInt32          GetPaperWidth() const       { return nPaperWidth; }
     bool                RefDevIsVirtual() const {return 
pRefDevPtr->IsVirtual();}
     const MapMode&  GetRefMapMode() const       { return 
pRefDevPtr->GetMapMode(); }
-    sal_uInt16  GetStretchX() const         { return nStretchX; }
-    sal_uInt16  GetStretchY() const         { return nStretchY; }
+    double  GetStretchX() const { return mnStretchX; }
+    double  GetStretchY() const { return mnStretchY; }
 };
 
 class ContentInfo
diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index b761e3bc4135..20e116b2ab3f 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -528,8 +528,8 @@ private:
 
     Color               maBackgroundColor;
 
-    sal_uInt16          nStretchX;
-    sal_uInt16          nStretchY;
+    double mnStretchX;
+    double mnStretchY;
 
     CharCompressType    nAsianCompressionMode;
 
@@ -1080,8 +1080,8 @@ public:
     SvxCellJustifyMethod    GetJustifyMethod( sal_Int32 nPara ) const;
     SvxCellVerJustify       GetVerJustification( sal_Int32 nPara ) const;
 
-    void                SetCharStretching( sal_uInt16 nX, sal_uInt16 nY );
-    inline void         GetCharStretching( sal_uInt16& rX, sal_uInt16& rY ) 
const;
+    void                SetCharStretching(double nX, double nY);
+    inline void         GetCharStretching(double& rX, double& rY) const;
 
     sal_Int32           GetBigTextObjectStart() const                          
     { return nBigTextObjectStart; }
 
@@ -1282,43 +1282,43 @@ inline ParaPortion* ImpEditEngine::FindParaPortion( 
ContentNode const * pNode )
     return GetParaPortions()[ nPos ];
 }
 
-inline void ImpEditEngine::GetCharStretching( sal_uInt16& rX, sal_uInt16& rY ) 
const
+inline void ImpEditEngine::GetCharStretching(double& rX, double& rY) const
 {
-    rX = nStretchX;
-    rY = nStretchY;
+    rX = mnStretchX;
+    rY = mnStretchY;
 }
 
 inline short ImpEditEngine::GetXValue( short nXValue ) const
 {
-    if ( !aStatus.DoStretch() || ( nStretchX == 100 ) )
+    if ( !aStatus.DoStretch() || ( mnStretchX == 100.0 ) )
         return nXValue;
 
-    return static_cast<short>(static_cast<tools::Long>(nXValue)*nStretchX/100);
+    return short(double(nXValue) * mnStretchX / 100.0);
 }
 
 
 inline tools::Long ImpEditEngine::GetXValue( tools::Long nXValue ) const
 {
-    if ( !aStatus.DoStretch() || ( nStretchX == 100 ) )
+    if ( !aStatus.DoStretch() || ( mnStretchX == 100.0 ) )
         return nXValue;
 
-    return nXValue*nStretchX/100;
+    return nXValue * mnStretchX / 100.0;
 }
 
 inline short ImpEditEngine::GetYValue( short nYValue ) const
 {
-    if ( !aStatus.DoStretch() || ( nStretchY == 100 ) )
+    if ( !aStatus.DoStretch() || ( mnStretchY == 100.0 ) )
         return nYValue;
 
-    return static_cast<short>(static_cast<tools::Long>(nYValue)*nStretchY/100);
+    return short(double(nYValue) * mnStretchY / 100.0);
 }
 
 inline sal_uInt16 ImpEditEngine::GetYValue( sal_uInt16 nYValue ) const
 {
-    if ( !aStatus.DoStretch() || ( nStretchY == 100 ) )
+    if ( !aStatus.DoStretch() || ( mnStretchY == 100.0 ) )
         return nYValue;
 
-    return 
static_cast<sal_uInt16>(static_cast<tools::Long>(nYValue)*nStretchY/100);
+    return sal_uInt16(double(nYValue) * mnStretchY / 100.0);
 }
 
 inline PointerStyle ImpEditView::GetPointer()
diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index 455587bac4a6..c7df8af33337 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -98,8 +98,8 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* 
pItemPool ) :
     pUndoManager(nullptr),
     aWordDelimiters(" .,;:-`'?!_=\"{}()[]"),
     maBackgroundColor(COL_AUTO),
-    nStretchX(100),
-    nStretchY(100),
+    mnStretchX(100.0),
+    mnStretchY(100.0),
     nAsianCompressionMode(CharCompressType::NONE),
     eDefaultHorizontalTextDirection(EEHorizontalTextDirection::Default),
     nBigTextObjectStart(20),
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index bdaab8a970bc..549d139e335f 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -1050,8 +1050,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                         // Search for Tab-Pos...
                         tools::Long nCurPos = nTmpWidth+nStartX;
                         // consider scaling
-                        if ( aStatus.DoStretch() && ( nStretchX != 100 ) )
-                            nCurPos = 
nCurPos*100/std::max(static_cast<sal_Int32>(nStretchX), 
static_cast<sal_Int32>(1));
+                        if ( aStatus.DoStretch() && ( mnStretchX != 100.0 ) )
+                            nCurPos = nCurPos * 100.0 / std::max(mnStretchX, 
1.0);
 
                         short nAllSpaceBeforeText = static_cast< short 
>(rLRItem.GetTextLeft()/* + rLRItem.GetTextLeft()*/ + 
nSpaceBeforeAndMinLabelWidth);
                         aCurrentTab.aTabStop = 
pNode->GetContentAttribs().FindTabStop( nCurPos - nAllSpaceBeforeText 
/*rLRItem.GetTextLeft()*/, aEditDoc.GetDefTab() );
@@ -2982,22 +2982,21 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, 
sal_Int32 nPos, SvxFont& rFo
 
         if ( aStatus.DoStretch() )
         {
-            if ( nStretchY != 100 )
+            if (mnStretchY != 100.0)
             {
-                aRealSz.setHeight( aRealSz.Height() * nStretchY );
-                aRealSz.setHeight( aRealSz.Height() / 100 );
+                aRealSz.setHeight(aRealSz.Height() * mnStretchY);
+                aRealSz.setHeight(aRealSz.Height() / 100.0);
             }
-            if ( nStretchX != 100 )
+            if (mnStretchX != 100.0)
             {
-                if ( nStretchX == nStretchY &&
-                     nRelWidth == 100 )
+                if (mnStretchX == mnStretchY && nRelWidth == 100 )
                 {
                     aRealSz.setWidth( 0 );
                 }
                 else
                 {
-                    aRealSz.setWidth( aRealSz.Width() * nStretchX );
-                    aRealSz.setWidth( aRealSz.Width() / 100 );
+                    aRealSz.setWidth(aRealSz.Width() * mnStretchX);
+                    aRealSz.setWidth(aRealSz.Width() / 100.0);
 
                     // Also the Kerning: (long due to handle Interim results)
                     tools::Long nKerning = rFont.GetFixKerning();
@@ -3012,16 +3011,16 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, 
sal_Int32 nPos, SvxFont& rFo
   >0        >100        > (Proportional)
   <0        >100        < (The amount, thus disproportional)
 */
-                    if ( ( nKerning < 0  ) && ( nStretchX > 100 ) )
+                    if (nKerning < 0 && mnStretchX > 100.0)
                     {
                         // disproportional
                         nKerning *= 100;
-                        nKerning /= nStretchX;
+                        nKerning /= mnStretchX;
                     }
                     else if ( nKerning )
                     {
                         // Proportional
-                        nKerning *= nStretchX;
+                        nKerning *= mnStretchX;
                         nKerning /= 100;
                     }
                     rFont.SetFixKerning( static_cast<short>(nKerning) );
@@ -4428,20 +4427,20 @@ void ImpEditEngine::SetFlatMode( bool bFlat )
         pActiveView->ShowCursor();
 }
 
-void ImpEditEngine::SetCharStretching( sal_uInt16 nX, sal_uInt16 nY )
+void ImpEditEngine::SetCharStretching(double nX, double nY)
 {
     bool bChanged;
     if ( !IsEffectivelyVertical() )
     {
-        bChanged = nStretchX!=nX || nStretchY!=nY;
-        nStretchX = nX;
-        nStretchY = nY;
+        bChanged = mnStretchX != nX || mnStretchY != nY;
+        mnStretchX = nX;
+        mnStretchY = nY;
     }
     else
     {
-        bChanged = nStretchX!=nY || nStretchY!=nX;
-        nStretchX = nY;
-        nStretchY = nX;
+        bChanged = mnStretchX != nY || mnStretchY != nX;
+        mnStretchX = nY;
+        mnStretchY = nX;
     }
 
     if (bChanged && aStatus.DoStretch())
diff --git a/editeng/source/editeng/impedit4.cxx 
b/editeng/source/editeng/impedit4.cxx
index ee9ebe89ff2e..251ac536b46c 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1083,7 +1083,7 @@ std::unique_ptr<EditTextObject> 
ImpEditEngine::CreateTextObject( EditSelection a
     // sleeper set up when Olli paragraphs not hacked!
     if ( bAllowBigObjects && bOnlyFullParagraphs && IsFormatted() && 
IsUpdateLayout() && ( nTextPortions >= nBigObjectStart ) )
     {
-        XParaPortionList* pXList = new XParaPortionList( GetRefDevice(), 
GetColumnWidth(aPaperSize), nStretchX, nStretchY );
+        XParaPortionList* pXList = new XParaPortionList( GetRefDevice(), 
GetColumnWidth(aPaperSize), mnStretchX, mnStretchY );
         pTxtObj->SetPortionInfo(std::unique_ptr<XParaPortionList>(pXList));
         for ( nNode = nStartNode; nNode <= nEndNode; nNode++  )
         {
@@ -1169,8 +1169,8 @@ EditSelection ImpEditEngine::InsertTextObject( const 
EditTextObject& rTextObject
 
     if ( pPortionInfo && ( 
static_cast<tools::Long>(pPortionInfo->GetPaperWidth()) == 
GetColumnWidth(aPaperSize) )
             && ( pPortionInfo->GetRefMapMode() == GetRefDevice()->GetMapMode() 
)
-            && ( pPortionInfo->GetStretchX() == nStretchX )
-            && ( pPortionInfo->GetStretchY() == nStretchY ) )
+            && ( pPortionInfo->GetStretchX() == sal_uInt16(mnStretchX))
+            && ( pPortionInfo->GetStretchY() == sal_uInt16(mnStretchY)) )
     {
         if ( (pPortionInfo->GetRefDevPtr() == GetRefDevice()) ||
              (pPortionInfo->RefDevIsVirtual() && GetRefDevice()->IsVirtual()) )
diff --git a/editeng/source/outliner/outlin2.cxx 
b/editeng/source/outliner/outlin2.cxx
index 951f6923563f..68b1d0fb802e 100644
--- a/editeng/source/outliner/outlin2.cxx
+++ b/editeng/source/outliner/outlin2.cxx
@@ -482,9 +482,8 @@ void Outliner::QuickFormatDoc()
     pEditEngine->QuickFormatDoc();
 }
 
-void Outliner::SetGlobalCharStretching( sal_uInt16 nX, sal_uInt16 nY )
+void Outliner::SetGlobalCharStretching(double nX, double nY)
 {
-
     // reset bullet size
     sal_Int32 nParagraphs = pParaList->GetParagraphCount();
     for ( sal_Int32 nPara = 0; nPara < nParagraphs; nPara++ )
@@ -497,9 +496,9 @@ void Outliner::SetGlobalCharStretching( sal_uInt16 nX, 
sal_uInt16 nY )
     pEditEngine->SetGlobalCharStretching( nX, nY );
 }
 
-void Outliner::GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) const
+void Outliner::GetGlobalCharStretching(double& rX, double& rY) const
 {
-    pEditEngine->GetGlobalCharStretching( rX, rY );
+    pEditEngine->GetGlobalCharStretching(rX, rY);
 }
 
 void Outliner::EraseVirtualDevice()
diff --git a/editeng/source/outliner/outliner.cxx 
b/editeng/source/outliner/outliner.cxx
index d7ea27662e77..f6b8feab3833 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -840,7 +840,7 @@ vcl::Font Outliner::ImpCalcBulletFont( sal_Int32 nPara ) 
const
     }
 
     // Use original scale...
-    sal_uInt16 nStretchX, nStretchY;
+    double nStretchX, nStretchY;
     GetGlobalCharStretching(nStretchX, nStretchY);
 
     sal_uInt16 nScale = pFmt->GetBulletRelSize() * nStretchY / 100;
@@ -887,12 +887,10 @@ void Outliner::PaintBullet(sal_Int32 nPara, const Point& 
rStartPos, const Point&
     bool bRightToLeftPara = pEditEngine->IsRightToLeft( nPara );
 
     tools::Rectangle aBulletArea( ImpCalcBulletArea( nPara, true, false ) );
-    sal_uInt16 nStretchX, nStretchY;
+    double nStretchX, nStretchY;
     GetGlobalCharStretching(nStretchX, nStretchY);
-    aBulletArea = tools::Rectangle( Point(aBulletArea.Left()*nStretchX/100,
-                                   aBulletArea.Top()),
-                             Size(aBulletArea.GetWidth()*nStretchX/100,
-                                  aBulletArea.GetHeight()) );
+    aBulletArea = tools::Rectangle( Point(aBulletArea.Left() * nStretchX / 
100.0, aBulletArea.Top()),
+                             Size(aBulletArea.GetWidth() * nStretchX / 100.0, 
aBulletArea.GetHeight()) );
 
     Paragraph* pPara = pParaList->GetParagraph( nPara );
     const SvxNumberFormat* pFmt = GetNumberFormat( nPara );
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx
index 1252487de836..f5487e779a4b 100644
--- a/include/editeng/editeng.hxx
+++ b/include/editeng/editeng.hxx
@@ -414,8 +414,8 @@ public:
     void            QuickDelete( const ESelection& rSel );
     void            QuickMarkToBeRepainted( sal_Int32 nPara );
 
-    void            SetGlobalCharStretching( sal_uInt16 nX, sal_uInt16 nY );
-    void            GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) 
const;
+    void            SetGlobalCharStretching(double nX, double nY);
+    void            GetGlobalCharStretching(double& rX, double& rY) const;
 
     void            SetEditTextObjectPool( SfxItemPool* pPool );
     SfxItemPool*    GetEditTextObjectPool() const;
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 03acc7cdc633..c6d57f09a086 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -930,8 +930,8 @@ public:
     bool            IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder );
     bool            IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder, 
bool* pbBulletPos );
 
-    void            SetGlobalCharStretching( sal_uInt16 nX = 100, sal_uInt16 
nY = 100 );
-    void            GetGlobalCharStretching( sal_uInt16& rX, sal_uInt16& rY ) 
const;
+    void            SetGlobalCharStretching(double nX = 100.0, double nY = 
100.0);
+    void            GetGlobalCharStretching(double& rX, double& rY) const;
     void            EraseVirtualDevice();
 
     bool            ShouldCreateBigTextObject() const;
diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx
index b10af08289fa..d8503d0412f7 100644
--- a/sd/source/ui/view/drtxtob.cxx
+++ b/sd/source/ui/view/drtxtob.cxx
@@ -165,7 +165,7 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet )
             case SID_ATTR_CHAR_STRIKEOUT:
             case SID_ATTR_CHAR_CASEMAP:
             {
-                sal_uInt16 stretchX = 100;
+                double stretchX = 100.0;
                 SvxScriptSetItem aSetItem( nSlotId, GetPool() );
                 aSetItem.GetItemSet().Put( aAttrSet, false );
 
@@ -183,9 +183,9 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet )
                     if (OutlineView* pOView = 
dynamic_cast<OutlineView*>(mpView))
                         pOLV = 
pOView->GetViewByWindow(mpViewShell->GetActiveWindow());
 
-                    sal_uInt16 stretchY = 100;
+                    double stretchY = 100.0;
                     if( pOutliner )
-                        pOutliner->GetGlobalCharStretching( stretchX, stretchY 
);
+                        pOutliner->GetGlobalCharStretching(stretchX, stretchY);
 
                     if(pOLV && !pOLV->GetSelection().HasRange())
                     {
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 53b32ddf28b2..b68726ad2bd0 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -921,56 +921,88 @@ void SdrTextObj::ImpSetCharStretching(SdrOutliner& 
rOutliner, const Size& rTextS
     tools::Long nXTolMi=nWantWdt/25;  // tolerance: -4%
     tools::Long nXCorr =nWantWdt/20;  // correction scale: 5%
 
-    tools::Long nX=(nWantWdt*100) /nIsWdt; // calculate X stretching
-    tools::Long nY=(nWantHgt*100) /nIsHgt; // calculate Y stretching
+    double nX = (nWantWdt * 100.0) / double(nIsWdt); // calculate X stretching
+    double nY = (nWantHgt * 100.0) / double(nIsHgt); // calculate Y stretching
     bool bChkX = true;
-    if (bNoStretching) { // might only be possible proportionally
-        if (nX>nY) { nX=nY; bChkX=false; }
-        else { nY=nX; }
+    if (bNoStretching)
+    { // might only be possible proportionally
+        if (nX > nY)
+        {
+            nX = nY;
+            bChkX = false;
+        }
+        else
+        {
+            nY=nX;
+        }
     }
 
-    while (nLoopCount<5 && !bNoMoreLoop) {
-        if (nX<0) nX=-nX;
-        if (nX<1) { nX=1; bNoMoreLoop = true; }
-        if (nX>65535) { nX=65535; bNoMoreLoop = true; }
+    while (nLoopCount<5 && !bNoMoreLoop)
+    {
+        if (nX < 0.0)
+            nX = -nX;
+        if (nX < 1.0)
+        {
+            nX = 1.0;
+            bNoMoreLoop = true;
+        }
+        if (nX > 65535.0)
+        {
+            nX = 65535.0;
+            bNoMoreLoop = true;
+        }
 
-        if (nY<0) nY=-nY;
-        if (nY<1) { nY=1; bNoMoreLoop = true; }
-        if (nY>65535) { nY=65535; bNoMoreLoop = true; }
+        if (nY < 0.0)
+        {
+            nY = -nY;
+        }
+        if (nY < 1.0)
+        {
+            nY = 1.0;
+            bNoMoreLoop = true;
+        }
+        if (nY > 65535.0)
+        {
+            nY = 65535.0;
+            bNoMoreLoop = true;
+        }
 
         // exception, there is no text yet (horizontal case)
-        if(nIsWdt <= 1)
+        if (nIsWdt <= 1.0)
         {
             nX = nY;
             bNoMoreLoop = true;
         }
 
         // exception, there is no text yet (vertical case)
-        if(nIsHgt <= 1)
+        if (nIsHgt <= 1)
         {
             nY = nX;
             bNoMoreLoop = true;
         }
-
-        
rOutliner.SetGlobalCharStretching(static_cast<sal_uInt16>(nX),static_cast<sal_uInt16>(nY));
+        rOutliner.SetGlobalCharStretching(nX, nY);
         nLoopCount++;
         Size aSiz(rOutliner.CalcTextSize());
-        tools::Long nXDiff=aSiz.Width()-nWantWdt;
+        tools::Long nXDiff = aSiz.Width() - nWantWdt;
         rFitXCorrection=Fraction(nWantWdt,aSiz.Width());
         if (((nXDiff>=nXTolMi || !bChkX) && nXDiff<=nXTolPl) || 
nXDiff==nXDiff0) {
             bNoMoreLoop = true;
         } else {
             // correct stretching factors
-            tools::Long nMul=nWantWdt;
-            tools::Long nDiv=aSiz.Width();
-            if (std::abs(nXDiff)<=2*nXCorr) {
-                if (nMul>nDiv) nDiv+=(nMul-nDiv)/2; // but only add half of 
what we calculated,
-                else nMul+=(nDiv-nMul)/2;           // because the EditEngine 
calculates wrongly later on
+            tools::Long nMul = nWantWdt;
+            tools::Long nDiv = aSiz.Width();
+            if (std::abs(nXDiff) <= 2 * nXCorr)
+            {
+                if (nMul > nDiv)
+                    nDiv += (nMul - nDiv) / 2.0; // but only add half of what 
we calculated,
+                else
+                    nMul += (nDiv - nMul) / 2.0;// because the EditEngine 
calculates wrongly later on
             }
-            nX=nX*nMul/nDiv;
-            if (bNoStretching) nY=nX;
+            nX = nX * nMul / nDiv;
+            if (bNoStretching)
+                nY = nX;
         }
-        nXDiff0=nXDiff;
+        nXDiff0 = nXDiff;
     }
 }
 
@@ -1133,7 +1165,7 @@ void SdrTextObj::ImpInitDrawOutliner( SdrOutliner& rOutl 
) const
         nOutlinerMode = OutlinerMode::TextObject;
     rOutl.Init( nOutlinerMode );
 
-    rOutl.SetGlobalCharStretching();
+    rOutl.SetGlobalCharStretching(100.0, 100.0);
     EEControlBits nStat=rOutl.GetControlWord();
     nStat &= 
~EEControlBits(EEControlBits::STRETCHING|EEControlBits::AUTOPAGESIZE);
     rOutl.SetControlWord(nStat);
@@ -1197,8 +1229,8 @@ sal_uInt16 SdrTextObj::GetFontScaleY() const
     // This eventually calls ImpAutoFitText
     UpdateOutlinerFormatting(rOutliner, o3tl::temporary(tools::Rectangle()));
 
-    sal_uInt16 nStretchY;
-    rOutliner.GetGlobalCharStretching(o3tl::temporary(sal_uInt16()), 
nStretchY);
+    double nStretchY;
+    rOutliner.GetGlobalCharStretching(o3tl::temporary(double()), nStretchY);
     return nStretchY;
 }
 
@@ -1218,7 +1250,8 @@ void SdrTextObj::ImpAutoFitText(SdrOutliner& rOutliner, 
const Size& rTextSize,
     // line-breaking text that we need some more samples
 
     // loop early-exits if we detect an already attained value
-    sal_uInt16 nMinStretchX=0, nMinStretchY=0;
+    double nMinStretchX = 0.0;
+    double nMinStretchY = 0.0;
     sal_uInt16 aOldStretchXVals[]={0,0,0,0,0,0,0,0,0,0};
     const size_t aStretchArySize=SAL_N_ELEMENTS(aOldStretchXVals);
     for(unsigned int i=0; i<aStretchArySize; ++i)
@@ -1243,15 +1276,15 @@ void SdrTextObj::ImpAutoFitText(SdrOutliner& rOutliner, 
const Size& rTextSize,
         // - bulleted words will have to go through more iterations
         fFactor = std::sqrt(fFactor);
 
-        sal_uInt16 nCurrStretchX, nCurrStretchY;
+        double nCurrStretchX, nCurrStretchY;
         rOutliner.GetGlobalCharStretching(nCurrStretchX, nCurrStretchY);
 
         if (fFactor >= 1.0 )
         {
             // resulting text area fits into available shape rect -
             // err on the larger stretching, to optimally fill area
-            nMinStretchX = std::max(nMinStretchX,nCurrStretchX);
-            nMinStretchY = std::max(nMinStretchY,nCurrStretchY);
+            nMinStretchX = std::max(nMinStretchX, nCurrStretchX);
+            nMinStretchY = std::max(nMinStretchY, nCurrStretchY);
         }
 
         aOldStretchXVals[i] = nCurrStretchX;
@@ -1260,10 +1293,10 @@ void SdrTextObj::ImpAutoFitText(SdrOutliner& rOutliner, 
const Size& rTextSize,
 
         if (fFactor < 1.0 || nCurrStretchX != 100)
         {
-            nCurrStretchX = 
sal::static_int_cast<sal_uInt16>(nCurrStretchX*fFactor);
-            nCurrStretchY = 
sal::static_int_cast<sal_uInt16>(nCurrStretchY*fFactor);
-            
rOutliner.SetGlobalCharStretching(std::min(sal_uInt16(100),nCurrStretchX),
-                                              
std::min(sal_uInt16(100),nCurrStretchY));
+            nCurrStretchX = nCurrStretchX * fFactor;
+            nCurrStretchY = nCurrStretchY * fFactor;
+
+            rOutliner.SetGlobalCharStretching(std::min(100.0, nCurrStretchX), 
std::min(100.0, nCurrStretchY));
             SAL_INFO("svx", "zoom is " << nCurrStretchX);
         }
     }
@@ -1276,8 +1309,7 @@ void SdrTextObj::ImpAutoFitText(SdrOutliner& rOutliner, 
const Size& rTextSize,
     }
 
     SAL_INFO("svx", "final zoom is " << nMinStretchX);
-    rOutliner.SetGlobalCharStretching(std::min(sal_uInt16(100),nMinStretchX),
-                                      std::min(sal_uInt16(100),nMinStretchY));
+    rOutliner.SetGlobalCharStretching(std::min(100.0, nMinStretchX), 
std::min(100.0, nMinStretchY));
 }
 
 void SdrTextObj::SetupOutlinerFormatting( SdrOutliner& rOutl, 
tools::Rectangle& rPaintRect ) const
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx 
b/svx/source/svdraw/svdotextdecomposition.cxx
index 0c8928891231..c6b2a8e1e964 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -1223,7 +1223,7 @@ void SdrTextObj::impDecomposeStretchTextPrimitive(
     // to layout without mirroring
     const double fScaleX(fabs(aScale.getX()) / aOutlinerScale.getX());
     const double fScaleY(fabs(aScale.getY()) / aOutlinerScale.getY());
-    rOutliner.SetGlobalCharStretching(static_cast<sal_Int16>(FRound(fScaleX * 
100.0)), static_cast<sal_Int16>(FRound(fScaleY * 100.0)));
+    rOutliner.SetGlobalCharStretching(fScaleX * 100.0, fScaleY * 100.0);
 
     // When mirroring in X and Y,
     // move the null point which was top left to bottom right.
commit 0d19ee3ab9b34084ec48290b4960476228873dab
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Tue Oct 18 21:20:47 2022 +0200
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Tue Oct 18 21:34:29 2022 +0200

    editeng: rename aBuf to aCharPositionArray
    
    Change-Id: Ie7614ee9eefe1160f6d1e6105cc5bf7b92a35cc4

diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 03fa46b9b4fc..bdaab8a970bc 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -838,7 +838,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
     EditLine aSaveLine( *pLine );
     SvxFont aTmpFont( pNode->GetCharAttribs().GetDefFont() );
 
-    std::vector<sal_Int32> aBuf( pNode->Len() );
+    std::vector<sal_Int32> aCharPositionArray(pNode->Len());
 
     bool bSameLineAgain = false;    // For TextRanger, if the height changes.
     TabInfo aCurrentTab;
@@ -1234,14 +1234,14 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                 if (bContinueLastPortion)
                 {
                      Size aSize( aTmpFont.QuickGetTextSize( GetRefDevice(),
-                            pParaPortion->GetNode()->GetString(), nTmpPos, 
nPortionLen, &aBuf ));
+                            pParaPortion->GetNode()->GetString(), nTmpPos, 
nPortionLen, &aCharPositionArray ));
                      pPortion->adjustSize(aSize.Width(), 0);
                      if (pPortion->GetSize().Height() < aSize.Height())
                          pPortion->setHeight(aSize.Height());
                 }
                 else
                 {
-                    auto aSize = aTmpFont.QuickGetTextSize(GetRefDevice(), 
pParaPortion->GetNode()->GetString(), nTmpPos, nPortionLen, &aBuf);
+                    auto aSize = aTmpFont.QuickGetTextSize(GetRefDevice(), 
pParaPortion->GetNode()->GetString(), nTmpPos, nPortionLen, 
&aCharPositionArray);
                     pPortion->SetSize(aSize);
                 }
 
@@ -1256,7 +1256,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                 // => Always simply quick inserts.
                 size_t nPos = nTmpPos - pLine->GetStart();
                 EditLine::CharPosArrayType& rArray = pLine->GetCharPosArray();
-                rArray.insert( rArray.begin() + nPos, aBuf.data(), aBuf.data() 
+ nPortionLen);
+                rArray.insert( rArray.begin() + nPos, 
aCharPositionArray.data(), aCharPositionArray.data() + nPortionLen);
 
                 // And now check for Compression:
                 if ( !bContinueLastPortion && nPortionLen && 
GetAsianCompressionMode() != CharCompressType::NONE )
commit 6c44de899bfd7d7a7880bd65ee761d8c2c3493cf
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Tue Oct 18 21:14:41 2022 +0200
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Tue Oct 18 21:34:29 2022 +0200

    editeng: don't use GetSize to set the size
    
    Change-Id: I80a2701d7c125dbe6c80f8c32b125c7b176a8bb4

diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 4b92a9be258f..e5c3abbef0cf 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -409,7 +409,29 @@ public:
     sal_Int32      GetLen() const              { return nLen; }
     void           SetLen( sal_Int32 nL )         { nLen = nL; }
 
-    Size&          GetSize()                   { return aOutSz; }
+    void setWidth(tools::Long nWidth)
+    {
+        aOutSz.setWidth(nWidth);
+    }
+
+    void setHeight(tools::Long nHeight)
+    {
+        aOutSz.setHeight(nHeight);
+    }
+
+    void adjustSize(tools::Long nDeltaX, tools::Long nDeltaY)
+    {
+        if (nDeltaX != 0)
+            aOutSz.AdjustWidth(nDeltaX);
+        if (nDeltaY != 0)
+            aOutSz.AdjustHeight(nDeltaY);
+    }
+
+    void SetSize(const Size& rSize)
+    {
+        aOutSz = rSize;
+    }
+
     const Size&    GetSize() const             { return aOutSz; }
 
     void           SetKind(PortionKind n)      { nKind = n; }
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 6efc74d95cfe..03fa46b9b4fc 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -1016,7 +1016,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                     nTmpWidth -= rPrev.GetSize().Width();
                     nTmpPos = nTmpPos - rPrev.GetLen();
                     rPrev.SetLen(rPrev.GetLen() + nTmpLen);
-                    rPrev.GetSize().setWidth( -1 );
+                    rPrev.setWidth(-1);
                 }
 
                 assert( nTmpPortion < pParaPortion->GetTextPortions().Count() 
&& "No more Portions left!" );
@@ -1079,11 +1079,11 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
 
                         pPortion->SetKind(PortionKind::TAB);
                         pPortion->SetExtraValue( 
aCurrentTab.aTabStop.GetFill() );
-                        pPortion->GetSize().setWidth( aCurrentTab.nTabPos - 
(nTmpWidth+nStartX) );
+                        pPortion->setWidth( aCurrentTab.nTabPos - 
(nTmpWidth+nStartX) );
 
                         // Height needed...
                         SeekCursor( pNode, nTmpPos+1, aTmpFont );
-                        pPortion->GetSize().setHeight( 
GetRefDevice()->GetTextHeight() );
+                        pPortion->setHeight( GetRefDevice()->GetTextHeight() );
 
                         DBG_ASSERT( pPortion->GetSize().Width() >= 0, "Tab 
incorrectly calculated!" );
 
@@ -1095,7 +1095,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                         {
                             // What now?
                             // make the tab fitting
-                            pPortion->GetSize().setWidth( nXWidth-nOldTmpWidth 
);
+                            pPortion->setWidth( nXWidth-nOldTmpWidth );
                             nTmpWidth = nXWidth-1;
                             bEOL = true;
                             bBrokenLine = true;
@@ -1109,7 +1109,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                     case EE_FEATURE_LINEBR:
                     {
                         assert( pPortion );
-                        pPortion->GetSize().setWidth( 0 );
+                        pPortion->setWidth(0);
                         bEOL = true;
                         bLineBreak = true;
                         pPortion->SetKind( PortionKind::LINEBREAK );
@@ -1128,8 +1128,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                         OUString aFieldValue = static_cast<const 
EditCharAttribField*>(pNextFeature)->GetFieldValue();
                         // get size, but also DXArray to allow length 
information in line breaking below
                         std::vector<sal_Int32> aTmpDXArray;
-                        pPortion->GetSize() = 
aTmpFont.QuickGetTextSize(GetRefDevice(),
-                            aFieldValue, 0, aFieldValue.getLength(), 
&aTmpDXArray);
+                        
pPortion->SetSize(aTmpFont.QuickGetTextSize(GetRefDevice(),
+                            aFieldValue, 0, aFieldValue.getLength(), 
&aTmpDXArray));
 
                         // So no scrolling for oversized fields
                         if ( pPortion->GetSize().Width() > nXWidth )
@@ -1235,21 +1235,23 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                 {
                      Size aSize( aTmpFont.QuickGetTextSize( GetRefDevice(),
                             pParaPortion->GetNode()->GetString(), nTmpPos, 
nPortionLen, &aBuf ));
-                     pPortion->GetSize().AdjustWidth(aSize.Width() );
+                     pPortion->adjustSize(aSize.Width(), 0);
                      if (pPortion->GetSize().Height() < aSize.Height())
-                         pPortion->GetSize().setHeight( aSize.Height() );
+                         pPortion->setHeight(aSize.Height());
                 }
                 else
                 {
-                    pPortion->GetSize() = aTmpFont.QuickGetTextSize( 
GetRefDevice(),
-                            pParaPortion->GetNode()->GetString(), nTmpPos, 
nPortionLen, &aBuf );
+                    auto aSize = aTmpFont.QuickGetTextSize(GetRefDevice(), 
pParaPortion->GetNode()->GetString(), nTmpPos, nPortionLen, &aBuf);
+                    pPortion->SetSize(aSize);
                 }
 
                 // #i9050# Do Kerning also behind portions...
                 if ( ( aTmpFont.GetFixKerning() > 0 ) && ( ( nTmpPos + 
nPortionLen ) < pNode->Len() ) )
-                    pPortion->GetSize().AdjustWidth(aTmpFont.GetFixKerning() );
+                    pPortion->adjustSize(aTmpFont.GetFixKerning(), 0);
                 if ( IsFixedCellHeight() )
-                    pPortion->GetSize().setHeight( 
ImplCalculateFontIndependentLineSpacing( aTmpFont.GetFontHeight() ) );
+                {
+                    pPortion->setHeight( 
ImplCalculateFontIndependentLineSpacing( aTmpFont.GetFontHeight() ) );
+                }
                 // The array is  generally flattened at the beginning
                 // => Always simply quick inserts.
                 size_t nPos = nTmpPos - pLine->GetStart();
@@ -1280,7 +1282,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                     {
                         tools::Long nExtraSpace = 
pPortion->GetSize().Height()/5;
                         nExtraSpace = GetXValue( nExtraSpace );
-                        pPortion->GetSize().AdjustWidth(nExtraSpace );
+                        pPortion->adjustSize(nExtraSpace, 0);
                         nTmpWidth += nExtraSpace;
                     }
                 }
@@ -1326,7 +1328,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                     aCurrentTab.bValid = false;
                 }
                 TextPortion& rTabPortion = 
pParaPortion->GetTextPortions()[aCurrentTab.nTabPortion];
-                rTabPortion.GetSize().setWidth( aCurrentTab.nTabPos - 
aCurrentTab.nStartPosX - nW - nStartX );
+                rTabPortion.setWidth( aCurrentTab.nTabPos - 
aCurrentTab.nStartPosX - nW - nStartX );
                 nTmpWidth = aCurrentTab.nStartPosX + 
rTabPortion.GetSize().Width() + nWidthAfterTab;
             }
 
@@ -1578,7 +1580,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
             {
                 pLine->GetCharPosArray()[ nPosInArray ] = nNewValue;
             }
-            rTP.GetSize().AdjustWidth(n );
+            rTP.adjustSize(n, 0);
         }
 
         pLine->SetTextWidth( aTextSize.Width() );
@@ -1803,9 +1805,9 @@ void ImpEditEngine::CreateAndInsertEmptyLine( 
ParaPortion* pParaPortion )
     aTmpFont.SetPhysFont(*pRefDev);
 
     TextPortion* pDummyPortion = new TextPortion( 0 );
-    pDummyPortion->GetSize() = aTmpFont.GetPhysTxtSize( pRefDev );
+    pDummyPortion->SetSize(aTmpFont.GetPhysTxtSize(pRefDev));
     if ( IsFixedCellHeight() )
-        pDummyPortion->GetSize().setHeight( 
ImplCalculateFontIndependentLineSpacing( aTmpFont.GetFontHeight() ) );
+        pDummyPortion->setHeight( ImplCalculateFontIndependentLineSpacing( 
aTmpFont.GetFontHeight() ) );
     pParaPortion->GetTextPortions().Append(pDummyPortion);
     FormatterFontMetric aFormatterMetrics;
     RecalcFormatterFontMetrics( aFormatterMetrics, aTmpFont );
@@ -2140,7 +2142,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* 
pParaPortion, EditLine* pLine, Te
         DBG_ASSERT( rTP.GetKind() == PortionKind::TEXT, "BlankRubber: No 
TextPortion!" );
         DBG_ASSERT( nBreakPos > pLine->GetStart(), "SplitTextPortion at the 
beginning of the line?" );
         sal_Int32 nPosInArray = nBreakPos - 1 - pLine->GetStart();
-        rTP.GetSize().setWidth( ( nPosInArray && ( rTP.GetLen() > 1 ) ) ? 
pLine->GetCharPosArray()[ nPosInArray-1 ] : 0 );
+        rTP.setWidth( ( nPosInArray && ( rTP.GetLen() > 1 ) ) ? 
pLine->GetCharPosArray()[ nPosInArray-1 ] : 0 );
         if (o3tl::make_unsigned(nPosInArray) < pLine->GetCharPosArray().size())
         {
             pLine->GetCharPosArray()[ nPosInArray ] = rTP.GetSize().Width();
@@ -2159,7 +2161,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* 
pParaPortion, EditLine* pLine, Te
             pHyphPortion->SetLen( nAltDelChar );
             if (cAlternateReplChar && !bAltFullLeft) 
pHyphPortion->SetExtraValue( cAlternateReplChar );
             // Correct width of the portion above:
-            rPrev.GetSize().setWidth(
+            rPrev.setWidth(
                 pLine->GetCharPosArray()[ nBreakPos-1 - pLine->GetStart() - 
nAltDelChar ] );
         }
 
@@ -2167,8 +2169,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* 
pParaPortion, EditLine* pLine, Te
         SvxFont aFont;
         SeekCursor( pParaPortion->GetNode(), nBreakPos, aFont );
         aFont.SetPhysFont(*GetRefDevice());
-        pHyphPortion->GetSize().setHeight( GetRefDevice()->GetTextHeight() );
-        pHyphPortion->GetSize().setWidth( GetRefDevice()->GetTextWidth( 
CH_HYPH ) );
+        pHyphPortion->SetSize(Size(GetRefDevice()->GetTextHeight(), 
GetRefDevice()->GetTextWidth(CH_HYPH)));
 
         pParaPortion->GetTextPortions().Insert(++nEndPortion, pHyphPortion);
     }
@@ -2251,7 +2252,7 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* 
pParaPortion, EditLine* pLine,
             // For the last character the portion must stop behind the blank
             // => Simplify correction:
             DBG_ASSERT( ( nPortionStart + rLastPortion.GetLen() ) == ( 
nLastChar+1 ), "Blank actually not at the end of the portion!?");
-            rLastPortion.GetSize().AdjustWidth( -nBlankWidth );
+            rLastPortion.adjustSize(-nBlankWidth, 0);
             nRemainingSpace += nBlankWidth;
         }
         pLine->GetCharPosArray()[nLastChar-nFirstChar] -= nBlankWidth;
@@ -2288,9 +2289,11 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* 
pParaPortion, EditLine* pLine,
             TextPortion& rLastPortion = pParaPortion->GetTextPortions()[ 
nPortion ];
 
             // The width of the portion:
-            rLastPortion.GetSize().AdjustWidth(nMore4Everyone );
-            if ( nSomeExtraSpace )
-                rLastPortion.GetSize().AdjustWidth( 1 );
+            rLastPortion.adjustSize(nMore4Everyone, 0);
+            if (nSomeExtraSpace)
+            {
+                rLastPortion.adjustSize(1, 0);
+            }
 
             // Correct positions in array
             sal_Int32 nPortionEnd = nPortionStart + rLastPortion.GetLen();
@@ -2546,7 +2549,7 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* 
pPortion, sal_Int32 nPos
     {
         // No new GetTextSize, instead use values from the Array:
         assert( nPos > pCurLine->GetStart() && "SplitTextPortion at the 
beginning of the line?" );
-        pTextPortion->GetSize().setWidth( pCurLine->GetCharPosArray()[ 
nPos-pCurLine->GetStart()-1 ] );
+        pTextPortion->setWidth(pCurLine->GetCharPosArray()[nPos - 
pCurLine->GetStart() - 1]);
 
         if ( pTextPortion->GetExtraInfos() && 
pTextPortion->GetExtraInfos()->bCompressed )
         {
@@ -2564,7 +2567,7 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* 
pPortion, sal_Int32 nPos
         }
     }
     else
-        pTextPortion->GetSize().setWidth( -1 );
+        pTextPortion->setWidth(-1);
 
     return nSplitPortion;
 }
@@ -2702,7 +2705,7 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* 
pParaPortion, sal_Int32 nSta
                 FindPortion( nStartPos, nPortionStart );
             TextPortion& rTP = pParaPortion->GetTextPortions()[ nTP ];
             rTP.SetLen( rTP.GetLen() + nNewChars );
-            rTP.GetSize().setWidth( -1 );
+            rTP.setWidth(-1);
         }
     }
     else
@@ -2768,7 +2771,7 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* 
pParaPortion, sal_Int32 nSta
                     TextPortion& rPrev = 
pParaPortion->GetTextPortions()[nLastPortion - 1];
                     DBG_ASSERT( rPrev.GetKind() == PortionKind::TEXT, 
"Portion?!" );
                     rPrev.SetLen( rPrev.GetLen() + pTP->GetLen() );
-                    rPrev.GetSize().setWidth( -1 );
+                    rPrev.setWidth(-1);
                 }
                 pParaPortion->GetTextPortions().Remove( nLastPortion );
             }
@@ -4743,7 +4746,7 @@ bool ImpEditEngine::ImplCalcAsianCompression(ContentNode* 
pNode,
         if ( bCompressed && ( n100thPercentFromMax == 10000 ) )
             pTextPortion->GetExtraInfos()->nWidthFullCompression = 
nNewPortionWidth;
 
-        pTextPortion->GetSize().setWidth( nNewPortionWidth );
+        pTextPortion->setWidth(nNewPortionWidth);
 
         if ( pTextPortion->GetExtraInfos() && ( n100thPercentFromMax != 10000 
) )
         {
@@ -4753,7 +4756,7 @@ bool ImpEditEngine::ImplCalcAsianCompression(ContentNode* 
pNode,
             nShrink /= 10000;
             tools::Long nNewWidth = pTextPortion->GetExtraInfos()->nOrgWidth - 
nShrink;
             if ( nNewWidth < pTextPortion->GetSize().Width() )
-                pTextPortion->GetSize().setWidth( nNewWidth );
+                pTextPortion->setWidth(nNewWidth);
         }
     }
     return bCompressed;
@@ -4795,7 +4798,7 @@ void ImpEditEngine::ImplExpandCompressedPortions( 
EditLine* pLine, ParaPortion*
     {
         pTP = pTP2;
         pTP->GetExtraInfos()->bCompressed = false;
-        pTP->GetSize().setWidth( pTP->GetExtraInfos()->nOrgWidth );
+        pTP->setWidth(pTP->GetExtraInfos()->nOrgWidth);
         if ( nCompressPercent )
         {
             sal_Int32 nTxtPortion = pParaPortion->GetTextPortions().GetPos( 
pTP );
commit 1594fa29ecaffb5014a1206020a8385ba8421347
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Tue Oct 18 21:06:55 2022 +0200
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Tue Oct 18 21:34:29 2022 +0200

    editeng: prefix the instance variable aDefFont-> maDefFont
    
    Change-Id: Ie9d18c19792962159e4e2ff4ddf91560323e42e6

diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 2a7aa0128423..4b92a9be258f 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -728,7 +728,7 @@ private:
     rtl::Reference<SfxItemPool> pItemPool;
     Link<LinkParamNone*,void>      aModifyHdl;
 
-    SvxFont         aDefFont;           //faster than ever from the pool!!
+    SvxFont         maDefFont;           //faster than ever from the pool!!
     sal_uInt16      nDefTab;
     bool            bIsVertical:1;
     TextRotation    mnRotation;
@@ -755,7 +755,7 @@ public:
     void            SetModifyHdl( const Link<LinkParamNone*,void>& rLink ) { 
aModifyHdl = rLink; }
 
     void            CreateDefFont( bool bUseStyles );
-    const SvxFont&  GetDefFont() const { return aDefFont; }
+    const SvxFont&  GetDefFont() const { return maDefFont; }
 
     void            SetDefTab( sal_uInt16 nTab )    { nDefTab = nTab ? nTab : 
DEFTAB; }
     sal_uInt16      GetDefTab() const           { return nDefTab; }
diff --git a/editeng/source/editeng/editdoc.cxx 
b/editeng/source/editeng/editdoc.cxx
index 108230a1666d..1fbf46de184b 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -2039,14 +2039,14 @@ void CreateFont( SvxFont& rFont, const SfxItemSet& 
rSet, bool bSearchInParent, S
 void EditDoc::CreateDefFont( bool bUseStyles )
 {
     SfxItemSetFixed<EE_PARA_START, EE_CHAR_END> aTmpSet( GetItemPool() );
-    CreateFont( aDefFont, aTmpSet );
-    aDefFont.SetVertical( IsEffectivelyVertical() );
-    aDefFont.SetOrientation( Degree10(IsEffectivelyVertical() ? 
(IsTopToBottom() ? 2700 : 900) : 0) );
+    CreateFont(maDefFont, aTmpSet);
+    maDefFont.SetVertical( IsEffectivelyVertical() );
+    maDefFont.SetOrientation( Degree10(IsEffectivelyVertical() ? 
(IsTopToBottom() ? 2700 : 900) : 0) );
 
     for ( sal_Int32 nNode = 0; nNode < Count(); nNode++ )
     {
         ContentNode* pNode = GetObject( nNode );
-        pNode->GetCharAttribs().GetDefFont() = aDefFont;
+        pNode->GetCharAttribs().GetDefFont() = maDefFont;
         if ( bUseStyles )
             pNode->CreateDefFont();
     }
commit b862094cc911e7b51343ba9efa009a13a1ee2740
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Thu Oct 13 10:12:27 2022 +0200
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Tue Oct 18 21:34:28 2022 +0200

    add division of length units to LengthUnitBase
    
    Reult of division of 2 length units is a ratio (double).
    
    Change-Id: I3d0e605492ca0af93580de138b5bc0c3e7877fa5

diff --git a/basegfx/test/LengthUnitTest.cxx b/basegfx/test/LengthUnitTest.cxx
index 8861a2ade316..11095f3222b5 100644
--- a/basegfx/test/LengthUnitTest.cxx
+++ b/basegfx/test/LengthUnitTest.cxx
@@ -32,11 +32,6 @@ public:
         CPPUNIT_ASSERT_EQUAL(sal_Int64(34200000000), cm3.raw());
         CPPUNIT_ASSERT_DOUBLES_EQUAL(95000.0, cm3.as_cm(), 1e-4);
 
-        gfx::Length cm4(1_cm);
-        cm4 /= 2;
-        CPPUNIT_ASSERT_EQUAL(sal_Int64(180000), cm4.raw());
-        CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5, cm4.as_cm(), 1e-4);
-
         // (635 * 20) + 3 * (635 * 15) = 41275EMU
         gfx::Length pt = 1_pt + 3_px;
         CPPUNIT_ASSERT_DOUBLES_EQUAL(3.25, pt.as_pt(), 1e-4);
@@ -92,6 +87,23 @@ public:
         CPPUNIT_ASSERT_EQUAL(sal_Int64(3636), bb.raw());
     }
 
+    void testDivision()
+    {
+        gfx::Length cm(1_cm);
+        cm /= 2;
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(180000), cm.raw());
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5, cm.as_cm(), 1e-4);
+
+        gfx::Length cm4(1_cm);
+        cm4 /= 2.0;
+        CPPUNIT_ASSERT_EQUAL(sal_Int64(180000), cm4.raw());
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5, cm4.as_cm(), 1e-4);
+
+        // with division of 2 length units you get a ratio
+        double aRatio = gfx::Length::hmm(10) / gfx::Length::hmm(20);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5, aRatio, 1e-9);
+    }
+
     void testInRange()
     {
         gfx::Range2DL aRange(1_cm, 2_cm, 2_cm, 30_mm);
@@ -159,6 +171,7 @@ public:
 
     CPPUNIT_TEST_SUITE(LengthTest);
     CPPUNIT_TEST(testBasic);
+    CPPUNIT_TEST(testDivision);
     CPPUNIT_TEST(testInRange);
     CPPUNIT_TEST(testInTuple);
     CPPUNIT_TEST(testConversionToRectanle);
diff --git a/include/basegfx/units/LengthUnitBase.hxx 
b/include/basegfx/units/LengthUnitBase.hxx
index c1d8a8e8e431..30daccef8015 100644
--- a/include/basegfx/units/LengthUnitBase.hxx
+++ b/include/basegfx/units/LengthUnitBase.hxx
@@ -173,14 +173,25 @@ inline LengthUnitBase<T> operator-(LengthUnitBase<T> lhs, 
const LengthUnitBase<T
     return lhs -= rhs;
 }
 
+/// Multiplication of a length unit with a scalar value.
+/// example 1cm * 2 = 2cm
 template <typename T> inline LengthUnitBase<T> operator*(LengthUnitBase<T> 
lhs, const long rhs)
 {
     return lhs *= rhs;
 }
 
+/// Division of a length unit with a scalar value.
+/// example 1cm / 2 = 0.5cm
 template <typename T> inline LengthUnitBase<T> operator/(LengthUnitBase<T> 
lhs, const long rhs)
 {
     return lhs /= rhs;
 }
 
+/// Division of 2 length units, which results in a ratio.
+/// example 1cm / 2cm = 0.5
+template <typename T> inline double operator/(LengthUnitBase<T> lhs, const 
LengthUnitBase<T> rhs)
+{
+    return lhs.raw() / double(rhs.raw());
+}
+
 } // end namespace gfx
commit 19654bd4aa85abe1a92764caed54bd8c9a2f71cf
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Fri Sep 16 13:15:03 2022 +0200
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Tue Oct 18 21:34:28 2022 +0200

    svx: change SdrPage left,right,upper,lower border to use gfx::Length
    
    Change-Id: I7cde7bccfe17cab27eb643d851509b68e128842d

diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index 60bafd2fa1bb..abf50cf476a0 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -321,12 +321,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 = 
gfx::length::toSizeHmm(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->getLeftBorder().as_emu() / 
aPageSize.getWidth().as_emu() +
+                pTargetSdrPage->getRightBorder().as_emu() / 
aPageSize.getWidth().as_emu() +
+                pTargetSdrPage->getUpperBorder().as_emu() / 
aPageSize.getHeight().as_emu() +
+                pTargetSdrPage->getLowerBorder().as_emu() / 
aPageSize.getHeight().as_emu()) / 4.0);
             const tools::Long nAllBorder(basegfx::fround((aGraphicSize.Width() 
+ aGraphicSize.Height()) * fBorderRelation * 0.5));
 
             // Adapt PageSize and Border stuff. To get all MasterPages and 
PresObjs
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index ccb7d581695b..0f101b3e6c63 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -353,6 +353,46 @@ public:
     void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
 
+class Border
+{
+private:
+    gfx::Length maLeft;
+    gfx::Length maRight;
+    gfx::Length maUpper;
+    gfx::Length maLower;
+public:
+    Border()
+        : maLeft(0_emu)
+        , maRight(0_emu)
+        , maUpper(0_emu)
+        , maLower(0_emu)
+    {}
+
+    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; }
+
+    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;
+    }
+};
 
 /**
   A SdrPage contains exactly one SdrObjList and a description of the physical
@@ -417,10 +457,8 @@ private:
 private:
     gfx::Size2DL maSize;
 
-    sal_Int32 mnBorderLeft;  // left page margin
-    sal_Int32 mnBorderUpper; // top page margin
-    sal_Int32 mnBorderRight; // right page margin
-    sal_Int32 mnBorderLower; // bottom page margin
+    Border maBorder;
+
     bool mbBackgroundFullSize = false; ///< Background object to represent the 
whole page.
 
     std::unique_ptr<SdrLayerAdmin> mpLayerAdmin;
@@ -496,25 +534,35 @@ public:
 
     gfx::Range2DL getInnerRectangle() const
     {
-        auto left = gfx::Length::hmm(mnBorderLeft);
-        auto upper = gfx::Length::hmm(mnBorderUpper);
-        auto right = gfx::Length::hmm(mnBorderRight);
-        auto lower = gfx::Length::hmm(mnBorderLower);
-
-        return gfx::Range2DL(left, upper, maSize.getWidth() - right, 
maSize.getHeight() - lower);
+        return gfx::Range2DL(maBorder.getLeft(), maBorder.getUpper(),
+                             maSize.getWidth() - maBorder.getRight(),
+                             maSize.getHeight() - maBorder.getLower());
     }
 
     virtual void SetOrientation(Orientation eOri);
     virtual Orientation GetOrientation() const;
-    virtual void  SetBorder(sal_Int32 nLft, sal_Int32 nUpp, sal_Int32 nRgt, 
sal_Int32 Lwr);
+
+    virtual Border const& getBorder() const
+    {
+        return maBorder;
+    }
+
+    virtual void setBorder(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;
+
+    gfx::Length getLeftBorder() const { return maBorder.getLeft(); }
+    gfx::Length getUpperBorder() const { return maBorder.getUpper(); }
+    gfx::Length getRightBorder() const { return maBorder.getRight(); }
+    gfx::Length getLowerBorder() const { return maBorder.getLower(); }
+
     void    SetBackgroundFullSize(bool bIn);
     bool    IsBackgroundFullSize() const;
 
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index 1aaed9622fa3..565996518874 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -444,8 +444,8 @@ void SdDrawDocument::AdaptPageSizeForAllPages(
                     this,
                     pPage,
                     pPage->GetSizeHmm(),
-                    pPage->GetLeftBorder(), pPage->GetRightBorder(),
-                    pPage->GetUpperBorder(), pPage->GetLowerBorder(),
+                    pPage->getLeftBorder().as_hmm(), 
pPage->getRightBorder().as_hmm(),
+                    pPage->getUpperBorder().as_hmm(), 
pPage->getLowerBorder().as_hmm(),
                     pPage->GetOrientation(),
                     pPage->GetPaperBin(),
                     pPage->IsBackgroundFullSize(),
@@ -499,8 +499,10 @@ void SdDrawDocument::AdaptPageSizeForAllPages(
                     this,
                     pPage,
                     pPage->GetSizeHmm(),
-                    pPage->GetLeftBorder(), pPage->GetRightBorder(),
-                    pPage->GetUpperBorder(), pPage->GetLowerBorder(),
+                    pPage->getLeftBorder().as_hmm(),
+                    pPage->getRightBorder().as_hmm(),
+                    pPage->getUpperBorder().as_hmm(),
+                    pPage->getLowerBorder().as_hmm(),
                     pPage->GetOrientation(),
                     pPage->GetPaperBin(),
                     pPage->IsBackgroundFullSize(),
diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx
index 83033715d2b4..c97952c239c2 100644
--- a/sd/source/core/drawdoc2.cxx
+++ b/sd/source/core/drawdoc2.cxx
@@ -512,7 +512,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const 
* pRefDocument /* =
     if( pRefPage )
     {
         pHandoutPage->setSize(pRefPage->getSize());
-        pHandoutPage->SetBorder( pRefPage->GetLeftBorder(), 
pRefPage->GetUpperBorder(), pRefPage->GetRightBorder(), 
pRefPage->GetLowerBorder() );
+        pHandoutPage->setBorder(pRefPage->getBorder());
     }
     else
     {
@@ -528,10 +528,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument 
const * pRefDocument /* =
     rtl::Reference<SdPage> pHandoutMPage = AllocSdPage(true);
     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 );
 
@@ -551,7 +548,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const 
* pRefDocument /* =
         if( pRefPage )
         {
             pPage->setSize(pRefPage->getSize());
-            pPage->SetBorder( pRefPage->GetLeftBorder(), 
pRefPage->GetUpperBorder(), pRefPage->GetRightBorder(), 
pRefPage->GetLowerBorder() );
+            pPage->setBorder(pRefPage->getBorder());
         }
         else if (meDocType == DocumentType::Draw)
         {
@@ -588,7 +585,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const 
* pRefDocument /* =
             // Impress: always use screen format, landscape.
             Size aSz( SvxPaperInfo::GetPaperSize(PAPER_SCREEN_16_9, 
MapUnit::Map100thMM) );
             pPage->setSize({ gfx::Length::hmm(aSz.Height()), 
gfx::Length::hmm(aSz.Width()) });
-            pPage->SetBorder(0, 0, 0, 0);
+            pPage->setBorder(Border());
         }
 
         InsertPage(pPage.get(), 1);
@@ -602,10 +599,7 @@ 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->setBorder(pPage->getBorder());
     InsertMasterPage(pMPage.get(), 1);
     pPage->TRG_SetMasterPage( *pMPage );
     if( bClipboard )
@@ -620,7 +614,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument const 
* pRefDocument /* =
     if( pRefPage )
     {
         pNotesPage->setSize(pRefPage->getSize());
-        pNotesPage->SetBorder( pRefPage->GetLeftBorder(), 
pRefPage->GetUpperBorder(), pRefPage->GetRightBorder(), 
pRefPage->GetLowerBorder() );
+        pNotesPage->setBorder(pRefPage->getBorder());
     }
     else
     {
@@ -645,10 +639,7 @@ void SdDrawDocument::CreateFirstPages( SdDrawDocument 
const * pRefDocument /* =
     rtl::Reference<SdPage> pNotesMPage = AllocSdPage(true);
     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 )
@@ -1094,10 +1085,7 @@ void SdDrawDocument::CheckMasterPages()
                 if( pRefNotesPage )
                 {
                     pNewNotesPage->setSize(pRefNotesPage->getSize());
-                    pNewNotesPage->SetBorder( pRefNotesPage->GetLeftBorder(),
-                                            pRefNotesPage->GetUpperBorder(),
-                                            pRefNotesPage->GetRightBorder(),
-                                            pRefNotesPage->GetLowerBorder() );
+                    pNewNotesPage->setBorder(pRefNotesPage->getBorder());
                 }
                 InsertMasterPage(pNewNotesPage.get(),  nPage );
                 pNewNotesPage->SetLayoutName( pPage->GetLayoutName() );
@@ -1164,10 +1152,7 @@ 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->setBorder(pPreviousStandardPage->getBorder());
 
     // Use master page of current page.
     
pStandardPage->TRG_SetMasterPage(pPreviousStandardPage->TRG_GetMasterPage());
@@ -1353,10 +1338,7 @@ void SdDrawDocument::SetupNewPage (
     if (pPreviousPage != nullptr)
     {
         pPage->setSize(pPreviousPage->getSize());
-        pPage->SetBorder( pPreviousPage->GetLeftBorder(),
-            pPreviousPage->GetUpperBorder(),
-            pPreviousPage->GetRightBorder(),
-            pPreviousPage->GetLowerBorder() );
+        pPage->setBorder(pPreviousPage->getBorder());
     }
     pPage->SetName(sPageName);
 
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index c7dd8a0cfa30..1a1ac33217ac 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -410,18 +410,12 @@ bool SdDrawDocument::InsertBookmarkAsPage(
     // Note that the pointers are used later on as general page pointers.
     SdPage* pRefPage = GetSdPage(0, PageKind::Standard);
     Size aSize = pRefPage->GetSizeHmm();
-    sal_Int32 nLeft  = pRefPage->GetLeftBorder();
-    sal_Int32 nRight = pRefPage->GetRightBorder();
-    sal_Int32 nUpper = pRefPage->GetUpperBorder();
-    sal_Int32 nLower = pRefPage->GetLowerBorder();
+    auto aBorder = pRefPage->getBorder();
     Orientation eOrient = pRefPage->GetOrientation();
 
     SdPage* pNPage = GetSdPage(0, PageKind::Notes);
     Size aNSize = pNPage->GetSizeHmm();
-    sal_Int32 nNLeft  = pNPage->GetLeftBorder();
-    sal_Int32 nNRight = pNPage->GetRightBorder();
-    sal_Int32 nNUpper = pNPage->GetUpperBorder();
-    sal_Int32 nNLower = pNPage->GetLowerBorder();
+    auto aNBorder = pNPage->getBorder();
     Orientation eNOrient = pNPage->GetOrientation();
 
     // Adapt page size and margins to those of the later pages?
@@ -448,10 +442,10 @@ bool SdDrawDocument::InsertBookmarkAsPage(
         SdPage* pBMPage = pBookmarkDoc->GetSdPage(0,PageKind::Standard);
 
         if (pBMPage->getSize() != pRefPage->getSize() ||
-            pBMPage->GetLeftBorder()   != pRefPage->GetLeftBorder()    ||
-            pBMPage->GetRightBorder()   != pRefPage->GetRightBorder()    ||
-            pBMPage->GetUpperBorder()   != pRefPage->GetUpperBorder()    ||
-            pBMPage->GetLowerBorder()   != pRefPage->GetLowerBorder())
+            pBMPage->getBorder().getLeft() != pRefPage->getBorder().getLeft() 
||
+            pBMPage->getBorder().getRight() != 
pRefPage->getBorder().getRight() ||
+            pBMPage->getBorder().getUpper() != 
pRefPage->getBorder().getUpper() ||
+            pBMPage->getBorder().getLower() != 
pRefPage->getBorder().getLower())
         {
             OUString aStr(SdResId(STR_SCALE_OBJECTS));
             std::unique_ptr<weld::MessageDialog> 
xQueryBox(Application::CreateMessageDialog(nullptr,
@@ -833,11 +827,13 @@ bool SdDrawDocument::InsertBookmarkAsPage(
 
             if (bScaleObjects)
             {
-                ::tools::Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
+                ::tools::Rectangle aBorderRect(
+                        aBorder.getLeft().as_hmm(), 
aBorder.getUpper().as_hmm(),
+                        aBorder.getRight().as_hmm(), 
aBorder.getLower().as_hmm());
                 pRefPage->ScaleObjects(aSize, aBorderRect, true);
             }
             pRefPage->setSize(gfx::length::fromSizeHmm(aSize));
-            pRefPage->SetBorder(nLeft, nUpper, nRight, nLower);
+            pRefPage->setBorder(aBorder);
             pRefPage->SetOrientation( eOrient );
 
             if( bRemoveEmptyPresObj )
@@ -852,12 +848,14 @@ bool SdDrawDocument::InsertBookmarkAsPage(
 
             if (bScaleObjects)
             {
-                ::tools::Rectangle aBorderRect(nNLeft, nNUpper, nNRight, 
nNLower);
+                ::tools::Rectangle aBorderRect(
+                        aNBorder.getLeft().as_hmm(), 
aNBorder.getUpper().as_hmm(),
+                        aNBorder.getRight().as_hmm(), 
aNBorder.getLower().as_hmm());
                 pRefPage->ScaleObjects(aNSize, aBorderRect, true);
             }
 
             pRefPage->setSize(gfx::length::fromSizeHmm(aNSize));
-            pRefPage->SetBorder(nNLeft, nNUpper, nNRight, nNLower);
+            pRefPage->setBorder(aNBorder);
             pRefPage->SetOrientation( eNOrient );
 
             if( bRemoveEmptyPresObj )
@@ -875,22 +873,27 @@ bool SdDrawDocument::InsertBookmarkAsPage(
             {
                 if (bScaleObjects)
                 {
-                    ::tools::Rectangle aBorderRect(nLeft, nUpper, nRight, 
nLower);
+                    ::tools::Rectangle aBorderRect(
+                        aBorder.getLeft().as_hmm(), 
aBorder.getUpper().as_hmm(),
+                        aBorder.getRight().as_hmm(), 
aBorder.getLower().as_hmm());
+
                     pRefPage->ScaleObjects(aSize, aBorderRect, true);
                 }
                 pRefPage->setSize(gfx::length::fromSizeHmm(aNSize));
-                pRefPage->SetBorder(nLeft, nUpper, nRight, nLower);
+                pRefPage->setBorder(aBorder);
                 pRefPage->SetOrientation( eOrient );
             }
             else        // Can only be notes
             {
                 if (bScaleObjects)
                 {
-                    ::tools::Rectangle aBorderRect(nNLeft, nNUpper, nNRight, 
nNLower);
+                    ::tools::Rectangle aBorderRect(
+                        aNBorder.getLeft().as_hmm(), 
aNBorder.getUpper().as_hmm(),
+                        aNBorder.getRight().as_hmm(), 
aNBorder.getLower().as_hmm());
                     pRefPage->ScaleObjects(aNSize, aBorderRect, true);
                 }
                 pRefPage->setSize(gfx::length::fromSizeHmm(aNSize));
-                pRefPage->SetBorder(nNLeft, nNUpper, nNRight, nNLower);
+                pRefPage->setBorder(aNBorder);
                 pRefPage->SetOrientation( eNOrient );
             }
 
@@ -1697,30 +1700,24 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 
nSdPageNum,
         if (pSourceDoc != this)
         {
             Size aSize = rOldMaster.GetSizeHmm();
-            ::tools::Rectangle aBorderRect(rOldMaster.GetLeftBorder(),
-                                  rOldMaster.GetUpperBorder(),
-                                  rOldMaster.GetRightBorder(),
-                                  rOldMaster.GetLowerBorder());
+            ::tools::Rectangle aBorderRect(rOldMaster.getLeftBorder().as_hmm(),
+                                  rOldMaster.getUpperBorder().as_hmm(),
+                                  rOldMaster.getRightBorder().as_hmm(),
+                                  rOldMaster.getLowerBorder().as_hmm());
             pMaster->ScaleObjects(aSize, aBorderRect, true);
             pMaster->setSize(rOldMaster.getSize());
-            pMaster->SetBorder(rOldMaster.GetLeftBorder(),
-                               rOldMaster.GetUpperBorder(),
-                               rOldMaster.GetRightBorder(),
-                               rOldMaster.GetLowerBorder());
+            pMaster->setBorder(rOldMaster.getBorder());
             pMaster->SetOrientation( rOldMaster.GetOrientation() );
             pMaster->SetAutoLayout(pMaster->GetAutoLayout());
 
             aSize = rOldNotesMaster.GetSizeHmm();
-            ::tools::Rectangle 
aNotesBorderRect(rOldNotesMaster.GetLeftBorder(),
-                                       rOldNotesMaster.GetUpperBorder(),
-                                       rOldNotesMaster.GetRightBorder(),
-                                       rOldNotesMaster.GetLowerBorder());
+            ::tools::Rectangle 
aNotesBorderRect(rOldNotesMaster.getLeftBorder().as_hmm(),
+                                       
rOldNotesMaster.getUpperBorder().as_hmm(),
+                                       
rOldNotesMaster.getRightBorder().as_hmm(),
+                                       
rOldNotesMaster.getLowerBorder().as_hmm());
             pNotesMaster->ScaleObjects(aSize, aNotesBorderRect, true);
             pNotesMaster->setSize(rOldNotesMaster.getSize());
-            pNotesMaster->SetBorder(rOldNotesMaster.GetLeftBorder(),
-                                    rOldNotesMaster.GetUpperBorder(),
-                                    rOldNotesMaster.GetRightBorder(),
-                                    rOldNotesMaster.GetLowerBorder());
+            pNotesMaster->setBorder(rOldNotesMaster.getBorder());
             pNotesMaster->SetOrientation( rOldNotesMaster.GetOrientation() );
             pNotesMaster->SetAutoLayout(pNotesMaster->GetAutoLayout());
 
@@ -1756,10 +1753,7 @@ void SdDrawDocument::SetMasterPage(sal_uInt16 nSdPageNum,
 
         pMaster = AllocSdPage(true);
         pMaster->setSize(pSelectedPage->getSize());
-        pMaster->SetBorder(pSelectedPage->GetLeftBorder(),
-                           pSelectedPage->GetUpperBorder(),
-                           pSelectedPage->GetRightBorder(),
-                           pSelectedPage->GetLowerBorder() );
+        pMaster->setBorder(pSelectedPage->getBorder());
         pMaster->SetName(aName);
         pMaster->SetLayoutName(aPageLayoutName);
         InsertMasterPage(pMaster.get());
@@ -1772,10 +1766,7 @@ 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->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 6c13ff2f6774..81e51556c46e 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -994,18 +994,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 );
+            Point aPosition(getBorder().getLeft().as_hmm(), 
getBorder().getUpper().as_hmm());
             Size aSize = GetSizeHmm();
-
-            aSize.AdjustWidth( -(nLftBorder + GetRightBorder()) );
-            aSize.AdjustHeight( -(nUppBorder + GetLowerBorder()) );
+            aSize.AdjustWidth(-basegfx::fround((getBorder().getLeft() + 
getBorder().getRight()).as_hmm()));
+            aSize.AdjustHeight(-basegfx::fround((getBorder().getUpper() + 
getBorder().getLower()).as_hmm()));
 
             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] ) );
 
@@ -1016,18 +1012,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
+            Point aPosition(getBorder().getLeft().as_hmm(), 
getBorder().getUpper().as_hmm());
             Size aPageSize = GetSizeHmm();
-            aPageSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
-            aPageSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
-
-            Point aPosition ( GetLeftBorder(), GetUpperBorder() );
+            aPageSize.AdjustWidth(-basegfx::fround((getBorder().getLeft() + 
getBorder().getRight()).as_hmm()));
+            aPageSize.AdjustHeight(-basegfx::fround((getBorder().getUpper() + 
getBorder().getLower()).as_hmm()));
 
             getPresObjProp( *this, sObjKind, sPageKind, propvalue);
             int NOTES_HEADER_FOOTER_WIDTH = ::tools::Long(aPageSize.Width() * 
propvalue[1]);
@@ -1086,10 +1081,11 @@ void SdPage::DestroyDefaultPresObj(PresObjKind eObjKind)
         /******************************************************************
         * standard- or note page: title area
         ******************************************************************/
-        Point aTitlePos ( GetLeftBorder(), GetUpperBorder() );
+        Point aTitlePos(getBorder().getLeft().as_hmm(), 
getBorder().getUpper().as_hmm());
         Size aTitleSize = GetSizeHmm();
-        aTitleSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
-        aTitleSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
+        aTitleSize.AdjustWidth(-basegfx::fround((getBorder().getLeft() + 
getBorder().getRight()).as_hmm()));
+        aTitleSize.AdjustHeight(-basegfx::fround((getBorder().getUpper() + 
getBorder().getLower()).as_hmm()));
+
         const char* sPageKind = PageKindVector[mePageKind];
 
         if (mePageKind == PageKind::Standard)
@@ -1169,10 +1165,10 @@ void SdPage::DestroyDefaultPresObj(PresObjKind eObjKind)
     {
         double propvalue[] = {0,0,0,0};
 
-        Point aLayoutPos( GetLeftBorder(), GetUpperBorder() );
+        Point aLayoutPos(getBorder().getLeft().as_hmm(), 
getBorder().getUpper().as_hmm());
         Size aLayoutSize = GetSizeHmm();
-        aLayoutSize.AdjustWidth( -(GetLeftBorder() + GetRightBorder()) );
-        aLayoutSize.AdjustHeight( -(GetUpperBorder() + GetLowerBorder()) );
+        aLayoutSize.AdjustWidth(-basegfx::fround((getBorder().getLeft() + 
getBorder().getRight()).as_hmm()));
+        aLayoutSize.AdjustHeight(-basegfx::fround((getBorder().getUpper() + 
getBorder().getLower()).as_hmm()));
         const char* sPageKind = PageKindVector[mePageKind];
 
         if (mePageKind == PageKind::Standard)
@@ -1755,18 +1751,18 @@ void SdPage::setSize(gfx::Size2DL const& rSize)
     }
 }
 
-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() )
+    if (gfx::Length::hmm(nLeft) != getBorder().getLeft() || 
gfx::Length::hmm(nUpper) != getBorder().getUpper() ||
+        gfx::Length::hmm(nRight) != getBorder().getRight() || 
gfx::Length::hmm(nLower) != getBorder().getLower())
     {
-        FmFormPage::SetBorder(nLft, nUpp, nRgt, nLwr);
+        FmFormPage::SetBorder(nLeft, nUpper, nRight, nLower);
     }
 }
 
 void SdPage::SetLeftBorder(sal_Int32 nBorder)
 {
-    if (nBorder != GetLeftBorder() )
+    if (gfx::Length::hmm(nBorder) != getBorder().getLeft())
     {
         FmFormPage::SetLeftBorder(nBorder);
     }
@@ -1774,7 +1770,7 @@ void SdPage::SetLeftBorder(sal_Int32 nBorder)
 
 void SdPage::SetRightBorder(sal_Int32 nBorder)
 {
-    if (nBorder != GetRightBorder() )
+    if (gfx::Length::hmm(nBorder) != getBorder().getRight())
     {
         FmFormPage::SetRightBorder(nBorder);
     }
@@ -1782,7 +1778,7 @@ void SdPage::SetRightBorder(sal_Int32 nBorder)
 
 void SdPage::SetUpperBorder(sal_Int32 nBorder)
 {
-    if (nBorder != GetUpperBorder() )
+    if (gfx::Length::hmm(nBorder) != getBorder().getUpper())
     {
         FmFormPage::SetUpperBorder(nBorder);
     }
@@ -1790,7 +1786,7 @@ void SdPage::SetUpperBorder(sal_Int32 nBorder)
 
 void SdPage::SetLowerBorder(sal_Int32 nBorder)
 {
-    if (nBorder != GetLowerBorder() )
+    if (gfx::Length::hmm(nBorder) != getBorder().getLower())
     {
         FmFormPage::SetLowerBorder(nBorder);
     }
@@ -1831,19 +1827,19 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, 
const ::tools::Rectangle& rN
     }
     if (nLeft < 0)
     {
-        nLeft = GetLeftBorder();
+        nLeft = getBorder().getLeft().as_hmm();
     }
     if (nRight < 0)
     {
-        nRight = GetRightBorder();
+        nRight = getBorder().getRight().as_hmm();
     }
     if (nUpper < 0)
     {
-        nUpper = GetUpperBorder();
+        nUpper = getBorder().getUpper().as_hmm();
     }
     if (nLower < 0)
     {
-        nLower = GetLowerBorder();
+        nLower = getBorder().getLower().as_hmm();
     }
 
     Size aBackgroundSize(aNewPageSize);
@@ -1855,8 +1851,8 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const 
::tools::Rectangle& rN
         aNewPageSize = aBackgroundSize;
     }
 
-    ::tools::Long nOldWidth  = GetSizeHmm().getWidth() - GetLeftBorder() - 
GetRightBorder();
-    ::tools::Long nOldHeight = GetSizeHmm().getHeight() - GetUpperBorder() - 
GetLowerBorder();
+    ::tools::Long nOldWidth  = (getSize().getWidth() - getBorder().getLeft() - 
getBorder().getRight()).as_hmm();
+    ::tools::Long nOldHeight = (getSize().getHeight() - getBorder().getUpper() 
- getBorder().getLower()).as_hmm();
 
     Fraction aFractX(aNewPageSize.Width(), nOldWidth);
     Fraction aFractY(aNewPageSize.Height(), nOldHeight);
@@ -2045,8 +2041,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().getLeft().as_hmm()) * static_cast<double>(aFractX)) + nLeft );
+                aNewPos.setY( ::tools::Long((aTopLeft.Y() - 
getBorder().getUpper().as_hmm()) * static_cast<double>(aFractY)) + nUpper );
 
                 Size aVec(aNewPos.X() - aTopLeft.X(), aNewPos.Y() - 
aTopLeft.Y());
 
@@ -2979,10 +2975,10 @@ void SdPage::CalculateHandoutAreas( SdDrawDocument& 
rModel, AutoLayout eLayout,
         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().getLeft().as_hmm();
+        ::tools::Long nRightBorder = 
rHandoutMaster.getBorder().getRight().as_hmm();
+        ::tools::Long nTopBorder = 
rHandoutMaster.getBorder().getUpper().as_hmm();
+        ::tools::Long nBottomBorder = 
rHandoutMaster.getBorder().getLower().as_hmm();
 
         const ::tools::Long nHeaderFooterHeight = static_cast< ::tools::Long 
>( (aArea.Height() - nTopBorder - nLeftBorder) * 0.05  );
 
diff --git a/sd/source/filter/grf/sdgrffilter.cxx 
b/sd/source/filter/grf/sdgrffilter.cxx
index fe17956ce027..7fd390edc844 100644
--- a/sd/source/filter/grf/sdgrffilter.cxx
+++ b/sd/source/filter/grf/sdgrffilter.cxx
@@ -162,8 +162,8 @@ bool SdGRFFilter::Import()
         Size        aGrfSize( OutputDevice::LogicToLogic( 
aGraphic.GetPrefSize(),
                                 aGraphic.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_hmm()));
+        aPagSize.AdjustHeight(-basegfx::fround((pPage->getBorder().getUpper() 
+ pPage->getBorder().getLower()).as_hmm()));
 
         // scale to fit page
         if ( ( ( aGrfSize.Height() > aPagSize.Height() ) || ( aGrfSize.Width() 
> aPagSize.Width() ) ) &&
@@ -186,8 +186,8 @@ bool SdGRFFilter::Import()
         }
 
         // 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().getLeft().as_hmm());
+        aPos.setY( ( ( aPagSize.Height() - aGrfSize.Height() ) / 2.0 ) + 
pPage->getBorder().getRight().as_hmm());
 
         pPage->InsertObject(
             new SdrGrafObj(
diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx
index fe5bfdb3fba5..39ebdf0afbc6 100644
--- a/sd/source/filter/html/htmlex.cxx
+++ b/sd/source/filter/html/htmlex.cxx
@@ -1671,11 +1671,11 @@ bool HtmlExport::CreateHtmlForPresPages()
                 Point     aLogPos(aRect.TopLeft());
                 bool      bIsSquare = aRect.GetWidth() == aRect.GetHeight();
 
-                sal_Int32 nPageWidth = pPage->GetSizeHmm().Width() - 
pPage->GetLeftBorder() - pPage->GetRightBorder();
+                sal_Int32 nPageWidth = 
basegfx::fround((pPage->getSize().getWidth() - pPage->getBorder().getLeft() - 
pPage->getBorder().getRight()).as_hmm());
 
                 // BoundRect is relative to the physical page origin, not the
                 // origin of ordinates
-                aRect.Move(-pPage->GetLeftBorder(), -pPage->GetUpperBorder());
+                aRect.Move(-pPage->getBorder().getLeft().as_hmm(), 
-pPage->getBorder().getUpper().as_hmm());
 
                 double fLogicToPixel = static_cast<double>(mnWidthPixel) / 
nPageWidth;
                 aRect.SetLeft( static_cast<tools::Long>(aRect.Left() * 
fLogicToPixel) );
@@ -1724,8 +1724,8 @@ bool HtmlExport::CreateHtmlForPresPages()
                                                  GetRectangle(false));
 
                                 // conversion into pixel coordinates
-                                aArea.Move(aLogPos.X() - 
pPage->GetLeftBorder(),
-                                           aLogPos.Y() - 
pPage->GetUpperBorder());
+                                aArea.Move(aLogPos.X() - 
pPage->getBorder().getLeft().as_hmm(),
+                                           aLogPos.Y() - 
pPage->getBorder().getUpper().as_hmm());
                                 aArea.SetLeft( 
static_cast<tools::Long>(aArea.Left() * fLogicToPixel) );
                                 aArea.SetTop( 
static_cast<tools::Long>(aArea.Top() * fLogicToPixel) );
                                 aArea.SetRight( 
static_cast<tools::Long>(aArea.Right() * fLogicToPixel) );
@@ -1739,8 +1739,8 @@ bool HtmlExport::CreateHtmlForPresPages()
                             {
                                 Point 
aCenter(static_cast<IMapCircleObject*>(pArea)->
                                                  GetCenter(false));
-                                aCenter += Point(aLogPos.X() - 
pPage->GetLeftBorder(),
-                                                 aLogPos.Y() - 
pPage->GetUpperBorder());
+                                aCenter += Point(aLogPos.X() - 
pPage->getBorder().getLeft().as_hmm(),
+                                                 aLogPos.Y() - 
pPage->getBorder().getUpper().as_hmm());
                                 aCenter.setX( 
static_cast<tools::Long>(aCenter.X() * fLogicToPixel) );
                                 aCenter.setY( 
static_cast<tools::Long>(aCenter.Y() * fLogicToPixel) );
 
@@ -1757,8 +1757,8 @@ bool HtmlExport::CreateHtmlForPresPages()
                             {
                                 tools::Polygon 
aArea(static_cast<IMapPolygonObject*>(pArea)->GetPolygon(false));
                                 
aStr.append(CreateHTMLPolygonArea(::basegfx::B2DPolyPolygon(aArea.getB2DPolygon()),
-                                                                  
Size(aLogPos.X() - pPage->GetLeftBorder(),
-                                                                       
aLogPos.Y() - pPage->GetUpperBorder()),
+                                                                  
Size(aLogPos.X() - pPage->getBorder().getLeft().as_hmm(),
+                                                                       
aLogPos.Y() - pPage->getBorder().getUpper().as_hmm()),
                                                                   
fLogicToPixel, aURL));
                             }
                             break;
@@ -1861,7 +1861,8 @@ bool HtmlExport::CreateHtmlForPresPages()
                                   pObject->GetObjIdentifier() == 
SdrObjKind::PolyLine ||
                                   pObject->GetObjIdentifier() == 
SdrObjKind::Polygon))
                         {
-                            
aStr.append(CreateHTMLPolygonArea(static_cast<SdrPathObj*>(pObject)->GetPathPoly(),
 Size(-pPage->GetLeftBorder(), -pPage->GetUpperBorder()), fLogicToPixel, 
aHRef));
+                            
aStr.append(CreateHTMLPolygonArea(static_cast<SdrPathObj*>(pObject)->GetPathPoly(),
+                                Size(-pPage->getBorder().getLeft().as_hmm(), 
-pPage->getBorder().getUpper().as_hmm()), fLogicToPixel, aHRef));
                         }
                         // something completely different: use the BoundRect
                         else
diff --git a/sd/source/ui/func/fuexpand.cxx b/sd/source/ui/func/fuexpand.cxx
index 45e430a266c7..8c9e69cba710 100644
--- a/sd/source/ui/func/fuexpand.cxx
+++ b/sd/source/ui/func/fuexpand.cxx
@@ -135,10 +135,7 @@ 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->setBorder(pActualPage->getBorder());
                 pPage->SetName(OUString());
 
                 // insert page after current page
@@ -157,10 +154,7 @@ 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->setBorder(pActualNotesPage->getBorder());
                 pNotesPage->SetPageKind(PageKind::Notes);
                 pNotesPage->SetName(OUString());
 
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index 542f2884a66e..c06f912fbb75 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -246,10 +246,14 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* 
pParent, const SfxRequest&
     SvxPaperBinItem aPaperBinItem( SID_ATTR_PAGE_PAPERBIN, 
static_cast<sal_uInt8>(mpPage->GetPaperBin()) );
     aNewAttr.Put( aPaperBinItem );
 
-    SvxLRSpaceItem aLRSpaceItem( 
static_cast<sal_uInt16>(mpPage->GetLeftBorder()), 
static_cast<sal_uInt16>(mpPage->GetRightBorder()), 0, 0, 
mpDoc->GetPool().GetWhich(SID_ATTR_LRSPACE));
+    SvxLRSpaceItem 
aLRSpaceItem(sal_uInt16(mpPage->getBorder().getLeft().as_hmm()),
+                                
sal_uInt16(mpPage->getBorder().getRight().as_hmm()),
+                                0, 0, 
mpDoc->GetPool().GetWhich(SID_ATTR_LRSPACE));
     aNewAttr.Put( aLRSpaceItem );
 
-    SvxULSpaceItem aULSpaceItem( 
static_cast<sal_uInt16>(mpPage->GetUpperBorder()), 
static_cast<sal_uInt16>(mpPage->GetLowerBorder()), 
mpDoc->GetPool().GetWhich(SID_ATTR_ULSPACE));
+    SvxULSpaceItem 
aULSpaceItem(sal_uInt16(mpPage->getBorder().getUpper().as_hmm()),
+                                
sal_uInt16(mpPage->getBorder().getLower().as_hmm()),
+                                mpDoc->GetPool().GetWhich(SID_ATTR_ULSPACE));
     aNewAttr.Put( aULSpaceItem );
 
     // Application
@@ -536,9 +540,11 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
         nLeft = static_cast<const SvxLRSpaceItem*>(pPoolItem)->GetLeft();
         nRight = static_cast<const SvxLRSpaceItem*>(pPoolItem)->GetRight();
 
-        if( mpPage->GetLeftBorder() != nLeft || mpPage->GetRightBorder() != 
nRight )
+        if (mpPage->getBorder().getLeft() != gfx::Length::hmm(nLeft)
+         || mpPage->getBorder().getRight() != gfx::Length::hmm(nRight))
+        {
             bSetPageSizeAndBorder = true;
-
+        }
     }
 
     if( pArgs->GetItemState(mpDoc->GetPool().GetWhich(SID_ATTR_ULSPACE),
@@ -547,8 +553,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().getUpper() != gfx::Length::hmm(nUpper)
+         || mpPage->getBorder().getLower() != gfx::Length::hmm(nLower))
+        {
             bSetPageSizeAndBorder = true;
+        }
     }
 
     if( pArgs->GetItemState(mpDoc->GetPool().GetWhich(SID_ATTR_PAGE_EXT1), 
true, &pPoolItem) == SfxItemState::SET )
@@ -595,14 +604,14 @@ void FuPage::ApplyItemSet( const SfxItemSet* pArgs )
     if (nLeft == -1 && nUpper != -1)
     {
         bSetPageSizeAndBorder = true;
-        nLeft  = mpPage->GetLeftBorder();
-        nRight = mpPage->GetRightBorder();
+        nLeft  = mpPage->getBorder().getLeft().as_hmm();
+        nRight = mpPage->getBorder().getRight().as_hmm();
     }
     else if (nLeft != -1 && nUpper == -1)
     {
         bSetPageSizeAndBorder = true;
-        nUpper = mpPage->GetUpperBorder();
-        nLower = mpPage->GetLowerBorder();
+        nUpper = mpPage->getBorder().getUpper().as_hmm();
+        nLower = mpPage->getBorder().getLower().as_hmm();
     }
 
     if( bSetPageSizeAndBorder || !mbMasterPage )
diff --git a/sd/source/ui/func/fusumry.cxx b/sd/source/ui/func/fusumry.cxx
index 8dff156f654e..aeea2505a0b9 100644
--- a/sd/source/ui/func/fusumry.cxx
+++ b/sd/source/ui/func/fusumry.cxx
@@ -120,10 +120,7 @@ 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->setBorder(pActualPage->getBorder());
 
                     // insert page at the back
                     mpDoc->InsertPage(pSummaryPage.get(), nCount * 2 + 1);
@@ -140,10 +137,7 @@ 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->setBorder(pActualNotesPage->getBorder());
                     pNotesPage->SetPageKind(PageKind::Notes);
 
                     // insert page at the back
diff --git a/sd/source/ui/sidebar/DocumentHelper.cxx 
b/sd/source/ui/sidebar/DocumentHelper.cxx
index c3188d9fc205..17aaeeeb38e0 100644
--- a/sd/source/ui/sidebar/DocumentHelper.cxx
+++ b/sd/source/ui/sidebar/DocumentHelper.cxx
@@ -363,11 +363,11 @@ SdPage* DocumentHelper::AddMasterPage (
         // the document.
         auto pPage = rTargetDocument.GetSdPage(0, pMasterPage->GetPageKind());
         Size aNewSize = pPage->GetSizeHmm();
-        ::tools::Rectangle aBorders (
-            pClonedMasterPage->GetLeftBorder(),
-            pClonedMasterPage->GetUpperBorder(),
-            pClonedMasterPage->GetRightBorder(),
-            pClonedMasterPage->GetLowerBorder());
+        ::tools::Rectangle aBorders(
+            pClonedMasterPage->getBorder().getLeft().as_hmm(),
+            pClonedMasterPage->getBorder().getUpper().as_hmm(),
+            pClonedMasterPage->getBorder().getRight().as_hmm(),
+            pClonedMasterPage->getBorder().getLower().as_hmm());
         pClonedMasterPage->ScaleObjects(aNewSize, aBorders, true);
         pClonedMasterPage->setSize(pPage->getSize());
         pClonedMasterPage->CreateTitleAndLayout(true);
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 2facbecd3272..d5e2432ccaf4 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -497,10 +497,7 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 
nPage, bool bDuplicate )
             pStandardPage = mpDoc->AllocSdPage(false);
 
         pStandardPage->setSize(pPreviousStandardPage->getSize());
-        pStandardPage->SetBorder( pPreviousStandardPage->GetLeftBorder(),
-                                    pPreviousStandardPage->GetUpperBorder(),
-                                    pPreviousStandardPage->GetRightBorder(),
-                                    pPreviousStandardPage->GetLowerBorder() );
+        pStandardPage->setBorder(pPreviousStandardPage->getBorder());
         pStandardPage->SetOrientation( pPreviousStandardPage->GetOrientation() 
);
         pStandardPage->SetName(OUString());
 
@@ -532,10 +529,7 @@ SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 
nPage, bool bDuplicate )
             pNotesPage = mpDoc->AllocSdPage(false);
 
         pNotesPage->setSize(pPreviousNotesPage->getSize());
-        pNotesPage->SetBorder( pPreviousNotesPage->GetLeftBorder(),
-                                pPreviousNotesPage->GetUpperBorder(),
-                                pPreviousNotesPage->GetRightBorder(),
-                                pPreviousNotesPage->GetLowerBorder() );
+        pNotesPage->setBorder(pPreviousNotesPage->getBorder());
         pNotesPage->SetOrientation( pPreviousNotesPage->GetOrientation() );
         pNotesPage->SetName(OUString());
         pNotesPage->SetPageKind(PageKind::Notes);
@@ -3209,10 +3203,7 @@ uno::Reference< drawing::XDrawPage > SAL_CALL 
SdMasterPagesAccess::insertNewByIn
         // 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->setBorder(pPage->getBorder());
         pMPage->SetLayoutName( aLayoutName );
         pDoc->InsertMasterPage(pMPage.get(),  
static_cast<sal_uInt16>(nInsertPos));
 
@@ -3227,10 +3218,7 @@ uno::Reference< drawing::XDrawPage > SAL_CALL 
SdMasterPagesAccess::insertNewByIn
         rtl::Reference<SdPage> pMNotesPage = mpModel->mpDoc->AllocSdPage(true);
         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 20f6843c314d..4db726afcb14 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -1001,16 +1001,16 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const 
OUString& PropertyName )
         aAny = getNavigationOrder();
         break;
     case WID_PAGE_LEFT:
-        aAny <<= GetPage()->GetLeftBorder();
+        aAny <<= basegfx::fround(GetPage()->getBorder().getLeft().as_hmm());
         break;
     case WID_PAGE_RIGHT:
-        aAny <<= GetPage()->GetRightBorder();
+        aAny <<= basegfx::fround(GetPage()->getBorder().getRight().as_hmm());
         break;
     case WID_PAGE_TOP:
-        aAny <<= GetPage()->GetUpperBorder();
+        aAny <<= basegfx::fround(GetPage()->getBorder().getUpper().as_hmm());
         break;
     case WID_PAGE_BOTTOM:
-        aAny <<= GetPage()->GetLowerBorder();
+        aAny <<= basegfx::fround(GetPage()->getBorder().getLower().as_hmm());
         break;
     case WID_PAGE_WIDTH:
         aAny <<= static_cast<sal_Int32>( GetPage()->GetSizeHmm().getWidth() );

... etc. - the rest is truncated

Reply via email to