sw/source/core/doc/docxforms.cxx                     |    7 +-
 sw/source/core/layout/dumpfilter.cxx                 |    5 +
 sw/source/core/ole/ndole.cxx                         |    4 +
 sw/source/core/swg/SwXMLTextBlocks.cxx               |    9 ++-
 sw/source/core/swg/SwXMLTextBlocks1.cxx              |   17 +++---
 sw/source/core/unocore/unochart.cxx                  |    5 +
 sw/source/filter/ww8/wrtww8gr.cxx                    |   16 +++---
 sw/source/filter/ww8/ww8par.cxx                      |   19 +++----
 sw/source/ui/dbui/mmoutputtypepage.cxx               |   13 +++--
 sw/source/ui/vba/vbadocument.cxx                     |   14 +++--
 sw/source/ui/vba/vbarange.cxx                        |    5 +
 sw/source/uibase/dbui/dbmgr.cxx                      |   15 +++--
 sw/source/uibase/misc/glshell.cxx                    |    5 +
 sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx |    4 +
 toolkit/source/hatchwindow/documentcloser.cxx        |   27 +++++-----
 ucb/source/ucp/cmis/cmis_datasupplier.cxx            |   48 +++++++++---------
 ucb/source/ucp/gio/gio_datasupplier.cxx              |   49 +++++++++----------
 17 files changed, 146 insertions(+), 116 deletions(-)

New commits:
commit 14b7b50701e3874034f7f98a73794ba8a79792bf
Author:     Noel Grandin <[email protected]>
AuthorDate: Tue Aug 13 13:29:23 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Wed Aug 14 12:56:50 2024 +0200

    use less exception throwing for flow control
    
    Change-Id: I289f1a2204af02576a585392b7f428a5dc65cf1a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171850
    Reviewed-by: Noel Grandin <[email protected]>
    Tested-by: Jenkins

diff --git a/sw/source/core/doc/docxforms.cxx b/sw/source/core/doc/docxforms.cxx
index 65dd7221ae7d..1924cddc56db 100644
--- a/sw/source/core/doc/docxforms.cxx
+++ b/sw/source/core/doc/docxforms.cxx
@@ -70,9 +70,10 @@ void SwDoc::initXForms( bool bCreateDefaultModel )
             OUString sName(u"Model 1"_ustr);
             Reference<XModel2> xModel = xforms::Model::create( 
comphelper::getProcessComponentContext() );
             xModel->setID( sName );
-            Reference<XFormsUIHelper1>( xModel, uno::UNO_QUERY_THROW 
)->newInstance(
-                u"Instance 1"_ustr,
-                OUString(), true );
+            Reference<XFormsUIHelper1> xHelper( xModel, uno::UNO_QUERY );
+            if (!xHelper)
+                return;
+            xHelper->newInstance(u"Instance 1"_ustr, OUString(), true );
             xModel->initialize();
             mxXForms->insertByName( sName, Any( xModel ) );
             OSL_ENSURE( mxXForms->hasElements(), "can't create XForms model" );
diff --git a/sw/source/core/layout/dumpfilter.cxx 
b/sw/source/core/layout/dumpfilter.cxx
index f5dfc2d661ae..28b667b0a7b6 100644
--- a/sw/source/core/layout/dumpfilter.cxx
+++ b/sw/source/core/layout/dumpfilter.cxx
@@ -53,8 +53,9 @@ namespace
         try
         {
             uno::XInterface* pObj = static_cast<uno::XInterface*>(pContext);
-            uno::Reference< io::XOutputStream > xOut( pObj, 
uno::UNO_QUERY_THROW );
-            xOut->closeOutput( );
+            uno::Reference< io::XOutputStream > xOut( pObj, uno::UNO_QUERY );
+            if (xOut)
+                xOut->closeOutput( );
         }
         catch (const uno::Exception&)
         {
diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx
index ea16a0aca80f..26dbd086f8c1 100644
--- a/sw/source/core/ole/ndole.cxx
+++ b/sw/source/core/ole/ndole.cxx
@@ -626,7 +626,9 @@ void SwOLENode::BreakFileLink_Impl()
 
     try
     {
-        uno::Reference< embed::XLinkageSupport > xLinkSupport( 
maOLEObj.GetOleRef(), uno::UNO_QUERY_THROW );
+        uno::Reference< embed::XLinkageSupport > xLinkSupport( 
maOLEObj.GetOleRef(), uno::UNO_QUERY );
+        if (!xLinkSupport)
+            return;
         xLinkSupport->breakLink( xStorage, maOLEObj.GetCurrentPersistName() );
         DisconnectFileLink_Impl();
         maLinkURL.clear();
diff --git a/sw/source/core/swg/SwXMLTextBlocks.cxx 
b/sw/source/core/swg/SwXMLTextBlocks.cxx
index b9ec1e2b35fe..00e1d750d5b6 100644
--- a/sw/source/core/swg/SwXMLTextBlocks.cxx
+++ b/sw/source/core/swg/SwXMLTextBlocks.cxx
@@ -293,9 +293,12 @@ ErrCode SwXMLTextBlocks::StartPutBlock( const OUString& 
rShort, const OUString&
     {
         m_xRoot = m_xBlkRoot->openStorageElement( rPackageName, 
embed::ElementModes::READWRITE );
 
-        uno::Reference< beans::XPropertySet > xRootProps( m_xRoot, 
uno::UNO_QUERY_THROW );
-        OUString aMime( SotExchange::GetFormatMimeType( 
SotClipboardFormatId::STARWRITER_8 ) );
-        xRootProps->setPropertyValue( u"MediaType"_ustr, uno::Any( aMime ) );
+        uno::Reference< beans::XPropertySet > xRootProps( m_xRoot, 
uno::UNO_QUERY );
+        if (xRootProps)
+        {
+            OUString aMime( SotExchange::GetFormatMimeType( 
SotClipboardFormatId::STARWRITER_8 ) );
+            xRootProps->setPropertyValue( u"MediaType"_ustr, uno::Any( aMime ) 
);
+        }
     }
     catch (const uno::Exception&)
     {
diff --git a/sw/source/core/swg/SwXMLTextBlocks1.cxx 
b/sw/source/core/swg/SwXMLTextBlocks1.cxx
index f5beebf6164d..3821138022ed 100644
--- a/sw/source/core/swg/SwXMLTextBlocks1.cxx
+++ b/sw/source/core/swg/SwXMLTextBlocks1.cxx
@@ -76,14 +76,17 @@ ErrCode SwXMLTextBlocks::GetDoc( sal_uInt16 nIdx )
             OUString sObjReplacements( u"ObjectReplacements"_ustr );
             if ( m_xRoot->hasByName( sObjReplacements ) )
             {
-                uno::Reference< document::XStorageBasedDocument > xDocStor( 
m_xDoc->GetDocShell()->GetModel(), uno::UNO_QUERY_THROW );
-                uno::Reference< embed::XStorage > xStr( 
xDocStor->getDocumentStorage() );
-                if ( xStr.is() )
+                uno::Reference< document::XStorageBasedDocument > xDocStor( 
m_xDoc->GetDocShell()->GetModel(), uno::UNO_QUERY );
+                if (xDocStor)
                 {
-                    m_xRoot->copyElementTo( sObjReplacements, xStr, 
sObjReplacements );
-                    uno::Reference< embed::XTransactedObject > xTrans( xStr, 
uno::UNO_QUERY );
-                    if ( xTrans.is() )
-                        xTrans->commit();
+                    uno::Reference< embed::XStorage > xStr( 
xDocStor->getDocumentStorage() );
+                    if ( xStr.is() )
+                    {
+                        m_xRoot->copyElementTo( sObjReplacements, xStr, 
sObjReplacements );
+                        uno::Reference< embed::XTransactedObject > xTrans( 
xStr, uno::UNO_QUERY );
+                        if ( xTrans.is() )
+                            xTrans->commit();
+                    }
                 }
             }
         }
diff --git a/sw/source/core/unocore/unochart.cxx 
b/sw/source/core/unocore/unochart.cxx
index 5872b607f753..996f96cfcc63 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -71,8 +71,9 @@ void SwChartHelper::DoUpdateAllCharts( SwDoc* pDoc )
             {
                 try
                 {
-                    uno::Reference< util::XModifiable > xModif( 
xIP->getComponent(), uno::UNO_QUERY_THROW );
-                    xModif->setModified( true );
+                    uno::Reference< util::XModifiable > xModif( 
xIP->getComponent(), uno::UNO_QUERY );
+                    if (xModif)
+                        xModif->setModified( true );
                 }
                 catch ( uno::Exception& )
                 {
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx 
b/sw/source/filter/ww8/wrtww8gr.cxx
index f8f4c813cd6f..721cd574be08 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -151,14 +151,14 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& 
rSet, rtl::Reference<SotSto
                 comphelper::EmbeddedObjectContainer aCnt( 
m_rDoc.GetDocStorage() );
                 try
                 {
-                    uno::Reference< embed::XEmbedPersist > xPersist(
-                            xObj,
-                            uno::UNO_QUERY_THROW );
-
-                    // it makes no sense to search the object in the container 
by reference since the object was created
-                    // outside of the container and was not inserted there, 
only the name makes sense
-                    pGraphicStream =
-                            ::utl::UcbStreamHelper::CreateStream( 
aCnt.GetGraphicStream( xPersist->getEntryName() ) );
+                    uno::Reference< embed::XEmbedPersist > xPersist(xObj, 
uno::UNO_QUERY );
+                    if (xPersist)
+                    {
+                        // it makes no sense to search the object in the 
container by reference since the object was created
+                        // outside of the container and was not inserted 
there, only the name makes sense
+                        pGraphicStream =
+                                ::utl::UcbStreamHelper::CreateStream( 
aCnt.GetGraphicStream( xPersist->getEntryName() ) );
+                    }
                 }
                 catch( const uno::Exception& )
                 {}
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 9812199f1d64..ef09c6e08006 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -398,17 +398,18 @@ OUString BasicProjImportHelper::getProjectName() const
 {
     OUString sProjName( u"Standard"_ustr );
     uno::Reference< beans::XPropertySet > xProps( mrDocShell.GetModel(), 
uno::UNO_QUERY );
-    if ( xProps.is() )
+    if ( !xProps )
+        return sProjName;
+    try
     {
-        try
-        {
-            uno::Reference< script::vba::XVBACompatibility > xVBA( 
xProps->getPropertyValue( u"BasicLibraries"_ustr ), uno::UNO_QUERY_THROW  );
-            sProjName = xVBA->getProjectName();
+        uno::Reference< script::vba::XVBACompatibility > xVBA( 
xProps->getPropertyValue( u"BasicLibraries"_ustr ), uno::UNO_QUERY  );
+        if ( !xVBA )
+            return sProjName;
+        sProjName = xVBA->getProjectName();
 
-        }
-        catch( const uno::Exception& )
-        {
-        }
+    }
+    catch( const uno::Exception& )
+    {
     }
     return sProjName;
 }
diff --git a/sw/source/ui/dbui/mmoutputtypepage.cxx 
b/sw/source/ui/dbui/mmoutputtypepage.cxx
index 33033f0a94ce..27430ce63c60 100644
--- a/sw/source/ui/dbui/mmoutputtypepage.cxx
+++ b/sw/source/ui/dbui/mmoutputtypepage.cxx
@@ -173,11 +173,14 @@ void SwMailDispatcherListener_Impl::DeleteAttachments( 
uno::Reference< mail::XMa
     {
         try
         {
-            uno::Reference< beans::XPropertySet > xTransferableProperties( 
rAttachment.Data, uno::UNO_QUERY_THROW);
-            OUString sURL;
-            xTransferableProperties->getPropertyValue(u"URL"_ustr) >>= sURL;
-            if(!sURL.isEmpty())
-                SWUnoHelper::UCB_DeleteFile( sURL );
+            uno::Reference< beans::XPropertySet > xTransferableProperties( 
rAttachment.Data, uno::UNO_QUERY);
+            if (xTransferableProperties)
+            {
+                OUString sURL;
+                xTransferableProperties->getPropertyValue(u"URL"_ustr) >>= 
sURL;
+                if(!sURL.isEmpty())
+                    SWUnoHelper::UCB_DeleteFile( sURL );
+            }
         }
         catch (const uno::Exception&)
         {
diff --git a/sw/source/ui/vba/vbadocument.cxx b/sw/source/ui/vba/vbadocument.cxx
index 2588c153788a..c7a110d016ef 100644
--- a/sw/source/ui/vba/vbadocument.cxx
+++ b/sw/source/ui/vba/vbadocument.cxx
@@ -692,13 +692,19 @@ SwVbaDocument::getFormControls() const
     uno::Reference< container::XNameAccess > xFormControls;
     try
     {
-        uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( 
mxTextDocument, uno::UNO_QUERY_THROW );
-        uno::Reference< form::XFormsSupplier >  xFormSupplier( 
xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
-        uno::Reference< container::XIndexAccess > xIndexAccess( 
xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
+        uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( 
mxTextDocument, uno::UNO_QUERY );
+        if (!xDrawPageSupplier)
+            return xFormControls;
+        uno::Reference< form::XFormsSupplier >  xFormSupplier( 
xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY );
+        if (!xFormSupplier)
+            return xFormControls;
+        uno::Reference< container::XIndexAccess > xIndexAccess( 
xFormSupplier->getForms(), uno::UNO_QUERY );
+        if (!xIndexAccess)
+            return xFormControls;
         // get the www-standard container ( maybe we should access the
         // 'www-standard' by name rather than index, this seems an
         // implementation detail
-        xFormControls.set( xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW );
+        xFormControls.set( xIndexAccess->getByIndex(0), uno::UNO_QUERY );
     }
     catch(const uno::Exception&)
     {
diff --git a/sw/source/ui/vba/vbarange.cxx b/sw/source/ui/vba/vbarange.cxx
index 39d369c92144..722dcfce92b1 100644
--- a/sw/source/ui/vba/vbarange.cxx
+++ b/sw/source/ui/vba/vbarange.cxx
@@ -134,8 +134,9 @@ SwVbaRange::setText( const OUString& rText )
         uno::Reference< text::XTextContent > xBookmark = 
SwVbaRangeHelper::findBookmarkByPosition( mxTextDocument, xRange->getStart() );
         if( xBookmark.is() )
         {
-            uno::Reference< container::XNamed > xNamed( xBookmark, 
uno::UNO_QUERY_THROW );
-            sName = xNamed->getName();
+            uno::Reference< container::XNamed > xNamed( xBookmark, 
uno::UNO_QUERY );
+            if (xNamed)
+                sName = xNamed->getName();
         }
     }
     catch (const uno::Exception&)
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 51e7cc4c259a..fd1b7bd1f6db 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -1887,13 +1887,14 @@ uno::Reference< sdbc::XConnection> 
SwDBManager::GetConnection(const OUString& rD
     try
     {
         uno::Reference<sdb::XCompletedConnection> 
xComplConnection(dbtools::getDataSource(rDataSource, xContext), uno::UNO_QUERY);
-        if ( xComplConnection.is() )
-        {
-            rxSource.set(xComplConnection, uno::UNO_QUERY);
-            weld::Window* pWindow = pView ? pView->GetFrameWeld() : nullptr;
-            uno::Reference< task::XInteractionHandler > xHandler( 
task::InteractionHandler::createWithParent(xContext, pWindow ? 
pWindow->GetXWindow() : nullptr), uno::UNO_QUERY_THROW );
-            xConnection = xComplConnection->connectWithCompletion( xHandler );
-        }
+        if ( !xComplConnection )
+            return xConnection;
+        rxSource.set(xComplConnection, uno::UNO_QUERY);
+        weld::Window* pWindow = pView ? pView->GetFrameWeld() : nullptr;
+        uno::Reference< task::XInteractionHandler > xHandler( 
task::InteractionHandler::createWithParent(xContext, pWindow ? 
pWindow->GetXWindow() : nullptr) );
+        if (!xHandler)
+            return xConnection;
+        xConnection = xComplConnection->connectWithCompletion( xHandler );
     }
     catch(const uno::Exception&)
     {
diff --git a/sw/source/uibase/misc/glshell.cxx 
b/sw/source/uibase/misc/glshell.cxx
index b15be1f8f833..fcd31ec39ea8 100644
--- a/sw/source/uibase/misc/glshell.cxx
+++ b/sw/source/uibase/misc/glshell.cxx
@@ -252,8 +252,9 @@ SwDocShellRef SwGlossaries::EditGroupDoc( const OUString& 
rGroup, const OUString
         try
         {
             // set the UI-title
-            uno::Reference< frame::XTitle > xTitle( xDocSh->GetModel(), 
uno::UNO_QUERY_THROW );
-            xTitle->setTitle( aDocTitle );
+            uno::Reference< frame::XTitle > xTitle( xDocSh->GetModel(), 
uno::UNO_QUERY );
+            if (xTitle)
+                xTitle->setTitle( aDocTitle );
         }
         catch (const uno::Exception&)
         {
diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx 
b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
index 8f871c2a19df..9dde50e56336 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx
@@ -5755,7 +5755,9 @@ void DomainMapper_Impl::SetNumberFormat( const OUString& 
rCommand,
     try
     {
         sal_Int32 nKey = 0;
-        uno::Reference< util::XNumberFormatsSupplier > xNumberSupplier( 
static_cast<cppu::OWeakObject*>(m_xTextDocument.get()), uno::UNO_QUERY_THROW );
+        uno::Reference< util::XNumberFormatsSupplier > xNumberSupplier( 
static_cast<cppu::OWeakObject*>(m_xTextDocument.get()), uno::UNO_QUERY );
+        if (!xNumberSupplier)
+            return;
         if( bDetectFormat )
         {
             uno::Reference< util::XNumberFormatter> 
xFormatter(util::NumberFormatter::create(m_xComponentContext), 
uno::UNO_QUERY_THROW);
diff --git a/toolkit/source/hatchwindow/documentcloser.cxx 
b/toolkit/source/hatchwindow/documentcloser.cxx
index b11a71df3124..53277e698292 100644
--- a/toolkit/source/hatchwindow/documentcloser.cxx
+++ b/toolkit/source/hatchwindow/documentcloser.cxx
@@ -108,16 +108,18 @@ IMPL_STATIC_LINK( MainThreadFrameCloserRequest, worker, 
void*, p, void )
         try
         {
             uno::Reference< awt::XWindow > xWindow = 
pMTRequest->m_xFrame->getContainerWindow();
-            uno::Reference< awt::XVclWindowPeer > xWinPeer( xWindow, 
uno::UNO_QUERY_THROW );
-
-            xWindow->setVisible( false );
-
-            // reparent the window
-            xWinPeer->setProperty( u"PluginParent"_ustr, uno::Any( 
sal_Int64(0) ) );
-
-            VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
-            if (pWindow)
-                vcl::EndAllDialogs(pWindow);
+            uno::Reference< awt::XVclWindowPeer > xWinPeer( xWindow, 
uno::UNO_QUERY );
+            if (xWinPeer)
+            {
+                xWindow->setVisible( false );
+
+                // reparent the window
+                xWinPeer->setProperty( u"PluginParent"_ustr, uno::Any( 
sal_Int64(0) ) );
+
+                VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow 
);
+                if (pWindow)
+                    vcl::EndAllDialogs(pWindow);
+            }
         }
         catch( uno::Exception& )
         {
@@ -126,8 +128,9 @@ IMPL_STATIC_LINK( MainThreadFrameCloserRequest, worker, 
void*, p, void )
 
         try
         {
-            uno::Reference< util::XCloseable > xCloseable( 
pMTRequest->m_xFrame, uno::UNO_QUERY_THROW );
-            xCloseable->close( true );
+            uno::Reference< util::XCloseable > xCloseable( 
pMTRequest->m_xFrame, uno::UNO_QUERY );
+            if (xCloseable)
+                xCloseable->close( true );
         }
         catch( uno::Exception& )
         {
diff --git a/ucb/source/ucp/cmis/cmis_datasupplier.cxx 
b/ucb/source/ucp/cmis/cmis_datasupplier.cxx
index 2a91770cd8f6..21ac2602de41 100644
--- a/ucb/source/ucp/cmis/cmis_datasupplier.cxx
+++ b/ucb/source/ucp/cmis/cmis_datasupplier.cxx
@@ -107,34 +107,34 @@ namespace cmis
             }
         }
 
-        if ( getResult( nIndex ) )
+        if ( !getResult( nIndex ) )
+            return {};
+
+        uno::Reference< ucb::XContent > xContent( queryContent( nIndex ) );
+        if ( !xContent )
+            return {};
+        try
         {
-            uno::Reference< ucb::XContent > xContent( queryContent( nIndex ) );
-            if ( xContent.is() )
+            uno::Reference< ucb::XCommandProcessor > xCmdProc( xContent, 
uno::UNO_QUERY );
+            if ( !xCmdProc )
+                return {};
+            sal_Int32 nCmdId( xCmdProc->createCommandIdentifier() );
+            ucb::Command aCmd;
+            aCmd.Name = "getPropertyValues";
+            aCmd.Handle = -1;
+            aCmd.Argument <<= getResultSet()->getProperties();
+            uno::Any aResult( xCmdProc->execute(
+                aCmd, nCmdId, getResultSet()->getEnvironment() ) );
+            uno::Reference< sdbc::XRow > xRow;
+            if ( aResult >>= xRow )
             {
-                try
-                {
-                    uno::Reference< ucb::XCommandProcessor > xCmdProc(
-                        xContent, uno::UNO_QUERY_THROW );
-                    sal_Int32 nCmdId( xCmdProc->createCommandIdentifier() );
-                    ucb::Command aCmd;
-                    aCmd.Name = "getPropertyValues";
-                    aCmd.Handle = -1;
-                    aCmd.Argument <<= getResultSet()->getProperties();
-                    uno::Any aResult( xCmdProc->execute(
-                        aCmd, nCmdId, getResultSet()->getEnvironment() ) );
-                    uno::Reference< sdbc::XRow > xRow;
-                    if ( aResult >>= xRow )
-                    {
-                        maResults[ nIndex ].xRow = xRow;
-                        return xRow;
-                    }
-                }
-                catch ( uno::Exception const & )
-                {
-                }
+                maResults[ nIndex ].xRow = xRow;
+                return xRow;
             }
         }
+        catch ( uno::Exception const & )
+        {
+        }
         return uno::Reference< sdbc::XRow >();
     }
 
diff --git a/ucb/source/ucp/gio/gio_datasupplier.cxx 
b/ucb/source/ucp/gio/gio_datasupplier.cxx
index 01fdc3e574ea..7f5c453c8307 100644
--- a/ucb/source/ucp/gio/gio_datasupplier.cxx
+++ b/ucb/source/ucp/gio/gio_datasupplier.cxx
@@ -207,34 +207,35 @@ css::uno::Reference< css::sdbc::XRow > 
DataSupplier::queryPropertyValues( sal_uI
         }
     }
 
-    if ( getResult( nIndex ) )
+    if ( !getResult( nIndex ) )
+        return {};
+
+    css::uno::Reference< css::ucb::XContent > xContent( queryContent( nIndex ) 
);
+    if ( !xContent )
+        return {};
+
+    try
     {
-        css::uno::Reference< css::ucb::XContent > xContent( queryContent( 
nIndex ) );
-        if ( xContent.is() )
+        css::uno::Reference< css::ucb::XCommandProcessor > xCmdProc( xContent, 
css::uno::UNO_QUERY );
+        if ( !xCmdProc )
+            return {};
+        sal_Int32 nCmdId( xCmdProc->createCommandIdentifier() );
+        css::ucb::Command aCmd;
+        aCmd.Name = "getPropertyValues";
+        aCmd.Handle = -1;
+        aCmd.Argument <<= getResultSet()->getProperties();
+        css::uno::Any aResult( xCmdProc->execute(
+            aCmd, nCmdId, getResultSet()->getEnvironment() ) );
+        css::uno::Reference< css::sdbc::XRow > xRow;
+        if ( aResult >>= xRow )
         {
-            try
-            {
-                css::uno::Reference< css::ucb::XCommandProcessor > xCmdProc(
-                    xContent, css::uno::UNO_QUERY_THROW );
-                sal_Int32 nCmdId( xCmdProc->createCommandIdentifier() );
-                css::ucb::Command aCmd;
-                aCmd.Name = "getPropertyValues";
-                aCmd.Handle = -1;
-                aCmd.Argument <<= getResultSet()->getProperties();
-                css::uno::Any aResult( xCmdProc->execute(
-                    aCmd, nCmdId, getResultSet()->getEnvironment() ) );
-                css::uno::Reference< css::sdbc::XRow > xRow;
-                if ( aResult >>= xRow )
-                {
-                    maResults[ nIndex ]->xRow = xRow;
-                    return xRow;
-                }
-            }
-            catch ( css::uno::Exception const & )
-            {
-            }
+            maResults[ nIndex ]->xRow = xRow;
+            return xRow;
         }
     }
+    catch ( css::uno::Exception const & )
+    {
+    }
     return css::uno::Reference< css::sdbc::XRow >();
 }
 

Reply via email to