tdf#77760 sw floattable: add support for footnotes, layout
Once the footnote was inserted to the document model, the layout was
also missing (footnote portion, footnote frame).
One problem is that the footnote portion was empty instead of the
footnote counter, because SwTextFormatter::NewFootnotePortion() returned
early in the fly case.
The other problem was the missing footnote frame, but once the footnote
portion was created correctly, the matching footnote frame was also
created.
File filters (ODT, DOCX) still needs more work.
Change-Id: If71c44962f604f23fdcfccfe80b0d97787fd99d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155961
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
diff --git a/sw/CppunitTest_sw_core_layout.mk b/sw/CppunitTest_sw_core_layout.mk
index 9431b6b..e965ae6 100644
--- a/sw/CppunitTest_sw_core_layout.mk
+++ b/sw/CppunitTest_sw_core_layout.mk
@@ -15,6 +15,7 @@ $(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_core_layout))
$(eval $(call gb_CppunitTest_add_exception_objects,sw_core_layout, \
sw/qa/core/layout/flycnt \
sw/qa/core/layout/ftnfrm \
sw/qa/core/layout/layout \
sw/qa/core/layout/paintfrm \
sw/qa/core/layout/tabfrm \
diff --git a/sw/qa/core/layout/ftnfrm.cxx b/sw/qa/core/layout/ftnfrm.cxx
new file mode 100644
index 0000000..4c87420
--- /dev/null
+++ b/sw/qa/core/layout/ftnfrm.cxx
@@ -0,0 +1,66 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <swmodeltestbase.hxx>
#include <IDocumentLayoutAccess.hxx>
#include <docsh.hxx>
#include <formatflysplit.hxx>
#include <frmmgr.hxx>
#include <pagefrm.hxx>
#include <rootfrm.hxx>
#include <view.hxx>
#include <wrtsh.hxx>
/// Covers sw/source/core/layout/ftnfrm.cxx fixes.
class Test : public SwModelTestBase
{
public:
Test()
: SwModelTestBase("/sw/qa/core/layout/data/")
{
}
};
CPPUNIT_TEST_FIXTURE(Test, testFlySplitFootnoteLayout)
{
// Given a document with a split fly (to host a table):
createSwDoc();
SwDoc* pDoc = getSwDoc();
SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
SwFlyFrameAttrMgr aMgr(true, pWrtShell, Frmmgr_Type::TEXT, nullptr);
RndStdIds eAnchor = RndStdIds::FLY_AT_PARA;
pWrtShell->StartAllAction();
aMgr.InsertFlyFrame(eAnchor, aMgr.GetPos(), aMgr.GetSize());
pWrtShell->EndAllAction();
pWrtShell->StartAllAction();
sw::FrameFormats<sw::SpzFrameFormat*>& rFlys = *pDoc->GetSpzFrameFormats();
sw::SpzFrameFormat* pFly = rFlys[0];
SwAttrSet aSet(pFly->GetAttrSet());
aSet.Put(SwFormatFlySplit(true));
pDoc->SetAttr(aSet, *pFly);
pWrtShell->EndAllAction();
pWrtShell->UnSelectFrame();
pWrtShell->LeaveSelFrameMode();
pWrtShell->GetView().AttrChangedNotify(nullptr);
pWrtShell->MoveSection(GoCurrSection, fnSectionEnd);
// When inserting a footnote:
pWrtShell->InsertFootnote(OUString());
// Then make sure the footnote frame and its container is created:
SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
auto pPage = dynamic_cast<SwPageFrame*>(pLayout->Lower());
CPPUNIT_ASSERT(pPage);
// Without the accompanying fix in place, this test would have failed, the footnote frame was
// not created, the footnote reference was empty.
CPPUNIT_ASSERT(pPage->FindFootnoteCont());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx
index 00c5db6..b2edab8 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -41,6 +41,7 @@
#include <osl/diagnose.h>
#include <sal/log.hxx>
#include <IDocumentSettingAccess.hxx>
#include <flyfrm.hxx>
#define ENDNOTE 0x80000000
@@ -888,7 +889,15 @@ SwLayoutFrame *SwFrame::GetPrevFootnoteLeaf( MakePageType eMakeFootnote )
bool SwFrame::IsFootnoteAllowed() const
{
if ( !IsInDocBody() )
bool bSplitFly = false;
const SwFlyFrame* pFlyFrame = FindFlyFrame();
if (pFlyFrame)
{
// This is a fly. Check if it's a split fly, which is OK to host a footnote.
bSplitFly = pFlyFrame->IsFlySplitAllowed();
}
if (!IsInDocBody() && !bSplitFly)
return false;
if ( IsInTab() )