summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-05-27 13:14:55 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2024-05-27 23:28:40 +0200
commitfbf3ef5e32d88655eb28b83cad3b1cf84dcc83b0 (patch)
tree564c9e6afffebf9cd61088a3ddb518941d99c79d /sc
parentbd91407294358745553c9c364728c8fc83a85f2f (diff)
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 <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/vba/vbaapplication.cxx10
-rw-r--r--sc/source/ui/vba/vbawindow.cxx46
-rw-r--r--sc/source/ui/vba/vbaworksheet.cxx13
3 files changed, 39 insertions, 30 deletions
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