sw/qa/extras/ooxmlexport/ooxmlexport25.cxx | 4 ++++ sw/source/filter/ww8/docxexport.cxx | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-)
New commits: commit e12c061dbf1330b00cdc73b7691171b6af883764 Author: Justin Luth <[email protected]> AuthorDate: Thu Feb 12 16:40:44 2026 -0500 Commit: Justin Luth <[email protected]> CommitDate: Fri Feb 13 02:07:13 2026 +0100 tdf#169101 docx export: create a _rels for customXml/item1.xml This patch is for the benefit of MS Word. LO doesn't need these relations - it just assumes them. Without the relation, MS Word was showing the placeholder text instead of showing the customXml 'Week #' after LO round-tripped the file. Change-Id: I9f743acb3e7e05d29c916056de00d0f623b2350a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199309 Reviewed-by: Justin Luth <[email protected]> Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx index c160cb326996..fc1fe5637b56 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx @@ -223,6 +223,10 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf169101_datePicker) // there is no valid date, so fullDate must not be provided (or MS Word says 'corrupt file') assertXPathNoAttribute(pXmlDoc, "//w:sdt/w:sdtPr/w:date", "fullDate"); assertXPathContent(pXmlDoc, "//w:sdt/w:sdtContent/w:r/w:t", u"Week #"); + + // if the relationship is missing, then MS Word shows placeholder text instead of customXml date + xmlDocUniquePtr pXmlCustomXmlRels = parseExport(u"customXml/_rels/item1.xml.rels"_ustr); + assertXPath(pXmlCustomXmlRels, "//rels:Relationship", "Target", u"itemProps1.xml"); } CPPUNIT_TEST_FIXTURE(Test, testTdf170389_manyTabstops) diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 9a6a9e159898..0f07bc346518 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1783,6 +1783,7 @@ void DocxExport::WriteCustomXml() for (sal_Int32 j = 0; j < customXmlDomlist.getLength(); j++) { + uno::Reference < css::io::XOutputStream > xCustomXmlItemOutStream; const uno::Reference<xml::dom::XDocument>& customXmlDom = customXmlDomlist[j]; const uno::Reference<xml::dom::XDocument>& customXmlDomProps = customXmlDomPropslist[j]; if (customXmlDom.is()) @@ -1794,8 +1795,8 @@ void DocxExport::WriteCustomXml() uno::Reference< xml::sax::XSAXSerializable > serializer( customXmlDom, uno::UNO_QUERY ); uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() ); - uno::Reference < css::io::XOutputStream > xOutStream = GetFilter().openFragmentStream("customXml/item" + OUString::number(j + 1) + ".xml", - u"application/xml"_ustr); + xCustomXmlItemOutStream = GetFilter().openFragmentStream( + "customXml/item" + OUString::number(j + 1) + ".xml", u"application/xml"_ustr); if (m_SdtData.size()) { // There are some SDT blocks data with data bindings which can update some custom xml values @@ -1815,7 +1816,8 @@ void DocxExport::WriteCustomXml() if (i == m_SdtData.size() - 1) { // last transformation - lcl_UpdateXmlValues(m_SdtData[i], xXSLTInStream->getInputStream(), xOutStream); + lcl_UpdateXmlValues( + m_SdtData[i], xXSLTInStream->getInputStream(), xCustomXmlItemOutStream); } else { @@ -1829,7 +1831,7 @@ void DocxExport::WriteCustomXml() } else { - writer->setOutputStream(xOutStream); + writer->setOutputStream(xCustomXmlItemOutStream); serializer->serialize(writer, uno::Sequence< beans::StringPair >()); } @@ -1844,8 +1846,7 @@ void DocxExport::WriteCustomXml() serializer->serialize(writer, uno::Sequence< beans::StringPair >()); // Adding itemprops's relationship entry to item.xml.rels file - m_rFilter.addRelation( GetFilter().openFragmentStream( "customXml/item"+OUString::number(j+1)+".xml", - u"application/xml"_ustr ) , + m_rFilter.addRelation(xCustomXmlItemOutStream, oox::getRelationship(Relationship::CUSTOMXMLPROPS), Concat2View("itemProps"+OUString::number(j+1)+".xml" )); }
