sw/qa/extras/ww8export/ww8export4.cxx | 31 +++++++++++++++++++++++++++++++ sw/source/filter/ww8/wrtww8.cxx | 13 +++++++++++++ 2 files changed, 44 insertions(+)
New commits: commit 24ab535087991f1ce8dee9a561476bc0a987bac5 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue Jun 4 13:43:23 2024 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Jun 4 14:46:53 2024 +0200 tdf#161417 DOC 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 for DOC, not DOCX. Change-Id: I4301d97115ba48f7ed1dacfdd5b29336bdaf9e63 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168401 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/ww8export/ww8export4.cxx b/sw/qa/extras/ww8export/ww8export4.cxx index b52e2b8f77f1..187e18267463 100644 --- a/sw/qa/extras/ww8export/ww8export4.cxx +++ b/sw/qa/extras/ww8export/ww8export4.cxx @@ -36,6 +36,7 @@ #include <frmmgr.hxx> #include <formatflysplit.hxx> #include <fmtwrapinfluenceonobjpos.hxx> +#include <fmtftntx.hxx> namespace { @@ -122,6 +123,36 @@ DECLARE_WW8EXPORT_TEST(testTdf141649_conditionalText, "tdf141649_conditionalText getParagraph(1, "trueResult"); } +CPPUNIT_TEST_FIXTURE(Test, testEndnotesAtSectEndDOC) +{ + // 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("MS Word 97"); + + // 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()); +} + DECLARE_WW8EXPORT_TEST(testTdf90408, "tdf90408.doc") { uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1), 1), uno::UNO_QUERY_THROW); diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index a14412469cf8..467a7c18949a 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -87,6 +87,7 @@ #include <fmtline.hxx> #include <fmtfsize.hxx> #include <formatflysplit.hxx> +#include <fmtftntx.hxx> #include "sprmids.hxx" #include <comphelper/sequenceashashmap.hxx> @@ -493,6 +494,18 @@ static void WriteDop( WW8Export& rWrt ) rDop.cParas = rDStat.nPara; rDop.cLines = rDStat.nPara; + SwSectionFormats& rSections = rWrt.m_rDoc.GetSections(); + if (!rSections.empty()) + { + SwSectionFormat* pFormat = rSections[0]; + bool bEndnAtEnd = pFormat->GetEndAtTextEnd().IsAtEnd(); + if (bEndnAtEnd) + { + // DopBase.epc: this is normally 3 (end of document), change this to end of section. + rDop.epc = 0; + } + } + SwDocShell *pDocShell(rWrt.m_rDoc.GetDocShell()); OSL_ENSURE(pDocShell, "no SwDocShell"); uno::Reference<document::XDocumentProperties> xDocProps;