sw/qa/extras/ooxmlexport/data/tdf165933.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport22.cxx   |   12 ++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |    9 +++++++++
 3 files changed, 21 insertions(+)

New commits:
commit 03126c28f36c9c1b92ccd7a410450a67c9fa0972
Author:     Jaume Pujantell <jaume.pujant...@collabora.com>
AuthorDate: Thu Mar 27 15:21:12 2025 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Apr 9 17:45:26 2025 +0200

    tdf#165933 avoid w:delText inside w:moveFrom
    
    w:delText should only be used inside a w:del, we differentiate if we use
    w:del or w:moveFrom by looking if the current redline is move and if it
    is inside a move bookmark. But sometimes the run contents are writen
    before the surrounding bookmarks, in that case we wrongly used delText.
    To avoid this we need to check not only the existing bookmarks but also
    the ones that will be opened in this run.
    
    Change-Id: I6653d18545cc5eb5f302c5753cdd7dfb24bee6fc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183458
    Reviewed-by: Jaume Pujantell <jaume.pujant...@collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit 80d036c0ddfce7025e0d069f54c65b28031a9f7c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183472
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf165933.docx 
b/sw/qa/extras/ooxmlexport/data/tdf165933.docx
new file mode 100644
index 000000000000..a5d40269b51c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf165933.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx
index f67344a82904..7f5d94092aa2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx
@@ -80,6 +80,18 @@ CPPUNIT_TEST_FIXTURE(Test, 
testTdf165047_contextualSpacingTopMargin)
     CPPUNIT_ASSERT_EQUAL(static_cast<SwTwips>(0), nParaTopMargin);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf165933_noDelTextOnMove)
+{
+    loadAndSave("tdf165933.docx");
+    xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
+    CPPUNIT_ASSERT(pXmlDoc);
+    // Wihtout the fix it fails with
+    // - Expected: 0
+    // - Actual  : 1
+    // a w:delText is created inside a w:moveFrom, which is invalid
+    assertXPath(pXmlDoc, "//w:moveFrom/w:r/w:delText", 0);
+}
+
 } // end of anonymous namespace
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 0070a93a05e8..f4f3c8d802c3 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3865,6 +3865,15 @@ void DocxAttributeOutput::RunText( const OUString& 
rText, rtl_TextEncoding /*eCh
             break;
         }
     }
+    // Check also the bookmarks that will be opened just now
+    for (const OUString& bookmarkName : m_rBookmarksStart)
+    {
+        if (bookmarkName.startsWith(u"__RefMove"))
+        {
+            isInMoveBookmark = true;
+            break;
+        }
+    }
     bool bMoved = isInMoveBookmark && 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;

Reply via email to