[Libreoffice-commits] core.git: basic/source vbahelper/source

Tor Lillqvist tml at collabora.com
Thu Feb 8 23:50:26 UTC 2018


 basic/source/classes/sbxmod.cxx                   |    5 ++++-
 vbahelper/source/vbahelper/vbaapplicationbase.cxx |    8 ++++++--
 vbahelper/source/vbahelper/vbahelper.cxx          |    8 +++++++-
 3 files changed, 17 insertions(+), 4 deletions(-)

New commits:
commit 73256b918119e378c762f6a3d79d04f311a075cc
Author: Tor Lillqvist <tml at collabora.com>
Date:   Thu Feb 8 19:31:20 2018 +0200

    Decrease fragility in odd use cases with no current document
    
    Change-Id: I9966166561d4c6e577f3f7e8e04572f97a0b295e
    Reviewed-on: https://gerrit.libreoffice.org/49450
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tor Lillqvist <tml at collabora.com>

diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index f0ee0f7f7f56..97fe73dbface 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -409,7 +409,10 @@ uno::Reference< vba::XVBACompatibility > getVBACompatibility( const uno::Referen
 
 bool getDefaultVBAMode( StarBASIC* pb )
 {
-    uno::Reference< vba::XVBACompatibility > xVBACompat = getVBACompatibility( getDocumentModel( pb ) );
+    uno::Reference< frame::XModel > xModel( getDocumentModel( pb ) );
+    if (!xModel.is())
+        return false;
+    uno::Reference< vba::XVBACompatibility > xVBACompat = getVBACompatibility( xModel );
     return xVBACompat.is() && xVBACompat->getVBACompatibilityMode();
 }
 
diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
index 753a389e5bb6..25e91647694b 100644
--- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx
+++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
@@ -184,7 +184,9 @@ VbaApplicationBase::~VbaApplicationBase()
 sal_Bool SAL_CALL
 VbaApplicationBase::getScreenUpdating()
 {
-    uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+    uno::Reference< frame::XModel > xModel = getCurrentDocument();
+    if (!xModel.is())
+        return false;
     return !xModel->hasControllersLocked();
 }
 
@@ -238,7 +240,9 @@ VbaApplicationBase::setDisplayStatusBar(sal_Bool bDisplayStatusBar)
 
 sal_Bool SAL_CALL VbaApplicationBase::getInteractive()
 {
-    uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+    uno::Reference< frame::XModel > xModel = getCurrentDocument();
+    if (!xModel.is())
+        return false;
     uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
     uno::Reference< awt::XWindow2 > xWindow( xFrame->getContainerWindow(), uno::UNO_QUERY_THROW );
 
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index 2471add85ce5..b7432c59935c 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -277,7 +277,13 @@ getCurrentWordDoc( const uno::Reference< uno::XComponentContext >& xContext )
     }
     catch (const uno::Exception&)
     {
-        xModel = getThisWordDoc( xContext );
+        try
+        {
+            xModel = getThisWordDoc( xContext );
+        }
+        catch (const uno::Exception&)
+        {
+        }
     }
     return xModel;
 }


More information about the Libreoffice-commits mailing list