comphelper/source/container/embeddedobjectcontainer.cxx |   30 +++++++++-------
 comphelper/source/misc/instancelocker.cxx               |    5 +-
 comphelper/source/misc/storagehelper.cxx                |    5 +-
 3 files changed, 23 insertions(+), 17 deletions(-)

New commits:
commit b55635172405350c8cdfb18737ddd74eb5c2e26a
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed Aug 21 15:43:57 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Aug 21 19:13:44 2024 +0200

    use less exception throwing for flow control
    
    Change-Id: Iaf273c1f54977d4b422a327ffbc1086da991cc4b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172212
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx 
b/comphelper/source/container/embeddedobjectcontainer.cxx
index 561548ebc364..b01ef3b0a9c6 100644
--- a/comphelper/source/container/embeddedobjectcontainer.cxx
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx
@@ -156,8 +156,9 @@ bool EmbeddedObjectContainer::CommitImageSubStorage()
         } // if ( xSet.is() )
         if ( !bReadOnlyMode )
         {
-            uno::Reference< embed::XTransactedObject > xTransact( 
pImpl->mxImageStorage, uno::UNO_QUERY_THROW );
-            xTransact->commit();
+            uno::Reference< embed::XTransactedObject > xTransact( 
pImpl->mxImageStorage, uno::UNO_QUERY );
+            if (xTransact)
+                xTransact->commit();
         }
     }
     catch (const uno::Exception&)
@@ -684,8 +685,9 @@ uno::Reference < embed::XEmbeddedObject > 
EmbeddedObjectContainer::CopyAndGetEmb
     OUString aOrigName;
     try
     {
-        uno::Reference < embed::XEmbedPersist > xPersist( xObj, 
uno::UNO_QUERY_THROW );
-        aOrigName = xPersist->getEntryName();
+        uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY 
);
+        if (xPersist)
+            aOrigName = xPersist->getEntryName();
     }
     catch (const uno::Exception&)
     {
@@ -1071,14 +1073,16 @@ bool EmbeddedObjectContainer::InsertGraphicStream( 
const css::uno::Reference < c
         ::comphelper::OStorageHelper::CopyInputToOutput( rStream, xOutStream );
         xOutStream->flush();
 
-        uno::Reference< beans::XPropertySet > xPropSet( xGraphicStream, 
uno::UNO_QUERY_THROW );
-
-        xPropSet->setPropertyValue(u"UseCommonStoragePasswordEncryption"_ustr,
-                                    uno::Any( true ) );
-        xPropSet->setPropertyValue(u"MediaType"_ustr, uno::Any(rMediaType) );
+        uno::Reference< beans::XPropertySet > xPropSet( xGraphicStream, 
uno::UNO_QUERY );
+        if (xPropSet)
+        {
+            
xPropSet->setPropertyValue(u"UseCommonStoragePasswordEncryption"_ustr,
+                                        uno::Any( true ) );
+            xPropSet->setPropertyValue(u"MediaType"_ustr, uno::Any(rMediaType) 
);
 
-        xPropSet->setPropertyValue(u"Compressed"_ustr,
-                                    uno::Any( true ) );
+            xPropSet->setPropertyValue(u"Compressed"_ustr,
+                                        uno::Any( true ) );
+        }
     }
     catch (const uno::Exception&)
     {
@@ -1481,8 +1485,8 @@ bool EmbeddedObjectContainer::SetPersistentEntries(const 
uno::Reference< embed::
                 // if this method is used as part of SaveCompleted the object 
must stay unmodified after execution
                 try
                 {
-                    uno::Reference< util::XModifiable > xModif( 
xObj->getComponent(), uno::UNO_QUERY_THROW );
-                    if ( xModif->isModified() )
+                    uno::Reference< util::XModifiable > xModif( 
xObj->getComponent(), uno::UNO_QUERY );
+                    if ( xModif && xModif->isModified() )
                         xModif->setModified( false );
                 }
                 catch (const uno::Exception&)
diff --git a/comphelper/source/misc/instancelocker.cxx 
b/comphelper/source/misc/instancelocker.cxx
index ebb0983ace17..a1e6b5b85e59 100644
--- a/comphelper/source/misc/instancelocker.cxx
+++ b/comphelper/source/misc/instancelocker.cxx
@@ -241,8 +241,9 @@ void OLockListener::Dispose()
     {
         try
         {
-            uno::Reference< frame::XDesktop > xDesktop( xInstance, 
uno::UNO_QUERY_THROW );
-            xDesktop->removeTerminateListener( static_cast< 
frame::XTerminateListener* >( this ) );
+            uno::Reference< frame::XDesktop > xDesktop( xInstance, 
uno::UNO_QUERY );
+            if (xDesktop)
+                xDesktop->removeTerminateListener( static_cast< 
frame::XTerminateListener* >( this ) );
         }
         catch( uno::Exception& )
         {}
diff --git a/comphelper/source/misc/storagehelper.cxx 
b/comphelper/source/misc/storagehelper.cxx
index 74f056851466..8304effe6693 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -719,8 +719,9 @@ OUString OStorageHelper::GetODFVersionFromStorage(const 
uno::Reference<embed::XS
     OUString aODFVersion;
     try
     {
-        uno::Reference<beans::XPropertySet> xPropSet(xStorage, 
uno::UNO_QUERY_THROW);
-        xPropSet->getPropertyValue(u"Version"_ustr) >>= aODFVersion;
+        uno::Reference<beans::XPropertySet> xPropSet(xStorage, uno::UNO_QUERY);
+        if (xPropSet)
+            xPropSet->getPropertyValue(u"Version"_ustr) >>= aODFVersion;
     }
     catch (uno::Exception&)
     {

Reply via email to