[Libreoffice-commits] core.git: 3 commits - framework/source i18npool/source package/source

Stephan Bergmann sbergman at redhat.com
Wed Feb 15 14:18:46 UTC 2017


 framework/source/services/taskcreatorsrv.cxx                          |    5 
 i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx |    5 
 package/source/xstor/ohierarchyholder.cxx                             |    8 
 package/source/xstor/owriteablestream.cxx                             |   64 +-----
 package/source/xstor/xstorage.cxx                                     |   94 ++--------
 package/source/zippackage/ZipPackage.cxx                              |   15 -
 package/source/zippackage/ZipPackageStream.cxx                        |   22 --
 package/source/zippackage/wrapstreamforshare.cxx                      |    4 
 8 files changed, 50 insertions(+), 167 deletions(-)

New commits:
commit 32cb8a544d25bc2a5150cd6818f505f5d5fa3687
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Feb 14 16:10:50 2017 +0100

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

diff --git a/framework/source/services/taskcreatorsrv.cxx b/framework/source/services/taskcreatorsrv.cxx
index d66eff4..13c5a56 100644
--- a/framework/source/services/taskcreatorsrv.cxx
+++ b/framework/source/services/taskcreatorsrv.cxx
@@ -250,10 +250,7 @@ css::uno::Reference< css::awt::XWindow > TaskCreatorService::implts_createContai
 
     // create a new blank container window and get access to parent container to append new created task.
     css::uno::Reference< css::awt::XWindowPeer > xPeer      = xToolkit->createWindow( aDescriptor );
-    css::uno::Reference< css::awt::XWindow >     xWindow    ( xPeer, css::uno::UNO_QUERY );
-    if ( ! xWindow.is())
-        throw css::uno::Exception("TaskCreator service was not able to create suitable frame window.",
-                                  static_cast< ::cppu::OWeakObject* >(this));
+    css::uno::Reference< css::awt::XWindow >     xWindow    ( xPeer, css::uno::UNO_QUERY_THROW );
 
     sal_Int32 nBackground = 0xffffffff;
 
commit f2fd6a6a3051000c04b175e33f16fe863df5735c
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Feb 14 16:10:46 2017 +0100

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

diff --git a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
index 79cc2b4..847434d 100644
--- a/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
+++ b/i18npool/source/defaultnumberingprovider/defaultnumberingprovider.cxx
@@ -993,10 +993,7 @@ DefaultNumberingProvider::isScriptFlagEnabled(const OUString& aName)
         Reference<XInterface> xInterface = xConfigProvider->createInstanceWithArguments(
             "com.sun.star.configuration.ConfigurationAccess", aArgs);
 
-        xHierarchicalNameAccess.set(xInterface, UNO_QUERY);
-
-        if (! xHierarchicalNameAccess.is())
-            throw RuntimeException();
+        xHierarchicalNameAccess.set(xInterface, UNO_QUERY_THROW);
     }
 
     Any aEnabled = xHierarchicalNameAccess->getByHierarchicalName(aName);
commit d2e77c3f9f5a0ceb40edda34b632abef5b0b57bb
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Feb 14 16:10:35 2017 +0100

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

diff --git a/package/source/xstor/ohierarchyholder.cxx b/package/source/xstor/ohierarchyholder.cxx
index f5bcc68..2837d9d 100644
--- a/package/source/xstor/ohierarchyholder.cxx
+++ b/package/source/xstor/ohierarchyholder.cxx
@@ -94,9 +94,7 @@ uno::Reference< embed::XExtendedStorageStream > OHierarchyElement_Impl::GetStrea
     uno::Reference< embed::XStorage > xOwnStor;
 
     xOwnStor = m_xOwnStorage.is() ? m_xOwnStorage
-                : uno::Reference< embed::XStorage >( m_xWeakOwnStorage.get(), uno::UNO_QUERY );
-    if ( !xOwnStor.is() )
-        throw uno::RuntimeException();
+                : uno::Reference< embed::XStorage >( m_xWeakOwnStorage.get(), uno::UNO_QUERY_THROW );
 
     if ( aListPath.empty() )
     {
@@ -177,9 +175,7 @@ void OHierarchyElement_Impl::RemoveStreamHierarchically( OStringList_Impl& aList
     uno::Reference< embed::XStorage > xOwnStor;
 
     xOwnStor = m_xOwnStorage.is() ? m_xOwnStorage
-                : uno::Reference< embed::XStorage >( m_xWeakOwnStorage.get(), uno::UNO_QUERY );
-    if ( !xOwnStor.is() )
-        throw uno::RuntimeException();
+                : uno::Reference< embed::XStorage >( m_xWeakOwnStorage.get(), uno::UNO_QUERY_THROW );
 
     if ( aListPath.empty() )
     {
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index 455d51c..a2c37e1 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -361,10 +361,7 @@ void OWriteStream_Impl::InsertIntoPackageFolder( const OUString& aName,
     if ( m_bFlushed )
     {
         SAL_WARN_IF( !m_xPackageStream.is(), "package.xstor", "An inserted stream is incomplete!\n" );
-        uno::Reference< lang::XUnoTunnel > xTunnel( m_xPackageStream, uno::UNO_QUERY );
-        if ( !xTunnel.is() )
-            throw uno::RuntimeException(); // TODO
-
+        uno::Reference< lang::XUnoTunnel > xTunnel( m_xPackageStream, uno::UNO_QUERY_THROW );
         xParentPackageFolder->insertByName( aName, uno::makeAny( xTunnel ) );
 
         m_bFlushed = false;
@@ -741,9 +738,7 @@ void OWriteStream_Impl::InsertStreamDirectly( const uno::Reference< io::XInputSt
     m_xPackageStream->setDataStream( xInStream );
 
     // copy properties to the package stream
-    uno::Reference< beans::XPropertySet > xPropertySet( m_xPackageStream, uno::UNO_QUERY );
-    if ( !xPropertySet.is() )
-        throw uno::RuntimeException();
+    uno::Reference< beans::XPropertySet > xPropertySet( m_xPackageStream, uno::UNO_QUERY_THROW );
 
     // The storage-package communication has a problem
     // the storage caches properties, thus if the package changes one of them itself
@@ -862,9 +857,7 @@ void OWriteStream_Impl::Commit()
     }
 
     // copy properties to the package stream
-    uno::Reference< beans::XPropertySet > xPropertySet( xNewPackageStream, uno::UNO_QUERY );
-    if ( !xPropertySet.is() )
-        throw uno::RuntimeException();
+    uno::Reference< beans::XPropertySet > xPropertySet( xNewPackageStream, uno::UNO_QUERY_THROW );
 
     for ( sal_Int32 nInd = 0; nInd < m_aProps.getLength(); nInd++ )
     {
@@ -1103,28 +1096,20 @@ uno::Sequence< beans::PropertyValue > OWriteStream_Impl::ReadPackageStreamProper
 
     // TODO: may be also raw stream should be marked
 
-    uno::Reference< beans::XPropertySet > xPropSet( m_xPackageStream, uno::UNO_QUERY );
-    if ( xPropSet.is() )
+    uno::Reference< beans::XPropertySet > xPropSet( m_xPackageStream, uno::UNO_QUERY_THROW );
+    for ( sal_Int32 nInd = 0; nInd < aResult.getLength(); nInd++ )
     {
-        for ( sal_Int32 nInd = 0; nInd < aResult.getLength(); nInd++ )
+        try {
+            aResult[nInd].Value = xPropSet->getPropertyValue( aResult[nInd].Name );
+        }
+        catch( const uno::Exception& rException )
         {
-            try {
-                aResult[nInd].Value = xPropSet->getPropertyValue( aResult[nInd].Name );
-            }
-            catch( const uno::Exception& rException )
-            {
-                AddLog( rException.Message );
-                AddLog( "Quiet exception" );
+            AddLog( rException.Message );
+            AddLog( "Quiet exception" );
 
-                SAL_WARN( "package.xstor", "A property can't be retrieved!" );
-            }
+            SAL_WARN( "package.xstor", "A property can't be retrieved!" );
         }
     }
-    else
-    {
-        SAL_WARN( "package.xstor", "Can not get properties from a package stream!" );
-        throw uno::RuntimeException();
-    }
 
     return aResult;
 }
@@ -1204,9 +1189,7 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream( sal_Int32 nStreamMod
 
     uno::Reference< io::XStream > xResultStream;
 
-    uno::Reference< beans::XPropertySet > xPropertySet( m_xPackageStream, uno::UNO_QUERY );
-    if ( !xPropertySet.is() )
-        throw uno::RuntimeException();
+    uno::Reference< beans::XPropertySet > xPropertySet( m_xPackageStream, uno::UNO_QUERY_THROW );
 
     if ( m_bHasCachedEncryptionData )
     {
@@ -1450,9 +1433,7 @@ void OWriteStream_Impl::CreateReadonlyCopyBasedOnData( const uno::Reference< io:
     else
         xTempFile = xTargetStream;
 
-    uno::Reference < io::XSeekable > xTempSeek( xTempFile, uno::UNO_QUERY );
-    if ( !xTempSeek.is() )
-        throw uno::RuntimeException(); // TODO
+    uno::Reference < io::XSeekable > xTempSeek( xTempFile, uno::UNO_QUERY_THROW );
 
     uno::Reference < io::XOutputStream > xTempOut = xTempFile->getOutputStream();
     if ( !xTempOut.is() )
@@ -1533,9 +1514,7 @@ void OWriteStream_Impl::GetCopyOfLastCommit( uno::Reference< io::XStream >& xTar
         // that means "use common pass" also should be remembered on flash
         uno::Sequence< beans::NamedValue > aKey = aEncryptionData.getAsConstNamedValueList();
 
-        uno::Reference< beans::XPropertySet > xProps( m_xPackageStream, uno::UNO_QUERY );
-        if ( !xProps.is() )
-            throw uno::RuntimeException();
+        uno::Reference< beans::XPropertySet > xProps( m_xPackageStream, uno::UNO_QUERY_THROW );
 
         bool bEncr = false;
         xProps->getPropertyValue( "Encrypted" ) >>= bEncr;
@@ -1792,9 +1771,7 @@ void OWriteStream::CopyToStreamInternally_Impl( const uno::Reference< io::XStrea
     if ( !m_xSeekable.is() )
         throw uno::RuntimeException();
 
-    uno::Reference< beans::XPropertySet > xDestProps( xDest, uno::UNO_QUERY );
-    if ( !xDestProps.is() )
-        throw uno::RuntimeException(); //TODO
+    uno::Reference< beans::XPropertySet > xDestProps( xDest, uno::UNO_QUERY_THROW );
 
     uno::Reference< io::XOutputStream > xDestOutStream = xDest->getOutputStream();
     if ( !xDestOutStream.is() )
@@ -2380,14 +2357,7 @@ void SAL_CALL OWriteStream::truncate()
     if ( !m_xOutStream.is() )
         throw uno::RuntimeException();
 
-    uno::Reference< io::XTruncate > xTruncate( m_xOutStream, uno::UNO_QUERY );
-
-    if ( !xTruncate.is() )
-    {
-        SAL_WARN( "package.xstor", "The output stream must support XTruncate interface!" );
-        throw uno::RuntimeException();
-    }
-
+    uno::Reference< io::XTruncate > xTruncate( m_xOutStream, uno::UNO_QUERY_THROW );
     xTruncate->truncate();
 
     m_pImpl->m_bHasDataToFlush = true;
diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index da757ea..424f2c7 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -105,10 +105,8 @@ void OStorage_Impl::completeStorageStreamCopy_Impl(
                             sal_Int32 nStorageType,
                             const uno::Sequence< uno::Sequence< beans::StringPair > >& aRelInfo )
 {
-        uno::Reference< beans::XPropertySet > xSourceProps( xSource, uno::UNO_QUERY );
-        uno::Reference< beans::XPropertySet > xDestProps( xDest, uno::UNO_QUERY );
-        if ( !xSourceProps.is() || !xDestProps.is() )
-            throw uno::RuntimeException( THROW_WHERE );
+        uno::Reference< beans::XPropertySet > xSourceProps( xSource, uno::UNO_QUERY_THROW );
+        uno::Reference< beans::XPropertySet > xDestProps( xDest, uno::UNO_QUERY_THROW );
 
         uno::Reference< io::XOutputStream > xDestOutStream = xDest->getOutputStream();
         if ( !xDestOutStream.is() )
@@ -603,10 +601,7 @@ void OStorage_Impl::ReadContents()
     if ( m_bIsRoot )
         OpenOwnPackage();
 
-    uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xPackageFolder, uno::UNO_QUERY );
-    if ( !xEnumAccess.is() )
-        throw uno::RuntimeException( THROW_WHERE );
-
+    uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xPackageFolder, uno::UNO_QUERY_THROW );
     uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration();
     if ( !xEnum.is() )
         throw uno::RuntimeException( THROW_WHERE );
@@ -771,10 +766,7 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
 
     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
 
-    uno::Reference< container::XNameAccess > xDestAccess( xDest, uno::UNO_QUERY );
-    if ( !xDestAccess.is() )
-        throw uno::RuntimeException( THROW_WHERE );
-
+    uno::Reference< container::XNameAccess > xDestAccess( xDest, uno::UNO_QUERY_THROW );
     if ( xDestAccess->hasByName( aName )
       && !( pElement->m_bIsStorage && xDest->isStorageElement( aName ) ) )
         xDest->removeElement( aName );
@@ -1006,10 +998,7 @@ void OStorage_Impl::InsertIntoPackageFolder( const OUString& aName,
     ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
 
     SAL_WARN_IF( !m_xPackageFolder.is(), "package.xstor", "An inserted storage is incomplete!" );
-    uno::Reference< lang::XUnoTunnel > xTunnel( m_xPackageFolder, uno::UNO_QUERY );
-    if ( !xTunnel.is() )
-        throw uno::RuntimeException( THROW_WHERE );
-
+    uno::Reference< lang::XUnoTunnel > xTunnel( m_xPackageFolder, uno::UNO_QUERY_THROW );
     xParentPackageFolder->insertByName( aName, uno::makeAny( xTunnel ) );
 
     m_bCommited = false;
@@ -1217,10 +1206,7 @@ void OStorage_Impl::Commit()
     if ( m_nStorageType == embed::StorageFormats::PACKAGE )
     {
         // move properties to the destination package folder
-        uno::Reference< beans::XPropertySet > xProps( xNewPackageFolder, uno::UNO_QUERY );
-        if ( !xProps.is() )
-            throw uno::RuntimeException( THROW_WHERE );
-
+        uno::Reference< beans::XPropertySet > xProps( xNewPackageFolder, uno::UNO_QUERY_THROW );
         xProps->setPropertyValue( "MediaType", uno::makeAny( m_aMediaType ) );
         xProps->setPropertyValue( "Version", uno::makeAny( m_aVersion ) );
     }
@@ -1230,12 +1216,7 @@ void OStorage_Impl::Commit()
 
     if ( m_bIsRoot )
     {
-        uno::Reference< util::XChangesBatch > xChangesBatch( m_xPackage, uno::UNO_QUERY );
-
-        SAL_WARN_IF( !xChangesBatch.is(), "package.xstor", "Impossible to commit package!" );
-        if ( !xChangesBatch.is() )
-            throw uno::RuntimeException( THROW_WHERE );
-
+        uno::Reference< util::XChangesBatch > xChangesBatch( m_xPackage, uno::UNO_QUERY_THROW );
         try
         {
             xChangesBatch->commitChanges();
@@ -1383,9 +1364,7 @@ SotElement_Impl* OStorage_Impl::InsertStream( const OUString& aName, bool bEncr
     if ( !xNewElement.is() )
         throw io::IOException( THROW_WHERE );
 
-    uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xNewElement, uno::UNO_QUERY );
-    if ( !xPackageSubStream.is() )
-        throw uno::RuntimeException( THROW_WHERE );
+    uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xNewElement, uno::UNO_QUERY_THROW );
 
     OSL_ENSURE( m_nStorageType == embed::StorageFormats::PACKAGE || !bEncr, "Only package storage supports encryption!\n" );
     if ( m_nStorageType != embed::StorageFormats::PACKAGE && bEncr )
@@ -1425,10 +1404,7 @@ void OStorage_Impl::InsertRawStream( const OUString& aName, const uno::Reference
     if ( !xNewElement.is() )
         throw io::IOException( THROW_WHERE );
 
-    uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xNewElement, uno::UNO_QUERY );
-    if ( !xPackageSubStream.is() )
-        throw uno::RuntimeException( THROW_WHERE );
-
+    uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xNewElement, uno::UNO_QUERY_THROW );
     xPackageSubStream->setRawStream( xInStrToInsert );
 
     // the mode is not needed for storage stream internal implementation
@@ -1457,10 +1433,7 @@ OStorage_Impl* OStorage_Impl::CreateNewStorageImpl( sal_Int32 nStorageMode )
     if ( !xNewElement.is() )
         throw io::IOException( THROW_WHERE );
 
-    uno::Reference< container::XNameContainer > xPackageSubFolder( xNewElement, uno::UNO_QUERY );
-    if ( !xPackageSubFolder.is() )
-        throw uno::RuntimeException( THROW_WHERE );
-
+    uno::Reference< container::XNameContainer > xPackageSubFolder( xNewElement, uno::UNO_QUERY_THROW );
     OStorage_Impl* pResult =
             new OStorage_Impl( this, nStorageMode, xPackageSubFolder, m_xPackage, m_xContext, m_nStorageType );
     pResult->m_bIsModified = true;
@@ -1533,13 +1506,7 @@ void OStorage_Impl::OpenSubStorage( SotElement_Impl* pElement, sal_Int32 nStorag
         if ( !xTunnel.is() )
             throw container::NoSuchElementException( THROW_WHERE );
 
-        uno::Reference< container::XNameContainer > xPackageSubFolder( xTunnel, uno::UNO_QUERY );
-
-        SAL_WARN_IF( !xPackageSubFolder.is(), "package.xstor", "Can not get XNameContainer interface from folder!" );
-
-        if ( !xPackageSubFolder.is() )
-            throw uno::RuntimeException( THROW_WHERE );
-
+        uno::Reference< container::XNameContainer > xPackageSubFolder( xTunnel, uno::UNO_QUERY_THROW );
         pElement->m_pStorage = new OStorage_Impl( this, nStorageMode, xPackageSubFolder, m_xPackage, m_xContext, m_nStorageType );
     }
 }
@@ -1560,9 +1527,7 @@ void OStorage_Impl::OpenSubStream( SotElement_Impl* pElement )
         if ( !xTunnel.is() )
             throw container::NoSuchElementException( THROW_WHERE );
 
-        uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xTunnel, uno::UNO_QUERY );
-        if ( !xPackageSubStream.is() )
-            throw uno::RuntimeException( THROW_WHERE );
+        uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xTunnel, uno::UNO_QUERY_THROW );
 
         // the stream can never be inserted here, because inserted stream element holds the stream till commit or destruction
         pElement->m_pStream = new OWriteStream_Impl( this, xPackageSubStream, m_xPackage, m_xContext, false, m_nStorageType, false, GetRelInfoStreamForName( pElement->m_aOriginalName ) );
@@ -2378,10 +2343,7 @@ uno::Reference< io::XStream > SAL_CALL OStorage::openStreamElement(
         if ( m_pData->m_bReadOnlyWrap )
         {
             // before the storage disposes the stream it must deregister itself as listener
-            uno::Reference< lang::XComponent > xStreamComponent( xResult, uno::UNO_QUERY );
-            if ( !xStreamComponent.is() )
-                throw uno::RuntimeException( THROW_WHERE );
-
+            uno::Reference< lang::XComponent > xStreamComponent( xResult, uno::UNO_QUERY_THROW );
             MakeLinkToSubComponent_Impl( xStreamComponent );
         }
     }
@@ -2540,10 +2502,7 @@ uno::Reference< embed::XStorage > SAL_CALL OStorage::openStorageElement(
             pElement->m_pStorage->SetReadOnlyWrap( *pResultStorage );
 
             // before the storage disposes the stream it must deregister itself as listener
-            uno::Reference< lang::XComponent > xStorageComponent( xResult, uno::UNO_QUERY );
-            if ( !xStorageComponent.is() )
-                throw uno::RuntimeException( THROW_WHERE );
-
+            uno::Reference< lang::XComponent > xStorageComponent( xResult, uno::UNO_QUERY_THROW );
             MakeLinkToSubComponent_Impl( xStorageComponent );
         }
     }
@@ -3149,10 +3108,7 @@ void SAL_CALL OStorage::copyElementTo(  const OUString& aElementName,
         if ( !pElement )
             throw container::NoSuchElementException( THROW_WHERE );
 
-        uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY );
-        if ( !xNameAccess.is() )
-            throw uno::RuntimeException( THROW_WHERE );
-
+        uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY_THROW );
         if ( xNameAccess->hasByName( aNewName ) )
             throw container::ElementExistException( THROW_WHERE );
 
@@ -3243,10 +3199,7 @@ void SAL_CALL OStorage::moveElementTo(  const OUString& aElementName,
         if ( !pElement )
             throw container::NoSuchElementException( THROW_WHERE ); //???
 
-        uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY );
-        if ( !xNameAccess.is() )
-            throw uno::RuntimeException( THROW_WHERE );
-
+        uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY_THROW );
         if ( xNameAccess->hasByName( aNewName ) )
             throw container::ElementExistException( THROW_WHERE );
 
@@ -3348,10 +3301,7 @@ uno::Reference< io::XStream > SAL_CALL OStorage::openEncryptedStream(
         if ( m_pData->m_bReadOnlyWrap )
         {
             // before the storage disposes the stream it must deregister itself as listener
-            uno::Reference< lang::XComponent > xStreamComponent( xResult, uno::UNO_QUERY );
-            if ( !xStreamComponent.is() )
-                throw uno::RuntimeException( THROW_WHERE );
-
+            uno::Reference< lang::XComponent > xStreamComponent( xResult, uno::UNO_QUERY_THROW );
             MakeLinkToSubComponent_Impl( xStreamComponent );
         }
     }
@@ -4724,10 +4674,7 @@ uno::Any SAL_CALL OStorage::getPropertyValue( const OUString& aPropertyName )
         {
             try {
                 m_pImpl->ReadContents();
-                uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY );
-                if ( !xPackPropSet.is() )
-                    throw uno::RuntimeException( THROW_WHERE );
-
+                uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY_THROW );
                 return xPackPropSet->getPropertyValue( aPropertyName );
             }
             catch ( const uno::RuntimeException& rRuntimeException )
@@ -5299,10 +5246,7 @@ void SAL_CALL OStorage::copyElementDirectlyTo(
         if ( !pElement )
             throw container::NoSuchElementException( THROW_WHERE );
 
-        uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY );
-        if ( !xNameAccess.is() )
-            throw uno::RuntimeException( THROW_WHERE );
-
+        uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY_THROW );
         if ( xNameAccess->hasByName( aNewName ) )
             throw container::ElementExistException( THROW_WHERE );
 
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 9a43267..c214e94 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -705,11 +705,7 @@ void SAL_CALL ZipPackage::initialize( const uno::Sequence< Any >& aArguments )
             {
                 // the stream must be seekable, if it is not it will be wrapped
                 m_xContentStream = ::comphelper::OSeekableInputWrapper::CheckSeekableCanWrap( m_xContentStream, m_xContext );
-                m_xContentSeek.set( m_xContentStream, UNO_QUERY );
-                if ( ! m_xContentSeek.is() )
-                    throw css::uno::Exception (THROW_WHERE "The package component _requires_ an XSeekable interface!",
-                            static_cast < ::cppu::OWeakObject * > ( this ) );
-
+                m_xContentSeek.set( m_xContentStream, UNO_QUERY_THROW );
                 if ( !m_xContentSeek->getLength() )
                     bHaveZipFile = false;
             }
@@ -1414,9 +1410,7 @@ void SAL_CALL ZipPackage::commitChanges()
             try
             {
                 xOutputStream = m_xStream->getOutputStream();
-                uno::Reference < XTruncate > xTruncate ( xOutputStream, UNO_QUERY );
-                if ( !xTruncate.is() )
-                    throw uno::RuntimeException(THROW_WHERE );
+                uno::Reference < XTruncate > xTruncate ( xOutputStream, UNO_QUERY_THROW );
 
                 // after successful truncation the original file contents are already lost
                 xTruncate->truncate();
@@ -1495,10 +1489,7 @@ void SAL_CALL ZipPackage::commitChanges()
             {
                 try
                 {
-                    uno::Reference < XPropertySet > xPropSet ( xTempInStream, UNO_QUERY );
-                    OSL_ENSURE( xPropSet.is(), "This is a temporary file that must implement XPropertySet!\n" );
-                    if ( !xPropSet.is() )
-                        throw uno::RuntimeException(THROW_WHERE );
+                    uno::Reference < XPropertySet > xPropSet ( xTempInStream, UNO_QUERY_THROW );
 
                     OUString sTargetFolder = m_aURL.copy ( 0, m_aURL.lastIndexOf ( static_cast < sal_Unicode > ( '/' ) ) );
                     Content aContent(
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index 6f7ab60..d684493 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -149,9 +149,7 @@ uno::Reference< io::XInputStream > const & ZipPackageStream::GetOwnSeekStream()
         // is accessed before commit it MUST be wrapped.
         // Wrap the stream in case it is not seekable
         m_xStream = ::comphelper::OSeekableInputWrapper::CheckSeekableCanWrap( m_xStream, m_xContext );
-        uno::Reference< io::XSeekable > xSeek( m_xStream, UNO_QUERY );
-        if ( !xSeek.is() )
-            throw RuntimeException( THROW_WHERE "The stream must support XSeekable!" );
+        uno::Reference< io::XSeekable > xSeek( m_xStream, UNO_QUERY_THROW );
 
         m_bHasSeekable = true;
     }
@@ -289,16 +287,11 @@ uno::Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream(
         pPackage->initialize( aArgs );
 
         // create a new package stream
-        uno::Reference< XDataSinkEncrSupport > xNewPackStream( xPackageAsFactory->createInstance(), UNO_QUERY );
-        if ( !xNewPackStream.is() )
-            throw RuntimeException(THROW_WHERE );
-
+        uno::Reference< XDataSinkEncrSupport > xNewPackStream( xPackageAsFactory->createInstance(), UNO_QUERY_THROW );
         xNewPackStream->setDataStream( static_cast< io::XInputStream* >(
                                                     new WrapStreamForShare( GetOwnSeekStream(), m_rZipPackage.GetSharedMutexRef() ) ) );
 
-        uno::Reference< XPropertySet > xNewPSProps( xNewPackStream, UNO_QUERY );
-        if ( !xNewPSProps.is() )
-            throw RuntimeException(THROW_WHERE );
+        uno::Reference< XPropertySet > xNewPSProps( xNewPackStream, UNO_QUERY_THROW );
 
         // copy all the properties of this stream to the new stream
         xNewPSProps->setPropertyValue("MediaType", makeAny( msMediaType ) );
@@ -313,9 +306,7 @@ uno::Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream(
         uno::Reference< XUnoTunnel > xTunnel;
         Any aRoot = pPackage->getByHierarchicalName("/");
         aRoot >>= xTunnel;
-        uno::Reference< container::XNameContainer > xRootNameContainer( xTunnel, UNO_QUERY );
-        if ( !xRootNameContainer.is() )
-            throw RuntimeException(THROW_WHERE );
+        uno::Reference< container::XNameContainer > xRootNameContainer( xTunnel, UNO_QUERY_THROW );
 
         uno::Reference< XUnoTunnel > xNPSTunnel( xNewPackStream, UNO_QUERY );
         xRootNameContainer->insertByName("dummy", makeAny( xNPSTunnel ) );
@@ -1107,10 +1098,7 @@ void SAL_CALL ZipPackageStream::setRawStream( const uno::Reference< io::XInputSt
 {
     // wrap the stream in case it is not seekable
     uno::Reference< io::XInputStream > xNewStream = ::comphelper::OSeekableInputWrapper::CheckSeekableCanWrap( aStream, m_xContext );
-    uno::Reference< io::XSeekable > xSeek( xNewStream, UNO_QUERY );
-    if ( !xSeek.is() )
-        throw RuntimeException(THROW_WHERE "The stream must support XSeekable!" );
-
+    uno::Reference< io::XSeekable > xSeek( xNewStream, UNO_QUERY_THROW );
     xSeek->seek( 0 );
     uno::Reference< io::XInputStream > xOldStream = m_xStream;
     m_xStream = xNewStream;
diff --git a/package/source/zippackage/wrapstreamforshare.cxx b/package/source/zippackage/wrapstreamforshare.cxx
index 393ad27..dbc8d92 100644
--- a/package/source/zippackage/wrapstreamforshare.cxx
+++ b/package/source/zippackage/wrapstreamforshare.cxx
@@ -38,12 +38,12 @@ WrapStreamForShare::WrapStreamForShare( const uno::Reference< io::XInputStream >
 , m_xInStream( xInStream )
 , m_nCurPos( 0 )
 {
-    m_xSeekable.set( m_xInStream, uno::UNO_QUERY );
-    if ( !m_rMutexRef.is() || !m_xInStream.is() || !m_xSeekable.is() )
+    if ( !m_rMutexRef.is() || !m_xInStream.is() )
     {
         OSL_FAIL( "Wrong initialization of wrapping stream!\n" );
         throw uno::RuntimeException(THROW_WHERE );
     }
+    m_xSeekable.set( m_xInStream, uno::UNO_QUERY_THROW );
 }
 
 WrapStreamForShare::~WrapStreamForShare()


More information about the Libreoffice-commits mailing list