From 7c5ae132faf03d451d6a041d822b97b9a1c04d9a Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Fri, 26 Jul 2024 17:06:00 +0200 Subject: [PATCH] sw: use calcLayout() everywhere Change-Id: Ie03a3f13808456c831db10f2203fbfb84a50b999 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171076 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sw/qa/core/layout/layout.cxx | 2 +- sw/qa/core/layout/tabfrm.cxx | 2 +- sw/qa/extras/layout/layout.cxx | 25 ++++++++++++------------- sw/qa/extras/layout/layout2.cxx | 10 ++++------ sw/qa/extras/layout/layout3.cxx | 3 +-- sw/qa/extras/uiwriter/uiwriter2.cxx | 2 +- 6 files changed, 20 insertions(+), 24 deletions(-) diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx index 59e7b54fe19d..11871b2b5f29 100644 --- a/sw/qa/core/layout/layout.cxx +++ b/sw/qa/core/layout/layout.cxx @@ -157,7 +157,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTablesMoveBackwards) pWrtShell->DelLeft(); // Calc the layout and check the number of pages. - pWrtShell->CalcLayout(); + calcLayout(); xmlDocUniquePtr pLayout = parseLayoutDump(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 1 diff --git a/sw/qa/core/layout/tabfrm.cxx b/sw/qa/core/layout/tabfrm.cxx index c74985c32bfc..cc60c3cd4bc5 100644 --- a/sw/qa/core/layout/tabfrm.cxx +++ b/sw/qa/core/layout/tabfrm.cxx @@ -251,7 +251,7 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyHeader) pWrtShell->SttEndDoc(/*bStt=*/true); pWrtShell->SplitNode(); // Without the accompanying fix in place, this test would have crashed here. - pWrtShell->CalcLayout(); + calcLayout(); // Then make sure we get one more page, since the first page is now 2 pages: CPPUNIT_ASSERT_EQUAL(9, getPages()); diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index ea03eef254de..81d5511d065f 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -3321,7 +3321,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineSections) dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); // why is this needed explicitly? - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); @@ -3399,7 +3399,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineSections) dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); // why is this needed explicitly? - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); discardDumpedLayout(); CheckRedlineSectionsHidden(); } @@ -3444,7 +3444,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineTables) dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); // why is this needed explicitly? - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -3504,7 +3504,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testRedlineTables) dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); // why is this needed explicitly? - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/merged"_ostr, "paraPropsNodeIndex"_ostr, @@ -3549,7 +3549,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf144057) // hide tracked table and table row deletions dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -3565,7 +3565,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf144057) // show tracked table and table row deletions again dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); assertXPath(pXmlDoc, "/root/page"_ostr, 4); @@ -3607,7 +3607,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf144347) for (int i = 0; i < 12; ++i) pEditShell->AcceptRedline(0); - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); // show tracked row deletions @@ -3621,7 +3621,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf144347) dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {}); dispatchCommand(mxComponent, u".uno:Delete"_ustr, {}); - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -3633,7 +3633,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf144347) while (pEditShell->GetRedlineCount() > 0) pEditShell->AcceptRedline(0); - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -3670,7 +3670,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf155345) // hide tracked table column deletions dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); @@ -3680,7 +3680,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf155345) // show tracked table column deletions again dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); discardDumpedLayout(); pXmlDoc = parseLayoutDump(); assertXPath(pXmlDoc, "/root/page"_ostr, 4); @@ -3768,9 +3768,8 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf147485Forcepoint) CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf118058) { createSwDoc("tdf118058.fodt"); - SwDoc* pDoc = getSwDoc(); // This resulted in a layout loop. - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); } //just care it doesn't crash/assert diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index b8ae7c8c6a41..08daf9024d5c 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -287,7 +287,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineCharAttributes) dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); // why is this needed explicitly? - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); discardDumpedLayout(); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); @@ -526,7 +526,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineCharAttributes) dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); CPPUNIT_ASSERT(pLayout->IsHideRedlines()); // why is this needed explicitly? - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); CheckRedlineCharAttributesHidden(); } @@ -583,7 +583,6 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testtdf138951) { // Open the bugdoc createSwDoc("tdf138951.odt"); - auto pDoc = getSwDoc(); // Get the only shape uno::Reference xShape(getShape(1), uno::UNO_QUERY); @@ -595,7 +594,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testtdf138951) const SwFrameFormat* pShFrm = SwTextBoxHelper::getOtherTextBoxFormat(pTxFrm, RES_FLYFRMFMT); CPPUNIT_ASSERT(pShFrm); - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); // Get the bound rectangle of the textframe tools::Rectangle aTxtFrmRect(pTxFrm->FindRealSdrObject()->GetLogicRect()); @@ -2430,9 +2429,8 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTableExtrusion2) CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf116848) { createSwDoc("tdf116848.odt"); - SwDoc* pDoc = getSwDoc(); // This resulted in a layout loop. - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf117245) diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index 69cb4922f924..239647e60f3f 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -1364,9 +1364,8 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf130218) CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf127235) { createSwDoc("tdf127235.odt"); - SwDoc* pDoc = getSwDoc(); // This resulted in a layout loop. - pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()->CalcLayout(); + calcLayout(); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf138039) diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 7d7afac16253..1ed402c2e02d 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -307,7 +307,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testRedlineSplitContentNode) sw::UndoManager& rUndoManager = pDoc->GetUndoManager(); - pWrtShell->CalcLayout(); + calcLayout(); pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 18, /*bBasicCall=*/false); pWrtShell->SplitNode(true); rUndoManager.Undo();