sw/qa/extras/ooxmlexport/data/line-break-in-ref.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport22.cxx | 12 ++++++++++++ sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-)
New commits: commit e0119fbf861af288e3efe55efcd9aa88adaff80f Author: Jaume Pujantell <jaume.pujant...@collabora.com> AuthorDate: Thu May 29 14:32:18 2025 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu May 29 15:39:26 2025 +0200 Defer line break in ref field In Writer ref fields contain only text strings and it does not support line breaks. So, to avoid misplacement of the content on load, we defer the breaks until after the field is finished. Change-Id: I3d9a78743deb0d4f7f187a5c59b58e74ae3b20d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186008 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sw/qa/extras/ooxmlexport/data/line-break-in-ref.docx b/sw/qa/extras/ooxmlexport/data/line-break-in-ref.docx new file mode 100644 index 000000000000..a2332eac79ba Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/line-break-in-ref.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx index 01f0220cd676..ee1bc153baa1 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx @@ -295,6 +295,18 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf166511) CPPUNIT_ASSERT_EQUAL(aDiffIds.size(), nIds); } +CPPUNIT_TEST_FIXTURE(Test, testLineBreakInRef) +{ + loadAndSave("line-break-in-ref.docx"); + xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr); + + // Without the fix if fails with + // assertion failed + // - Expression: xmlXPathNodeSetGetLength(pXmlNodes) > 0 + // - In <>, XPath '/w:document/w:body/w:p[1]/w:r[4]/w:t' not found + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[4]/w:t", u"Text1"); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index c945fe45ce84..683672875e93 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -2209,7 +2209,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con if (pFieldContext && pFieldContext->IsCommandCompleted()) { - if (pFieldContext->GetFieldId() == FIELD_IF) + if (pFieldContext->GetFieldId() == FIELD_IF || pFieldContext->GetFieldId() == FIELD_REF) { // Conditional text fields can't contain newlines, finish the paragraph later. FieldParagraph aFinish{pPropertyMap, bRemove};