[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Wed Nov 27 10:48:10 UTC 2019


 sw/source/filter/inc/msfilter.hxx     |    3 ++-
 sw/source/filter/ww8/writerhelper.cxx |   13 ++++++++-----
 sw/source/filter/ww8/ww8par5.cxx      |    6 ++++--
 3 files changed, 14 insertions(+), 8 deletions(-)

New commits:
commit 4115b4c461fc6f4710e24a2e2b24d99e6bbca565
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Tue Nov 26 15:56:30 2019 +0100
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Wed Nov 27 11:47:03 2019 +0100

    sw: WW8 import: fix again asserts on fdo45983-1.doc export to ODT
    
    The problem is that we now insert 2 dummy characters at the start of a
    fieldmark instead of 1, so the checks in RedlineStack::MoveAttrs()
    were off by 1 and we get the same invalid redline containing the start
    but not the end of a fieldmark.
    
    (regression from 7f2e61f884949ab27bcb7e1a02ece9a5cb4354b9)
    
    Change-Id: I9752ca4c3a281539e37ddac4fe811e2f9d7374a6
    Reviewed-on: https://gerrit.libreoffice.org/83783
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit 10d72337640677e2d49b522a734728646c9b8e96)
    Reviewed-on: https://gerrit.libreoffice.org/83812

diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx
index b5fbfdb2e737..f05283e46c51 100644
--- a/sw/source/filter/inc/msfilter.hxx
+++ b/sw/source/filter/inc/msfilter.hxx
@@ -299,7 +299,8 @@ namespace sw
 
         public:
             explicit RedlineStack(SwDoc &rDoc) : mrDoc(rDoc) {}
-            void MoveAttrs(const SwPosition& rPos);
+            enum class MoveAttrsMode { Default, FieldmarkInserted };
+            void MoveAttrs(const SwPosition& rPos, MoveAttrsMode eMode = MoveAttrsMode::Default);
             void open(const SwPosition& rPos, const SfxPoolItem& rAttr);
             bool close(const SwPosition& rPos, RedlineType eType);
             void close(const SwPosition& rPos, RedlineType eType,
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index fa56ce68878e..46d1b4411fd1 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -738,11 +738,14 @@ namespace sw
             std::for_each(maStack.begin(), maStack.end(), SetEndIfOpen(rPos));
         }
 
-        void RedlineStack::MoveAttrs( const SwPosition& rPos )
+        void RedlineStack::MoveAttrs(const SwPosition& rPos, MoveAttrsMode const eMode)
         {
             size_t nCnt = maStack.size();
+            sal_Int32 const nInserted = eMode == MoveAttrsMode::FieldmarkInserted
+                ? 2 // CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDSEP
+                : 1;
             sal_uLong nPosNd = rPos.nNode.GetIndex();
-            sal_Int32 nPosCt = rPos.nContent.GetIndex() - 1;
+            sal_Int32 nPosCt = rPos.nContent.GetIndex() - nInserted;
 
             for (size_t i=0; i < nCnt; ++i)
             {
@@ -751,12 +754,12 @@ namespace sw
                 if ((rEntry.m_aMkPos.m_nNode.GetIndex()+1 == nPosNd) &&
                     (nPosCt <= rEntry.m_aMkPos.m_nContent))
                 {
-                    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++;
+                        rEntry.m_aPtPos.m_nContent += nInserted;
                         continue;
                     }
                 }
@@ -765,7 +768,7 @@ namespace sw
                 if ((rEntry.m_aPtPos.m_nNode.GetIndex()+1 == nPosNd) &&
                     (nPosCt < rEntry.m_aPtPos.m_nContent))
                 {
-                    rEntry.m_aPtPos.m_nContent++;
+                    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");
                 }
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index e6f31bb0736a..ea0a435371a3 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -542,7 +542,8 @@ sal_uInt16 SwWW8ImplReader::End_Field()
             if (pFieldmark!=nullptr) {
                 // adapt redline positions to inserted field mark start
                 // dummy char (assume not necessary for end dummy char)
-                m_xRedlineStack->MoveAttrs(*aFieldPam.Start());
+                m_xRedlineStack->MoveAttrs(*aFieldPam.Start(),
+                        RedlineStack::MoveAttrsMode::FieldmarkInserted);
                 const IFieldmark::parameter_map_t& rParametersToAdd = m_aFieldStack.back().getParameters();
                 pFieldmark->GetParameters()->insert(rParametersToAdd.begin(), rParametersToAdd.end());
             }
@@ -642,7 +643,8 @@ sal_uInt16 SwWW8ImplReader::End_Field()
                     {
                         // adapt redline positions to inserted field mark start
                         // dummy char (assume not necessary for end dummy char)
-                        m_xRedlineStack->MoveAttrs(*aFieldPam.Start());
+                        m_xRedlineStack->MoveAttrs(*aFieldPam.Start(),
+                            RedlineStack::MoveAttrsMode::FieldmarkInserted);
                         const IFieldmark::parameter_map_t& rParametersToAdd = m_aFieldStack.back().getParameters();
                         pFieldmark->GetParameters()->insert(rParametersToAdd.begin(), rParametersToAdd.end());
                         OUString sFieldId = OUString::number( m_aFieldStack.back().mnFieldId );


More information about the Libreoffice-commits mailing list