sw/source/core/access/accselectionhelper.cxx | 13 +++++-------- sw/source/core/doc/tblrwcl.cxx | 6 ++++-- sw/source/core/docnode/ndtbl.cxx | 22 +++++++++++++++------- sw/source/core/undo/untbl.cxx | 3 ++- sw/source/core/unocore/unotbl.cxx | 3 ++- sw/source/ui/vba/vbadocumentproperties.cxx | 5 +---- sw/source/ui/vba/vbaselection.cxx | 5 +---- sw/source/uibase/app/docst.cxx | 7 +++++-- sw/source/uibase/shells/textsh1.cxx | 3 ++- 9 files changed, 37 insertions(+), 30 deletions(-)
New commits: commit 3f1da0d66dc2379e822f96c75a68674f50ebb0af Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Wed Feb 15 17:06:33 2023 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Feb 16 09:25:39 2023 +0000 check GetFEShell() Similar to 24889135773204c6e3002dcb417c75ff1a99ccd0 "check GetEditShell()" These two crash reports might be related: - https://crashreport.libreoffice.org/stats/signature/SwView::GetDocShell() - https://crashreport.libreoffice.org/stats/signature/SwFEShell::UpdateTableStyleFormatting(SwTableNode%20*,bool,rtl::OUString%20const%20*) Change-Id: I7ce286f7be933b34af270abd11a4c9c4c58fe4a8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147114 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/core/access/accselectionhelper.cxx b/sw/source/core/access/accselectionhelper.cxx index 6bced3eaa053..fb56e71e35dd 100644 --- a/sw/source/core/access/accselectionhelper.cxx +++ b/sw/source/core/access/accselectionhelper.cxx @@ -89,8 +89,7 @@ void SwAccessibleSelectionHelper::selectAccessibleChild( // we can only select fly frames, so we ignore (should: return // false) all other attempts at child selection - SwFEShell* pFEShell = GetFEShell(); - if( pFEShell != nullptr ) + if (GetFEShell()) { const SdrObject *pObj = aChild.GetDrawObject(); if( pObj ) @@ -142,8 +141,7 @@ bool SwAccessibleSelectionHelper::isAccessibleChildSelected( // ... and compare to the currently selected frame bool bRet = false; - const SwFEShell* pFEShell = GetFEShell(); - if( pFEShell ) + if (const SwFEShell* pFEShell = GetFEShell()) { if ( aChild.GetSwFrame() != nullptr ) { @@ -172,7 +170,7 @@ void SwAccessibleSelectionHelper::selectAllAccessibleChildren( ) // the first we can select, and select it. SwFEShell* pFEShell = GetFEShell(); - if( !pFEShell ) + if (!pFEShell) return; std::list< SwAccessibleChild > aChildren; @@ -198,8 +196,7 @@ sal_Int64 SwAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) sal_Int64 nCount = 0; // Only one frame can be selected at a time, and we only frames // for selectable children. - const SwFEShell* pFEShell = GetFEShell(); - if( pFEShell != nullptr ) + if (const SwFEShell* pFEShell = GetFEShell()) { const SwFlyFrame* pFlyFrame = pFEShell->GetSelectedFlyFrame(); if( pFlyFrame ) @@ -251,7 +248,7 @@ Reference<XAccessible> SwAccessibleSelectionHelper::getSelectedAccessibleChild( // be 0, and a selection must exist, otherwise we have to throw an // lang::IndexOutOfBoundsException SwFEShell* pFEShell = GetFEShell(); - if( nullptr == pFEShell ) + if (!pFEShell) throwIndexOutOfBoundsException(); SwAccessibleChild aChild; diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index d45457e138d7..3f8e46ea7fb0 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -506,7 +506,8 @@ bool SwTable::InsertCol( SwDoc& rDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, pPCD->AddRowCols( *this, rBoxes, nCnt, bBehind ); rDoc.UpdateCharts( GetFrameFormat()->GetName() ); - rDoc.GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(); + if (SwFEShell* pFEShell = rDoc.GetDocShell()->GetFEShell()) + pFEShell->UpdateTableStyleFormatting(); return bRes; } @@ -624,7 +625,8 @@ bool SwTable::InsertRow_( SwDoc* pDoc, const SwSelBoxes& rBoxes, pPCD->AddRowCols( *this, rBoxes, nCnt, bBehind ); pDoc->UpdateCharts( GetFrameFormat()->GetName() ); - pDoc->GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTableNd); + if (SwFEShell* pFEShell = pDoc->GetDocShell()->GetFEShell()) + pFEShell->UpdateTableStyleFormatting(pTableNd); return true; } diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 77f7a4d3e97c..55f47b780554 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -2081,7 +2081,8 @@ bool SwDoc::DeleteRowCol(const SwSelBoxes& rBoxes, RowColMode const eMode) getIDocumentContentOperations().DeleteSection( pTableNd ); } - GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(); + if (SwFEShell* pFEShell = GetDocShell()->GetFEShell()) + pFEShell->UpdateTableStyleFormatting(); getIDocumentState().SetModified(); getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, SwNodeOffset(0) ); @@ -2115,7 +2116,8 @@ bool SwDoc::DeleteRowCol(const SwSelBoxes& rBoxes, RowColMode const eMode) bRet = rTable.DeleteSel( this, aSelBoxes, nullptr, pUndo.get(), true, true ); if (bRet) { - GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(); + if (SwFEShell* pFEShell = GetDocShell()->GetFEShell()) + pFEShell->UpdateTableStyleFormatting(); getIDocumentState().SetModified(); getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, SwNodeOffset(0) ); @@ -2180,7 +2182,8 @@ bool SwDoc::SplitTable( const SwSelBoxes& rBoxes, bool bVert, sal_uInt16 nCnt, if (bRet) { - GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(); + if (SwFEShell* pFEShell = GetDocShell()->GetFEShell()) + pFEShell->UpdateTableStyleFormatting(); getIDocumentState().SetModified(); getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, SwNodeOffset(0) ); @@ -3227,8 +3230,11 @@ void SwDoc::SplitTable( const SwPosition& rPos, SplitTable_HeadlineOption eHdlnM UpdateCharts( rTable.GetFrameFormat()->GetName() ); // update table style formatting of both the tables - GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTNd); - GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pNew); + if (SwFEShell* pFEShell = GetDocShell()->GetFEShell()) + { + pFEShell->UpdateTableStyleFormatting(pTNd); + pFEShell->UpdateTableStyleFormatting(pNew); + } getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, SwNodeOffset(0) ); } @@ -3504,7 +3510,8 @@ bool SwDoc::MergeTable( const SwPosition& rPos, bool bWithPrev ) } if( bRet ) { - GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(); + if (SwFEShell* pFEShell = GetDocShell()->GetFEShell()) + pFEShell->UpdateTableStyleFormatting(); getIDocumentState().SetModified(); getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, SwNodeOffset(0) ); @@ -4628,7 +4635,8 @@ void SwDoc::ChgTableStyle(const OUString& rName, const SwTableAutoFormat& rNewFo SwFrameFormat* pFrameFormat = &GetTableFrameFormat(i, true); SwTable* pTable = SwTable::FindTable(pFrameFormat); if (pTable->GetTableStyleName() == rName) - GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTable->GetTableNode()); + if (SwFEShell* pFEShell = GetDocShell()->GetFEShell()) + pFEShell->UpdateTableStyleFormatting(pTable->GetTableNode()); } getIDocumentState().SetModified(); diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 4621bb8d6e75..d1f8c380ccf9 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -1783,7 +1783,8 @@ void SwUndoTableNdsChg::UndoImpl(::sw::UndoRedoContext & rContext) // TL_CHART2: need to inform chart of probably changed cell names rDoc.UpdateCharts( pTableNd->GetTable().GetFrameFormat()->GetName() ); - rDoc.GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTableNd); + if (SwFEShell* pFEShell = rDoc.GetDocShell()->GetFEShell()) + pFEShell->UpdateTableStyleFormatting(pTableNd); if( IsDelBox() ) m_nSttNode = pTableNd->GetIndex(); ClearFEShellTabCols(rDoc, nullptr); diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index f1d697a36c81..882251965686 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2703,7 +2703,8 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::An SwStyleNameMapper::FillUIName(sName, sName, SwGetPoolIdFromName::TabStyle); pTable->SetTableStyleName(sName); SwDoc* pDoc = pFormat->GetDoc(); - pDoc->GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTable->GetTableNode()); + if (SwFEShell* pFEShell = pDoc->GetDocShell()->GetFEShell()) + pFEShell->UpdateTableStyleFormatting(pTable->GetTableNode()); } break; diff --git a/sw/source/ui/vba/vbadocumentproperties.cxx b/sw/source/ui/vba/vbadocumentproperties.cxx index 7b7c265591c5..6d5f06830f47 100644 --- a/sw/source/ui/vba/vbadocumentproperties.cxx +++ b/sw/source/ui/vba/vbadocumentproperties.cxx @@ -312,11 +312,8 @@ public: { if ( mpDocShell ) { - SwFEShell* pFEShell = mpDocShell->GetFEShell(); - if(pFEShell) - { + if (SwFEShell* pFEShell = mpDocShell->GetFEShell()) aReturn <<= pFEShell->GetLineCount(); - } } } else diff --git a/sw/source/ui/vba/vbaselection.cxx b/sw/source/ui/vba/vbaselection.cxx index 4a1e783dec34..d983bd2bd2a3 100644 --- a/sw/source/ui/vba/vbaselection.cxx +++ b/sw/source/ui/vba/vbaselection.cxx @@ -1115,11 +1115,8 @@ void SAL_CALL SwVbaSelection::SplitTable() SwDocShell* pDocShell = word::getDocShell( mxModel ); if( pDocShell ) { - SwFEShell* pFEShell = pDocShell->GetFEShell(); - if( pFEShell ) - { + if (SwFEShell* pFEShell = pDocShell->GetFEShell()) pFEShell->SplitTable( SplitTable_HeadlineOption::ContentCopy ); - } } } diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index f13b90b70af6..c38e51776567 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -1344,9 +1344,12 @@ void SwDocShell::UpdateStyle(const OUString &rName, SfxStyleFamily nFamily, SwWr break; case SfxStyleFamily::Table: { - if(GetFEShell()->IsTableMode()) + if (SwFEShell* pFEShell = GetFEShell()) { - GetFEShell()->TableCursorToCursor(); + if(pFEShell->IsTableMode()) + { + pFEShell->TableCursorToCursor(); + } } SwTableAutoFormat aFormat(rName); if (pCurrWrtShell->GetTableAutoFormat(aFormat)) diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 832f6d7820c1..589af9e5beeb 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -643,7 +643,8 @@ void SwTextShell::Execute(SfxRequest &rReq) rWrtSh.ResetAttr( aAttribs ); // also clear the direct formatting flag inside SwTableBox(es) - GetView().GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(nullptr, true); + if (SwFEShell* pFEShell = GetView().GetDocShell()->GetFEShell()) + pFEShell->UpdateTableStyleFormatting(nullptr, true); rReq.Done(); break;