[Libreoffice-commits] core.git: sw/qa sw/source
Samuel Mehrbrodt (via logerrit)
logerrit at kemper.freedesktop.org
Thu Sep 5 06:52:42 UTC 2019
sw/qa/extras/layout/data/tdf64222.docx |binary
sw/qa/extras/layout/layout.cxx | 7 +++
sw/source/core/text/txtfld.cxx | 61 +++++++++++++++++----------------
3 files changed, 39 insertions(+), 29 deletions(-)
New commits:
commit 2c0d3ce5292b45a8897758508ee61801e4e8340d
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Fri Aug 30 15:19:49 2019 +0200
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Thu Sep 5 08:51:39 2019 +0200
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 at cib.de>
diff --git a/sw/qa/extras/layout/data/tdf64222.docx b/sw/qa/extras/layout/data/tdf64222.docx
new file mode 100644
index 000000000000..4a2de828a902
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf64222.docx differ
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);
}
}
More information about the Libreoffice-commits
mailing list