diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2024-06-05 12:13:14 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-06-05 14:49:36 +0200 |
commit | 937bdd08ee8ff9ce90db06fd463719ba8e9da996 (patch) | |
tree | 02830458db055b8bdbd14bd29b98a76a8c1b3de9 /sw/qa/extras/rtfexport | |
parent | b3a70a28b0becc9c872f2a92c35dfdaac4822600 (diff) |
tdf#161417 RTF export: handle endnotes at section ends
Similar to commit 566c7017a84e3d573de85a6d986b81d3f59de0fa (tdf#160984
sw continuous endnotes: DOCX: export of <w:endnotePr> pos == sectEnd,
2024-05-29), but this is RTF, not DOCX.
Additional complexity is that it's not enough to just write \aendnotes
(sect end) or \aenddoc (doc end) to export the position, also \fet and
\endnhere needs writing, otherwise Word ignores this.
Last bit is to ignore section formats which are not nullptr but are -1,
ignore these in RtfAttributeOutput::SectionBreak(), similar to how
DocxAttributeOutput::SectionBreak() does the same already.
Change-Id: I2327c979d5af402eb15523d97149f6409fcf4adf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168468
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa/extras/rtfexport')
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport8.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfexport/rtfexport8.cxx b/sw/qa/extras/rtfexport/rtfexport8.cxx index 33219edcfe9d..347b39c68563 100644 --- a/sw/qa/extras/rtfexport/rtfexport8.cxx +++ b/sw/qa/extras/rtfexport/rtfexport8.cxx @@ -39,6 +39,7 @@ #include <frmmgr.hxx> #include <formatflysplit.hxx> #include <fmtwrapinfluenceonobjpos.hxx> +#include <fmtftntx.hxx> using namespace css; @@ -173,6 +174,36 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf158586_lostFrame) verify(); } +CPPUNIT_TEST_FIXTURE(Test, testEndnotesAtSectEndRTF) +{ + // Given a document, endnotes at collected at section end: + createSwDoc(); + { + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->SplitNode(); + pWrtShell->Up(/*bSelect=*/false); + pWrtShell->Insert("x"); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, /*bBasicCall=*/false); + SwSectionData aSection(SectionType::Content, pWrtShell->GetUniqueSectionName()); + pWrtShell->StartAction(); + SfxItemSetFixed<RES_FTN_AT_TXTEND, RES_FRAMEDIR> aSet(pWrtShell->GetAttrPool()); + aSet.Put(SwFormatEndAtTextEnd(FTNEND_ATTXTEND)); + pWrtShell->InsertSection(aSection, &aSet); + pWrtShell->EndAction(); + pWrtShell->InsertFootnote(OUString(), /*bEndNote=*/true); + } + + // When saving to DOC: + saveAndReload(mpFilter); + + // Then make sure the endnote position is section end: + SwDoc* pDoc = getSwDoc(); + SwSectionFormats& rSections = pDoc->GetSections(); + SwSectionFormat* pFormat = rSections[0]; + // Without the accompanying fix in place, this test would have failed, endnotes were at doc end. + CPPUNIT_ASSERT(pFormat->GetEndAtTextEnd().IsAtEnd()); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf158983) { auto verify = [this]() { |