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

Stephan Bergmann sbergman at redhat.com
Wed Feb 15 14:19:44 UTC 2017


 basic/source/uno/namecont.cxx             |   18 ++----------------
 basic/source/uno/scriptcont.cxx           |   28 ++++------------------------
 cli_ure/source/climaker/climaker_emit.cxx |    5 +----
 3 files changed, 7 insertions(+), 44 deletions(-)

New commits:
commit 878a8ff3f0b6b7f956e8ed40932ff47e0e56a0cd
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Feb 14 16:11:21 2017 +0100

    Some simplifications, using UNO_QUERY_THROW
    
    Change-Id: Ie7b5bb82868f517d056907567dd8e53a34d8a0b0
    Reviewed-on: https://gerrit.libreoffice.org/34273
    Tested-by: Stephan Bergmann <sbergman at redhat.com>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index ae83e5a..221c2d3 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -2076,14 +2076,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
         try
         {
             xInfoStream = xTargetLibrariesStor->openStreamElement( aStreamName, embed::ElementModes::READWRITE );
-            uno::Reference< beans::XPropertySet > xProps( xInfoStream, uno::UNO_QUERY );
-            SAL_WARN_IF(
-                !xProps.is(), "basic",
-                "The stream must implement XPropertySet!");
-            if ( !xProps.is() )
-            {
-                throw uno::RuntimeException("InfoStream doesn't implement XPropertySet");
-            }
+            uno::Reference< beans::XPropertySet > xProps( xInfoStream, uno::UNO_QUERY_THROW );
             OUString aMime( "text/xml" );
             xProps->setPropertyValue("MediaType", uno::Any( aMime ) );
 
@@ -2134,14 +2127,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
         xmlscript::exportLibraryContainer( xWriter, pLibArray.get() );
         if ( bStorage )
         {
-            uno::Reference< embed::XTransactedObject > xTransact( xTargetLibrariesStor, uno::UNO_QUERY );
-            SAL_WARN_IF(
-                !xTransact.is(), "basic",
-                "The storage must implement XTransactedObject!");
-            if ( !xTransact.is() )
-            {
-                throw uno::RuntimeException("xTargetLibrariesStor doesn't implement XTransactedObject");
-            }
+            uno::Reference< embed::XTransactedObject > xTransact( xTargetLibrariesStor, uno::UNO_QUERY_THROW );
             xTransact->commit();
         }
     }
diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx
index cfd7447..e18fe5c 100644
--- a/basic/source/uno/scriptcont.cxx
+++ b/basic/source/uno/scriptcont.cxx
@@ -668,11 +668,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons
                     uno::Reference< io::XStream > xSourceStream = xStorage->openStreamElement(
                             aSourceStreamName,
                             embed::ElementModes::READWRITE );
-                    uno::Reference< beans::XPropertySet > xProps( xSourceStream, uno::UNO_QUERY );
-                    if ( !xProps.is() )
-                    {
-                        throw uno::RuntimeException("xSourceStream doesn't implement XPropertySet");
-                    }
+                    uno::Reference< beans::XPropertySet > xProps( xSourceStream, uno::UNO_QUERY_THROW );
                     OUString aMime( "text/xml" );
                     xProps->setPropertyValue("MediaType", uno::Any( aMime ) );
 
@@ -796,13 +792,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons
                             embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE );
 
                         // #87671 Allow encryption
-                        uno::Reference< embed::XEncryptionProtectedSource > xEncr( xSourceStream, uno::UNO_QUERY );
-                        OSL_ENSURE( xEncr.is(),
-                                    "StorageStream opened for writing must implement XEncryptionProtectedSource!\n" );
-                        if ( !xEncr.is() )
-                        {
-                            throw uno::RuntimeException("xSourceStream doesn't implement XEncryptionProtectedSource");
-                        }
+                        uno::Reference< embed::XEncryptionProtectedSource > xEncr( xSourceStream, uno::UNO_QUERY_THROW );
                         xEncr->setEncryptionPassword( pLib->maPassword );
                     }
                     catch(const css::packages::WrongPasswordException& )
@@ -813,11 +803,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons
                                 pLib->maPassword );
                     }
 
-                    uno::Reference< beans::XPropertySet > xProps( xSourceStream, uno::UNO_QUERY );
-                    if ( !xProps.is() )
-                    {
-                        throw uno::RuntimeException("xSourceStream doesn't implement XPropertySet");
-                    }
+                    uno::Reference< beans::XPropertySet > xProps( xSourceStream, uno::UNO_QUERY_THROW );
                     OUString aMime( "text/xml" );
                     xProps->setPropertyValue("MediaType", uno::Any( aMime ) );
 
@@ -827,13 +813,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons
                     // i50568: sax writer already closes stream
                     // xOut->closeOutput();
 
-                    uno::Reference< embed::XTransactedObject > xTransact( xElementRootStorage, uno::UNO_QUERY );
-                    OSL_ENSURE( xTransact.is(), "The storage must implement XTransactedObject!\n" );
-                    if ( !xTransact.is() )
-                    {
-                        throw uno::RuntimeException("xElementRootStorage doesn't implement XTransactedObject");
-                    }
-
+                    uno::Reference< embed::XTransactedObject > xTransact( xElementRootStorage, uno::UNO_QUERY_THROW );
                     xTransact->commit();
                 }
                 catch(const uno::Exception& )
commit 22f96dad080e3fad30b164be8ee45caa11ae4407
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Feb 14 16:11:16 2017 +0100

    Some simplifications, using UNO_QUERY_THROW
    
    Change-Id: I3d29240b7a3aa1d8941ca97f3c3e941e884cbf8b
    Reviewed-on: https://gerrit.libreoffice.org/34272
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/cli_ure/source/climaker/climaker_emit.cxx b/cli_ure/source/climaker/climaker_emit.cxx
index 55e7bc9..720d04f 100644
--- a/cli_ure/source/climaker/climaker_emit.cxx
+++ b/cli_ure/source/climaker/climaker_emit.cxx
@@ -2266,10 +2266,7 @@ resolveInterfaceTypedef(
         return xIfaceTd;
 
     Reference<reflection::XIndirectTypeDescription> xIndTd(
-        type, UNO_QUERY);
-    if (xIndTd.is() == sal_False)
-        throw css::uno::Exception(
-            "resolveInterfaceTypedef was called with an invalid argument", 0);
+        type, UNO_QUERY_THROW);
 
     return resolveInterfaceTypedef(xIndTd->getReferencedType());
 }


More information about the Libreoffice-commits mailing list