editeng/inc/editdoc.hxx                     |   28 ++++
 editeng/source/editeng/editdoc.cxx          |    8 -
 editeng/source/editeng/editeng.cxx          |    4 
 editeng/source/editeng/editobj.cxx          |    6 
 editeng/source/editeng/editobj2.hxx         |   10 -
 editeng/source/editeng/impedit.hxx          |   30 ++--
 editeng/source/editeng/impedit2.cxx         |    4 
 editeng/source/editeng/impedit3.cxx         |  118 +++++++++----------
 editeng/source/editeng/impedit4.cxx         |    6 
 editeng/source/outliner/outlin2.cxx         |    7 -
 editeng/source/outliner/outliner.cxx        |   12 -
 include/editeng/editeng.hxx                 |    4 
 include/editeng/outliner.hxx                |    4 
 include/svl/solar.hrc                       |    2 
 include/svx/svdotext.hxx                    |    2 
 include/svx/unoshprp.hxx                    |    4 
 oox/source/export/drawingml.cxx             |    5 
 sd/qa/unit/export-tests-ooxml2.cxx          |    5 
 sd/source/ui/view/drtxtob.cxx               |    6 
 svx/source/svdraw/svdotext.cxx              |  171 ++++++++++++----------------
 svx/source/svdraw/svdotextdecomposition.cxx |    2 
 svx/source/unodraw/unoshape.cxx             |   26 ++++
 22 files changed, 246 insertions(+), 218 deletions(-)

New commits:
commit e87afb348cbb4e9e37cd3e6b1cca031a48f137ca
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Oct 31 13:28:27 2022 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Nov 3 15:39:27 2022 +0100

    fix rendering of text when "fit to frame" is enabled
    
    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).
    
    (cherry picked from commit 4c349be1d74c669e5804c3c43f3f0a3960c88bc5)
    
    Conflicts:
            editeng/source/editeng/impedit.hxx
            editeng/source/editeng/impedit4.cxx
            sd/qa/unit/import-tests2.cxx
            sd/source/ui/view/drtxtob.cxx
            svx/source/svdraw/svdotext.cxx
    
    Change-Id: Ic92d03043af0abe86f1b67ae15522d0176ebb

diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index 73d85a07b7ce..e8f57b80cd5e 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -2251,12 +2251,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 f93d4a6205ad..6d42ec021e5a 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -79,10 +79,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 41bbc5404e50..e817f68cc8a6 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -95,12 +95,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;
@@ -109,8 +109,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 bf6196953ea6..9c4159ec9796 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -470,8 +470,8 @@ private:
 
     Color               maBackgroundColor;
 
-    sal_uInt16          nStretchX;
-    sal_uInt16          nStretchY;
+    double mnStretchX;
+    double mnStretchY;
 
     CharCompressType    nAsianCompressionMode;
 
@@ -1007,8 +1007,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; }
 
@@ -1168,43 +1168,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<long>(nXValue)*nStretchX/100);
+    return basegfx::fround(double(nXValue) * mnStretchX / 100.0);
 }
 
 
 inline long ImpEditEngine::GetXValue( long nXValue ) const
 {
-    if ( !aStatus.DoStretch() || ( nStretchX == 100 ) )
+    if ( !aStatus.DoStretch() || ( mnStretchX == 100.0 ) )
         return nXValue;
 
-    return nXValue*nStretchX/100;
+    return basegfx::fround(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<long>(nYValue)*nStretchY/100);
+    return basegfx::fround(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<long>(nYValue)*nStretchY/100);
+    return basegfx::fround(double(nYValue) * mnStretchY / 100.0);
 }
 
 inline PointerStyle ImpEditView::GetPointer()
diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index eb9ef5eca2c3..2748cfcae9b6 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -95,8 +95,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 97edc586962d..63fc1516f153 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -962,8 +962,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                         // Search for Tab-Pos...
                         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 = basegfx::fround(double(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() );
@@ -2776,22 +2776,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 );
+                double fNewHeight = (double(aRealSz.Height()) * mnStretchY) / 
100.0;
+                aRealSz.setHeight(basegfx::fround(fNewHeight));
             }
-            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 );
+                    double fNewWidth = (double(aRealSz.Width()) * mnStretchX) 
/ 100.0;
+                    aRealSz.setWidth(basegfx::fround(fNewWidth));
 
                     // Also the Kerning: (long due to handle Interim results)
                     long nKerning = rFont.GetFixKerning();
@@ -2806,17 +2805,15 @@ 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 = basegfx::fround((double(nKerning) * 100.0) 
/ mnStretchX);
                     }
                     else if ( nKerning )
                     {
                         // Proportional
-                        nKerning *= nStretchX;
-                        nKerning /= 100;
+                        nKerning = basegfx::fround((double(nKerning) * 
mnStretchX) / 100.0);
                     }
                     rFont.SetFixKerning( static_cast<short>(nKerning) );
                 }
@@ -4250,20 +4247,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(false);
     if ( !IsVertical() )
     {
-        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 00a999a5abac..d850a880cc99 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1094,7 +1094,7 @@ std::unique_ptr<EditTextObject> 
ImpEditEngine::CreateTextObject( EditSelection a
     // sleeper set up when Olli paragraphs not hacked!
     if ( bAllowBigObjects && bOnlyFullParagraphs && IsFormatted() && 
GetUpdateMode() && ( nTextPortions >= nBigObjectStart ) )
     {
-        XParaPortionList* pXList = new XParaPortionList( GetRefDevice(), 
aPaperSize.Width(), nStretchX, nStretchY );
+        XParaPortionList* pXList = new XParaPortionList( GetRefDevice(), 
aPaperSize.Width(), mnStretchX, mnStretchY );
         
pTxtObj->mpImpl->SetPortionInfo(std::unique_ptr<XParaPortionList>(pXList));
         for ( nNode = nStartNode; nNode <= nEndNode; nNode++  )
         {
@@ -1179,8 +1179,8 @@ EditSelection ImpEditEngine::InsertTextObject( const 
EditTextObject& rTextObject
 
     if ( pPortionInfo && ( static_cast<long>(pPortionInfo->GetPaperWidth()) == 
aPaperSize.Width() )
             && ( pPortionInfo->GetRefMapMode() == GetRefDevice()->GetMapMode() 
)
-            && ( pPortionInfo->GetStretchX() == nStretchX )
-            && ( pPortionInfo->GetStretchY() == nStretchY ) )
+            && ( pPortionInfo->GetStretchX() == mnStretchX)
+            && ( pPortionInfo->GetStretchY() == mnStretchY))
     {
         if ( (pPortionInfo->GetRefDevPtr() == GetRefDevice()) ||
              (pPortionInfo->RefDevIsVirtual() && GetRefDevice()->IsVirtual()) )
diff --git a/editeng/source/outliner/outlin2.cxx 
b/editeng/source/outliner/outlin2.cxx
index ff3d1583a5f1..f7d983c3349f 100644
--- a/editeng/source/outliner/outlin2.cxx
+++ b/editeng/source/outliner/outlin2.cxx
@@ -477,9 +477,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++ )
@@ -492,9 +491,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 8cf7132c5a6b..6ad7c7c5e3d4 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -852,7 +852,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;
@@ -899,12 +899,12 @@ void Outliner::PaintBullet( sal_Int32 nPara, const Point& 
rStartPos,
     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()) );
+    long nStretchBulletX = basegfx::fround(double(aBulletArea.Left()) * 
nStretchX / 100.0);
+    long nStretchBulletWidth = basegfx::fround(double(aBulletArea.GetWidth()) 
* nStretchX / 100.0);
+    aBulletArea = tools::Rectangle(Point(nStretchBulletX, aBulletArea.Top()),
+                             Size(nStretchBulletWidth, 
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 292b620a9b95..ea454a63e588 100644
--- a/include/editeng/editeng.hxx
+++ b/include/editeng/editeng.hxx
@@ -407,8 +407,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 a048c4e06ac0..9603197cb3f1 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -910,8 +910,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 d010706ab7da..7f1e0bb003dd 100644
--- a/sd/source/ui/view/drtxtob.cxx
+++ b/sd/source/ui/view/drtxtob.cxx
@@ -165,8 +165,8 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet )
             case SID_ATTR_CHAR_STRIKEOUT:
             case SID_ATTR_CHAR_CASEMAP:
             {
-                sal_uInt16 stretchX = 100;
-                sal_uInt16 stretchY = 100;
+                double stretchX = 100;
+                double stretchY = 100;
                 SvxScriptSetItem aSetItem( nSlotId, GetPool() );
                 aSetItem.GetItemSet().Put( aAttrSet, false );
 
@@ -188,7 +188,7 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet )
                     }
 
                     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 5d9cefe2dcd3..21ae05d4abbe 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -866,56 +866,88 @@ void SdrTextObj::ImpSetCharStretching(SdrOutliner& 
rOutliner, const Size& rTextS
     long nXTolMi=nWantWdt/25;  // tolerance: -4%
     long nXCorr =nWantWdt/20;  // correction scale: 5%
 
-    long nX=(nWantWdt*100) /nIsWdt; // calculate X stretching
-    long nY=(nWantHgt*100) /nIsHgt; // calculate Y stretching
+    double nX = (nWantWdt * 100) / double(nIsWdt); // calculate X stretching
+    double nY = (nWantHgt * 100) / 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)
         {
             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());
-        long nXDiff=aSiz.Width()-nWantWdt;
+        long nXDiff = aSiz.Width() - nWantWdt;
         rFitXCorrection=Fraction(nWantWdt,aSiz.Width());
         if (((nXDiff>=nXTolMi || !bChkX) && nXDiff<=nXTolPl) || 
nXDiff==nXDiff0) {
             bNoMoreLoop = true;
         } else {
             // correct stretching factors
-            long nMul=nWantWdt;
-            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
+            long nMul = nWantWdt;
+            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 * double(nMul) / double(nDiv);
+            if (bNoStretching)
+                nY = nX;
         }
-        nXDiff0=nXDiff;
+        nXDiff0 = nXDiff;
     }
 }
 
@@ -1131,7 +1163,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);
@@ -1195,8 +1227,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;
 }
 
@@ -1215,13 +1247,14 @@ 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)
     {
         const Size aCurrTextSize = rOutliner.CalcTextSizeNTP();
-        double fFactor(1.0);
+        double fFactor = 1.0;
         if( bIsVerticalWriting )
         {
             if (aCurrTextSize.Width() != 0)
@@ -1240,15 +1273,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;
@@ -1257,17 +1290,16 @@ 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);
         }
     }
 
     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 8769b16b8ddc..63804b4fd1d1 100644
--- a/svx/source/svdraw/svdotextdecomposition.cxx
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -1173,7 +1173,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 a80c403f6b1bdbfab4c965bfbcf52fbd20d2c204
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sun Jun 6 21:50:53 2021 +0300
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Nov 3 15:13:00 2022 +0100

    Fix and unify the two methods that get scaled text size
    
    GetTextFitToSizeScale and SdrTextObj::GetFontScaleY both didn't
    initialize outliners properly, and thus returned wrong results.
    
    (cherry picked from commit a1ae30166e92a0a40dff06740f0bb8e9ee63f70a)
    
    Change-Id: I6fe63c51ed838a0d0fafdfa03597cac97ce29831

diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index 6f1804bb1757..7f51b7ec23ec 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -389,7 +389,7 @@ public:
     // FitToSize and Fontwork are not taken into account in GetTextSize()!
     virtual const Size& GetTextSize() const;
     void FitFrameToTextSize();
-    double GetFontScaleY() const;
+    sal_uInt16 GetFontScaleY() const;
 
     // Simultaneously sets the text into the Outliner (possibly
     // the one of the EditOutliner) and sets the PaperSize.
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 14910f759598..bb46d31369ca 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2959,10 +2959,7 @@ void DrawingML::WriteText( const Reference< XInterface 
>& rXIface, const OUStrin
                 {
                     SdrTextObj* pTextObject = 
dynamic_cast<SdrTextObj*>(pTextShape->GetSdrObject());
                     if (pTextObject)
-                    {
-                        double fScaleY = pTextObject->GetFontScaleY();
-                        nFontScale = static_cast<sal_uInt32>(fScaleY * 100) * 
1000;
-                    }
+                        nFontScale = pTextObject->GetFontScaleY() * 1000;
                 }
 
                 mpFS->singleElementNS(XML_a, XML_normAutofit, XML_fontScale,
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index c6d2f48aedde..a12d76573e22 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -1774,10 +1774,9 @@ void SdOOXMLExportTest2::testFontScale()
     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, 
"ppt/slides/slide1.xml");
 
-    // Rounding errors possible, approximate value
+    // Rounding errors possible, approximate value (+/- 1%)
     OUString sScale = getXPath(pXmlDocContent, 
"/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:bodyPr/a:normAutofit", "fontScale");
-    if (sScale != "73000" && sScale != "72000" && sScale != "74000")
-        CPPUNIT_ASSERT_EQUAL(OUString("73000"), sScale);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(76000), sScale.toInt32(), 1000);
 
     xDocShRef->DoClose();
 }
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index e43fdedae0cf..5d9cefe2dcd3 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -51,6 +51,7 @@
 #include <vcl/virdev.hxx>
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <sal/log.hxx>
+#include <o3tl/temporary.hxx>
 
 using namespace com::sun::star;
 
@@ -1188,67 +1189,15 @@ void SdrTextObj::ImpSetupDrawOutlinerForPaint( bool     
        bContourFrame,
     }
 }
 
-double SdrTextObj::GetFontScaleY() const
+sal_uInt16 SdrTextObj::GetFontScaleY() const
 {
-    SdrText* pText = getActiveText();
-    if (pText == nullptr || !pText->GetOutlinerParaObject())
-        return 1.0;
-
     SdrOutliner& rOutliner = ImpGetDrawOutliner();
-    const Size aShapeSize = GetSnapRect().GetSize();
-    const Size aSize(aShapeSize.Width() - GetTextLeftDistance() - 
GetTextRightDistance(),
-        aShapeSize.Height() - GetTextUpperDistance() - GetTextLowerDistance());
-
-    rOutliner.SetPaperSize(aSize);
-    rOutliner.SetUpdateMode(true);
-    rOutliner.SetText(*pText->GetOutlinerParaObject());
-    bool bIsVerticalWriting = IsVerticalWriting();
-
-    // Algorithm from SdrTextObj::ImpAutoFitText
-
-    sal_uInt16 nMinStretchX = 0, nMinStretchY = 0;
-    sal_uInt16 nCurrStretchX = 100, nCurrStretchY = 100;
-    sal_uInt16 aOldStretchXVals[] = { 0,0,0 };
-    const size_t aStretchArySize = SAL_N_ELEMENTS(aOldStretchXVals);
-    for (unsigned int i = 0; i<aStretchArySize; ++i)
-    {
-        const Size aCurrTextSize = rOutliner.CalcTextSizeNTP();
-        double fFactor(1.0);
-        if (bIsVerticalWriting)
-        {
-            if (aCurrTextSize.Width() != 0)
-            {
-                fFactor = double(aSize.Width()) / aCurrTextSize.Width();
-            }
-        }
-        else if (aCurrTextSize.Height() != 0)
-        {
-            fFactor = double(aSize.Height()) / aCurrTextSize.Height();
-        }
-        fFactor = std::sqrt(fFactor);
-
-        rOutliner.GetGlobalCharStretching(nCurrStretchX, nCurrStretchY);
-
-        if (fFactor >= 1.0)
-        {
-            nMinStretchX = std::max(nMinStretchX, nCurrStretchX);
-            nMinStretchY = std::max(nMinStretchY, nCurrStretchY);
-        }
-
-        aOldStretchXVals[i] = nCurrStretchX;
-        if (std::find(aOldStretchXVals, aOldStretchXVals + i, nCurrStretchX) 
!= aOldStretchXVals + i)
-            break; // same value already attained once; algo is looping, exit
-
-        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));
-        }
-    }
+    // This eventually calls ImpAutoFitText
+    UpdateOutlinerFormatting(rOutliner, o3tl::temporary(tools::Rectangle()));
 
-    return std::min(sal_uInt16(100), nCurrStretchY) / 100.0;
+    sal_uInt16 nStretchY;
+    rOutliner.GetGlobalCharStretching(o3tl::temporary(sal_uInt16()), 
nStretchY);
+    return nStretchY;
 }
 
 void SdrTextObj::ImpAutoFitText( SdrOutliner& rOutliner ) const
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 7802e5dde0fa..0dee49b099fe 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -184,14 +184,7 @@ sal_Int16 GetTextFitToSizeScale(SdrObject* pObject)
         return 0;
     }
 
-    std::unique_ptr<SdrOutliner> pOutliner
-        = 
pTextObj->getSdrModelFromSdrObject().createOutliner(OutlinerMode::TextObject);
-    tools::Rectangle aBoundRect(pTextObj->GetCurrentBoundRect());
-    pTextObj->SetupOutlinerFormatting(*pOutliner, aBoundRect);
-    sal_uInt16 nX = 0;
-    sal_uInt16 nY = 0;
-    pOutliner->GetGlobalCharStretching(nX, nY);
-    return nY;
+    return pTextObj->GetFontScaleY();
 }
 }
 
commit cf08e56ce97259e65109db88f5511b20c2b5897a
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Sep 8 17:26:12 2020 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Nov 3 14:32:10 2022 +0100

    svx UNO API for shapes: expose what scaling factor is used for autofit 
scaling
    
    TextFitToSizeScale is 0 when the shape has no text or autofit is not
    enabled, 100 when there is autofit (but no scale-down), a value between
    the two otherwise.
    
    Towards allowing both "autofit" and "same font size for these shapes" at
    the same time for SmartArt purposes.
    
    (cherry picked from commit cd268f0047443ddbb22361cdc15093e881f83588)
    
    Conflicts:
            include/svx/unoshprp.hxx
            svx/source/unodraw/unoshape.cxx
    
    Change-Id: Iff88fcc4c2e67b543687b1d87d614622cbf2e38a

diff --git a/include/svl/solar.hrc b/include/svl/solar.hrc
index 6b4cb07bbc33..317d45a84bc1 100644
--- a/include/svl/solar.hrc
+++ b/include/svl/solar.hrc
@@ -23,7 +23,7 @@
 // defines ------------------------------------------------------------------
 
 #define OWN_ATTR_VALUE_START                    3900
-#define OWN_ATTR_VALUE_END                      4004
+#define OWN_ATTR_VALUE_END                      4005
 
 #define RID_LIB_START               10000
 #define RID_LIB_END                 19999
diff --git a/include/svx/unoshprp.hxx b/include/svx/unoshprp.hxx
index 9aa2ecb16dae..8051634c3e42 100644
--- a/include/svx/unoshprp.hxx
+++ b/include/svx/unoshprp.hxx
@@ -192,7 +192,8 @@
 #define OWN_ATTR_SIGNATURELINE_UNSIGNED_IMAGE   (OWN_ATTR_VALUE_START+102)
 #define OWN_ATTR_SIGNATURELINE_IS_SIGNED        (OWN_ATTR_VALUE_START+103)
 #define OWN_ATTR_QRCODE                         (OWN_ATTR_VALUE_START+104)
-// ATTENTION: maximum is OWN_ATTR_VALUE_START+104 svx, see 
include/svl/solar.hrc
+#define OWN_ATTR_TEXTFITTOSIZESCALE             (OWN_ATTR_VALUE_START+105)
+// ATTENTION: maximum is OWN_ATTR_VALUE_START+105 svx, see 
include/svl/solar.hrc
 
 // #FontWork#
 #define FONTWORK_PROPERTIES \
@@ -348,6 +349,7 @@
     { OUString(UNO_NAME_MISC_OBJ_SIZEPROTECT),  SDRATTR_OBJSIZEPROTECT         
 , cppu::UnoType<bool>::get(),                      0,  0},\
     { OUString("UINameSingular"),               OWN_ATTR_UINAME_SINGULAR       
 , ::cppu::UnoType<OUString>::get(),    
css::beans::PropertyAttribute::READONLY,   0}, \
     { OUString("UINamePlural"),                 OWN_ATTR_UINAME_PLURAL         
 , ::cppu::UnoType<OUString>::get(),    
css::beans::PropertyAttribute::READONLY,   0}, \
+    { OUString("TextFitToSizeScale"), OWN_ATTR_TEXTFITTOSIZESCALE, 
::cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::READONLY, 0}, 
\
     /* #i68101# */ \
     { OUString(UNO_NAME_MISC_OBJ_TITLE),        OWN_ATTR_MISC_OBJ_TITLE        
 , ::cppu::UnoType<OUString>::get(),    0,  0}, \
     { OUString(UNO_NAME_MISC_OBJ_DESCRIPTION),  OWN_ATTR_MISC_OBJ_DESCRIPTION  
 , ::cppu::UnoType<OUString>::get(),    0,  0},
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 2bab0013c112..7802e5dde0fa 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -83,6 +83,8 @@
 #include <vcl/gdimtf.hxx>
 #include <vcl/wmf.hxx>
 #include <svx/svdopath.hxx>
+#include <svx/sdtfsitm.hxx>
+#include <svx/svdoutl.hxx>
 
 #include <memory>
 #include <vector>
@@ -166,6 +168,31 @@ protected:
     }
 };
 
+/// Calculates what scaling factor will be used for autofit text scaling of 
this shape.
+sal_Int16 GetTextFitToSizeScale(SdrObject* pObject)
+{
+    SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObject);
+    if (!pTextObj)
+    {
+        return 0;
+    }
+
+    const SfxItemSet& rTextObjSet = pTextObj->GetMergedItemSet();
+    if 
(rTextObjSet.GetItem<SdrTextFitToSizeTypeItem>(SDRATTR_TEXT_FITTOSIZE)->GetValue()
+        != drawing::TextFitToSizeType_AUTOFIT)
+    {
+        return 0;
+    }
+
+    std::unique_ptr<SdrOutliner> pOutliner
+        = 
pTextObj->getSdrModelFromSdrObject().createOutliner(OutlinerMode::TextObject);
+    tools::Rectangle aBoundRect(pTextObj->GetCurrentBoundRect());
+    pTextObj->SetupOutlinerFormatting(*pOutliner, aBoundRect);
+    sal_uInt16 nX = 0;
+    sal_uInt16 nY = 0;
+    pOutliner->GetGlobalCharStretching(nX, nY);
+    return nY;
+}
 }
 
 SvxShape::SvxShape( SdrObject* pObject )
@@ -2848,6 +2875,12 @@ bool SvxShape::getPropertyValueImpl( const OUString&, 
const SfxItemPropertySimpl
         break;
     }
 
+    case OWN_ATTR_TEXTFITTOSIZESCALE:
+    {
+        rValue <<= GetTextFitToSizeScale(GetSdrObject());
+        break;
+    }
+
     case OWN_ATTR_UINAME_PLURAL:
     {
         rValue <<= GetSdrObject()->TakeObjNamePlural();
commit 7c893371a5311b685173611b9b14348d8085d520
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Tue Oct 18 21:20:47 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Nov 3 14:08:56 2022 +0100

    editeng: rename pBuf to pCharPositionArray
    
    (cherry picked from commit 8ec62a84c84d818d01cd3e6dcb874e1a801512c7)
    
    Conflicts:
            editeng/source/editeng/impedit3.cxx
    
    Change-Id: Ie7614ee9eefe1160f6d1e6105cc5bf7b92a35cc4

diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 9a680f723de4..97edc586962d 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -749,7 +749,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
 
     ImplInitLayoutMode( GetRefDevice(), nPara, nIndex );
 
-    std::unique_ptr<long[]> pBuf(new long[ pNode->Len() ]);
+    std::unique_ptr<long[]> pCharPositionArray(new long[ pNode->Len() ]);
 
     bool bSameLineAgain = false;    // For TextRanger, if the height changes.
     TabInfo aCurrentTab;
@@ -1146,7 +1146,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                 if (bContinueLastPortion)
                 {
                      Size aSize( aTmpFont.QuickGetTextSize( GetRefDevice(),
-                            pParaPortion->GetNode()->GetString(), nTmpPos, 
nPortionLen, pBuf.get() ));
+                            pParaPortion->GetNode()->GetString(), nTmpPos, 
nPortionLen, pCharPositionArray.get() ));
                      pPortion->adjustSize(aSize.Width(), 0);
                      if (pPortion->GetSize().Height() < aSize.Height())
                          pPortion->setHeight(aSize.Height());
@@ -1154,7 +1154,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                 else
                 {
                     auto aSize = aTmpFont.QuickGetTextSize( GetRefDevice(),
-                            pParaPortion->GetNode()->GetString(), nTmpPos, 
nPortionLen, pBuf.get() );
+                            pParaPortion->GetNode()->GetString(), nTmpPos, 
nPortionLen, pCharPositionArray.get() );
                     pPortion->SetSize(aSize);
                 }
 
@@ -1169,7 +1169,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, pBuf.get(), pBuf.get() + 
nPortionLen);
+                rArray.insert( rArray.begin() + nPos, 
pCharPositionArray.get(), pCharPositionArray.get() + nPortionLen);
 
                 // And now check for Compression:
                 if ( !bContinueLastPortion && nPortionLen && 
GetAsianCompressionMode() != CharCompressType::NONE )
@@ -1652,7 +1652,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
     if ( bLineBreak )
         CreateAndInsertEmptyLine( pParaPortion );
 
-    pBuf.reset();
+    pCharPositionArray.reset();
 
     bool bHeightChanged = FinishCreateLines( pParaPortion );
 
commit a4b57d68bb3db7a4723c72d5979d995ca7a6fd55
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Tue Oct 18 21:14:41 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Nov 3 14:06:38 2022 +0100

    editeng: don't use GetSize to set the size
    
    (cherry picked from commit 190cd40e01bd36e99b265ef5da36a382199f18b9)
    
    Conflicts:
            editeng/source/editeng/impedit3.cxx
    
    Change-Id: I80a2701d7c125dbe6c80f8c32b125c7b176a8bb4

diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 2d6acc42f8d5..c46af2e1751f 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -408,7 +408,29 @@ public:
     sal_Int32      GetLen() const              { return nLen; }
     void           SetLen( sal_Int32 nL )         { nLen = nL; }
 
-    Size&          GetSize()                   { return aOutSz; }
+    void setWidth(long nWidth)
+    {
+        aOutSz.setWidth(nWidth);
+    }
+
+    void setHeight(long nHeight)
+    {
+        aOutSz.setHeight(nHeight);
+    }
+
+    void adjustSize(long nDeltaX, 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 0d00c5197184..9a680f723de4 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -928,7 +928,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);
                 }
 
                 DBG_ASSERT( nTmpPortion < 
pParaPortion->GetTextPortions().Count(), "No more Portions left!" );
@@ -991,11 +991,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( 
aTmpFont.QuickGetTextSize( GetRefDevice(), OUString(), 0, 0 ).Height() );
+                        pPortion->setHeight( aTmpFont.QuickGetTextSize( 
GetRefDevice(), OUString(), 0, 0 ).Height() );
 
                         DBG_ASSERT( pPortion->GetSize().Width() >= 0, "Tab 
incorrectly calculated!" );
 
@@ -1007,7 +1007,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;
@@ -1021,7 +1021,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                     case EE_FEATURE_LINEBR:
                     {
                         DBG_ASSERT( pPortion, "?!" );
-                        pPortion->GetSize().setWidth( 0 );
+                        pPortion->setWidth( 0 );
                         bEOL = true;
                         bLineBreak = true;
                         pPortion->SetKind( PortionKind::LINEBREAK );
@@ -1041,7 +1041,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                         // get size, but also DXArray to allow length 
information in line breaking below
                         const sal_Int32 nLength(aFieldValue.getLength());
                         std::unique_ptr<long[]> pTmpDXArray(new long[nLength]);
-                        pPortion->GetSize() = 
aTmpFont.QuickGetTextSize(GetRefDevice(), aFieldValue, 0, 
aFieldValue.getLength(), pTmpDXArray.get());
+                        
pPortion->SetSize(aTmpFont.QuickGetTextSize(GetRefDevice(), aFieldValue, 0, 
aFieldValue.getLength(), pTmpDXArray.get()));
 
                         // So no scrolling for oversized fields
                         if ( pPortion->GetSize().Width() > nXWidth )
@@ -1147,21 +1147,24 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                 {
                      Size aSize( aTmpFont.QuickGetTextSize( GetRefDevice(),
                             pParaPortion->GetNode()->GetString(), nTmpPos, 
nPortionLen, pBuf.get() ));
-                     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(),
+                    auto aSize = aTmpFont.QuickGetTextSize( GetRefDevice(),
                             pParaPortion->GetNode()->GetString(), nTmpPos, 
nPortionLen, pBuf.get() );
+                    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();
@@ -1192,7 +1195,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
                     {
                         long nExtraSpace = pPortion->GetSize().Height()/5;
                         nExtraSpace = GetXValue( nExtraSpace );
-                        pPortion->GetSize().AdjustWidth(nExtraSpace );
+                        pPortion->adjustSize(nExtraSpace, 0);
                         nTmpWidth += nExtraSpace;
                     }
                 }
@@ -1237,7 +1240,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;
             }
 
@@ -1486,7 +1489,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
             sal_Int32 nPosInArray = pLine->GetEnd()-1-pLine->GetStart();
             long nNewValue = ( nPosInArray ? pLine->GetCharPosArray()[ 
nPosInArray-1 ] : 0 ) + n;
             pLine->GetCharPosArray()[ nPosInArray ] = nNewValue;
-            rTP.GetSize().AdjustWidth(n );
+            rTP.adjustSize(n, 0);
         }
 
         pLine->SetTextWidth( aTextSize.Width() );
@@ -1702,9 +1705,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 );
@@ -2040,7 +2043,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 );
         pLine->GetCharPosArray()[ nPosInArray ] = rTP.GetSize().Width();
     }
     else if ( bHyphenated )
@@ -2057,7 +2060,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 ] );
         }
 
@@ -2065,8 +2068,8 @@ 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( 
aHyphText ) );
+        pHyphPortion->setHeight( GetRefDevice()->GetTextHeight() );
+        pHyphPortion->setWidth( GetRefDevice()->GetTextWidth( aHyphText ) );
 
         pParaPortion->GetTextPortions().Insert(++nEndPortion, pHyphPortion);
     }
@@ -2147,7 +2150,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;
@@ -2171,9 +2174,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
             // Even for kashidas just change positions, VCL will then draw the 
kashida automatically
@@ -2354,7 +2359,7 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* 
pPortion, sal_Int32 nPos
     {
         // No new GetTextSize, instead use values from the Array:
         DBG_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 )
         {
@@ -2371,7 +2376,7 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* 
pPortion, sal_Int32 nPos
         }
     }
     else
-        pTextPortion->GetSize().setWidth( -1 );
+        pTextPortion->setWidth(-1);
 
     return nSplitPortion;
 }
@@ -2510,7 +2515,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
@@ -2576,7 +2581,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 );
             }
@@ -4565,7 +4570,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 
) )
         {
@@ -4575,7 +4580,7 @@ bool ImpEditEngine::ImplCalcAsianCompression(ContentNode* 
pNode,
             nShrink /= 10000;
             long nNewWidth = pTextPortion->GetExtraInfos()->nOrgWidth - 
nShrink;
             if ( nNewWidth < pTextPortion->GetSize().Width() )
-                pTextPortion->GetSize().setWidth( nNewWidth );
+                pTextPortion->setWidth(nNewWidth);
         }
     }
     return bCompressed;
@@ -4617,7 +4622,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 06b5c5e58ae200591bc78a51c5373740a20f51f9
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Tue Oct 18 21:06:55 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Nov 3 13:49:52 2022 +0100

    editeng: prefix the instance variable aDefFont-> maDefFont
    
    (cherry picked from commit 9f02ccb4b4fa891e9e74e320d9ca0da40b1a626a)
    
    Conflicts:
            editeng/source/editeng/editdoc.cxx
    
    Change-Id: Ie9d18c19792962159e4e2ff4ddf91560323e42e6

diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 2a5fc1e3f8de..2d6acc42f8d5 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -723,7 +723,7 @@ private:
     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;
@@ -751,7 +751,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 fbcb4c51ed41..63b8cb0d3341 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -2037,14 +2037,14 @@ void CreateFont( SvxFont& rFont, const SfxItemSet& 
rSet, bool bSearchInParent, S
 void EditDoc::CreateDefFont( bool bUseStyles )
 {
     SfxItemSet aTmpSet( GetItemPool(), svl::Items<EE_PARA_START, 
EE_CHAR_END>{} );
-    CreateFont( aDefFont, aTmpSet );
-    aDefFont.SetVertical( IsVertical() );
-    aDefFont.SetOrientation( IsVertical() ? (IsTopToBottom() ? 2700 : 900) : 0 
);
+    CreateFont( maDefFont, aTmpSet );
+    maDefFont.SetVertical( IsVertical() );
+    maDefFont.SetOrientation( IsVertical() ? (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();
     }

Reply via email to