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 9751c938364a0961142e507e74eb27ab6902f7c3 Author: Jaume Pujantell <jaume.pujant...@collabora.com> AuthorDate: Thu Mar 27 15:21:12 2025 +0100 Commit: Jaume Pujantell <jaume.pujant...@collabora.com> CommitDate: Fri Mar 28 15:02:34 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 (cherry picked from commit 29127079c3f01bb28f6007a3b883b749a068c435) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183432 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Jaume Pujantell <jaume.pujant...@collabora.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 00ad9f1766dc..46991f634f85 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"_ostr, 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 770da84aabc3..18162ccf88e6 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3812,6 +3812,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;