sw/source/core/text/itrpaint.cxx |   90 ++++++++++++++++++++++++---------------
 1 file changed, 56 insertions(+), 34 deletions(-)

New commits:
commit c3abf43d59e1d2a7f8ded32a412218d16c5c6433
Author:     Miklos Vajna <[email protected]>
AuthorDate: Fri Jan 16 16:39:41 2026 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Fri Jan 16 17:43:24 2026 +0100

    cool#13574 sw redline render mode: extract SwTextPaintOmitter from text 
painter
    
    SwTextPainter::DrawTextLine() is quite large, pull out part of that to a
    new class, see
    <https://gerrit.libreoffice.org/c/core/+/197320/comment/22f3c720_6f7c95fb/>.
    
    Change-Id: I89a0a49646481e174e3a2fa7508de6827d7683cd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197417
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx
index 1ee13b7b89ae..c97828886f21 100644
--- a/sw/source/core/text/itrpaint.cxx
+++ b/sw/source/core/text/itrpaint.cxx
@@ -121,6 +121,61 @@ SwLinePortion *SwTextPainter::CalcPaintOfst(const SwRect 
&rPaint, bool& rbSkippe
     return pPor;
 }
 
+namespace
+{
+/// See if the redline render mode requires to omit the paint of the text 
portion.
+class SwTextPaintOmitter
+{
+    SwTextPainter& m_rPainter;
+    bool m_bOmitPaint;
+
+public:
+    SwTextPaintOmitter(SwTextPainter& rPainter, const SwRedlineTable& 
rRedlineTable);
+    ~SwTextPaintOmitter();
+};
+
+SwTextPaintOmitter::SwTextPaintOmitter(SwTextPainter& rPainter, const 
SwRedlineTable& rRedlineTable)
+    : m_rPainter(rPainter)
+    , m_bOmitPaint(false)
+{
+    if (!rPainter.GetRedln() || !rPainter.GetRedln()->IsOn())
+    {
+        return;
+    }
+
+    SwRedlineTable::size_type nRedline = rPainter.GetRedln()->GetAct();
+    if (nRedline == SwRedlineTable::npos)
+    {
+        return;
+    }
+
+    SwRedlineRenderMode eRedlineRenderMode = 
rPainter.GetInfo().GetOpt().GetRedlineRenderMode();
+    const SwRangeRedline* pRedline = rRedlineTable[nRedline];
+    RedlineType eType = pRedline->GetType();
+    if (eRedlineRenderMode == SwRedlineRenderMode::OmitInserts && eType == 
RedlineType::Insert)
+    {
+        m_bOmitPaint = true;
+    }
+    else if (eRedlineRenderMode == SwRedlineRenderMode::OmitDeletes && eType 
== RedlineType::Delete)
+    {
+        m_bOmitPaint = true;
+    }
+
+    if (m_bOmitPaint)
+    {
+        rPainter.GetInfo().SetOmitPaint(true);
+    }
+}
+
+SwTextPaintOmitter::~SwTextPaintOmitter()
+{
+    if (m_bOmitPaint)
+    {
+        m_rPainter.GetInfo().SetOmitPaint(false);
+    }
+}
+}
+
 // There are two possibilities to output transparent font:
 // 1) DrawRect on the whole line and DrawText afterwards
 //    (objectively fast, subjectively slow)
@@ -424,37 +479,9 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, 
SwSaveClip &rClip,
             roTaggedLabel.emplace(nullptr, nullptr, &aPorInfo, *pOut);
         }
 
-        // See if the redline render mode requires to omit the paint of the 
text portion.
-        SwRedlineTable::size_type nRedline = SwRedlineTable::npos;
-        SwRedlineRenderMode eRedlineRenderMode = SwRedlineRenderMode::Standard;
-        if (GetRedln() && GetRedln()->IsOn())
-        {
-            nRedline = GetRedln()->GetAct();
-            eRedlineRenderMode = GetInfo().GetOpt().GetRedlineRenderMode();
-        }
-        bool bOmitPaint = false;
-        if (nRedline != SwRedlineTable::npos)
         {
-            const SwRangeRedline* pRedline = rRedlineTable[nRedline];
-            RedlineType eType = pRedline->GetType();
-            if (eRedlineRenderMode == SwRedlineRenderMode::OmitInserts
-                && eType == RedlineType::Insert)
-            {
-                bOmitPaint = true;
-            }
-            else if (eRedlineRenderMode == SwRedlineRenderMode::OmitDeletes
-                     && eType == RedlineType::Delete)
-            {
-                bOmitPaint = true;
-            }
-        }
-
-        if (bOmitPaint)
-        {
-            GetInfo().SetOmitPaint(true);
-        }
+            SwTextPaintOmitter aTextPaintOmitter(*this, rRedlineTable);
 
-        {
             // #i16816# tagged pdf support
             Por_Info aPorInfo(*pPor, *this, 0);
             SwTaggedPDFHelper aTaggedPDFHelper( nullptr, nullptr, &aPorInfo, 
*pOut );
@@ -465,11 +492,6 @@ void SwTextPainter::DrawTextLine( const SwRect &rPaint, 
SwSaveClip &rClip,
                 pPor->Paint( GetInfo() );
         }
 
-        if (bOmitPaint)
-        {
-            GetInfo().SetOmitPaint(false);
-        }
-
         // lazy open LBody and paragraph tag after num portions have been 
painted to Lbl
         if (pPor->InNumberGrp() // also footnote label
             // note: numbering portion may be split if it has multiple scripts

Reply via email to