diff options
Diffstat (limited to 'package/source/zippackage/ZipPackage.cxx')
-rw-r--r-- | package/source/zippackage/ZipPackage.cxx | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 6ca9981d2291..a692586681b5 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -135,25 +135,6 @@ sal_Bool isLocalFile_Impl( ::rtl::OUString aURL ) return ( aSystemPath.getLength() != 0 ); } -class PostinitializationGuard -{ - uno::Reference< io::XInputStream > m_xTempStream; - - ZipPackage& m_rZipPackage; - -public: - PostinitializationGuard( const uno::Reference< io::XInputStream >& xTempStream, - ZipPackage& rZipPackage ) - : m_xTempStream( xTempStream ) - , m_rZipPackage( rZipPackage ) - {} - - virtual ~PostinitializationGuard() - { - m_rZipPackage.ConnectTo( m_xTempStream ); - } -}; - } //=========================================================================== @@ -1370,8 +1351,18 @@ void SAL_CALL ZipPackage::commitChanges() { uno::Reference< io::XSeekable > xTempSeek( xTempInStream, uno::UNO_QUERY_THROW ); - // switch to the new temporary stream only after the transfer - PostinitializationGuard aPostInitGuard( xTempInStream, *this ); + try + { + xTempSeek->seek( 0 ); + } + catch( uno::Exception& r ) + { + throw WrappedTargetException( OUString( RTL_CONSTASCII_USTRINGPARAM ( OSL_LOG_PREFIX "Temporary file should be seekable!" ) ), + static_cast < OWeakObject * > ( this ), makeAny ( r ) ); + } + + // connect to the temporary stream + ConnectTo( xTempInStream ); if ( m_eMode == e_IMode_XStream ) { @@ -1381,8 +1372,6 @@ void SAL_CALL ZipPackage::commitChanges() // preparation for copy step try { - xTempSeek->seek( 0 ); - xOutputStream = m_xStream->getOutputStream(); uno::Reference < XTruncate > xTruncate ( xOutputStream, UNO_QUERY ); if ( !xTruncate.is() ) |