editeng/source/outliner/outlin2.cxx  |    9 ----
 editeng/source/outliner/outliner.cxx |   25 +++++++----
 editeng/source/outliner/paralist.cxx |   12 -----
 include/editeng/outliner.hxx         |   73 ++++++++++++++++++++++++++++++-----
 4 files changed, 78 insertions(+), 41 deletions(-)

New commits:
commit 1b29a50b28a691535084f081162fefbd0fd2ed86
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Mon Jan 19 13:00:43 2026 +0900
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Wed Jan 21 08:47:18 2026 +0100

    sd: Fix different rendering when in view and edit when scaling
    
    If the text box is scaled and the scaling changes, we need to
    invalidate the bullet sizes, but we only do this when scaling
    is set from the outside. If the scaling adjustment is done
    internally we don't invalidate the bullet size, which results to
    different rendering.
    
    So instead of relying that the bullet size is invalidated at some
    point, we store the scaling factor with the bullet and recalculate
    it when it doesn't match with the current scaling factor.
    
    Change-Id: I116249f111bd8dd57ab38c4066d4ab51ae396f49
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197537
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/editeng/source/outliner/outlin2.cxx 
b/editeng/source/outliner/outlin2.cxx
index a53c11db8676..c2cbca480b16 100644
--- a/editeng/source/outliner/outlin2.cxx
+++ b/editeng/source/outliner/outlin2.cxx
@@ -479,15 +479,6 @@ const ScalingParameters & Outliner::getScalingParameters() 
const
 
 void Outliner::setScalingParameters(ScalingParameters const& 
rScalingParameters)
 {
-    // reset bullet size
-    sal_Int32 nParagraphs = pParaList->GetParagraphCount();
-    for ( sal_Int32 nPara = 0; nPara < nParagraphs; nPara++ )
-    {
-        Paragraph* pPara = pParaList->GetParagraph( nPara );
-        if ( pPara )
-            pPara->aBulSize.setWidth( -1 );
-    }
-
     pEditEngine->setScalingParameters(rScalingParameters);
 }
 
diff --git a/editeng/source/outliner/outliner.cxx 
b/editeng/source/outliner/outliner.cxx
index d86a259f0411..ea5e8b6067fd 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -677,7 +677,7 @@ void Outliner::ImplCheckNumBulletItem( sal_Int32 nPara )
 {
     Paragraph* pPara = pParaList->GetParagraph( nPara );
     if (pPara)
-        pPara->aBulSize.setWidth( -1 );
+        pPara->Invalidate();
 }
 
 void Outliner::ImplSetLevelDependentStyleSheet( sal_Int32 nPara )
@@ -995,7 +995,7 @@ void Outliner::StripBullet(
                 DrawBulletInfo aDrawBulletInfo(
                     *pFmt->GetBrush()->GetGraphicObject(),
                     aBulletPos,
-                    pPara->aBulSize);
+                    pPara->GetBulletSize());
                 rStripPortionsHelper.processDrawBulletInfo(aDrawBulletInfo);
             }
         }
@@ -1317,14 +1317,16 @@ Size Outliner::ImplGetBulletSize( sal_Int32 nPara )
     if (!pPara)
         return Size();
 
-    if( pPara->aBulSize.Width() == -1 )
+    auto aScalingParameters = getScalingParameters();
+    Size aSize;
+
+    if (pPara->IsBulletInvalid(aScalingParameters))
     {
         const SvxNumberFormat* pFmt = GetNumberFormat( nPara );
         assert(pFmt && "ImplGetBulletSize - no Bullet!");
-
         if ( pFmt->GetNumberingType() == SVX_NUM_NUMBER_NONE )
         {
-            pPara->aBulSize = Size( 0, 0 );
+            aSize = Size(0, 0);
         }
         else if( pFmt->GetNumberingType() != SVX_NUM_BITMAP )
         {
@@ -1333,19 +1335,22 @@ Size Outliner::ImplGetBulletSize( sal_Int32 nPara )
             vcl::Font aBulletFont( ImpCalcBulletFont( nPara ) );
             vcl::Font aRefFont( pRefDev->GetFont());
             pRefDev->SetFont( aBulletFont );
-            pPara->aBulSize.setWidth( pRefDev->GetTextWidth( aBulletText ) );
-            pPara->aBulSize.setHeight( pRefDev->GetTextHeight() );
+            tools::Long x = pRefDev->GetTextWidth(aBulletText);
+            tools::Long y = pRefDev->GetTextHeight();
+            aSize = Size(x, y);
             pRefDev->SetFont( aRefFont );
         }
         else
         {
-            pPara->aBulSize = 
OutputDevice::LogicToLogic(pFmt->GetGraphicSize(),
+            aSize = OutputDevice::LogicToLogic(pFmt->GetGraphicSize(),
                     MapMode(MapUnit::Map100thMM),
                     pEditEngine->GetRefDevice()->GetMapMode());
         }
+
+        pPara->SetBulletSize(aSize, aScalingParameters);
     }
 
-    return pPara->aBulSize;
+    return pPara->GetBulletSize();
 }
 
 void Outliner::ImplCheckParagraphs( sal_Int32 nStart, sal_Int32 nEnd )
@@ -1779,7 +1784,7 @@ void Outliner::SetFlatMode( bool bFlat )
     if( bFlat != pEditEngine->IsFlatMode() )
     {
         for ( sal_Int32 nPara = pParaList->GetParagraphCount(); nPara; )
-            pParaList->GetParagraph( --nPara )->aBulSize.setWidth( -1 );
+            pParaList->GetParagraph( --nPara )->Invalidate();
 
         pEditEngine->SetFlatMode( bFlat );
     }
diff --git a/editeng/source/outliner/paralist.cxx 
b/editeng/source/outliner/paralist.cxx
index d25a00b18207..d46fc8cf7d48 100644
--- a/editeng/source/outliner/paralist.cxx
+++ b/editeng/source/outliner/paralist.cxx
@@ -43,30 +43,18 @@ bool ParagraphData::operator==(const ParagraphData& 
rCandidate) const
 }
 
 Paragraph::Paragraph( sal_Int16 nDDepth )
-: aBulSize( -1, -1)
 {
-
     DBG_ASSERT(  ( nDDepth >= -1 ) && ( nDDepth < SVX_MAX_NUM ), 
"Paragraph-CTOR: nDepth invalid!" );
-
     nDepth = nDDepth;
-    nFlags = ParaFlag::NONE;
-    bVisible = true;
 }
 
 Paragraph::Paragraph( const ParagraphData& rData )
-: aBulSize( -1, -1)
-, nFlags( ParaFlag::NONE )
-, bVisible( true )
 {
     nDepth = rData.nDepth;
     mnNumberingStartValue = rData.mnNumberingStartValue;
     mbParaIsNumberingRestart = rData.mbParaIsNumberingRestart;
 }
 
-Paragraph::~Paragraph()
-{
-}
-
 void Paragraph::SetNumberingStartValue( sal_Int16 nNumberingStartValue )
 {
     mnNumberingStartValue = nNumberingStartValue;
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 274ac4f23c14..e2052f215e89 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -115,6 +115,15 @@ namespace o3tl
 #define OLUNDO_INSERT           EDITUNDO_USER+6
 // #define OLUNDO_MOVEPARAGRAPHS    EDITUNDO_USER+7
 
+/** Information about the bullet in the paragraph*/
+struct BulletInfo
+{
+public:
+    OUString maText;
+    Size maSize = Size(-1, -1);
+    ScalingParameters maScalingParameters;
+};
+
 class Paragraph : protected ParagraphData
 {
 private:
@@ -128,17 +137,61 @@ private:
 
     Paragraph& operator=(const Paragraph& rPara ) = delete;
 
-    OUString            aBulText;
-    Size                aBulSize;
-    ParaFlag            nFlags;
-    bool                bVisible;
+    BulletInfo maBullet;
+    ParaFlag nFlags = ParaFlag::NONE;
+    bool bVisible = true;
 
     bool                IsVisible() const { return bVisible; }
-    void                SetText( const OUString& rText ) { aBulText = rText; 
aBulSize.setWidth(-1); }
-    void                Invalidate() { aBulSize.setWidth(-1); }
-    void                SetDepth( sal_Int16 nNewDepth ) { nDepth = nNewDepth; 
aBulSize.setWidth(-1); }
-    const OUString&     GetText() const { return aBulText; }
 
+    void SetText(const OUString& rText)
+    {
+        maBullet.maText = rText;
+        Invalidate();
+    }
+
+    /// Sets the bullet size as well as the scaling parameters used to 
calculate the size
+    void SetBulletSize(Size const& rSize, ScalingParameters const& 
rScalingParameters)
+    {
+        maBullet.maSize = rSize;
+        maBullet.maScalingParameters = rScalingParameters;
+    }
+
+    /// Current size of the bullet
+    Size const& GetBulletSize()
+    {
+        return maBullet.maSize;
+    }
+
+    /// Is the bullet size invalid for the current scaling parameters
+    bool IsBulletInvalid(ScalingParameters const& rCurrentScalingParameters)
+    {
+        return rCurrentScalingParameters != maBullet.maScalingParameters
+            || maBullet.maSize.Width() == -1
+            || maBullet.maSize.Height() == -1;
+    }
+
+    /// Invalidate paragraph calculated information: bullet size
+    void Invalidate()
+    {
+        maBullet.maSize.setWidth(-1);
+        maBullet.maSize.setHeight(-1);
+    }
+
+    void SetDepth(sal_Int16 nNewDepth)
+    {
+        nDepth = nNewDepth;
+        Invalidate();
+    }
+
+    const OUString& GetText() const
+    {
+        return maBullet.maText;
+    }
+
+    BulletInfo const& GetBullet()
+    {
+        return maBullet;
+    }
                         Paragraph( sal_Int16 nDepth );
                         Paragraph( const Paragraph& ) = delete;
                         Paragraph( const ParagraphData& );
@@ -154,9 +207,9 @@ private:
     void                SetFlag( ParaFlag nFlag ) { nFlags |= nFlag; }
     void                RemoveFlag( ParaFlag nFlag ) { nFlags &= ~nFlag; }
     bool                HasFlag( ParaFlag nFlag ) const { return bool(nFlags & 
nFlag); }
+
 public:
-                        ~Paragraph();
-    void                dumpAsXml(xmlTextWriterPtr pWriter) const;
+    void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
 
 struct ParaRange

Reply via email to