#112923# storage switching for OOo embedded object

This commit is contained in:
Mikhail Voitenko
2003-11-25 12:21:47 +00:00
parent 4c5a0eade6
commit 883d995bd3
2 changed files with 54 additions and 15 deletions

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: persistence.cxx,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: mav $ $Date: 2003-11-14 15:24:24 $
* last change: $Author: mav $ $Date: 2003-11-25 13:21:47 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -213,6 +213,38 @@ uno::Reference< io::XInputStream > createTempInpStreamFromStor(
}
//------------------------------------------------------
void OCommonEmbeddedObject::SwitchOwnPersistence( const uno::Reference< embed::XStorage >& xNewParentStorage,
const uno::Reference< embed::XStorage >& xNewObjectStorage,
const ::rtl::OUString& aNewName )
{
try {
uno::Reference< lang::XComponent > xComponent( m_xObjectStorage, uno::UNO_QUERY );
OSL_ENSURE( xComponent.is(), "Wrong storage implementation!" );
if ( xComponent.is() )
xComponent->dispose();
}
catch ( uno::Exception& )
{
}
m_xObjectStorage = xNewObjectStorage;
m_xParentStorage = xNewParentStorage;
m_aEntryName = aNewName;
}
//------------------------------------------------------
void OCommonEmbeddedObject::SwitchOwnPersistence( const uno::Reference< embed::XStorage >& xNewParentStorage,
const ::rtl::OUString& aNewName )
{
sal_Int32 nStorageMode = m_bReadOnly ? embed::ElementModes::ELEMENT_READ : embed::ElementModes::ELEMENT_READWRITE;
uno::Reference< embed::XStorage > xNewOwnStorage = xNewParentStorage->openStorageElement( aNewName, nStorageMode );
OSL_ENSURE( xNewOwnStorage.is(), "The method can not return empty reference!" );
SwitchOwnPersistence( xNewParentStorage, xNewOwnStorage, aNewName );
}
//------------------------------------------------------
uno::Reference< frame::XModel > OCommonEmbeddedObject::InitNewDocument_Impl()
{
@@ -565,9 +597,7 @@ void SAL_CALL OCommonEmbeddedObject::setPersistentEntry(
sal_Int32 nStorageMode = m_bReadOnly ? embed::ElementModes::ELEMENT_READ : embed::ElementModes::ELEMENT_READWRITE;
m_xObjectStorage = xStorage->openStorageElement( sEntName, nStorageMode );
m_xParentStorage = xStorage;
m_aEntryName = sEntName;
SwitchOwnPersistence( xStorage, sEntName );
if ( nEntryConnectionMode == embed::EntryInitModes::ENTRY_DEFAULT_INIT )
{
@@ -800,11 +830,16 @@ void SAL_CALL OCommonEmbeddedObject::saveCompleted( sal_Bool bUseNew )
if ( bUseNew )
{
// the link object is not linked any more
// TODO: the link will have own persistence, so the link will stay the link
m_bIsLink = sal_False;
m_aLinkURL = ::rtl::OUString();
SwitchOwnPersistence( m_xNewParentStorage, m_xNewObjectStorage, m_aNewEntryName );
}
else
{
try {
uno::Reference< lang::XComponent > xComponent( m_xObjectStorage, uno::UNO_QUERY );
uno::Reference< lang::XComponent > xComponent( m_xNewObjectStorage, uno::UNO_QUERY );
OSL_ENSURE( xComponent.is(), "Wrong storage implementation!" );
if ( xComponent.is() )
xComponent->dispose();
@@ -812,10 +847,6 @@ void SAL_CALL OCommonEmbeddedObject::saveCompleted( sal_Bool bUseNew )
catch ( uno::Exception& )
{
}
m_xObjectStorage = m_xNewObjectStorage;
m_xParentStorage = m_xNewParentStorage;
m_aEntryName = m_aNewEntryName;
}
m_xNewObjectStorage = uno::Reference< embed::XStorage >();
@@ -979,9 +1010,8 @@ void SAL_CALL OCommonEmbeddedObject::breakLink( const uno::Reference< embed::XSt
m_bReadOnly = sal_False;
sal_Int32 nStorageMode = embed::ElementModes::ELEMENT_READWRITE;
m_xObjectStorage = xStorage->openStorageElement( sEntName, nStorageMode );
m_xParentStorage = xStorage;
m_aEntryName = sEntName;
if ( m_xParentStorage != xStorage || !m_aEntryName.equals( sEntName ) )
SwitchOwnPersistence( xStorage, sEntName );
// for linked object it means that it becomes embedded object
// the document must switch it's persistence also

View File

@@ -2,9 +2,9 @@
*
* $RCSfile: commonembobj.hxx,v $
*
* $Revision: 1.6 $
* $Revision: 1.7 $
*
* last change: $Author: mav $ $Date: 2003-11-18 12:47:08 $
* last change: $Author: mav $ $Date: 2003-11-25 13:21:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -191,6 +191,15 @@ class OCommonEmbeddedObject : public ::com::sun::star::embed::XEmbeddedObject
private:
void CommonInit_Impl();
void SwitchOwnPersistence(
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xNewParentStorage,
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xNewObjectStorage,
const ::rtl::OUString& aNewName );
void SwitchOwnPersistence(
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xNewParentStorage,
const ::rtl::OUString& aNewName );
::rtl::OUString GetDocumentServiceName() { return m_aDocServiceName; }
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > StoreDocumentToTempStream_Impl();