tdf#32363 sw DOCX: add unit test/documentation for shortening headings

Using Styles fields with custom character styles allows shortening
the numbered headings in the header/footer, both in ODT and DOCX
documents. See test document sw/qa/extras/ooxmlexport/data/tdf32363.docx
for more information.

Follow-up to commit da88bd54eb
"tdf#163894 sw DOCX: (p)refer char style-ref on the actual page",
commit fce6492756
"tdf#163894 sw DOCX: add character styles to style-ref window",
commit 955f0f9b5e
"tdf#163894 sw DOCX: fix style-ref with character style",
commit d4fdafa103 "tdf#160402
writerfilter,sw: STYLEREF field can refer to character style"
and commit 32c588dd11
"tdf#86790: Add support for a word-style styleref".

Change-Id: Ib1908fa392ff838f60c0a2330e2443b558bf48fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199672
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: Jenkins
This commit is contained in:
László Németh
2026-02-19 10:34:57 +01:00
parent ed7460c6d7
commit cd9da3e6d7
2 changed files with 37 additions and 0 deletions
Binary file not shown.
@@ -852,6 +852,43 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf163894_hidden)
"expand", u"modicum");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf32363)
{
createSwDoc("tdf32363.docx");
save(TestFilter::DOCX);
xmlDocUniquePtr pLayout = parseLayoutDump();
assertXPath(pLayout, "/root/page[3]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
"expand", u"1 ");
assertXPath(pLayout, "/root/page[3]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
"expand", u"Do not shorten this short heading");
assertXPath(pLayout, "/root/page[4]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
"expand", u"2 ");
assertXPath(pLayout, "/root/page[4]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
"expand", u"Beginning of the paragraph");
assertXPath(pLayout, "/root/page[5]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
"expand", u"3 ");
assertXPath(pLayout, "/root/page[5]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
"expand", u"Beginning of the paragraph + ellipsis…");
assertXPath(pLayout, "/root/page[6]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
"expand", u"3 ");
assertXPath(pLayout, "/root/page[6]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
"expand", u"Beginning of the paragraph + ellipsis…");
assertXPath(pLayout, "/root/page[7]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
"expand", u"4 ");
assertXPath(pLayout, "/root/page[7]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
"expand", u"Hidden text with the referred character style");
assertXPath(pLayout, "/root/page[8]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[1]",
"expand", u"4 ");
assertXPath(pLayout, "/root/page[8]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion[2]",
"expand", u"Hidden text with the referred character style");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf161643)
{
createSwDoc("fdo76163.docx");