sw/qa/extras/ooxmlexport/data/line-break-in-ref.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport22.cxx | 12 ++++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-)
New commits: commit 367f714a2a49f1fe6ed66f7ecb8d191e3417fba6 Author: Jaume Pujantell <[email protected]> AuthorDate: Thu May 29 14:32:18 2025 +0200 Commit: Jaume Pujantell <[email protected]> CommitDate: Tue Jun 17 11:18:25 2025 +0200 tdf#166940 sw: 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 <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> (cherry picked from commit e0119fbf861af288e3efe55efcd9aa88adaff80f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186450 Tested-by: Jenkins Reviewed-by: Jaume Pujantell <[email protected]> (cherry picked from commit aa689d596c44c1c51ab9345df5d063768936fe74) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186554 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 3360a8696536..a92c72dc57c6 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx @@ -140,6 +140,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"_ostr, "Text1"); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 83251d3e2cec..a70b1c18149e 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -2188,7 +2188,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};
