Kaydet (Commit) 878a8ff3 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Some simplifications, using UNO_QUERY_THROW

Change-Id: Ie7b5bb82868f517d056907567dd8e53a34d8a0b0
Reviewed-on: https://gerrit.libreoffice.org/34273Tested-by: 's avatarStephan Bergmann <sbergman@redhat.com>
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 22f96dad
...@@ -2076,14 +2076,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto ...@@ -2076,14 +2076,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
try try
{ {
xInfoStream = xTargetLibrariesStor->openStreamElement( aStreamName, embed::ElementModes::READWRITE ); xInfoStream = xTargetLibrariesStor->openStreamElement( aStreamName, embed::ElementModes::READWRITE );
uno::Reference< beans::XPropertySet > xProps( xInfoStream, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xProps( xInfoStream, uno::UNO_QUERY_THROW );
SAL_WARN_IF(
!xProps.is(), "basic",
"The stream must implement XPropertySet!");
if ( !xProps.is() )
{
throw uno::RuntimeException("InfoStream doesn't implement XPropertySet");
}
OUString aMime( "text/xml" ); OUString aMime( "text/xml" );
xProps->setPropertyValue("MediaType", uno::Any( aMime ) ); xProps->setPropertyValue("MediaType", uno::Any( aMime ) );
...@@ -2134,14 +2127,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto ...@@ -2134,14 +2127,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
xmlscript::exportLibraryContainer( xWriter, pLibArray.get() ); xmlscript::exportLibraryContainer( xWriter, pLibArray.get() );
if ( bStorage ) if ( bStorage )
{ {
uno::Reference< embed::XTransactedObject > xTransact( xTargetLibrariesStor, uno::UNO_QUERY ); uno::Reference< embed::XTransactedObject > xTransact( xTargetLibrariesStor, uno::UNO_QUERY_THROW );
SAL_WARN_IF(
!xTransact.is(), "basic",
"The storage must implement XTransactedObject!");
if ( !xTransact.is() )
{
throw uno::RuntimeException("xTargetLibrariesStor doesn't implement XTransactedObject");
}
xTransact->commit(); xTransact->commit();
} }
} }
......
...@@ -668,11 +668,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons ...@@ -668,11 +668,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons
uno::Reference< io::XStream > xSourceStream = xStorage->openStreamElement( uno::Reference< io::XStream > xSourceStream = xStorage->openStreamElement(
aSourceStreamName, aSourceStreamName,
embed::ElementModes::READWRITE ); embed::ElementModes::READWRITE );
uno::Reference< beans::XPropertySet > xProps( xSourceStream, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xProps( xSourceStream, uno::UNO_QUERY_THROW );
if ( !xProps.is() )
{
throw uno::RuntimeException("xSourceStream doesn't implement XPropertySet");
}
OUString aMime( "text/xml" ); OUString aMime( "text/xml" );
xProps->setPropertyValue("MediaType", uno::Any( aMime ) ); xProps->setPropertyValue("MediaType", uno::Any( aMime ) );
...@@ -796,13 +792,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons ...@@ -796,13 +792,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons
embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE ); embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE );
// #87671 Allow encryption // #87671 Allow encryption
uno::Reference< embed::XEncryptionProtectedSource > xEncr( xSourceStream, uno::UNO_QUERY ); uno::Reference< embed::XEncryptionProtectedSource > xEncr( xSourceStream, uno::UNO_QUERY_THROW );
OSL_ENSURE( xEncr.is(),
"StorageStream opened for writing must implement XEncryptionProtectedSource!\n" );
if ( !xEncr.is() )
{
throw uno::RuntimeException("xSourceStream doesn't implement XEncryptionProtectedSource");
}
xEncr->setEncryptionPassword( pLib->maPassword ); xEncr->setEncryptionPassword( pLib->maPassword );
} }
catch(const css::packages::WrongPasswordException& ) catch(const css::packages::WrongPasswordException& )
...@@ -813,11 +803,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons ...@@ -813,11 +803,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons
pLib->maPassword ); pLib->maPassword );
} }
uno::Reference< beans::XPropertySet > xProps( xSourceStream, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xProps( xSourceStream, uno::UNO_QUERY_THROW );
if ( !xProps.is() )
{
throw uno::RuntimeException("xSourceStream doesn't implement XPropertySet");
}
OUString aMime( "text/xml" ); OUString aMime( "text/xml" );
xProps->setPropertyValue("MediaType", uno::Any( aMime ) ); xProps->setPropertyValue("MediaType", uno::Any( aMime ) );
...@@ -827,13 +813,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons ...@@ -827,13 +813,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons
// i50568: sax writer already closes stream // i50568: sax writer already closes stream
// xOut->closeOutput(); // xOut->closeOutput();
uno::Reference< embed::XTransactedObject > xTransact( xElementRootStorage, uno::UNO_QUERY ); uno::Reference< embed::XTransactedObject > xTransact( xElementRootStorage, uno::UNO_QUERY_THROW );
OSL_ENSURE( xTransact.is(), "The storage must implement XTransactedObject!\n" );
if ( !xTransact.is() )
{
throw uno::RuntimeException("xElementRootStorage doesn't implement XTransactedObject");
}
xTransact->commit(); xTransact->commit();
} }
catch(const uno::Exception& ) catch(const uno::Exception& )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment