sw/qa/extras/ooxmlexport/ooxmlexport12.cxx   |    9 +++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   16 ++++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)

New commits:
commit 9a74d37762d0311c608062cd715df1b35d4f6ac4
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Wed Aug 3 16:09:14 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Aug 8 11:54:45 2022 +0200

    tdf#150166 DOCX export: revert ToC w:move* to fix broken file
    
    Export w:moveFrom/w:moveTo of tracked ToC moving as w:del/w:ins
    (and w:delText for runs in w:del) again to avoid of interoperability
    problems.
    
    Partial revert of commit 9e1e88ad5cf2dc0e9b188c60930445652a6c7519
    "tdf#145720 DOCX export: fix loss of tracked moving".
    
    Follow-up to commit 64ac089ad5464c832592e050f5d51a136f533f21
    "tdf#150166 DOCX export: fix broken file with tracked ToC moving".
    
    Note: Commit 64ac089ad5464c832592e050f5d51a136f533f21 was only part
    of the fix for the broken export with interoperability problems.
    
    Change-Id: I520f3a7e08eca0ccd6aa221a2406b41925f70fa7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137752
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit 9c637252f9e965302458ccfc514addc473a0a980)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137729
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index 351c1f804dfe..0f4913375aac 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -1235,6 +1235,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf150166, "tdf150166.docx")
         assertXPath(pXmlDoc, "//w:moveFromRangeStart", 0);
         // This was 2 (missing RangeStart elements, but bad unpaired RangeEnds)
         assertXPath(pXmlDoc, "//w:moveFromRangeEnd", 0);
+
+        // These were 0 (moveFrom, moveTo and t)
+        assertXPath(pXmlDoc, "//w:del", 11);
+        assertXPath(pXmlDoc, "//w:ins", 12);
+        assertXPath(pXmlDoc, "//w:delText", 7);
+
+        // no more moveFrom/moveTo to avoid of problems with ToC
+        assertXPath(pXmlDoc, "//w:moveFrom", 0);
+        assertXPath(pXmlDoc, "//w:moveTo", 0);
     }
 }
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index e1e9176bdb74..1014f69ed64b 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3385,8 +3385,12 @@ void DocxAttributeOutput::RunText( const OUString& 
rText, rtl_TextEncoding /*eCh
 
     // the text run is usually XML_t, with the exception of the deleted (and 
not moved) text
     sal_Int32 nTextToken = XML_t;
-    if ( m_pRedlineData && !m_pRedlineData->IsMoved() &&
-            m_pRedlineData->GetType() == RedlineType::Delete )
+
+    bool bMoved = m_pRedlineData && m_pRedlineData->IsMoved() &&
+       // tdf#150166 save tracked moving around TOC as w:ins, w:del
+       SwDoc::GetCurTOX(*m_rExport.m_pCurPam->GetPoint()) == nullptr;
+
+    if ( m_pRedlineData && m_pRedlineData->GetType() == RedlineType::Delete && 
!bMoved )
     {
         nTextToken = XML_delText;
     }
@@ -3790,7 +3794,9 @@ void DocxAttributeOutput::StartRedline( const 
SwRedlineData * pRedlineData )
     const DateTime aDateTime = pRedlineData->GetTimeStamp();
     bool bNoDate = bRemovePersonalInfo ||
         ( aDateTime.GetYear() == 1970 && aDateTime.GetMonth() == 1 && 
aDateTime.GetDay() == 1 );
-    bool bMoved = pRedlineData->IsMoved();
+    bool bMoved = pRedlineData->IsMoved() &&
+       // tdf#150166 save tracked moving around TOC as w:ins, w:del
+       SwDoc::GetCurTOX(*m_rExport.m_pCurPam->GetPoint()) == nullptr;
     switch ( pRedlineData->GetType() )
     {
         case RedlineType::Insert:
@@ -3823,7 +3829,9 @@ void DocxAttributeOutput::EndRedline( const SwRedlineData 
* pRedlineData )
     if ( !pRedlineData || m_bWritingField )
         return;
 
-    bool bMoved = pRedlineData->IsMoved();
+    bool bMoved = pRedlineData->IsMoved() &&
+       // tdf#150166 save tracked moving around TOC as w:ins, w:del
+       SwDoc::GetCurTOX(*m_rExport.m_pCurPam->GetPoint()) == nullptr;
     switch ( pRedlineData->GetType() )
     {
         case RedlineType::Insert:

Reply via email to