[Libreoffice-commits] core.git: sw/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 2 09:13:35 UTC 2021


 sw/source/filter/basflt/fltshell.cxx  |    3 -
 sw/source/filter/inc/msfilter.hxx     |    2 +
 sw/source/filter/ww8/writerhelper.cxx |   52 ++++++++++++++++++----------------
 3 files changed, 31 insertions(+), 26 deletions(-)

New commits:
commit 3fe274dcfeca17ee7713b306fcd36183f6cf4689
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Mar 1 13:55:38 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Mar 2 10:12:48 2021 +0100

    split out MoveAttrFieldmarkInserted
    
    Change-Id: Ib48bd62994167b1703790857cb562fc7f7dbd76f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111755
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx
index 9514f2534095..43bea4896896 100644
--- a/sw/source/filter/basflt/fltshell.cxx
+++ b/sw/source/filter/basflt/fltshell.cxx
@@ -191,11 +191,10 @@ SwFltControlStack::~SwFltControlStack()
 // same paragraph further out by one character.
 void SwFltControlStack::MoveAttrs(const SwPosition& rPos, MoveAttrsMode eMode)
 {
-    size_t nCnt = m_Entries.size();
     sal_uLong nPosNd = rPos.nNode.GetIndex();
     sal_uInt16 nPosCt = rPos.nContent.GetIndex() - 1;
 
-    for (size_t i=0; i < nCnt; ++i)
+    for (size_t i = 0, nCnt = m_Entries.size(); i < nCnt; ++i)
     {
         SwFltStackEntry& rEntry = *m_Entries[i];
         if (
diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx
index 209eb0fced41..c0ebc8ea6be7 100644
--- a/sw/source/filter/inc/msfilter.hxx
+++ b/sw/source/filter/inc/msfilter.hxx
@@ -287,6 +287,8 @@ namespace sw
             std::map<std::unique_ptr<InsertedTableListener>, SwNodeIndex*> maTables;
         };
 
+        void MoveAttrFieldmarkInserted(SwFltPosition& rMkPos, SwFltPosition& rPtPos, const SwPosition& rPos);
+
         class RedlineStack
         {
         private:
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index 641b1168798c..199d2f6c9f51 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -757,39 +757,43 @@ namespace sw
             std::for_each(maStack.begin(), maStack.end(), SetEndIfOpen(rPos));
         }
 
-        void RedlineStack::MoveAttrsFieldmarkInserted(const SwPosition& rPos)
+        void MoveAttrFieldmarkInserted(SwFltPosition& rMkPos, SwFltPosition& rPtPos, const SwPosition& rPos)
         {
-            size_t nCnt = maStack.size();
             sal_Int32 const nInserted = 2; // CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDSEP
             sal_uLong nPosNd = rPos.nNode.GetIndex();
             sal_Int32 nPosCt = rPos.nContent.GetIndex() - nInserted;
 
-            for (size_t i=0; i < nCnt; ++i)
+            bool const isPoint(rMkPos == rPtPos);
+            if ((rMkPos.m_nNode.GetIndex()+1 == nPosNd) &&
+                (nPosCt <= rMkPos.m_nContent))
             {
-                SwFltStackEntry& rEntry = *maStack[i];
-                bool const isPoint(rEntry.m_aMkPos == rEntry.m_aPtPos);
-                if ((rEntry.m_aMkPos.m_nNode.GetIndex()+1 == nPosNd) &&
-                    (nPosCt <= rEntry.m_aMkPos.m_nContent))
-                {
-                    rEntry.m_aMkPos.m_nContent += nInserted;
-                    SAL_WARN_IF(rEntry.m_aMkPos.m_nContent > rPos.nNode.GetNodes()[nPosNd]->GetContentNode()->Len(),
-                            "sw.ww8", "redline ends after end of line");
-                    if (isPoint) // sigh ... important special case...
-                    {
-                        rEntry.m_aPtPos.m_nContent += nInserted;
-                        continue;
-                    }
-                }
-                // for the end position, leave it alone if it's *on* the dummy
-                // char position, that should remain *before*
-                if ((rEntry.m_aPtPos.m_nNode.GetIndex()+1 == nPosNd) &&
-                    (nPosCt < rEntry.m_aPtPos.m_nContent))
+                rMkPos.m_nContent += nInserted;
+                SAL_WARN_IF(rMkPos.m_nContent > rPos.nNode.GetNodes()[nPosNd]->GetContentNode()->Len(),
+                        "sw.ww8", "redline ends after end of line");
+                if (isPoint) // sigh ... important special case...
                 {
-                    rEntry.m_aPtPos.m_nContent += nInserted;
-                    SAL_WARN_IF(rEntry.m_aPtPos.m_nContent > rPos.nNode.GetNodes()[nPosNd]->GetContentNode()->Len(),
-                            "sw.ww8", "redline ends after end of line");
+                    rPtPos.m_nContent += nInserted;
+                    return;
                 }
             }
+            // for the end position, leave it alone if it's *on* the dummy
+            // char position, that should remain *before*
+            if ((rPtPos.m_nNode.GetIndex()+1 == nPosNd) &&
+                (nPosCt < rPtPos.m_nContent))
+            {
+                rPtPos.m_nContent += nInserted;
+                SAL_WARN_IF(rPtPos.m_nContent > rPos.nNode.GetNodes()[nPosNd]->GetContentNode()->Len(),
+                        "sw.ww8", "range ends after end of line");
+            }
+        }
+
+        void RedlineStack::MoveAttrsFieldmarkInserted(const SwPosition& rPos)
+        {
+            for (size_t i = 0, nCnt = maStack.size(); i < nCnt; ++i)
+            {
+                SwFltStackEntry& rEntry = *maStack[i];
+                MoveAttrFieldmarkInserted(rEntry.m_aMkPos, rEntry.m_aPtPos, rPos);
+            }
         }
 
         void SetInDocAndDelete::operator()(std::unique_ptr<SwFltStackEntry>& pEntry)


More information about the Libreoffice-commits mailing list