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 <vmiklos@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> (cherry picked from commit e0119fbf861af288e3efe55efcd9aa88adaff80f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186450 Tested-by: Jenkins Reviewed-by: Jaume Pujantell <jaume.pujantell@collabora.com>
This commit is contained in:
Binary file not shown.
@@ -369,6 +369,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();
|
||||
|
||||
|
||||
@@ -2211,7 +2211,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};
|
||||
|
||||
Reference in New Issue
Block a user