summaryrefslogtreecommitdiff
path: root/sc/source/ui/vba/vbaapplication.cxx
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-05-18 13:31:14 +0200
committerCaolán McNamara <caolan.mcnamara@collabora.com>2023-05-19 10:06:45 +0200
commit286a1c03fa10acf60f076a0af987112d24cb2ff5 (patch)
tree506aa529a3c3bc0eb705603866180aba2bdc2e44 /sc/source/ui/vba/vbaapplication.cxx
parent63707596eefa4f141a5c7146e69bb5684ed51cf6 (diff)
sc: check excel::getDocShell
There seems to be some crashes related. See https://crashreport.libreoffice.org/stats/signature/ScDocShell::GetDocument() or https://crashreport.libreoffice.org/stats/signature/ScDocShell::RegisterAutomationWorkbookObject(com::sun::star::uno::Reference%3Cooo::vba::excel::XWorkbook%3E%20const%20&) Change-Id: I9affce5a28cb1198eb472d369debf83fd7dd8c0e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151955 Tested-by: Jenkins Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sc/source/ui/vba/vbaapplication.cxx')
-rw-r--r--sc/source/ui/vba/vbaapplication.cxx13
1 files changed, 10 insertions, 3 deletions
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
index d9e5ba984f5a..f951cbd4581b 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -1203,7 +1203,8 @@ uno::Reference< excel::XRange > lclCreateVbaRange(
const ListOfScRange& rList )
{
ScDocShell* pDocShell = excel::getDocShell( rxModel );
- if( !pDocShell ) throw uno::RuntimeException();
+ if( !pDocShell )
+ throw uno::RuntimeException();
ScRangeList aCellRanges;
for( const auto& rItem : rList )
@@ -1350,8 +1351,11 @@ ScVbaApplication::Volatile( const uno::Any& aVolatile )
if ( pMeth )
{
uno::Reference< frame::XModel > xModel( getCurrentDocument() );
- ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument();
- rDoc.GetMacroManager()->SetUserFuncVolatile( pMeth->GetName(), bVolatile);
+ if ( ScDocShell* pShell = excel::getDocShell( xModel ))
+ {
+ ScDocument& rDoc = pShell->GetDocument();
+ rDoc.GetMacroManager()->SetUserFuncVolatile( pMeth->GetName(), bVolatile);
+ }
}
// this is bound to break when loading the document
@@ -1451,7 +1455,10 @@ void SAL_CALL ScVbaApplication::setScreenUpdating(sal_Bool bUpdate)
VbaApplicationBase::setScreenUpdating( bUpdate );
uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ), uno::UNO_SET_THROW );
+
ScDocShell* pDocShell = excel::getDocShell( xModel );
+ if (!pDocShell)
+ return;
ScDocument& rDoc = pDocShell->GetDocument();
if( bUpdate )