diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 37fd20b323d7..981cd77471e5 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -2257,18 +2257,42 @@ bool SwFlowFrame::MoveBwd( bool &rbReformat ) const bool bEndnote = pFootnote->GetAttr()->GetFootnote().IsEndNote(); const IDocumentSettingAccess& rSettings = pFootnote->GetAttrSet()->GetDoc()->getIDocumentSettingAccess(); - if( bEndnote && pFootnote->IsInSct() ) + bool bContEndnotes = rSettings.get(DocumentSettingId::CONTINUOUS_ENDNOTES); + if( bEndnote && pFootnote->IsInSct() && !bContEndnotes) { SwSectionFrame* pSect = pFootnote->FindSctFrame(); if( pSect->IsEndnAtEnd() ) // Endnotes at the end of the section. pRef = pSect->FindLastContent( SwFindMode::LastCnt ); } - else if (bEndnote && rSettings.get(DocumentSettingId::CONTINUOUS_ENDNOTES)) + else if (bEndnote && bContEndnotes) { // Endnotes at the end of the document. - SwPageFrame* pPage = m_rThis.getRootFrame()->GetLastPage(); - pRef = pPage->FindLastBodyContent(); + SwSectionFrame* pSect = pFootnote->FindSctFrame(); + if (!pSect->GetPrev() && !pSect->FindMaster()) + { + SwLayoutFrame* pPrev = pSect->GetPrevLayoutLeaf(); + if (pPrev && pPrev->IsBodyFrame() && pSect->FindPageFrame() != pPrev->FindPageFrame()) + { + SwPageFrame* pSectPage = pSect->FindPageFrame(); + SwPageFrame* pPage = pPrev->FindPageFrame(); + if (pPage != pSectPage) + { + SwSectionFrame* pNew = new SwSectionFrame(*pSect, true); + pNew->InsertBehind(pPage->FindBodyCont(), pPage->FindLastBodyContent()); + pNew->Init(); + SwFrame* pLower = pNew->GetLower(); + if (pLower->IsColumnFrame()) + { + pRef = pLower; + } + } + } + } + else + { + pRef = pFootnote->FindFootnoteBossFrame(); + } } if( !pRef ) // Endnotes on a separate page. diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx index 0fd430ccc31d..71d1feadbb87 100644 --- a/sw/source/core/layout/ftnfrm.cxx +++ b/sw/source/core/layout/ftnfrm.cxx @@ -768,26 +768,18 @@ SwLayoutFrame *SwFrame::GetPrevFootnoteLeaf( MakePageType eMakeFootnote ) SwFrame* pTmpRef = nullptr; const IDocumentSettingAccess& rSettings = pFootnote->GetAttrSet()->GetDoc()->getIDocumentSettingAccess(); - if( bEndn && pFootnote->IsInSct() ) + bool bContEndnotes = rSettings.get(DocumentSettingId::CONTINUOUS_ENDNOTES); + if( bEndn && pFootnote->IsInSct() && !bContEndnotes) { SwSectionFrame* pSect = pFootnote->FindSctFrame(); if( pSect->IsEndnAtEnd() ) // Endnotes at the end of the section. pTmpRef = pSect->FindLastContent( SwFindMode::LastCnt ); } - else if (bEndn && rSettings.get(DocumentSettingId::CONTINUOUS_ENDNOTES)) + else if (bEndn && bContEndnotes) { // Endnotes at the end of the document. - SwPageFrame* pPage = getRootFrame()->GetLastPage(); - assert(pPage); - SwFrame* pPrevPage = pPage->GetPrev(); - if (pPrevPage) - { - // Have a last but one page, use that since we try to get a preceding frame. - assert(pPrevPage->IsPageFrame()); - pPage = static_cast(pPrevPage); - } - pTmpRef = pPage->FindLastBodyContent(); + pTmpRef = pFootnote->FindFootnoteBossFrame(); } if( !pTmpRef ) // Endnotes on a separate page. @@ -1581,8 +1573,25 @@ void SwFootnoteBossFrame::AppendFootnote( SwContentFrame *pRef, SwTextFootnote * else if (rSettings.get(DocumentSettingId::CONTINUOUS_ENDNOTES)) { // Endnotes at the end of the document. - pBoss = getRootFrame()->GetLastPage(); - pPage = pBoss->FindPageFrame(); + while ( pPage->GetNext() && !pPage->GetEndNoteSection()) + { + pPage = pPage->GetNext()->DynCastPageFrame(); + } + SwSectionFrame* pEndnoteSection = pPage->GetEndNoteSection(); + if (!pEndnoteSection) + { + SwSection* pSwSection = pDoc->GetEndNoteInfo().GetSwSection(*pDoc); + pEndnoteSection = new SwSectionFrame(*pSwSection, pPage); + pEndnoteSection->InsertBehind(pPage->FindBodyCont(), pPage->FindLastBodyContent()); + pEndnoteSection->Init(); + pEndnoteSection->SetEndNoteSection(true); + } + + SwFrame* pColumnFrame = pEndnoteSection->GetLower(); + if (pColumnFrame->IsColumnFrame()) + { + pBoss = static_cast(pColumnFrame); + } } else { @@ -1931,10 +1940,7 @@ void SwFootnoteBossFrame::CollectFootnotes_( const SwContentFrame* _pRef, bool bCollectFoundFootnote = false; // Ignore endnotes which are on a separate endnote page. bool bEndNote = _pFootnote->GetAttr()->GetFootnote().IsEndNote(); - const IDocumentSettingAccess& rSettings - = _pFootnote->GetAttrSet()->GetDoc()->getIDocumentSettingAccess(); - bool bContinuousEndnotes = rSettings.get(DocumentSettingId::CONTINUOUS_ENDNOTES); - if (_pFootnote->GetRef() == _pRef && (!bEndNote || bContinuousEndnotes)) + if (_pFootnote->GetRef() == _pRef && !bEndNote) { if (_pRefFootnoteBossFrame) { diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx index 145a3a30d00f..24a7688ee37c 100644 --- a/sw/source/core/text/txtftn.cxx +++ b/sw/source/core/text/txtftn.cxx @@ -598,8 +598,6 @@ void SwTextFrame::ConnectFootnote( SwTextFootnote *pFootnote, const SwTwips nDea mbFootnote = true; mbInFootnoteConnect = true; // Just reset! // See if pFootnote is an endnote on a separate endnote page. - const IDocumentSettingAccess& rSettings = GetDoc().getIDocumentSettingAccess(); - const bool bContinuousEndnotes = rSettings.get(DocumentSettingId::CONTINUOUS_ENDNOTES); const bool bEnd = pFootnote->GetFootnote().IsEndNote(); // We want to store this value, because it is needed as a fallback @@ -630,15 +628,11 @@ void SwTextFrame::ConnectFootnote( SwTextFootnote *pFootnote, const SwTwips nDea if( bDocEnd ) { - if ((pSect || bContinuousEndnotes) && pSrcFrame) + if (pSect && pSrcFrame) { SwFootnoteFrame *pFootnoteFrame = SwFootnoteBossFrame::FindFootnote( pSrcFrame, pFootnote ); - if (pFootnoteFrame && (pFootnoteFrame->IsInSct() || bContinuousEndnotes)) + if (pFootnoteFrame && pFootnoteFrame->IsInSct()) { - // We either have a foot/endnote that goes to the end of the section or are in Word - // compatibility mode where endnotes go to the end of the document. Handle both - // cases by removing the footnote here, then later appending them to the correct - // last page of the document or section. pBoss->RemoveFootnote( pSrcFrame, pFootnote ); pSrcFrame = nullptr; } diff --git a/sw/source/writerfilter/filter/WriterFilter.cxx b/sw/source/writerfilter/filter/WriterFilter.cxx index 742ae2bbeee2..ee8131f95ae3 100644 --- a/sw/source/writerfilter/filter/WriterFilter.cxx +++ b/sw/source/writerfilter/filter/WriterFilter.cxx @@ -333,6 +333,7 @@ void WriterFilter::setTargetDocument(const uno::Reference& xDo // rely on default for HyphenateURLs=false // rely on default for APPLY_TEXT_ATTR_TO_EMPTY_LINE_AT_END_OF_PARAGRAPH=true xSettings->setPropertyValue("DoNotMirrorRtlDrawObjs", uno::Any(true)); + xSettings->setPropertyValue("ContinuousEndnotes", uno::Any(true)); } void WriterFilter::setSourceDocument(const uno::Reference& xDoc)