diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-02-14 16:10:56 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-02-15 14:18:47 +0000 |
commit | 5ce42c21654db41544d831ac18c1388dde64d122 (patch) | |
tree | e85bf95ebf62c88b12d2f77107702feb3e295362 /embeddedobj/source/msole | |
parent | Some simplifications, using UNO_QUERY_THROW (diff) | |
download | core-5ce42c21654db41544d831ac18c1388dde64d122.tar.gz core-5ce42c21654db41544d831ac18c1388dde64d122.zip |
Some simplifications, using UNO_QUERY_THROW
Change-Id: Ieee649609a7f01b4d51ed6ed78a8ae809ca61d9e
Reviewed-on: https://gerrit.libreoffice.org/34268
Tested-by: Stephan Bergmann <sbergman@redhat.com>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'embeddedobj/source/msole')
-rw-r--r-- | embeddedobj/source/msole/olepersist.cxx | 44 | ||||
-rw-r--r-- | embeddedobj/source/msole/olevisual.cxx | 4 | ||||
-rw-r--r-- | embeddedobj/source/msole/xdialogcreator.cxx | 6 | ||||
-rw-r--r-- | embeddedobj/source/msole/xolefactory.cxx | 46 |
4 files changed, 23 insertions, 77 deletions
diff --git a/embeddedobj/source/msole/olepersist.cxx b/embeddedobj/source/msole/olepersist.cxx index 30095d175760..82fb981c5afc 100644 --- a/embeddedobj/source/msole/olepersist.cxx +++ b/embeddedobj/source/msole/olepersist.cxx @@ -191,20 +191,14 @@ OUString GetNewFilledTempFile_Impl( const uno::Reference< embed::XOptimizedStora void SetStreamMediaType_Impl( const uno::Reference< io::XStream >& xStream, const OUString& aMediaType ) { - uno::Reference< beans::XPropertySet > xPropSet( xStream, uno::UNO_QUERY ); - if ( !xPropSet.is() ) - throw uno::RuntimeException(); // TODO: all the storage streams must support XPropertySet - + uno::Reference< beans::XPropertySet > xPropSet( xStream, uno::UNO_QUERY_THROW ); xPropSet->setPropertyValue("MediaType", uno::makeAny( aMediaType ) ); } #endif void LetCommonStoragePassBeUsed_Impl( const uno::Reference< io::XStream >& xStream ) { - uno::Reference< beans::XPropertySet > xPropSet( xStream, uno::UNO_QUERY ); - if ( !xPropSet.is() ) - throw uno::RuntimeException(); // Only StorageStreams must be provided here, they must implement the interface - + uno::Reference< beans::XPropertySet > xPropSet( xStream, uno::UNO_QUERY_THROW ); xPropSet->setPropertyValue("UseCommonStoragePasswordEncryption", uno::makeAny( true ) ); } @@ -382,10 +376,7 @@ void OleEmbeddedObject::InsertVisualCache_Impl( const uno::Reference< io::XStrea m_xFactory->createInstanceWithArguments( "com.sun.star.embed.OLESimpleStorage", aArgs ), - uno::UNO_QUERY ); - - if ( !xNameContainer.is() ) - throw uno::RuntimeException(); + uno::UNO_QUERY_THROW ); uno::Reference< io::XSeekable > xCachedSeek( xCachedVisualRepresentation, uno::UNO_QUERY_THROW ); if ( xCachedSeek.is() ) @@ -509,10 +500,7 @@ void OleEmbeddedObject::InsertVisualCache_Impl( const uno::Reference< io::XStrea else xNameContainer->insertByName( aCacheName, uno::makeAny( xTempFile ) ); - uno::Reference< embed::XTransactedObject > xTransacted( xNameContainer, uno::UNO_QUERY ); - if ( !xTransacted.is() ) - throw uno::RuntimeException(); - + uno::Reference< embed::XTransactedObject > xTransacted( xNameContainer, uno::UNO_QUERY_THROW ); xTransacted->commit(); } @@ -530,10 +518,7 @@ void OleEmbeddedObject::RemoveVisualCache_Impl( const uno::Reference< io::XStrea m_xFactory->createInstanceWithArguments( "com.sun.star.embed.OLESimpleStorage", aArgs ), - uno::UNO_QUERY ); - - if ( !xNameContainer.is() ) - throw uno::RuntimeException(); + uno::UNO_QUERY_THROW ); for ( sal_uInt8 nInd = 0; nInd < 10; nInd++ ) { @@ -542,10 +527,7 @@ void OleEmbeddedObject::RemoveVisualCache_Impl( const uno::Reference< io::XStrea xNameContainer->removeByName( aStreamName ); } - uno::Reference< embed::XTransactedObject > xTransacted( xNameContainer, uno::UNO_QUERY ); - if ( !xTransacted.is() ) - throw uno::RuntimeException(); - + uno::Reference< embed::XTransactedObject > xTransacted( xNameContainer, uno::UNO_QUERY_THROW ); xTransacted->commit(); } @@ -1014,10 +996,7 @@ uno::Reference< io::XOutputStream > OleEmbeddedObject::GetStreamForSaving() if ( !xOutStream.is() ) throw io::IOException(); //TODO: access denied - uno::Reference< io::XTruncate > xTruncate( xOutStream, uno::UNO_QUERY ); - if ( !xTruncate.is() ) - throw uno::RuntimeException(); //TODO: - + uno::Reference< io::XTruncate > xTruncate( xOutStream, uno::UNO_QUERY_THROW ); xTruncate->truncate(); return xOutStream; @@ -1046,10 +1025,7 @@ void OleEmbeddedObject::StoreObjectToStream( uno::Reference< io::XOutputStream > if ( xTempInStream.is() ) { // write all the contents to XOutStream - uno::Reference< io::XTruncate > xTrunc( xOutStream, uno::UNO_QUERY ); - if ( !xTrunc.is() ) - throw uno::RuntimeException(); //TODO: - + uno::Reference< io::XTruncate > xTrunc( xOutStream, uno::UNO_QUERY_THROW ); xTrunc->truncate(); ::comphelper::OStorageHelper::CopyInputToOutput( xTempInStream, xOutStream ); @@ -1336,9 +1312,7 @@ void SAL_CALL OleEmbeddedObject::setPersistentEntry( static_cast< ::cppu::OWeakObject* >(this) ); } - uno::Reference< container::XNameAccess > xNameAccess( xStorage, uno::UNO_QUERY ); - if ( !xNameAccess.is() ) - throw uno::RuntimeException(); //TODO + uno::Reference< container::XNameAccess > xNameAccess( xStorage, uno::UNO_QUERY_THROW ); // detect entry existence bool bElExists = xNameAccess->hasByName( sEntName ); diff --git a/embeddedobj/source/msole/olevisual.cxx b/embeddedobj/source/msole/olevisual.cxx index 0676d4dba68b..329c4fa17457 100644 --- a/embeddedobj/source/msole/olevisual.cxx +++ b/embeddedobj/source/msole/olevisual.cxx @@ -45,9 +45,9 @@ embed::VisualRepresentation OleEmbeddedObject::GetVisualRepresentationInNativeFo // TODO: detect the format in the future for now use workaround uno::Reference< io::XInputStream > xInStream = xCachedVisRepr->getInputStream(); - uno::Reference< io::XSeekable > xSeekable( xCachedVisRepr, uno::UNO_QUERY ); - if ( !xInStream.is() || !xSeekable.is() ) + if ( !xInStream.is() ) throw uno::RuntimeException(); + uno::Reference< io::XSeekable > xSeekable( xCachedVisRepr, uno::UNO_QUERY_THROW ); uno::Sequence< sal_Int8 > aSeq( 2 ); xInStream->readBytes( aSeq, 2 ); diff --git a/embeddedobj/source/msole/xdialogcreator.cxx b/embeddedobj/source/msole/xdialogcreator.cxx index 5d5f7b3ebe5b..847e48e6f0b3 100644 --- a/embeddedobj/source/msole/xdialogcreator.cxx +++ b/embeddedobj/source/msole/xdialogcreator.cxx @@ -297,11 +297,7 @@ embed::InsertedObjectInfo SAL_CALL MSOLEDialogObjectCreator::createInstanceInitF static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xFactory ) ), uno::UNO_QUERY ); - uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY ); - - if ( !xPersist.is() ) - throw uno::RuntimeException(); // TODO: the interface must be supported by own document objects - + uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW ); xPersist->setPersistentEntry( xStorage, sEntryName, embed::EntryInitModes::DEFAULT_INIT, diff --git a/embeddedobj/source/msole/xolefactory.cxx b/embeddedobj/source/msole/xolefactory.cxx index 9f726d39e243..deb9cfc4d7ee 100644 --- a/embeddedobj/source/msole/xolefactory.cxx +++ b/embeddedobj/source/msole/xolefactory.cxx @@ -73,9 +73,7 @@ uno::Reference< uno::XInterface > SAL_CALL OleEmbeddedObjectFactory::createInsta static_cast< ::cppu::OWeakObject* >(this), 2 ); - uno::Reference< container::XNameAccess > xNameAccess( xStorage, uno::UNO_QUERY ); - if ( !xNameAccess.is() ) - throw uno::RuntimeException(); //TODO + uno::Reference< container::XNameAccess > xNameAccess( xStorage, uno::UNO_QUERY_THROW ); // detect entry existence if ( !xNameAccess->hasByName( sEntName ) ) @@ -91,11 +89,7 @@ uno::Reference< uno::XInterface > SAL_CALL OleEmbeddedObjectFactory::createInsta static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xFactory, false ) ), uno::UNO_QUERY ); - uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY ); - - if ( !xPersist.is() ) - throw uno::RuntimeException(); // TODO: the interface must be supported by own document objects - + uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW ); xPersist->setPersistentEntry( xStorage, sEntName, embed::EntryInitModes::DEFAULT_INIT, @@ -143,11 +137,7 @@ uno::Reference< uno::XInterface > SAL_CALL OleEmbeddedObjectFactory::createInsta static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xFactory, false ) ), uno::UNO_QUERY ); - uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY ); - - if ( !xPersist.is() ) - throw uno::RuntimeException(); // TODO: the interface must be supported ( what about applets? ) - + uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW ); xPersist->setPersistentEntry( xStorage, sEntName, embed::EntryInitModes::MEDIA_DESCRIPTOR_INIT, @@ -179,11 +169,7 @@ uno::Reference< uno::XInterface > SAL_CALL OleEmbeddedObjectFactory::createInsta static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xFactory, aClassID, aClassName ) ), uno::UNO_QUERY ); - uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY ); - - if ( !xPersist.is() ) - throw uno::RuntimeException(); // TODO: the interface must be supported by own document objects - + uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW ); xPersist->setPersistentEntry( xStorage, sEntName, embed::EntryInitModes::TRUNCATE_INIT, @@ -214,11 +200,7 @@ uno::Reference< uno::XInterface > SAL_CALL OleEmbeddedObjectFactory::createInsta static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xFactory, true ) ), uno::UNO_QUERY ); - uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY ); - - if ( !xPersist.is() ) - throw uno::RuntimeException(); // TODO: the interface must be supported by own document objects - + uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW ); xPersist->setPersistentEntry( xStorage, sEntName, embed::EntryInitModes::MEDIA_DESCRIPTOR_INIT, @@ -253,18 +235,12 @@ uno::Reference< uno::XInterface > SAL_CALL OleEmbeddedObjectFactory::createInsta static_cast< ::cppu::OWeakObject* > ( new OleEmbeddedObject( m_xFactory, aClassID, aClassName ) ), uno::UNO_QUERY ); - uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY ); - if ( xPersist.is() ) - { - xPersist->setPersistentEntry( xStorage, - sEntName, - embed::EntryInitModes::DEFAULT_INIT, - uno::Sequence< beans::PropertyValue >(), - lObjArgs ); - - } - else - throw uno::RuntimeException(); // TODO: + uno::Reference< embed::XEmbedPersist > xPersist( xResult, uno::UNO_QUERY_THROW ); + xPersist->setPersistentEntry( xStorage, + sEntName, + embed::EntryInitModes::DEFAULT_INIT, + uno::Sequence< beans::PropertyValue >(), + lObjArgs ); return xResult; } |