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 29127079c3f01bb28f6007a3b883b749a068c435
Author:     Jaume Pujantell <jaume.pujant...@collabora.com>
AuthorDate: Thu Mar 27 15:21:12 2025 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Mar 28 08:21:06 2025 +0100

    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/+/183403
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

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 34408dcc958b..997ccec46071 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx
@@ -43,6 +43,18 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf165642_glossaryFootnote)
     parseExport(u"word/glossary/footnotes.xml"_ustr);
 }
 
+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 a47df51234cf..afae3da1fe77 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3869,6 +3869,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