summaryrefslogtreecommitdiff
path: root/embeddedobj
diff options
context:
space:
mode:
authorMikhail Voitenko <mav@openoffice.org>2003-11-24 08:42:58 +0000
committerMikhail Voitenko <mav@openoffice.org>2003-11-24 08:42:58 +0000
commitb48620947caf316db386694cedafd1cb3a199fe3 (patch)
tree9c1b29e99e8cde2ec2e2cbf0a53213265117ea3b /embeddedobj
parent841e5e03b29c712465dad1711d31ac7a63e3b1ea (diff)
#112923# truncate stream on reusing for write and reopen temporary file
Diffstat (limited to 'embeddedobj')
-rw-r--r--embeddedobj/source/msole/olecomponent.cxx39
1 files changed, 34 insertions, 5 deletions
diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx
index d1116b35bf51..2680c3603655 100644
--- a/embeddedobj/source/msole/olecomponent.cxx
+++ b/embeddedobj/source/msole/olecomponent.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: olecomponent.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: mav $ $Date: 2003-11-17 16:19:24 $
+ * last change: $Author: mav $ $Date: 2003-11-24 09:42:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -82,6 +82,10 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
+#ifndef _COM_SUN_STAR_IO_XTRUNCATE_HPP_
+#include <com/sun/star/io/XTruncate.hpp>
+#endif
+
#include <platform.h>
@@ -403,7 +407,14 @@ CComPtr< IStorage > OleComponent::CreateIStorageOnXInputStream_Impl( const uno::
if ( ::osl::FileBase::getSystemPathFromFileURL( m_aTempURL, aTempFilePath ) != ::osl::FileBase::E_None )
throw uno::RuntimeException(); // TODO: something dangerous happend
- HRESULT hr = StgCreateDocfile( aTempFilePath, STGM_READWRITE | STGM_DELETEONRELEASE, 0, &m_pIStorage );
+ // TODO: remove temporary file when not needed any more
+ HRESULT hr = StgOpenStorage( aTempFilePath,
+ NULL,
+ STGM_READWRITE | STGM_TRANSACTED, // | STGM_DELETEONRELEASE,
+ NULL,
+ 0,
+ &m_pIStorage );
+
if ( FAILED( hr ) || !m_pIStorage )
throw io::IOException(); // TODO: transport error code?
@@ -579,7 +590,11 @@ void OleComponent::LoadEmbeddedObject( const uno::Reference< io::XInputStream >&
HRESULT hr = OleLoad( m_pIStorage, IID_IUnknown, NULL, (void**)&m_pObj );
if ( FAILED( hr ) || !m_pObj )
+ {
+ // STATSTG aStat;
+ // m_pIStorage->Stat( &aStat, STATFLAG_NONAME );
throw uno::RuntimeException();
+ }
if ( !InitializeObject_Impl( NULL ) )
throw uno::RuntimeException(); // TODO
@@ -801,8 +816,16 @@ void OleComponent::StoreObjectToStream( uno::Reference< io::XOutputStream > xOut
if ( FAILED( hr ) )
throw io::IOException(); // TODO
- pPersistStorage->SaveCompleted(NULL);
- m_pIStorage->Commit( STGC_DEFAULT );
+ hr = pPersistStorage->SaveCompleted(NULL);
+ if ( FAILED( hr ) )
+ throw io::IOException(); // TODO
+
+ hr = m_pIStorage->Commit( STGC_DEFAULT );
+ if ( FAILED( hr ) )
+ throw io::IOException(); // TODO
+
+ // STATSTG aStat;
+ // m_pIStorage->Stat( &aStat, STATFLAG_NONAME );
// now all the changes should be in temporary location
@@ -823,6 +846,12 @@ void OleComponent::StoreObjectToStream( uno::Reference< io::XOutputStream > xOut
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:
+
+ xTrunc->truncate();
+
copyInputToOutput_Impl( xTempInStream, xOutStream );
}
else