diff options
Diffstat (limited to 'embeddedobj/source')
-rw-r--r-- | embeddedobj/source/msole/olecomponent.cxx | 3 | ||||
-rw-r--r-- | embeddedobj/source/msole/olepersist.cxx | 15 |
2 files changed, 18 insertions, 0 deletions
diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx index 9fe827bb00d9..9843e4999f44 100644 --- a/embeddedobj/source/msole/olecomponent.cxx +++ b/embeddedobj/source/msole/olecomponent.cxx @@ -1299,7 +1299,10 @@ void OleComponent::StoreOwnTmpIfNecessary() GUID aCLSID; hr = m_pNativeImpl->m_pOleObject->GetUserClassID( &aCLSID ); if ( FAILED( hr ) ) + { + SAL_WARN("embeddedobj.ole", "OleComponent::StoreOwnTmpIfNecessary: GetUserClassID() failed"); throw io::IOException(); // TODO + } hr = WriteClassStg( m_pNativeImpl->m_pIStorage, aCLSID ); if ( FAILED( hr ) ) diff --git a/embeddedobj/source/msole/olepersist.cxx b/embeddedobj/source/msole/olepersist.cxx index 7f5002ec2772..fddf46d6e658 100644 --- a/embeddedobj/source/msole/olepersist.cxx +++ b/embeddedobj/source/msole/olepersist.cxx @@ -768,6 +768,21 @@ void OleEmbeddedObject::SwitchOwnPersistence( const uno::Reference< embed::XStor sal_Int32 nStreamMode = m_bReadOnly ? embed::ElementModes::READ : embed::ElementModes::READWRITE; uno::Reference< io::XStream > xNewOwnStream = xNewParentStorage->openStreamElement( aNewName, nStreamMode ); + + uno::Reference<io::XSeekable> xNewSeekable (xNewOwnStream, uno::UNO_QUERY); + if (xNewSeekable.is() && xNewSeekable->getLength() == 0) + { + uno::Reference<io::XSeekable> xOldSeekable(m_xObjectStream, uno::UNO_QUERY); + if (xOldSeekable.is() && xOldSeekable->getLength() > 0) + { + SAL_WARN("embeddedobj.ole", "OleEmbeddedObject::SwitchOwnPersistence: empty new stream, reusing old one"); + uno::Reference<io::XInputStream> xInput = m_xObjectStream->getInputStream(); + uno::Reference<io::XOutputStream> xOutput = xNewOwnStream->getOutputStream(); + comphelper::OStorageHelper::CopyInputToOutput(xInput, xOutput); + xNewSeekable->seek(0); + } + } + SAL_WARN_IF( !xNewOwnStream.is(), "embeddedobj.ole", "The method can not return empty reference!" ); SwitchOwnPersistence( xNewParentStorage, xNewOwnStream, aNewName ); |