Some simplifications, using UNO_QUERY_THROW

Change-Id: I3d5024ee6e43e5c1ac9f19e967dd6e210757e4d7
Reviewed-on: https://gerrit.libreoffice.org/34265
Tested-by: Stephan Bergmann <sbergman@redhat.com>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann 2017-02-14 16:10:35 +01:00
parent e3aef4dc7c
commit d2e77c3f9f
6 changed files with 50 additions and 161 deletions

View File

@ -94,9 +94,7 @@ uno::Reference< embed::XExtendedStorageStream > OHierarchyElement_Impl::GetStrea
uno::Reference< embed::XStorage > xOwnStor; uno::Reference< embed::XStorage > xOwnStor;
xOwnStor = m_xOwnStorage.is() ? m_xOwnStorage xOwnStor = m_xOwnStorage.is() ? m_xOwnStorage
: uno::Reference< embed::XStorage >( m_xWeakOwnStorage.get(), uno::UNO_QUERY ); : uno::Reference< embed::XStorage >( m_xWeakOwnStorage.get(), uno::UNO_QUERY_THROW );
if ( !xOwnStor.is() )
throw uno::RuntimeException();
if ( aListPath.empty() ) if ( aListPath.empty() )
{ {
@ -177,9 +175,7 @@ void OHierarchyElement_Impl::RemoveStreamHierarchically( OStringList_Impl& aList
uno::Reference< embed::XStorage > xOwnStor; uno::Reference< embed::XStorage > xOwnStor;
xOwnStor = m_xOwnStorage.is() ? m_xOwnStorage xOwnStor = m_xOwnStorage.is() ? m_xOwnStorage
: uno::Reference< embed::XStorage >( m_xWeakOwnStorage.get(), uno::UNO_QUERY ); : uno::Reference< embed::XStorage >( m_xWeakOwnStorage.get(), uno::UNO_QUERY_THROW );
if ( !xOwnStor.is() )
throw uno::RuntimeException();
if ( aListPath.empty() ) if ( aListPath.empty() )
{ {

View File

@ -361,10 +361,7 @@ void OWriteStream_Impl::InsertIntoPackageFolder( const OUString& aName,
if ( m_bFlushed ) if ( m_bFlushed )
{ {
SAL_WARN_IF( !m_xPackageStream.is(), "package.xstor", "An inserted stream is incomplete!\n" ); SAL_WARN_IF( !m_xPackageStream.is(), "package.xstor", "An inserted stream is incomplete!\n" );
uno::Reference< lang::XUnoTunnel > xTunnel( m_xPackageStream, uno::UNO_QUERY ); uno::Reference< lang::XUnoTunnel > xTunnel( m_xPackageStream, uno::UNO_QUERY_THROW );
if ( !xTunnel.is() )
throw uno::RuntimeException(); // TODO
xParentPackageFolder->insertByName( aName, uno::makeAny( xTunnel ) ); xParentPackageFolder->insertByName( aName, uno::makeAny( xTunnel ) );
m_bFlushed = false; m_bFlushed = false;
@ -741,9 +738,7 @@ void OWriteStream_Impl::InsertStreamDirectly( const uno::Reference< io::XInputSt
m_xPackageStream->setDataStream( xInStream ); m_xPackageStream->setDataStream( xInStream );
// copy properties to the package stream // copy properties to the package stream
uno::Reference< beans::XPropertySet > xPropertySet( m_xPackageStream, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xPropertySet( m_xPackageStream, uno::UNO_QUERY_THROW );
if ( !xPropertySet.is() )
throw uno::RuntimeException();
// The storage-package communication has a problem // The storage-package communication has a problem
// the storage caches properties, thus if the package changes one of them itself // 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 // copy properties to the package stream
uno::Reference< beans::XPropertySet > xPropertySet( xNewPackageStream, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xPropertySet( xNewPackageStream, uno::UNO_QUERY_THROW );
if ( !xPropertySet.is() )
throw uno::RuntimeException();
for ( sal_Int32 nInd = 0; nInd < m_aProps.getLength(); nInd++ ) for ( sal_Int32 nInd = 0; nInd < m_aProps.getLength(); nInd++ )
{ {
@ -1103,27 +1096,19 @@ uno::Sequence< beans::PropertyValue > OWriteStream_Impl::ReadPackageStreamProper
// TODO: may be also raw stream should be marked // TODO: may be also raw stream should be marked
uno::Reference< beans::XPropertySet > xPropSet( m_xPackageStream, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xPropSet( m_xPackageStream, uno::UNO_QUERY_THROW );
if ( xPropSet.is() ) 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 );
try { }
aResult[nInd].Value = xPropSet->getPropertyValue( aResult[nInd].Name ); catch( const uno::Exception& rException )
} {
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; return aResult;
@ -1204,9 +1189,7 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream( sal_Int32 nStreamMod
uno::Reference< io::XStream > xResultStream; uno::Reference< io::XStream > xResultStream;
uno::Reference< beans::XPropertySet > xPropertySet( m_xPackageStream, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xPropertySet( m_xPackageStream, uno::UNO_QUERY_THROW );
if ( !xPropertySet.is() )
throw uno::RuntimeException();
if ( m_bHasCachedEncryptionData ) if ( m_bHasCachedEncryptionData )
{ {
@ -1450,9 +1433,7 @@ void OWriteStream_Impl::CreateReadonlyCopyBasedOnData( const uno::Reference< io:
else else
xTempFile = xTargetStream; xTempFile = xTargetStream;
uno::Reference < io::XSeekable > xTempSeek( xTempFile, uno::UNO_QUERY ); uno::Reference < io::XSeekable > xTempSeek( xTempFile, uno::UNO_QUERY_THROW );
if ( !xTempSeek.is() )
throw uno::RuntimeException(); // TODO
uno::Reference < io::XOutputStream > xTempOut = xTempFile->getOutputStream(); uno::Reference < io::XOutputStream > xTempOut = xTempFile->getOutputStream();
if ( !xTempOut.is() ) 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 // that means "use common pass" also should be remembered on flash
uno::Sequence< beans::NamedValue > aKey = aEncryptionData.getAsConstNamedValueList(); uno::Sequence< beans::NamedValue > aKey = aEncryptionData.getAsConstNamedValueList();
uno::Reference< beans::XPropertySet > xProps( m_xPackageStream, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xProps( m_xPackageStream, uno::UNO_QUERY_THROW );
if ( !xProps.is() )
throw uno::RuntimeException();
bool bEncr = false; bool bEncr = false;
xProps->getPropertyValue( "Encrypted" ) >>= bEncr; xProps->getPropertyValue( "Encrypted" ) >>= bEncr;
@ -1792,9 +1771,7 @@ void OWriteStream::CopyToStreamInternally_Impl( const uno::Reference< io::XStrea
if ( !m_xSeekable.is() ) if ( !m_xSeekable.is() )
throw uno::RuntimeException(); throw uno::RuntimeException();
uno::Reference< beans::XPropertySet > xDestProps( xDest, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xDestProps( xDest, uno::UNO_QUERY_THROW );
if ( !xDestProps.is() )
throw uno::RuntimeException(); //TODO
uno::Reference< io::XOutputStream > xDestOutStream = xDest->getOutputStream(); uno::Reference< io::XOutputStream > xDestOutStream = xDest->getOutputStream();
if ( !xDestOutStream.is() ) if ( !xDestOutStream.is() )
@ -2380,14 +2357,7 @@ void SAL_CALL OWriteStream::truncate()
if ( !m_xOutStream.is() ) if ( !m_xOutStream.is() )
throw uno::RuntimeException(); throw uno::RuntimeException();
uno::Reference< io::XTruncate > xTruncate( m_xOutStream, uno::UNO_QUERY ); uno::Reference< io::XTruncate > xTruncate( m_xOutStream, uno::UNO_QUERY_THROW );
if ( !xTruncate.is() )
{
SAL_WARN( "package.xstor", "The output stream must support XTruncate interface!" );
throw uno::RuntimeException();
}
xTruncate->truncate(); xTruncate->truncate();
m_pImpl->m_bHasDataToFlush = true; m_pImpl->m_bHasDataToFlush = true;

View File

@ -105,10 +105,8 @@ void OStorage_Impl::completeStorageStreamCopy_Impl(
sal_Int32 nStorageType, sal_Int32 nStorageType,
const uno::Sequence< uno::Sequence< beans::StringPair > >& aRelInfo ) const uno::Sequence< uno::Sequence< beans::StringPair > >& aRelInfo )
{ {
uno::Reference< beans::XPropertySet > xSourceProps( xSource, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xSourceProps( xSource, uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySet > xDestProps( xDest, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xDestProps( xDest, uno::UNO_QUERY_THROW );
if ( !xSourceProps.is() || !xDestProps.is() )
throw uno::RuntimeException( THROW_WHERE );
uno::Reference< io::XOutputStream > xDestOutStream = xDest->getOutputStream(); uno::Reference< io::XOutputStream > xDestOutStream = xDest->getOutputStream();
if ( !xDestOutStream.is() ) if ( !xDestOutStream.is() )
@ -603,10 +601,7 @@ void OStorage_Impl::ReadContents()
if ( m_bIsRoot ) if ( m_bIsRoot )
OpenOwnPackage(); OpenOwnPackage();
uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xPackageFolder, uno::UNO_QUERY ); uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xPackageFolder, uno::UNO_QUERY_THROW );
if ( !xEnumAccess.is() )
throw uno::RuntimeException( THROW_WHERE );
uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration(); uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration();
if ( !xEnum.is() ) if ( !xEnum.is() )
throw uno::RuntimeException( THROW_WHERE ); throw uno::RuntimeException( THROW_WHERE );
@ -771,10 +766,7 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() ); ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
uno::Reference< container::XNameAccess > xDestAccess( xDest, uno::UNO_QUERY ); uno::Reference< container::XNameAccess > xDestAccess( xDest, uno::UNO_QUERY_THROW );
if ( !xDestAccess.is() )
throw uno::RuntimeException( THROW_WHERE );
if ( xDestAccess->hasByName( aName ) if ( xDestAccess->hasByName( aName )
&& !( pElement->m_bIsStorage && xDest->isStorageElement( aName ) ) ) && !( pElement->m_bIsStorage && xDest->isStorageElement( aName ) ) )
xDest->removeElement( aName ); xDest->removeElement( aName );
@ -1006,10 +998,7 @@ void OStorage_Impl::InsertIntoPackageFolder( const OUString& aName,
::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() ); ::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
SAL_WARN_IF( !m_xPackageFolder.is(), "package.xstor", "An inserted storage is incomplete!" ); SAL_WARN_IF( !m_xPackageFolder.is(), "package.xstor", "An inserted storage is incomplete!" );
uno::Reference< lang::XUnoTunnel > xTunnel( m_xPackageFolder, uno::UNO_QUERY ); uno::Reference< lang::XUnoTunnel > xTunnel( m_xPackageFolder, uno::UNO_QUERY_THROW );
if ( !xTunnel.is() )
throw uno::RuntimeException( THROW_WHERE );
xParentPackageFolder->insertByName( aName, uno::makeAny( xTunnel ) ); xParentPackageFolder->insertByName( aName, uno::makeAny( xTunnel ) );
m_bCommited = false; m_bCommited = false;
@ -1217,10 +1206,7 @@ void OStorage_Impl::Commit()
if ( m_nStorageType == embed::StorageFormats::PACKAGE ) if ( m_nStorageType == embed::StorageFormats::PACKAGE )
{ {
// move properties to the destination package folder // move properties to the destination package folder
uno::Reference< beans::XPropertySet > xProps( xNewPackageFolder, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xProps( xNewPackageFolder, uno::UNO_QUERY_THROW );
if ( !xProps.is() )
throw uno::RuntimeException( THROW_WHERE );
xProps->setPropertyValue( "MediaType", uno::makeAny( m_aMediaType ) ); xProps->setPropertyValue( "MediaType", uno::makeAny( m_aMediaType ) );
xProps->setPropertyValue( "Version", uno::makeAny( m_aVersion ) ); xProps->setPropertyValue( "Version", uno::makeAny( m_aVersion ) );
} }
@ -1230,12 +1216,7 @@ void OStorage_Impl::Commit()
if ( m_bIsRoot ) if ( m_bIsRoot )
{ {
uno::Reference< util::XChangesBatch > xChangesBatch( m_xPackage, uno::UNO_QUERY ); uno::Reference< util::XChangesBatch > xChangesBatch( m_xPackage, uno::UNO_QUERY_THROW );
SAL_WARN_IF( !xChangesBatch.is(), "package.xstor", "Impossible to commit package!" );
if ( !xChangesBatch.is() )
throw uno::RuntimeException( THROW_WHERE );
try try
{ {
xChangesBatch->commitChanges(); xChangesBatch->commitChanges();
@ -1383,9 +1364,7 @@ SotElement_Impl* OStorage_Impl::InsertStream( const OUString& aName, bool bEncr
if ( !xNewElement.is() ) if ( !xNewElement.is() )
throw io::IOException( THROW_WHERE ); throw io::IOException( THROW_WHERE );
uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xNewElement, uno::UNO_QUERY ); uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xNewElement, uno::UNO_QUERY_THROW );
if ( !xPackageSubStream.is() )
throw uno::RuntimeException( THROW_WHERE );
OSL_ENSURE( m_nStorageType == embed::StorageFormats::PACKAGE || !bEncr, "Only package storage supports encryption!\n" ); OSL_ENSURE( m_nStorageType == embed::StorageFormats::PACKAGE || !bEncr, "Only package storage supports encryption!\n" );
if ( m_nStorageType != embed::StorageFormats::PACKAGE && bEncr ) if ( m_nStorageType != embed::StorageFormats::PACKAGE && bEncr )
@ -1425,10 +1404,7 @@ void OStorage_Impl::InsertRawStream( const OUString& aName, const uno::Reference
if ( !xNewElement.is() ) if ( !xNewElement.is() )
throw io::IOException( THROW_WHERE ); throw io::IOException( THROW_WHERE );
uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xNewElement, uno::UNO_QUERY ); uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xNewElement, uno::UNO_QUERY_THROW );
if ( !xPackageSubStream.is() )
throw uno::RuntimeException( THROW_WHERE );
xPackageSubStream->setRawStream( xInStrToInsert ); xPackageSubStream->setRawStream( xInStrToInsert );
// the mode is not needed for storage stream internal implementation // 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() ) if ( !xNewElement.is() )
throw io::IOException( THROW_WHERE ); throw io::IOException( THROW_WHERE );
uno::Reference< container::XNameContainer > xPackageSubFolder( xNewElement, uno::UNO_QUERY ); uno::Reference< container::XNameContainer > xPackageSubFolder( xNewElement, uno::UNO_QUERY_THROW );
if ( !xPackageSubFolder.is() )
throw uno::RuntimeException( THROW_WHERE );
OStorage_Impl* pResult = OStorage_Impl* pResult =
new OStorage_Impl( this, nStorageMode, xPackageSubFolder, m_xPackage, m_xContext, m_nStorageType ); new OStorage_Impl( this, nStorageMode, xPackageSubFolder, m_xPackage, m_xContext, m_nStorageType );
pResult->m_bIsModified = true; pResult->m_bIsModified = true;
@ -1533,13 +1506,7 @@ void OStorage_Impl::OpenSubStorage( SotElement_Impl* pElement, sal_Int32 nStorag
if ( !xTunnel.is() ) if ( !xTunnel.is() )
throw container::NoSuchElementException( THROW_WHERE ); throw container::NoSuchElementException( THROW_WHERE );
uno::Reference< container::XNameContainer > xPackageSubFolder( xTunnel, uno::UNO_QUERY ); uno::Reference< container::XNameContainer > xPackageSubFolder( xTunnel, uno::UNO_QUERY_THROW );
SAL_WARN_IF( !xPackageSubFolder.is(), "package.xstor", "Can not get XNameContainer interface from folder!" );
if ( !xPackageSubFolder.is() )
throw uno::RuntimeException( THROW_WHERE );
pElement->m_pStorage = new OStorage_Impl( this, nStorageMode, xPackageSubFolder, m_xPackage, m_xContext, m_nStorageType ); 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() ) if ( !xTunnel.is() )
throw container::NoSuchElementException( THROW_WHERE ); throw container::NoSuchElementException( THROW_WHERE );
uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xTunnel, uno::UNO_QUERY ); uno::Reference< packages::XDataSinkEncrSupport > xPackageSubStream( xTunnel, uno::UNO_QUERY_THROW );
if ( !xPackageSubStream.is() )
throw uno::RuntimeException( THROW_WHERE );
// the stream can never be inserted here, because inserted stream element holds the stream till commit or destruction // 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 ) ); 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 ) if ( m_pData->m_bReadOnlyWrap )
{ {
// before the storage disposes the stream it must deregister itself as listener // before the storage disposes the stream it must deregister itself as listener
uno::Reference< lang::XComponent > xStreamComponent( xResult, uno::UNO_QUERY ); uno::Reference< lang::XComponent > xStreamComponent( xResult, uno::UNO_QUERY_THROW );
if ( !xStreamComponent.is() )
throw uno::RuntimeException( THROW_WHERE );
MakeLinkToSubComponent_Impl( xStreamComponent ); MakeLinkToSubComponent_Impl( xStreamComponent );
} }
} }
@ -2540,10 +2502,7 @@ uno::Reference< embed::XStorage > SAL_CALL OStorage::openStorageElement(
pElement->m_pStorage->SetReadOnlyWrap( *pResultStorage ); pElement->m_pStorage->SetReadOnlyWrap( *pResultStorage );
// before the storage disposes the stream it must deregister itself as listener // before the storage disposes the stream it must deregister itself as listener
uno::Reference< lang::XComponent > xStorageComponent( xResult, uno::UNO_QUERY ); uno::Reference< lang::XComponent > xStorageComponent( xResult, uno::UNO_QUERY_THROW );
if ( !xStorageComponent.is() )
throw uno::RuntimeException( THROW_WHERE );
MakeLinkToSubComponent_Impl( xStorageComponent ); MakeLinkToSubComponent_Impl( xStorageComponent );
} }
} }
@ -3149,10 +3108,7 @@ void SAL_CALL OStorage::copyElementTo( const OUString& aElementName,
if ( !pElement ) if ( !pElement )
throw container::NoSuchElementException( THROW_WHERE ); throw container::NoSuchElementException( THROW_WHERE );
uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY ); uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY_THROW );
if ( !xNameAccess.is() )
throw uno::RuntimeException( THROW_WHERE );
if ( xNameAccess->hasByName( aNewName ) ) if ( xNameAccess->hasByName( aNewName ) )
throw container::ElementExistException( THROW_WHERE ); throw container::ElementExistException( THROW_WHERE );
@ -3243,10 +3199,7 @@ void SAL_CALL OStorage::moveElementTo( const OUString& aElementName,
if ( !pElement ) if ( !pElement )
throw container::NoSuchElementException( THROW_WHERE ); //??? throw container::NoSuchElementException( THROW_WHERE ); //???
uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY ); uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY_THROW );
if ( !xNameAccess.is() )
throw uno::RuntimeException( THROW_WHERE );
if ( xNameAccess->hasByName( aNewName ) ) if ( xNameAccess->hasByName( aNewName ) )
throw container::ElementExistException( THROW_WHERE ); throw container::ElementExistException( THROW_WHERE );
@ -3348,10 +3301,7 @@ uno::Reference< io::XStream > SAL_CALL OStorage::openEncryptedStream(
if ( m_pData->m_bReadOnlyWrap ) if ( m_pData->m_bReadOnlyWrap )
{ {
// before the storage disposes the stream it must deregister itself as listener // before the storage disposes the stream it must deregister itself as listener
uno::Reference< lang::XComponent > xStreamComponent( xResult, uno::UNO_QUERY ); uno::Reference< lang::XComponent > xStreamComponent( xResult, uno::UNO_QUERY_THROW );
if ( !xStreamComponent.is() )
throw uno::RuntimeException( THROW_WHERE );
MakeLinkToSubComponent_Impl( xStreamComponent ); MakeLinkToSubComponent_Impl( xStreamComponent );
} }
} }
@ -4724,10 +4674,7 @@ uno::Any SAL_CALL OStorage::getPropertyValue( const OUString& aPropertyName )
{ {
try { try {
m_pImpl->ReadContents(); m_pImpl->ReadContents();
uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY ); uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY_THROW );
if ( !xPackPropSet.is() )
throw uno::RuntimeException( THROW_WHERE );
return xPackPropSet->getPropertyValue( aPropertyName ); return xPackPropSet->getPropertyValue( aPropertyName );
} }
catch ( const uno::RuntimeException& rRuntimeException ) catch ( const uno::RuntimeException& rRuntimeException )
@ -5299,10 +5246,7 @@ void SAL_CALL OStorage::copyElementDirectlyTo(
if ( !pElement ) if ( !pElement )
throw container::NoSuchElementException( THROW_WHERE ); throw container::NoSuchElementException( THROW_WHERE );
uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY ); uno::Reference< XNameAccess > xNameAccess( xDest, uno::UNO_QUERY_THROW );
if ( !xNameAccess.is() )
throw uno::RuntimeException( THROW_WHERE );
if ( xNameAccess->hasByName( aNewName ) ) if ( xNameAccess->hasByName( aNewName ) )
throw container::ElementExistException( THROW_WHERE ); throw container::ElementExistException( THROW_WHERE );

View File

@ -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 // the stream must be seekable, if it is not it will be wrapped
m_xContentStream = ::comphelper::OSeekableInputWrapper::CheckSeekableCanWrap( m_xContentStream, m_xContext ); m_xContentStream = ::comphelper::OSeekableInputWrapper::CheckSeekableCanWrap( m_xContentStream, m_xContext );
m_xContentSeek.set( m_xContentStream, UNO_QUERY ); m_xContentSeek.set( m_xContentStream, UNO_QUERY_THROW );
if ( ! m_xContentSeek.is() )
throw css::uno::Exception (THROW_WHERE "The package component _requires_ an XSeekable interface!",
static_cast < ::cppu::OWeakObject * > ( this ) );
if ( !m_xContentSeek->getLength() ) if ( !m_xContentSeek->getLength() )
bHaveZipFile = false; bHaveZipFile = false;
} }
@ -1414,9 +1410,7 @@ void SAL_CALL ZipPackage::commitChanges()
try try
{ {
xOutputStream = m_xStream->getOutputStream(); xOutputStream = m_xStream->getOutputStream();
uno::Reference < XTruncate > xTruncate ( xOutputStream, UNO_QUERY ); uno::Reference < XTruncate > xTruncate ( xOutputStream, UNO_QUERY_THROW );
if ( !xTruncate.is() )
throw uno::RuntimeException(THROW_WHERE );
// after successful truncation the original file contents are already lost // after successful truncation the original file contents are already lost
xTruncate->truncate(); xTruncate->truncate();
@ -1495,10 +1489,7 @@ void SAL_CALL ZipPackage::commitChanges()
{ {
try try
{ {
uno::Reference < XPropertySet > xPropSet ( xTempInStream, UNO_QUERY ); uno::Reference < XPropertySet > xPropSet ( xTempInStream, UNO_QUERY_THROW );
OSL_ENSURE( xPropSet.is(), "This is a temporary file that must implement XPropertySet!\n" );
if ( !xPropSet.is() )
throw uno::RuntimeException(THROW_WHERE );
OUString sTargetFolder = m_aURL.copy ( 0, m_aURL.lastIndexOf ( static_cast < sal_Unicode > ( '/' ) ) ); OUString sTargetFolder = m_aURL.copy ( 0, m_aURL.lastIndexOf ( static_cast < sal_Unicode > ( '/' ) ) );
Content aContent( Content aContent(

View File

@ -149,9 +149,7 @@ uno::Reference< io::XInputStream > const & ZipPackageStream::GetOwnSeekStream()
// is accessed before commit it MUST be wrapped. // is accessed before commit it MUST be wrapped.
// Wrap the stream in case it is not seekable // Wrap the stream in case it is not seekable
m_xStream = ::comphelper::OSeekableInputWrapper::CheckSeekableCanWrap( m_xStream, m_xContext ); m_xStream = ::comphelper::OSeekableInputWrapper::CheckSeekableCanWrap( m_xStream, m_xContext );
uno::Reference< io::XSeekable > xSeek( m_xStream, UNO_QUERY ); uno::Reference< io::XSeekable > xSeek( m_xStream, UNO_QUERY_THROW );
if ( !xSeek.is() )
throw RuntimeException( THROW_WHERE "The stream must support XSeekable!" );
m_bHasSeekable = true; m_bHasSeekable = true;
} }
@ -289,16 +287,11 @@ uno::Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream(
pPackage->initialize( aArgs ); pPackage->initialize( aArgs );
// create a new package stream // create a new package stream
uno::Reference< XDataSinkEncrSupport > xNewPackStream( xPackageAsFactory->createInstance(), UNO_QUERY ); uno::Reference< XDataSinkEncrSupport > xNewPackStream( xPackageAsFactory->createInstance(), UNO_QUERY_THROW );
if ( !xNewPackStream.is() )
throw RuntimeException(THROW_WHERE );
xNewPackStream->setDataStream( static_cast< io::XInputStream* >( xNewPackStream->setDataStream( static_cast< io::XInputStream* >(
new WrapStreamForShare( GetOwnSeekStream(), m_rZipPackage.GetSharedMutexRef() ) ) ); new WrapStreamForShare( GetOwnSeekStream(), m_rZipPackage.GetSharedMutexRef() ) ) );
uno::Reference< XPropertySet > xNewPSProps( xNewPackStream, UNO_QUERY ); uno::Reference< XPropertySet > xNewPSProps( xNewPackStream, UNO_QUERY_THROW );
if ( !xNewPSProps.is() )
throw RuntimeException(THROW_WHERE );
// copy all the properties of this stream to the new stream // copy all the properties of this stream to the new stream
xNewPSProps->setPropertyValue("MediaType", makeAny( msMediaType ) ); xNewPSProps->setPropertyValue("MediaType", makeAny( msMediaType ) );
@ -313,9 +306,7 @@ uno::Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream(
uno::Reference< XUnoTunnel > xTunnel; uno::Reference< XUnoTunnel > xTunnel;
Any aRoot = pPackage->getByHierarchicalName("/"); Any aRoot = pPackage->getByHierarchicalName("/");
aRoot >>= xTunnel; aRoot >>= xTunnel;
uno::Reference< container::XNameContainer > xRootNameContainer( xTunnel, UNO_QUERY ); uno::Reference< container::XNameContainer > xRootNameContainer( xTunnel, UNO_QUERY_THROW );
if ( !xRootNameContainer.is() )
throw RuntimeException(THROW_WHERE );
uno::Reference< XUnoTunnel > xNPSTunnel( xNewPackStream, UNO_QUERY ); uno::Reference< XUnoTunnel > xNPSTunnel( xNewPackStream, UNO_QUERY );
xRootNameContainer->insertByName("dummy", makeAny( xNPSTunnel ) ); 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 // wrap the stream in case it is not seekable
uno::Reference< io::XInputStream > xNewStream = ::comphelper::OSeekableInputWrapper::CheckSeekableCanWrap( aStream, m_xContext ); uno::Reference< io::XInputStream > xNewStream = ::comphelper::OSeekableInputWrapper::CheckSeekableCanWrap( aStream, m_xContext );
uno::Reference< io::XSeekable > xSeek( xNewStream, UNO_QUERY ); uno::Reference< io::XSeekable > xSeek( xNewStream, UNO_QUERY_THROW );
if ( !xSeek.is() )
throw RuntimeException(THROW_WHERE "The stream must support XSeekable!" );
xSeek->seek( 0 ); xSeek->seek( 0 );
uno::Reference< io::XInputStream > xOldStream = m_xStream; uno::Reference< io::XInputStream > xOldStream = m_xStream;
m_xStream = xNewStream; m_xStream = xNewStream;

View File

@ -38,12 +38,12 @@ WrapStreamForShare::WrapStreamForShare( const uno::Reference< io::XInputStream >
, m_xInStream( xInStream ) , m_xInStream( xInStream )
, m_nCurPos( 0 ) , m_nCurPos( 0 )
{ {
m_xSeekable.set( m_xInStream, uno::UNO_QUERY ); if ( !m_rMutexRef.is() || !m_xInStream.is() )
if ( !m_rMutexRef.is() || !m_xInStream.is() || !m_xSeekable.is() )
{ {
OSL_FAIL( "Wrong initialization of wrapping stream!\n" ); OSL_FAIL( "Wrong initialization of wrapping stream!\n" );
throw uno::RuntimeException(THROW_WHERE ); throw uno::RuntimeException(THROW_WHERE );
} }
m_xSeekable.set( m_xInStream, uno::UNO_QUERY_THROW );
} }
WrapStreamForShare::~WrapStreamForShare() WrapStreamForShare::~WrapStreamForShare()