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 13069df04419b4dc85822be4fb5a079231c9bdf0 Author: Justin Luth <[email protected]> AuthorDate: Tue Mar 3 15:01:15 2026 -0500 Commit: Justin Luth <[email protected]> CommitDate: Thu Mar 5 00:46:52 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 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 ddac9aa94ec8..802c9ccdec76 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx @@ -395,6 +395,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 2c29bffb408f..3b52e0dbeabd 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -8863,6 +8863,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()) @@ -8877,6 +8878,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 )
