sw/qa/extras/ooxmlexport/data/tdf170908_delText_sdt.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport25.cxx | 14 ++++++++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 2 ++ 3 files changed, 16 insertions(+)
New commits: commit 5f8378f2495fb658b0be444728f05ea879a3f19d Author: Justin Luth <[email protected]> AuthorDate: Tue Mar 3 15:01:15 2026 -0500 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Mar 6 08:56:39 2026 +0100 tdf#170908 docx export: WritePendingPlaceholder in Redline as needed Commit 1b0f67018fa1d says that MS Word does not redline content controls, but I think that comment is simply bogus. It came from someone without Writer experience who would have expected the code to be relatively correct in the first place. In any case, MS Word certainly opens (and considers as redline-deleted) when a w:sdt is wrapped in a w:del. If needed in the future, an alternative to redlining the entire sdt would be to m_pRedlineData.push_back(nullptr) just before RunText, and then immediately to pop it. make CppunitTest_sw_ooxmlexport25 \ CPPUNIT_TEST_NAME=testTdf170908_delText_sdt Change-Id: Ib5ec69899277b24bcf1307d66c19703ce878edae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200916 Reviewed-by: Justin Luth <[email protected]> Tested-by: Jenkins (cherry picked from commit 13069df04419b4dc85822be4fb5a079231c9bdf0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200990 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/data/tdf170908_delText_sdt.odt b/sw/qa/extras/ooxmlexport/data/tdf170908_delText_sdt.odt new file mode 100644 index 000000000000..e814af9f1783 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf170908_delText_sdt.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx index ba0d2abdbc29..cac6ecdbaa2b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx @@ -364,6 +364,20 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf170908_delText) CPPUNIT_ASSERT_GREATER(nRunsBeforeDelText, nRunsBeforeAnchor); } +CPPUNIT_TEST_FIXTURE(Test, testTdf170908_delText_sdt) +{ + // Given a document with a deleted, exported-with-WritePendingPlaceholder sdt + + createSwDoc("tdf170908_delText_sdt.odt"); + + save(TestFilter::DOCX); + + xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr); + // delText must be inside a w:del or MS Word considers the document to be corrupt + assertXPath(pXmlDoc, "//w:delText", 1); // there is only one delTree element + assertXPath(pXmlDoc, "//w:del/w:sdt/w:sdtContent/w:r/w:delText", 1); // the whole sdt is deleted +} + CPPUNIT_TEST_FIXTURE(Test, testTdf170952_delText) { // Given a document with deleted text at the end of the paragraph diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index fac50ae76dd3..6d405f05272b 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -8858,6 +8858,7 @@ void DocxAttributeOutput::WritePendingPlaceholder() return; const SwField* pField = m_PendingPlaceholder; m_PendingPlaceholder = nullptr; + StartRedline(m_pRedlineData.back()); m_pSerializer->startElementNS(XML_w, XML_sdt); m_pSerializer->startElementNS(XML_w, XML_sdtPr); if( !pField->GetPar2().isEmpty()) @@ -8872,6 +8873,7 @@ void DocxAttributeOutput::WritePendingPlaceholder() m_pSerializer->endElementNS( XML_w, XML_r ); m_pSerializer->endElementNS( XML_w, XML_sdtContent ); m_pSerializer->endElementNS( XML_w, XML_sdt ); + EndRedline(m_pRedlineData.back()); } void DocxAttributeOutput::SetField( const SwField& rField, ww::eField eType, const OUString& rCmd )
