sc/source/ui/vba/vbaapplication.cxx | 10 ++++++- sc/source/ui/vba/vbawindow.cxx | 46 +++++++++++++++++++----------------- sc/source/ui/vba/vbaworksheet.cxx | 13 ++++------ 3 files changed, 39 insertions(+), 30 deletions(-)
New commits: commit fbf3ef5e32d88655eb28b83cad3b1cf84dcc83b0 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon May 27 13:14:55 2024 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon May 27 23:28:40 2024 +0200 sc: warning C6011: Dereferencing NULL pointer Change-Id: I37d541f4c75f053023f67fc3617492bf38a13ea3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168095 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 2fceecb58024..299e6adb4527 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -664,11 +664,14 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) OUString sRangeName; if( Reference >>= sRangeName ) { + ScTabViewShell* pShell = excel::getCurrentBestViewShell( mxContext ); + if (!pShell) + return; + uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_SET_THROW ); uno::Reference< sheet::XSpreadsheetView > xSpreadsheet( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - ScTabViewShell* pShell = excel::getCurrentBestViewShell( mxContext ); ScGridWindow* gridWindow = static_cast<ScGridWindow*>(pShell->GetWindow()); try { @@ -709,8 +712,11 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) uno::Reference< excel::XRange > xRange; if( Reference >>= xRange ) { - uno::Reference< excel::XRange > xVbaRange( Reference, uno::UNO_QUERY ); ScTabViewShell* pShell = excel::getCurrentBestViewShell( mxContext ); + if (!pShell) + return; + + uno::Reference< excel::XRange > xVbaRange( Reference, uno::UNO_QUERY ); ScGridWindow* gridWindow = static_cast<ScGridWindow*>(pShell->GetWindow()); if ( xVbaRange.is() ) { diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx index 4608a2a73f02..2c860eadcf86 100644 --- a/sc/source/ui/vba/vbawindow.cxx +++ b/sc/source/ui/vba/vbawindow.cxx @@ -380,15 +380,17 @@ ScVbaWindow::getWindowState() { sal_Int32 nwindowState = xlNormal; // !! TODO !! get view shell from controller - ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); - SfxViewFrame& rViewFrame = pViewShell->GetViewFrame(); - WorkWindow* pWork = static_cast<WorkWindow*>( rViewFrame.GetFrame().GetSystemWindow() ); - if ( pWork ) + if (ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel )) { - if ( pWork -> IsMaximized()) - nwindowState = xlMaximized; - else if (pWork -> IsMinimized()) - nwindowState = xlMinimized; + SfxViewFrame& rViewFrame = pViewShell->GetViewFrame(); + WorkWindow* pWork = static_cast<WorkWindow*>( rViewFrame.GetFrame().GetSystemWindow() ); + if ( pWork ) + { + if ( pWork -> IsMaximized()) + nwindowState = xlMaximized; + else if (pWork -> IsMinimized()) + nwindowState = xlMinimized; + } } return uno::Any( nwindowState ); } @@ -399,19 +401,21 @@ ScVbaWindow::setWindowState( const uno::Any& _windowstate ) sal_Int32 nwindowState = xlMaximized; _windowstate >>= nwindowState; // !! TODO !! get view shell from controller - ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel ); - SfxViewFrame& rViewFrame = pViewShell->GetViewFrame(); - WorkWindow* pWork = static_cast<WorkWindow*>( rViewFrame.GetFrame().GetSystemWindow() ); - if ( pWork ) - { - if ( nwindowState == xlMaximized) - pWork -> Maximize(); - else if (nwindowState == xlMinimized) - pWork -> Minimize(); - else if (nwindowState == xlNormal) - pWork -> Restore(); - else - throw uno::RuntimeException(u"Invalid Parameter"_ustr ); + if (ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel )) + { + SfxViewFrame& rViewFrame = pViewShell->GetViewFrame(); + WorkWindow* pWork = static_cast<WorkWindow*>( rViewFrame.GetFrame().GetSystemWindow() ); + if ( pWork ) + { + if ( nwindowState == xlMaximized) + pWork -> Maximize(); + else if (nwindowState == xlMinimized) + pWork -> Minimize(); + else if (nwindowState == xlNormal) + pWork -> Restore(); + else + throw uno::RuntimeException(u"Invalid Parameter"_ustr ); + } } } diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index b5aa32dce8f7..4501c967e07b 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -868,14 +868,13 @@ void SAL_CALL ScVbaWorksheet::ShowDataForm( ) { uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_SET_THROW ); - ScTabViewShell* pTabViewShell = excel::getBestViewShell( xModel ); - - ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); - - ScopedVclPtr<AbstractScDataFormDlg> pDlg(pFact->CreateScDataFormDlg(pTabViewShell->GetFrameWeld(), + if (ScTabViewShell* pTabViewShell = excel::getBestViewShell( xModel )) + { + ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); + ScopedVclPtr<AbstractScDataFormDlg> pDlg(pFact->CreateScDataFormDlg(pTabViewShell->GetFrameWeld(), pTabViewShell)); - - pDlg->Execute(); + pDlg->Execute(); + } } uno::Any SAL_CALL