1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <swmodeltestbase.hxx>
12 #include <vcl/scheduler.hxx>
14 #include <IDocumentLayoutAccess.hxx>
15 #include <anchoredobject.hxx>
18 #include <pagefrm.hxx>
19 #include <rootfrm.hxx>
21 #include <sortedobjs.hxx>
27 /// Covers sw/source/core/layout/layact.cxx fixes.
28 class Test
: public SwModelTestBase
32 : SwModelTestBase("/sw/qa/core/layout/data/")
37 CPPUNIT_TEST_FIXTURE(Test
, testSplitFlyNextRowInvalidatePos
)
39 // Given a multi-page floating table, row1 is split, i.e. is both on page 1 and page 2:
40 createSwDoc("floattable-next-row-invalidate-pos.docx");
41 // Make sure the follow anchor's IsCompletePaint() reaches its false state, as it happens in the
43 Scheduler::ProcessEventsToIdle();
44 SwDoc
* pDoc
= getSwDoc();
45 SwRootFrame
* pLayout
= pDoc
->getIDocumentLayoutAccess().GetCurrentLayout();
46 auto pPage1
= pLayout
->Lower()->DynCastPageFrame();
47 CPPUNIT_ASSERT(pPage1
);
48 auto pPage2
= pPage1
->GetNext()->DynCastPageFrame();
49 CPPUNIT_ASSERT(pPage2
);
50 CPPUNIT_ASSERT(pPage2
->GetSortedObjs());
51 SwSortedObjs
& rPage2Objs
= *pPage2
->GetSortedObjs();
52 auto pFly2
= rPage2Objs
[0]->DynCastFlyFrame();
53 auto pTable2
= pFly2
->GetLower()->DynCastTabFrame();
54 auto pRow2
= pTable2
->GetLastLower()->DynCastRowFrame();
55 SwTwips nOldRow2Top
= pRow2
->getFrameArea().Top();
57 // When adding a new paragraph at the end of B1:
58 // Go to the table: A1 cell.
59 SwWrtShell
* pWrtShell
= getSwDocShell()->GetWrtShell();
60 pWrtShell
->GotoTable("Table1");
61 // Go to the column: B1 cell.
62 pWrtShell
->GoNextCell();
63 // Go to the end of the B1 cell, on page 2.
64 pWrtShell
->EndOfSection();
65 // Add a new paragraph at the cell end.
66 pWrtShell
->SplitNode();
68 // Then make sure row 2 is shifted down:
69 SwTwips nNewRow2Top
= pRow2
->getFrameArea().Top();
70 // Without the accompanying fix in place, this test would have failed with:
71 // - Expected greater than: 7121
73 // i.e. row 2 has to be shifted down to 7390, but this didn't happen.
74 CPPUNIT_ASSERT_GREATER(nOldRow2Top
, nNewRow2Top
);
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */