tdf#133145 sw ContinuousEndnotes: fix moving endnotes to a previous page
Regression from commit 4814e8caa5
(tdf#124601 sw: add ContinuousEndnotes layout compat option,
2019-09-30), the problem was that SwFrame::GetPrevFootnoteLeaf() did not
take the new compat flag into account when determining the previous
footnote page for endnotes.
Do the same pattern here as the cases already handled in the above
commit, just try to get the "last but one" and not the "last" page,
since we try to move these endnotes to a previous page.
Change-Id: I77841a3a0fb68f054941184ee2a8aca0707d2a9c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96395
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
parent
f187556543
commit
35bb0594b2
3 changed files with 35 additions and 0 deletions
BIN
sw/qa/core/layout/data/continuous-endnotes-move-backwards.doc
Normal file
BIN
sw/qa/core/layout/data/continuous-endnotes-move-backwards.doc
Normal file
Binary file not shown.
|
@ -129,6 +129,23 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTablesMoveBackwards)
|
|||
assertXPath(pLayout, "//page", 1);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testContinuousEndnotesMoveBackwards)
|
||||
{
|
||||
// Load a document with the ContinuousEndnotes flag turned on.
|
||||
load(DATA_DIRECTORY, "continuous-endnotes-move-backwards.doc");
|
||||
xmlDocUniquePtr pLayout = parseLayoutDump();
|
||||
// We have 2 pages.
|
||||
assertXPath(pLayout, "/root/page", 2);
|
||||
// No endnote container on page 1.
|
||||
// Without the accompanying fix in place, this test would have failed with:
|
||||
// - Expected: 0
|
||||
// - Actual : 1
|
||||
// i.e. there were unexpected endnotes on page 1.
|
||||
assertXPath(pLayout, "/root/page[1]/ftncont", 0);
|
||||
// All endnotes are in a container on page 2.
|
||||
assertXPath(pLayout, "/root/page[2]/ftncont", 1);
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -750,13 +750,31 @@ SwLayoutFrame *SwFrame::GetPrevFootnoteLeaf( MakePageType eMakeFootnote )
|
|||
{
|
||||
bool bEndn = pFootnote->GetAttr()->GetFootnote().IsEndNote();
|
||||
SwFrame* pTmpRef = nullptr;
|
||||
const IDocumentSettingAccess& rSettings
|
||||
= pFootnote->GetAttrSet()->GetDoc()->getIDocumentSettingAccess();
|
||||
if( bEndn && pFootnote->IsInSct() )
|
||||
{
|
||||
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))
|
||||
{
|
||||
// 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<SwPageFrame*>(pPrevPage);
|
||||
}
|
||||
pTmpRef = pPage->FindLastBodyContent();
|
||||
}
|
||||
if( !pTmpRef )
|
||||
// Endnotes on a separate page.
|
||||
pTmpRef = pFootnote->GetRef();
|
||||
SwFootnoteBossFrame* pStop = pTmpRef->FindFootnoteBossFrame( !bEndn );
|
||||
|
||||
|
|
Loading…
Reference in a new issue