sw/qa/core/layout/flycnt.cxx | 49 ++++++++++++++++++++++++++++++++++++++++++ sw/source/core/layout/fly.cxx | 1 2 files changed, 50 insertions(+)
New commits: commit 25a01778f998618d9a4d0de9da5784e0e60e3259 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Mar 1 08:08:43 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Mar 1 07:56:19 2023 +0000 sw floattable: update layout when enabling fly split via UNO Changing e.g. the HoriOrientPosition property resulted in a layout update, but setting IsSplitAllowed to true had no effect on the layout. The problem seems to be that the new RES_FLY_SPLIT is not handled in any update notification. Fix the problem by initially handling this the same way as RES_FRM_SIZE is already done, that triggers a 2nd page when a large fly frame is newly allowed to split, for existing fly frames as well. Disabling needs more work, still. Change-Id: I2cba04213286e72384a56a28f2b321f7fd577639 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148029 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index 75e6d64366c7..12ec5785b4f3 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -22,6 +22,12 @@ #include <sortedobjs.hxx> #include <tabfrm.hxx> #include <txtfrm.hxx> +#include <fmtfsize.hxx> +#include <docsh.hxx> +#include <wrtsh.hxx> +#include <itabenum.hxx> +#include <frmmgr.hxx> +#include <frameformats.hxx> namespace { @@ -263,6 +269,49 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyRow) // i.e. the 2nd page's fly had a wrong position. CPPUNIT_ASSERT_EQUAL(static_cast<SwTwips>(0), nPage2FlyTop - nPage2AnchorTop); } + +CPPUNIT_TEST_FIXTURE(Test, testSplitFlyEnable) +{ + // Given a document with a table in a textframe: + createSwDoc(); + SwDocShell* pDocShell = getSwDocShell(); + SwDoc* pDoc = getSwDoc(); + SwPageDesc aStandard(pDoc->GetPageDesc(0)); + SwFormatFrameSize aPageSize(aStandard.GetMaster().GetFrameSize()); + // 5cm for the page height, 2cm are the top and bottom margins, so 1cm remains for the body + // frame: + aPageSize.SetHeight(2834); + aStandard.GetMaster().SetFormatAttr(aPageSize); + pDoc->ChgPageDesc(0, aStandard); + // Insert a table: + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + SwInsertTableOptions aTableOptions(SwInsertTableFlags::DefaultBorder, 0); + pWrtShell->InsertTable(aTableOptions, /*nRows=*/2, /*nCols=*/1); + pWrtShell->MoveTable(GotoPrevTable, fnTableStart); + pWrtShell->SelAll(); + // Wrap it in a text frame: + SwFlyFrameAttrMgr aMgr(true, pWrtShell, Frmmgr_Type::TEXT, nullptr); + pWrtShell->StartAllAction(); + aMgr.InsertFlyFrame(RndStdIds::FLY_AT_PARA, aMgr.GetPos(), aMgr.GetSize()); + pWrtShell->EndAllAction(); + + // When allowing the text frame to split: + pWrtShell->StartAllAction(); + SwFrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); + SwFrameFormat* pFly = rFlys[0]; + SwAttrSet aSet(pFly->GetAttrSet()); + aSet.Put(SwFormatFlySplit(true)); + pDoc->SetAttr(aSet, *pFly); + pWrtShell->EndAllAction(); + + // Then make sure that the layout is updated and we have 2 pages: + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage1 = dynamic_cast<SwPageFrame*>(pLayout->Lower()); + CPPUNIT_ASSERT(pPage1); + auto pPage2 = dynamic_cast<SwPageFrame*>(pPage1->GetNext()); + // Without the accompanying fix in place, this test would have failed, there was no 2nd page. + CPPUNIT_ASSERT(pPage2); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 37ef27e0961e..5cfe9b3d4950 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -841,6 +841,7 @@ void SwFlyFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew, case RES_FRM_SIZE: case RES_FMT_CHG: + case RES_FLY_SPLIT: { const SwFormatFrameSize &rNew = GetFormat()->GetFrameSize(); if ( FrameSizeChg( rNew ) )