sw/qa/extras/globalfilter/globalfilter.cxx | 4 ++- sw/qa/extras/htmlimport/htmlimport.cxx | 12 +++++---- sw/qa/extras/layout/layout.cxx | 1 sw/qa/extras/layout/layout2.cxx | 7 +++++ sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 1 sw/qa/extras/uiwriter/uiwriter.cxx | 2 + sw/qa/extras/uiwriter/uiwriter2.cxx | 1 sw/qa/extras/uiwriter/uiwriter3.cxx | 2 + sw/qa/extras/uiwriter/uiwriter4.cxx | 4 +++ sw/qa/extras/uiwriter/uiwriter5.cxx | 20 ++++++++++++++++ sw/qa/extras/uiwriter/uiwriter6.cxx | 18 ++++++++++++-- sw/qa/extras/uiwriter/uiwriter7.cxx | 35 ++++++++++++++++++++++------- sw/qa/extras/uiwriter/uiwriter8.cxx | 9 ++++++- sw/qa/extras/ww8import/ww8import.cxx | 1 sw/qa/uibase/shells/shells.cxx | 5 +++- 15 files changed, 103 insertions(+), 19 deletions(-)
New commits: commit 16a56dfccbd3abd01ec370ce611880ad5c2cb8b8 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Wed May 22 10:45:47 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu May 23 09:35:31 2024 +0200 sw/qa: warning C6011: Dereferencing NULL pointer Change-Id: I2e84af9463b82600079660a1b136bc9a85d8eb0d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167925 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index 79b9d71c7265..d4ef7c16fd20 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -199,7 +199,9 @@ void Test::testLinkedGraphicRT() CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_uLong(864900), aGraphic.GetSizeBytes()); // Check if linked graphic is registered in LinkManager - sfx2::LinkManager& rLinkManager = pTextDoc->GetDocShell()->GetDoc()->GetEditShell()->GetLinkManager(); + SwEditShell* const pEditShell(pTextDoc->GetDocShell()->GetDoc()->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); + sfx2::LinkManager& rLinkManager = pEditShell->GetLinkManager(); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), size_t(1), rLinkManager.GetLinks().size()); const tools::SvRef<sfx2::SvBaseLink> & rLink = rLinkManager.GetLinks()[0]; CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), rLink->GetLinkSourceName().indexOf("linked_graphic.jpg") >= 0); diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index e7880c3427e9..74c93ae1d064 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -49,7 +49,9 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testPictureImport) SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); CPPUNIT_ASSERT(pTextDoc); // The document contains two pictures stored as a link. - sfx2::LinkManager& rLinkManager = pTextDoc->GetDocShell()->GetDoc()->GetEditShell()->GetLinkManager(); + SwEditShell* const pEditShell(pTextDoc->GetDocShell()->GetDoc()->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); + sfx2::LinkManager& rLinkManager = pEditShell->GetLinkManager(); CPPUNIT_ASSERT_EQUAL(size_t(2), rLinkManager.GetLinks().size()); rLinkManager.Remove(0,2); CPPUNIT_ASSERT_EQUAL(size_t(0), rLinkManager.GetLinks().size()); @@ -106,8 +108,7 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testInlinedImagesPageAndParagraph) // The document contains embedded pictures inlined for PageBackground and // ParagraphBackground, check for their existence after import - SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); - SwEditShell* pEditShell = pDoc->GetEditShell(); + SwEditShell* const pEditShell(pTextDoc->GetDocShell()->GetDoc()->GetEditShell()); CPPUNIT_ASSERT(pEditShell); // images are not linked, check for zero links @@ -210,8 +211,9 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testImageWidthAuto) createSwWebDoc("image-width-auto.html"); SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); CPPUNIT_ASSERT(pTextDoc); - SwTextAttr const*const pAttr(pTextDoc->GetDocShell()->GetDoc()->GetEditShell()-> - GetCursor()->GetPointNode().GetTextNode()->GetTextAttrForCharAt(0, RES_TXTATR_FLYCNT)); + SwEditShell* const pEditShell(pTextDoc->GetDocShell()->GetDoc()->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); + SwTextAttr const*const pAttr(pEditShell->GetCursor()->GetPointNode().GetTextNode()->GetTextAttrForCharAt(0, RES_TXTATR_FLYCNT)); CPPUNIT_ASSERT(pAttr); SwFrameFormat const*const pFmt(pAttr->GetFlyCnt().GetFrameFormat()); SwFormatFrameSize const& rSize(pFmt->GetFormatAttr(RES_FRM_SIZE)); diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 95f5eb8a93d2..3fd9a4819da6 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -3490,6 +3490,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf144347) // remove first table SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); for (int i = 0; i < 12; ++i) pEditShell->AcceptRedline(0); diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index e2e80ee85981..a393f06d4306 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -840,6 +840,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf149711_importDOCXMoveToParagraphMar // reject tracked insertion (moveTo) SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), pEditShell->GetRedlineCount()); pEditShell->RejectRedline(1); @@ -903,6 +904,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf151954) // accept tracked insertion (moveTo) SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(3), pEditShell->GetRedlineCount()); pEditShell->AcceptRedline(0); @@ -1014,6 +1016,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineMoving) // create a 3-element list without change tracking SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); pEditShell->RejectRedline(0); pEditShell->AcceptRedline(0); @@ -1042,6 +1045,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineMoving2) // create a 3-element list without change tracking SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); pEditShell->RejectRedline(0); pEditShell->AcceptRedline(0); @@ -1075,6 +1079,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineMovingDOCX) SwDocShell* pShell = pDoc->GetDocShell(); SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); // This was 2 (moveFrom and moveTo joined other redlines) CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(5), pEditShell->GetRedlineCount()); @@ -1207,6 +1212,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf145225_RedlineMovingWithBadInsertio // create a 3-element list without change tracking // (because the fixed problem depends on the own changes) SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); pEditShell->RejectRedline(0); pEditShell->AcceptRedline(0); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(0), pEditShell->GetRedlineCount()); @@ -1257,6 +1263,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf146964_ReappearingMovedTextInHideCh dispatchCommand(mxComponent, ".uno:Paste", {}); SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), pEditShell->GetRedlineCount()); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index 281981e9a51a..d7795a5b1e0d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -603,6 +603,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf121867) CPPUNIT_ASSERT_EQUAL(1, getPages()); SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); SwEditShell* pEditShell = pTextDoc->GetDocShell()->GetEditShell(); + CPPUNIT_ASSERT(pEditShell); // Without the accompanying fix in place, this test would have failed with // 'Expected: 3; Actual : 0', i.e. page width zoom was lost on export. CPPUNIT_ASSERT_EQUAL(SvxZoomType::PAGEWIDTH, pEditShell->GetViewOptions()->GetZoomType()); diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 2ac9bb97ec75..9f58fc0f95b8 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -1037,6 +1037,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testWatermarkPosition) createSwDoc("watermark-position.odt"); SwDoc* pDoc = getSwDoc(); SwEditShell* pEditShell = pDoc->GetEditShell(); + CPPUNIT_ASSERT(pEditShell); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); uno::Reference<frame::XModel> xModel = pDoc->GetDocShell()->GetBaseModel(); uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(xModel, uno::UNO_QUERY); @@ -1487,6 +1488,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testMergeDoc) SwDoc* const pDoc2(pxDoc2Document->GetDocShell()->GetDoc()); SwEditShell* const pEditShell(pDoc1->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); pEditShell->MergeDoc(*pDoc2); // accept all redlines diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 15852718f463..b1835e7a0769 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -1316,6 +1316,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf145311_move_over_empty_paragraphs) dispatchCommand(mxComponent, ".uno:MoveDown", {}); SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); // This was 3 (bad conversion of the empty item to a tracked insertion) CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), pEditShell->GetRedlineCount()); diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 20b853b01468..b3a8c97c877b 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -1009,6 +1009,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf61154) const SwTOXBase* pTOXBase = pWrtShell->GetCurTOX(); pWrtShell->UpdateTableOf(*pTOXBase); SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); SwTextNode* pTitleNode = pShell->GetCursor()->GetPointNode().GetTextNode(); SwNodeIndex aIdx(*pTitleNode); @@ -1058,6 +1059,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf100691) const SwTOXBase* pTOXBase = pWrtShell->GetCurTOX(); pWrtShell->UpdateTableOf(*pTOXBase); SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); SwTextNode* pTitleNode = pShell->GetCursor()->GetPointNode().GetTextNode(); SwNodeIndex aIdx(*pTitleNode); diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx index 654bb33ae92c..d5acb6d32161 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -1249,6 +1249,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf135260) } SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); // accept all redlines while (pEditShell->GetRedlineCount()) pEditShell->AcceptRedline(0); @@ -1634,6 +1635,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf104814) SwDoc* pDoc1 = getSwDoc(); SwEditShell* const pEditShell(pDoc1->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); // accept all redlines while (pEditShell->GetRedlineCount()) @@ -1746,6 +1748,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTableRemoveHasTextChangesOnly2) // check redline count SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(14), pEditShell->GetRedlineCount()); // 4 rows in Show Changes mode @@ -1799,6 +1802,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf147182_AcceptAllChangesInTableSelec // check redline count SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(14), pEditShell->GetRedlineCount()); // 4 rows in Show Changes mode diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index 702f6d7dd30e..575fccb63397 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -578,6 +578,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf50447_keep_hints) // multiple format redlines for the multiple hints SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); // This was 1. CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(7), pEditShell->GetRedlineCount()); @@ -1027,6 +1028,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf125916_redline_restart_numbering) // Accept the first inline moveFrom redline before accepting the remaining ones // to leave a paragraph long deletion to test the fix for tdf#125916. SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT(pEditShell->GetRedlineCount() > 0); pEditShell->AcceptRedline(0); @@ -1784,6 +1786,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testRedlineTableRowDeletion) // accept the deletion of the content of the first cell SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), pEditShell->GetRedlineCount()); pEditShell->AcceptRedline(0); @@ -1896,6 +1899,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf150976) // deleted text content SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); // This was 1 before fixing tdf#151478 (testSelectRowWithNestedTable) CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(3), pEditShell->GetRedlineCount()); @@ -1949,6 +1953,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf151657) // deleted text content SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); // This was 1 before fixing tdf#151478 (testSelectRowWithNestedTable) CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(3), pEditShell->GetRedlineCount()); @@ -2107,6 +2112,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testRedlineTableRowDeletionWithExport) // accept the deletion of the content of the first cell SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), pEditShell->GetRedlineCount()); pEditShell->AcceptRedline(0); @@ -2163,6 +2169,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testRedlineTableRowDeletionWithDOCXExport) // accept the deletion of the content of the first cell SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), pEditShell->GetRedlineCount()); pEditShell->AcceptRedline(0); @@ -2195,6 +2202,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testRedlineDOCXTableInsertion) // reject the text insertions of the table cells (also reject deletion of the tabulated // text source of the table, which was used by the tracked text to table conversion) SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(10), pEditShell->GetRedlineCount()); while (pEditShell->GetRedlineCount()) pEditShell->RejectRedline(0); @@ -2249,6 +2257,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf157662_AcceptInsertRedlineCutWithDe IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(9), pEditShell->GetRedlineCount()); // Accept the insert that splitted into 3 parts .. accept all 3 of them @@ -2283,6 +2292,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf157662_RejectInsertRedlineCutWithDe IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(9), pEditShell->GetRedlineCount()); // Reject the insert that splitted into 3 parts. reject all 3 of them @@ -2311,6 +2321,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf157663_RedlineMoveRecognition) IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(23), pEditShell->GetRedlineCount()); @@ -2569,6 +2580,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf144748) dispatchCommand(mxComponent, ".uno:Redo", {}); SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); // This was 2 (bad extra redline for the empty row of the deleted table) CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), pEditShell->GetRedlineCount()); @@ -2687,6 +2699,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testRedlineTableColumnDeletion) // accept the deletion SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), pEditShell->GetRedlineCount()); pEditShell->AcceptRedline(0); @@ -3061,6 +3074,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf150673_RedlineTableColumnDeletionWi // accept the deletion of the content of the first cell SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), pEditShell->GetRedlineCount()); pEditShell->AcceptRedline(0); @@ -3147,6 +3161,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testRedlineTableColumnDeletionWithDOCXExpo // accept the deletion of the content of the first cell SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), pEditShell->GetRedlineCount()); pEditShell->AcceptRedline(0); @@ -3193,6 +3208,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf155341_RedlineTableColumnInsertionW // reject the insertion of the hidden content of the cell SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), pEditShell->GetRedlineCount()); pEditShell->RejectRedline(0); @@ -3272,6 +3288,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testRedlineTableRowDeletionWithReject) // reject the deletion of the content of the first cell // HasTextChangesOnly property of the table row will be true SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), pEditShell->GetRedlineCount()); pEditShell->RejectRedline(0); @@ -3337,6 +3354,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testRedlineTableRowInsertionWithReject) dispatchCommand(mxComponent, ".uno:InsertRowsAfter", {}); SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); // This was 0 (not tracked row insertion) CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), pEditShell->GetRedlineCount()); @@ -3397,6 +3415,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf145089_RedlineTableRowInsertionDOCX // reject redlines SwDoc* pDOCXDoc(pTextDoc->GetDocShell()->GetDoc()); SwEditShell* const pEditShell(pDOCXDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), pEditShell->GetRedlineCount()); pEditShell->RejectRedline(0); pEditShell->RejectRedline(0); @@ -3559,6 +3578,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf145091) // reject all redlines SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(3), pEditShell->GetRedlineCount()); while (pEditShell->GetRedlineCount() > 0) pEditShell->RejectRedline(0); diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx index 43c74906e10d..fb3ecb357bcd 100644 --- a/sw/qa/extras/uiwriter/uiwriter6.cxx +++ b/sw/qa/extras/uiwriter/uiwriter6.cxx @@ -580,6 +580,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf99689TableOfContents) const SwTOXBase* pTOXBase = pWrtShell->GetCurTOX(); pWrtShell->UpdateTableOf(*pTOXBase); SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); SwTextNode* pTitleNode = pShell->GetCursor()->GetPointNode().GetTextNode(); SwNodeIndex aIdx(*pTitleNode); // skip the title @@ -608,6 +609,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf99689TableOfFigures) const SwTOXBase* pTOXBase = pWrtShell->GetCurTOX(); pWrtShell->UpdateTableOf(*pTOXBase); SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); SwTextNode* pTitleNode = pShell->GetCursor()->GetPointNode().GetTextNode(); SwNodeIndex aIdx(*pTitleNode); @@ -634,6 +636,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf99689TableOfTables) const SwTOXBase* pTOXBase = pWrtShell->GetCurTOX(); pWrtShell->UpdateTableOf(*pTOXBase); SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); SwTextNode* pTitleNode = pShell->GetCursor()->GetPointNode().GetTextNode(); SwNodeIndex aIdx(*pTitleNode); @@ -963,7 +966,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf115013) CPPUNIT_ASSERT(pDoc); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); CPPUNIT_ASSERT(pWrtShell); - SwPaM* pCursor = pDoc->GetEditShell()->GetCursor(); + SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); + SwPaM* pCursor = pShell->GetCursor(); CPPUNIT_ASSERT(pCursor); // Get the field at the beginning of the document @@ -2023,6 +2028,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf124603) SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); emulateTyping(*pTextDoc, u"the "); SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); SwTextNode* pNode = pShell->GetCursor()->GetPointNode().GetTextNode(); // no bad word CPPUNIT_ASSERT_EQUAL(static_cast<SwWrongList*>(nullptr), pNode->GetWrong()); @@ -2076,6 +2082,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf45949) SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); emulateTyping(*pTextDoc, u"baaad http://www.baaad.org baaad"); SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); SwTextNode* pNode = pShell->GetCursor()->GetPointNode().GetTextNode(); // tdf#152492: Without the fix in place, this test would have failed with @@ -2132,6 +2139,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157442) SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); emulateTyping(*pTextDoc, u"ErrorError Treee2 "); SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); SwTextNode* pNode = pShell->GetCursor()->GetPointNode().GetTextNode(); // Without the fix in place, this test would have crashed because GetWrong() returns nullptr @@ -3113,7 +3121,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf146178) SwDoc* pDoc = getSwDoc(); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - SwPaM* pCursor = pDoc->GetEditShell()->GetCursor(); + SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); + SwPaM* pCursor = pShell->GetCursor(); // insert two fields dispatchCommand(mxComponent, ".uno:InsertTimeField", {}); @@ -3142,7 +3152,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf106663HeaderTextFrameGoToNextPlacem createSwDoc("testTdf106663.odt"); SwDoc* pDoc = getSwDoc(); - SwPaM* pCursor = pDoc->GetEditShell()->GetCursor(); + SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); + SwPaM* pCursor = pShell->GetCursor(); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); // Move the cursor into the fly frame of the document's header diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx b/sw/qa/extras/uiwriter/uiwriter7.cxx index e824974bef45..12a88a951def 100644 --- a/sw/qa/extras/uiwriter/uiwriter7.cxx +++ b/sw/qa/extras/uiwriter/uiwriter7.cxx @@ -213,7 +213,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTextSearch) // Create a new empty Writer document createSwDoc(); SwDoc* pDoc = getSwDoc(); - SwPaM* pCursor = pDoc->GetEditShell()->GetCursor(); + SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); + SwPaM* pCursor = pShell->GetCursor(); IDocumentContentOperations& rIDCO(pDoc->getIDocumentContentOperations()); // Insert some text rIDCO.InsertString(*pCursor, "Hello World This is a test"); @@ -590,7 +592,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf72788) createSwDoc(); SwDoc* pDoc = getSwDoc(); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - SwPaM* pCursor = pDoc->GetEditShell()->GetCursor(); + SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); + SwPaM* pCursor = pShell->GetCursor(); IDocumentContentOperations& rIDCO(pDoc->getIDocumentContentOperations()); //Insert some text - two paragraphs rIDCO.InsertString(*pCursor, "this is text"); @@ -654,7 +658,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf60967) createSwDoc(); SwDoc* pDoc = getSwDoc(); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - SwPaM* pCursor = pDoc->GetEditShell()->GetCursor(); + SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); + SwPaM* pCursor = pShell->GetCursor(); sw::UndoManager& rUndoManager = pDoc->GetUndoManager(); pWrtShell->ChangeHeaderOrFooter(u"Default Page Style", true, true, true); //Inserting table @@ -806,7 +812,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf77342) createSwDoc(); SwDoc* pDoc = getSwDoc(); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - SwPaM* pCursor = pDoc->GetEditShell()->GetCursor(); + SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); + SwPaM* pCursor = pShell->GetCursor(); //inserting first footnote pWrtShell->InsertFootnote(""); SwFieldType* pField = pWrtShell->GetFieldType(0, SwFieldIds::GetRef); @@ -1060,7 +1068,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf63553) createSwDoc(); SwDoc* pDoc = getSwDoc(); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - SwPaM* pCursor = pDoc->GetEditShell()->GetCursor(); + SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); + SwPaM* pCursor = pShell->GetCursor(); //inserting sequence field 1 SwSetExpFieldType* pSeqType = static_cast<SwSetExpFieldType*>( pWrtShell->GetFieldType(SwFieldIds::SetExp, "Illustration")); @@ -1639,7 +1649,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf83798) pWrtShell->GotoNextTOXBase(); const SwTOXBase* pTOXBase = pWrtShell->GetCurTOX(); pWrtShell->UpdateTableOf(*pTOXBase); - SwPaM* pCursor = pDoc->GetEditShell()->GetCursor(); + SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); + SwPaM* pCursor = pShell->GetCursor(); pCursor->SetMark(); pCursor->Move(fnMoveForward, GoInNode); pCursor->Move(fnMoveBackward, GoInContent); @@ -1891,6 +1903,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testUndoDelAsCharTdf107512) sw::UndoManager& rUndoManager(pDoc->GetUndoManager()); IDocumentContentOperations& rIDCO(pDoc->getIDocumentContentOperations()); SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); SfxItemSet frameSet(pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END - 1>); SfxItemSet grfSet(pDoc->GetAttrPool(), svl::Items<RES_GRFATR_BEGIN, RES_GRFATR_END - 1>); rIDCO.InsertString(*pShell->GetCursor(), "foo"); @@ -2043,7 +2056,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testUndoCharAttribute) // Create a new empty Writer document createSwDoc(); SwDoc* pDoc = getSwDoc(); - SwPaM* pCursor = pDoc->GetEditShell()->GetCursor(); + SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); + SwPaM* pCursor = pShell->GetCursor(); sw::UndoManager& rUndoManager = pDoc->GetUndoManager(); IDocumentContentOperations& rIDCO(pDoc->getIDocumentContentOperations()); // Insert some text @@ -2082,6 +2097,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testUndoDelAsChar) sw::UndoManager& rUndoManager(pDoc->GetUndoManager()); IDocumentContentOperations& rIDCO(pDoc->getIDocumentContentOperations()); SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); SfxItemSet frameSet(pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END - 1>); SfxItemSet grfSet(pDoc->GetAttrPool(), svl::Items<RES_GRFATR_BEGIN, RES_GRFATR_END - 1>); SwFormatAnchor anchor(RndStdIds::FLY_AS_CHAR); @@ -2275,6 +2291,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf127635) emulateTyping(*pXTextDocument, u"c d"); SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); // accept all redlines while (pEditShell->GetRedlineCount()) pEditShell->AcceptRedline(0); @@ -2339,7 +2356,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf94804) createSwDoc(); SwDoc* pDoc = getSwDoc(); //get cursor for making bookmark at a particular location - SwPaM* pCrsr = pDoc->GetEditShell()->GetCursor(); + SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); + SwPaM* pCrsr = pShell->GetCursor(); IDocumentMarkAccess* pIDMAccess(pDoc->getIDocumentMarkAccess()); //make first bookmark, CROSSREF_HEADING, with *empty* name sw::mark::IMark* pMark1( diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx index cf65368249af..fdc47adcbd6a 100644 --- a/sw/qa/extras/uiwriter/uiwriter8.cxx +++ b/sw/qa/extras/uiwriter/uiwriter8.cxx @@ -806,12 +806,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf140731) dispatchCommand(mxComponent, ".uno:TrackChanges", {}); SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); pShell->SelectTextModel(1, 500); dispatchCommand(mxComponent, ".uno:ChangeCaseToTitleCase", {}); SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(120), pEditShell->GetRedlineCount()); @@ -1052,6 +1054,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf152964) SwDoc* pDoc = getSwDoc(); SwEditShell* const pEditShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), pEditShell->GetRedlineCount()); dispatchCommand(mxComponent, ".uno:GoDown", {}); dispatchCommand(mxComponent, ".uno:DeleteRows", {}); @@ -2354,6 +2357,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf127652) // moving up to the previous page would not work any more sal_uInt16 assertPage = 3; SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); sal_uInt16 currentPage = pShell->GetPageNumSeqNonEmpty(); CPPUNIT_ASSERT_EQUAL_MESSAGE("We are on the wrong page!", assertPage, currentPage); } @@ -2824,7 +2828,10 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf97899) createSwDoc(); SwDoc* pDoc = getSwDoc(); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - SwPaM* pCursor = pDoc->GetEditShell()->GetCursor(); + SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); + SwPaM* pCursor = pShell->GetCursor(); + IDocumentContentOperations& rIDCO(pDoc->getIDocumentContentOperations()); // Create an Ordered List diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index d522a429d6d2..32dd9bf1e79c 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -267,6 +267,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf142003) CPPUNIT_ASSERT(pTextDoc); SwEditShell* const pEditShell(pTextDoc->GetDocShell()->GetDoc()->GetEditShell()); + CPPUNIT_ASSERT(pEditShell); pEditShell->AcceptRedline(0); //The changes were offset from where they should have been diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx index 2111cedf2502..9b27c79addb4 100644 --- a/sw/qa/uibase/shells/shells.cxx +++ b/sw/qa/uibase/shells/shells.cxx @@ -58,6 +58,7 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testTdf130179) SwDoc* pDoc = getSwDoc(); IDocumentContentOperations& rIDCO = pDoc->getIDocumentContentOperations(); SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); SfxItemSet aFrameSet(pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END - 1>); SfxItemSet aGrfSet(pDoc->GetAttrPool(), svl::Items<RES_GRFATR_BEGIN, RES_GRFATR_END - 1>); SwFormatAnchor aAnchor(RndStdIds::FLY_AT_PARA); @@ -1056,7 +1057,9 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testUpdateSelectedField) createSwDoc(); SwDoc* pDoc = getSwDoc(); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - SwPaM* pCursor = pDoc->GetEditShell()->GetCursor(); + SwCursorShell* pShell(pDoc->GetEditShell()); + CPPUNIT_ASSERT(pShell); + SwPaM* pCursor = pShell->GetCursor(); // Insert a time field and select it: dispatchCommand(mxComponent, ".uno:InsertTimeFieldVar", {});