summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-02-14 16:11:21 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-02-15 14:19:32 +0000
commit878a8ff3f0b6b7f956e8ed40932ff47e0e56a0cd (patch)
treef9c102c825b04ddbdb3a5f0f4e589806a480a764 /basic
parent22f96dad080e3fad30b164be8ee45caa11ae4407 (diff)
Some simplifications, using UNO_QUERY_THROW
Change-Id: Ie7b5bb82868f517d056907567dd8e53a34d8a0b0 Reviewed-on: https://gerrit.libreoffice.org/34273 Tested-by: Stephan Bergmann <sbergman@redhat.com> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/uno/namecont.cxx18
-rw-r--r--basic/source/uno/scriptcont.cxx28
2 files changed, 6 insertions, 40 deletions
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index ae83e5a939f1..221c2d30fcd4 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 cfd744708f5b..e18fe5cfa000 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& )