diff options
author | Justin Luth <justin.luth@collabora.com> | 2019-11-29 22:10:27 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-12-20 10:58:33 +0100 |
commit | acb9d901009d026cb48e6a8b94e6200f05110504 (patch) | |
tree | 402534f6ad8fa82972678fa98a0775e110b5aa30 /sw/qa | |
parent | 10d345faa087fa49692f38bb2ece22560f423ba7 (diff) |
tdf#123262 writerfilter: completely ignore footnote separators
... except for processing enough to observe the separator exists.
For each footnote reference, the entire footnote.xml file is
parsed every time. The text in the "separator" footnote was
being added to every footnote. The normal case where this is just
a single paragraph was already handled, but this patch generalizes
everything to handle cases of actual text or multiple paragraphs.
Not every footnote has a type, so we can't depend on that to turn
ignoringText ON/OFF. Every footnote has an ID, but theoretically
the ID could be processed before or after the type, and it has
no idea which type it is. Finally, the skipped text has no idea
how many times/paragaphs it needs to skip. So a three-way
control was needed to handle on/used/off. As a safeguard, finishing
the footnote.xml parse (PopFootOrEndnote) ensures that
ignoring won't be left on in the unlikely case that
the separator is the last footnote.
Change-Id: Ia30ca8d3a36417a4691e3b2e1c978720be017030
Reviewed-on: https://gerrit.libreoffice.org/82172
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf123262_textFootnoteSeparators.docx | bin | 0 -> 29044 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 18 |
2 files changed, 18 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf123262_textFootnoteSeparators.docx b/sw/qa/extras/ooxmlexport/data/tdf123262_textFootnoteSeparators.docx Binary files differnew file mode 100644 index 000000000000..ceccb767e27e --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf123262_textFootnoteSeparators.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index b0f2cd7dd98c..8e394f7a445c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -526,6 +526,24 @@ DECLARE_OOXMLEXPORT_TEST(testFDO79062, "fdo79062.docx") CPPUNIT_ASSERT_EQUAL_MESSAGE( "Paragraph starts with W(87), not tab(9)", u'W', sFootnotePara[0] ); } +DECLARE_OOXMLEXPORT_TEST(testTdf123262_textFootnoteSeparators, "tdf123262_textFootnoteSeparators.docx") +{ + //Everything easily fits on one page + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Pages", 1, getPages() ); + + uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes(); + uno::Reference<text::XText> xFootnoteText(xFootnotes->getByIndex(0), uno::UNO_QUERY); + + // The text in the separator footnote should not be added to the footnotes + OUString sText = " Microsoft Office."; + CPPUNIT_ASSERT_EQUAL(sText, xFootnoteText->getString()); + + // Ensure that paragraph markers are not lost. + xFootnoteText.set(xFootnotes->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of paragraphs in second footnote", 2, getParagraphs(xFootnoteText) ); +} + DECLARE_OOXMLEXPORT_TEST(testfdo79668,"fdo79668.docx") { // fdo#79668: Document was Crashing on DebugUtil build while Saving |