diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-08-30 15:19:49 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-09-05 08:51:39 +0200 |
commit | 2c0d3ce5292b45a8897758508ee61801e4e8340d (patch) | |
tree | 86edec64f4eb501e4221a91b03dd4cc2fa5ffcda /sw | |
parent | 9dac199094a71a9f0d806c39a6a990b31f5e0f4c (diff) |
tdf#64222 Consistently apply direct formatting to numbering
Change-Id: I54d672409c969389f33dd07021f10e1203bb64c6
Reviewed-on: https://gerrit.libreoffice.org/78299
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/layout/data/tdf64222.docx | bin | 0 -> 11201 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/text/txtfld.cxx | 61 |
3 files changed, 39 insertions, 29 deletions
diff --git a/sw/qa/extras/layout/data/tdf64222.docx b/sw/qa/extras/layout/data/tdf64222.docx Binary files differnew file mode 100644 index 000000000000..4a2de828a902 --- /dev/null +++ b/sw/qa/extras/layout/data/tdf64222.docx diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index f5cae5aa8405..6fd861d68dc8 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -3038,6 +3038,13 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testImageComment) CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(5), aPosition.nContent.GetIndex()); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf64222) +{ + createDoc("tdf64222.docx"); + xmlDocPtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page/body/txt[2]/Special", "nHeight", "560"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index 440916cb001e..90edb00b7e0b 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -422,6 +422,7 @@ static void checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm TextFrameIndex const nTextLen(rInf.GetTextFrame()->GetText().getLength()); SwTextNode const* pNode(nullptr); sw::MergedAttrIterReverse iter(*rInf.GetTextFrame()); + std::shared_ptr<SfxItemSet> pSet; for (SwTextAttr const* pHint = iter.PrevAttr(&pNode); pHint; pHint = iter.PrevAttr(&pNode)) { @@ -431,41 +432,43 @@ static void checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm { break; // only those at para end are interesting } - // Formatting for the paragraph mark is set to apply only to the - // (non-existent) extra character at end of the text node. - if (pHint->Which() == RES_TXTATR_AUTOFMT - && pHint->GetStart() == *pHint->End()) + // Formatting for the paragraph mark is usually set to apply only to the + // (non-existent) extra character at end of the text node, but there can be + // other hints too (ending at nTextLen), so look for all matching hints. + // Still the (non-existent) extra character at the end is preferred if it exists. + if (pHint->Which() == RES_TXTATR_AUTOFMT) { - std::shared_ptr<SfxItemSet> pSet(pHint->GetAutoFormat().GetStyleHandle()); - - // Check each item and in case it should be ignored, then clear it. - std::unique_ptr<SfxItemSet> pCleanedSet; - if (pSet.get()) - { - pCleanedSet = pSet->Clone(); - - SfxItemIter aIter(*pSet); - const SfxPoolItem* pItem = aIter.GetCurItem(); - while (true) - { - if (SwTextNode::IsIgnoredCharFormatForNumbering(pItem->Which())) - pCleanedSet->ClearItem(pItem->Which()); - else if (pFormat && pFormat->HasItem(pItem->Which())) - pCleanedSet->ClearItem(pItem->Which()); + pSet = pHint->GetAutoFormat().GetStyleHandle(); + // When we find an empty hint (start == end) we got what we are looking for. + if (pHint->GetStart() == *pHint->End()) + break; + } + } - if (aIter.IsAtEnd()) - break; + // Check each item and in case it should be ignored, then clear it. + std::unique_ptr<SfxItemSet> pCleanedSet; + if (pSet.get()) + { + pCleanedSet = pSet->Clone(); - pItem = aIter.NextItem(); - } - } + SfxItemIter aIter(*pSet); + const SfxPoolItem* pItem = aIter.GetCurItem(); + while (true) + { + if (SwTextNode::IsIgnoredCharFormatForNumbering(pItem->Which())) + pCleanedSet->ClearItem(pItem->Which()); + else if (pFormat && pFormat->HasItem(pItem->Which())) + pCleanedSet->ClearItem(pItem->Which()); - // Highlightcolor also needed to be untouched, but we can't have that just by clearing the item - Color nSaveHighlight = pNumFnt->GetHighlightColor(); + if (aIter.IsAtEnd()) + break; - pNumFnt->SetDiffFnt(pCleanedSet.get(), pIDSA); - pNumFnt->SetHighlightColor(nSaveHighlight); + pItem = aIter.NextItem(); } + // Highlightcolor also needed to be untouched, but we can't have that just by clearing the item + Color nSaveHighlight = pNumFnt->GetHighlightColor(); + pNumFnt->SetDiffFnt(pCleanedSet.get(), pIDSA); + pNumFnt->SetHighlightColor(nSaveHighlight); } } |