diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-10-20 15:53:16 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-10-20 17:02:04 +0200 |
commit | cb0e1b52d68aa6d5b505f91cb4ce577f7f3b2a8f (patch) | |
tree | caaaa6bcaa9ab1be076bba7de83c1f83d43e3b39 /sw/qa/core/text/text.cxx | |
parent | a25ed05617f304858c6c4c8ced93722130aa1d58 (diff) |
sw, numbering portion format: consider full-para char formats as well
The bugdoc had a single paragraph with direct formatting (24pt font
size), numbering enabled and a bookmark covering half of the paragraph.
The numbering had default font size, not inheriting from the paragraph.
Turns out that in case the bookmark is removed, then the custom font
size is not an autoformat set on the whole text of the paragraph but
rather a format on the paragraph level, which does influence the
formatting of the numbering portion, as expected.
Fix the problem by extending SwTextFormatter::NewNumberPortion(), so it
looks for char props not only in the item set of the SwTextNode, but
also in the hints of SwTextNode, if they cover the whole paragraph. This
fixes the inconsistency that adding a bookmark to the document should
not change the rendering of the portions.
Interestingly DOCX import already set the font size on the SwTextNode in
this case, but the ODT import created a char autofmt hint, that covered
the full paragraph.
Change-Id: I09ffabd84511da439bc05a6f8d134615e5dd8599
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141572
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa/core/text/text.cxx')
-rw-r--r-- | sw/qa/core/text/text.cxx | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index d5b1761476c3..a0f7726c42b1 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -810,6 +810,25 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testRichContentControlPDF) CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount()); } +CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testNumberPortionFormat) +{ + // Given a document with a single paragraph, direct formatting asks 24pt font size for the + // numbering and the text portion: + createSwDoc(DATA_DIRECTORY, "number-portion-format.odt"); + + // When laying out that document: + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + + // Then make sure that the numbering portion has the correct font size: + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 480 + // - Actual : 240 + // i.e. the numbering portion font size was 12pt, not 24pt (but only when the doc had a + // bookmark). + assertXPath(pXmlDoc, "//SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']", + "font-height", "480"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |