#112923# do not close stream untill it is needed
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: miscobj.cxx,v $
|
||||
*
|
||||
* $Revision: 1.5 $
|
||||
* $Revision: 1.6 $
|
||||
*
|
||||
* last change: $Author: mav $ $Date: 2003-11-18 12:47:06 $
|
||||
* last change: $Author: mav $ $Date: 2003-11-20 17:02:21 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -467,6 +467,23 @@ void SAL_CALL OCommonEmbeddedObject::close( sal_Bool bDeliverOwnership )
|
||||
m_pDocHolder = NULL;
|
||||
}
|
||||
|
||||
// TODO: for now the storage will be disposed by the object, but after the document
|
||||
// will use the storage, the storage will be disposed by the document and recreated by the object
|
||||
if ( m_xObjectStorage.is() )
|
||||
{
|
||||
uno::Reference< lang::XComponent > xComp( m_xObjectStorage, uno::UNO_QUERY );
|
||||
OSL_ENSURE( xComp.is(), "Storage does not support XComponent!\n" );
|
||||
|
||||
if ( xComp.is() )
|
||||
{
|
||||
try {
|
||||
xComp->dispose();
|
||||
} catch ( uno::Exception& ) {}
|
||||
}
|
||||
|
||||
m_xObjectStorage = uno::Reference< embed::XStorage >();
|
||||
}
|
||||
|
||||
m_bClosed = sal_True; // the closing succeeded
|
||||
}
|
||||
|
||||
|
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: oleembobj.hxx,v $
|
||||
*
|
||||
* $Revision: 1.3 $
|
||||
* $Revision: 1.4 $
|
||||
*
|
||||
* last change: $Author: mav $ $Date: 2003-11-18 09:03:54 $
|
||||
* last change: $Author: mav $ $Date: 2003-11-20 17:02:21 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -165,6 +165,9 @@ class OleEmbeddedObject : public ::cppu::WeakImplHelper8
|
||||
::rtl::OUString m_aLinkURL; // ???
|
||||
|
||||
protected:
|
||||
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > GetStreamForSaving();
|
||||
|
||||
::com::sun::star::uno::Sequence< sal_Int32 > GetIntermediateVerbsSequence_Impl( sal_Int32 nNewState );
|
||||
|
||||
::com::sun::star::uno::Sequence< sal_Int32 > GetReachableStatesList_Impl(
|
||||
|
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: olemisc.cxx,v $
|
||||
*
|
||||
* $Revision: 1.3 $
|
||||
* $Revision: 1.4 $
|
||||
*
|
||||
* last change: $Author: mav $ $Date: 2003-11-18 09:03:55 $
|
||||
* last change: $Author: mav $ $Date: 2003-11-20 17:02:23 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -66,7 +66,9 @@
|
||||
#include <com/sun/star/embed/EmbedStates.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
|
||||
#include <com/sun/star/lang/XComponent.hpp>
|
||||
#endif
|
||||
#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
|
||||
#include <com/sun/star/lang/DisposedException.hpp>
|
||||
#endif
|
||||
@@ -118,9 +120,10 @@ OleEmbeddedObject::OleEmbeddedObject( const uno::Reference< lang::XMultiServiceF
|
||||
//------------------------------------------------------
|
||||
OleEmbeddedObject::~OleEmbeddedObject()
|
||||
{
|
||||
OSL_ENSURE( !m_pInterfaceContainer && !m_pOleComponent, "The object is not closed! DISASTER is possible!" );
|
||||
OSL_ENSURE( !m_pInterfaceContainer && !m_pOleComponent && !m_xObjectStream.is(),
|
||||
"The object is not closed! DISASTER is possible!" );
|
||||
|
||||
if ( m_pOleComponent || m_pInterfaceContainer )
|
||||
if ( m_pOleComponent || m_pInterfaceContainer || m_xObjectStream.is() )
|
||||
{
|
||||
// the component must be cleaned during closing
|
||||
m_refCount++; // to avoid crash
|
||||
@@ -155,6 +158,22 @@ void OleEmbeddedObject::Dispose()
|
||||
m_pOleComponent = NULL;
|
||||
}
|
||||
|
||||
if ( m_xObjectStream.is() )
|
||||
{
|
||||
uno::Reference< lang::XComponent > xComp( m_xObjectStream, uno::UNO_QUERY );
|
||||
OSL_ENSURE( xComp.is(), "Storage stream doesn't support XComponent!\n" );
|
||||
|
||||
if ( xComp.is() )
|
||||
{
|
||||
try {
|
||||
xComp->dispose();
|
||||
} catch( uno::Exception& ) {}
|
||||
}
|
||||
m_xObjectStream = uno::Reference< io::XStream >();
|
||||
}
|
||||
|
||||
m_xParentStorage = uno::Reference< embed::XStorage >();
|
||||
|
||||
m_bDisposed = true;
|
||||
}
|
||||
|
||||
|
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: olepersist.cxx,v $
|
||||
*
|
||||
* $Revision: 1.3 $
|
||||
* $Revision: 1.4 $
|
||||
*
|
||||
* last change: $Author: mav $ $Date: 2003-11-18 09:03:56 $
|
||||
* last change: $Author: mav $ $Date: 2003-11-20 17:02:23 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -94,6 +94,10 @@
|
||||
#include <com/sun/star/container/XNameAccess.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef _COM_SUN_STAR_IO_XTRUNCATE_HPP_
|
||||
#include <com/sun/star/io/XTruncate.hpp>
|
||||
#endif
|
||||
|
||||
#include <olecomponent.hxx>
|
||||
#include <closepreventer.hxx>
|
||||
|
||||
@@ -167,6 +171,25 @@ void OleEmbeddedObject::CreateOleComponent_Impl()
|
||||
OSL_ENSURE( sal_False, "Trying to recreate OLE component!\n" );
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
uno::Reference< io::XOutputStream > OleEmbeddedObject::GetStreamForSaving()
|
||||
{
|
||||
if ( !m_xObjectStream.is() )
|
||||
throw uno::RuntimeException(); //TODO:
|
||||
|
||||
uno::Reference< io::XOutputStream > xOutStream = m_xObjectStream->getOutputStream();
|
||||
if ( !xOutStream.is() )
|
||||
throw io::IOException(); //TODO: access denied
|
||||
|
||||
uno::Reference< io::XTruncate > xTruncate( xOutStream, uno::UNO_QUERY );
|
||||
if ( !xTruncate.is() )
|
||||
throw uno::RuntimeException(); //TODO:
|
||||
|
||||
xTruncate->truncate();
|
||||
|
||||
return xOutStream;
|
||||
}
|
||||
|
||||
//------------------------------------------------------
|
||||
void SAL_CALL OleEmbeddedObject::setPersistentEntry(
|
||||
const uno::Reference< embed::XStorage >& xStorage,
|
||||
@@ -367,21 +390,15 @@ void SAL_CALL OleEmbeddedObject::storeOwn()
|
||||
// in case visual repersentation must be stored also
|
||||
// the procedure should be the same as for embedded objects
|
||||
|
||||
uno::Reference< io::XOutputStream > xOutStream = m_xObjectStream->getOutputStream();
|
||||
if ( !xOutStream.is() )
|
||||
throw io::IOException(); //TODO: access denied
|
||||
uno::Reference< io::XOutputStream > xOutStream = GetStreamForSaving();
|
||||
|
||||
// should the component detect that it is a link???
|
||||
m_pOleComponent->StoreObjectToStream( xOutStream, m_bStoreVisRepl );
|
||||
xOutStream->closeOutput(); //TODO: allow to reopen the stream object ???
|
||||
}
|
||||
else
|
||||
{
|
||||
uno::Reference< io::XOutputStream > xOutStream = m_xObjectStream->getOutputStream();
|
||||
if ( !xOutStream.is() )
|
||||
throw io::IOException(); //TODO: access denied
|
||||
uno::Reference< io::XOutputStream > xOutStream = GetStreamForSaving();
|
||||
m_pOleComponent->StoreObjectToStream( xOutStream, m_bStoreVisRepl );
|
||||
xOutStream->closeOutput(); //TODO: allow to reopen the stream object ???
|
||||
}
|
||||
|
||||
// TODO:
|
||||
@@ -431,7 +448,6 @@ void SAL_CALL OleEmbeddedObject::storeToEntry( const uno::Reference< embed::XSto
|
||||
throw io::IOException(); //TODO: access denied
|
||||
|
||||
m_pOleComponent->StoreObjectToStream( xOutStream, m_bStoreVisRepl );
|
||||
xOutStream->closeOutput();
|
||||
|
||||
uno::Reference< lang::XComponent > xComp( xTargetStream, uno::UNO_QUERY );
|
||||
if ( xComp.is() )
|
||||
@@ -485,7 +501,6 @@ void SAL_CALL OleEmbeddedObject::storeAsEntry( const uno::Reference< embed::XSto
|
||||
throw io::IOException(); //TODO: access denied
|
||||
|
||||
m_pOleComponent->StoreObjectToStream( xOutStream, m_bStoreVisRepl );
|
||||
xOutStream->closeOutput(); // TODO: allow to reuse the stream
|
||||
|
||||
try {
|
||||
uno::Reference< lang::XComponent > xComp( xTargetStream, uno::UNO_QUERY );
|
||||
|
Reference in New Issue
Block a user