diff options
author | Rüdiger Timm <rt@openoffice.org> | 2004-11-26 15:15:37 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2004-11-26 15:15:37 +0000 |
commit | 2095abc004ed550a61014c5fdb2a3614ab8ff355 (patch) | |
tree | b8c805598b274a381c082a5c57263f566cf2c730 | |
parent | 8181e29abd2239a995eb893c22f30731f2a7cb53 (diff) |
INTEGRATION: CWS leanobjects (1.13.8); FILE MERGED
2004/11/18 11:35:06 mav 1.13.8.3: #i37014# avoid assertion in case document has unknown mediatype
2004/11/15 17:08:26 mav 1.13.8.2: #i30190# on saveTo/saveAs switch object to running state if the different format is used
2004/11/15 16:22:16 mav 1.13.8.1: #i30190# on saveTo/saveAs switch object to running state if the different format is used
-rw-r--r-- | embeddedobj/source/commonembedding/persistence.cxx | 117 |
1 files changed, 95 insertions, 22 deletions
diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx index 6454b19742c8..a73b6d6c3308 100644 --- a/embeddedobj/source/commonembedding/persistence.cxx +++ b/embeddedobj/source/commonembedding/persistence.cxx @@ -2,9 +2,9 @@ * * $RCSfile: persistence.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: obo $ $Date: 2004-11-17 13:25:22 $ + * last change: $Author: rt $ $Date: 2004-11-26 16:15:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -121,6 +121,9 @@ #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ #include <com/sun/star/beans/XPropertySet.hpp> #endif +#ifndef _COM_SUN_STAR_BEANS_ILLEGALTYPEEXCEPTION_HPP_ +#include <com/sun/star/beans/IllegalTypeException.hpp> +#endif #include <comphelper/fileformat.h> #include <comphelper/storagehelper.hxx> @@ -765,6 +768,10 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::CreateTempDocFromLink_ try { nStorageFormat = ::comphelper::OStorageHelper::GetXStorageFormat( m_xParentStorage ); } + catch ( beans::IllegalTypeException& ) + { + // the container just has an unknown type, use current file format + } catch ( uno::Exception& ) { OSL_ENSURE( sal_False, "Can not retrieve storage media type!\n" ); @@ -1000,11 +1007,49 @@ void SAL_CALL OCommonEmbeddedObject::storeToEntry( const uno::Reference< embed:: OSL_ENSURE( m_xParentStorage.is() && m_xObjectStorage.is(), "The object has no valid persistence!\n" ); - // TODO/LATER: Storing to different format can be done only in running state, - // copiing is not legal for documents with relative links. + sal_Int32 nTargetStorageFormat = SOFFICE_FILEFORMAT_CURRENT; + sal_Int32 nOriginalStorageFormat = SOFFICE_FILEFORMAT_CURRENT; + try { + nTargetStorageFormat = ::comphelper::OStorageHelper::GetXStorageFormat( xStorage ); + } + catch ( beans::IllegalTypeException& ) + { + // the container just has an unknown type, use current file format + } + catch ( uno::Exception& ) + { + OSL_ENSURE( sal_False, "Can not retrieve target storage media type!\n" ); + } + + try + { + nOriginalStorageFormat = ::comphelper::OStorageHelper::GetXStorageFormat( m_xParentStorage ); + } + catch ( beans::IllegalTypeException& ) + { + // the container just has an unknown type, use current file format + } + catch ( uno::Exception& ) + { + OSL_ENSURE( sal_False, "Can not retrieve own storage media type!\n" ); + } + + sal_Bool bSwitchBackToLoaded = sal_False; + + // Storing to different format can be done only in running state. if ( m_nObjectState == embed::EmbedStates::LOADED ) - m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName ); - else + { + // TODO/LATER: copiing is not legal for documents with relative links. + if ( nTargetStorageFormat == nOriginalStorageFormat ) + m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName ); + else + { + changeState( embed::EmbedStates::RUNNING ); + bSwitchBackToLoaded = sal_True; + } + } + + if ( m_nObjectState != embed::EmbedStates::LOADED ) { uno::Reference< embed::XStorage > xSubStorage = xStorage->openStorageElement( sEntName, embed::ElementModes::READWRITE ); @@ -1012,17 +1057,10 @@ void SAL_CALL OCommonEmbeddedObject::storeToEntry( const uno::Reference< embed:: if ( !xSubStorage.is() ) throw uno::RuntimeException(); //TODO - sal_Int32 nStorageFormat = SOFFICE_FILEFORMAT_CURRENT; - try { - nStorageFormat = ::comphelper::OStorageHelper::GetXStorageFormat( xStorage ); - } - catch ( uno::Exception& ) - { - OSL_ENSURE( sal_False, "Can not retrieve storage media type!\n" ); - } - // TODO/LATER: support hierarchical name for embedded objects in embedded objects - StoreDocToStorage_Impl( xSubStorage, nStorageFormat, GetBaseURLFrom_Impl( lArguments, lObjArgs ), sEntName ); + StoreDocToStorage_Impl( xSubStorage, nTargetStorageFormat, GetBaseURLFrom_Impl( lArguments, lObjArgs ), sEntName ); + if ( bSwitchBackToLoaded ) + changeState( embed::EmbedStates::LOADED ); } // TODO: should the listener notification be done? @@ -1063,20 +1101,49 @@ void SAL_CALL OCommonEmbeddedObject::storeAsEntry( const uno::Reference< embed:: OSL_ENSURE( m_xParentStorage.is() && m_xObjectStorage.is(), "The object has no valid persistence!\n" ); - sal_Int32 nStorageFormat = SOFFICE_FILEFORMAT_CURRENT; + sal_Int32 nTargetStorageFormat = SOFFICE_FILEFORMAT_CURRENT; + sal_Int32 nOriginalStorageFormat = SOFFICE_FILEFORMAT_CURRENT; try { - nStorageFormat = ::comphelper::OStorageHelper::GetXStorageFormat( xStorage ); + nTargetStorageFormat = ::comphelper::OStorageHelper::GetXStorageFormat( xStorage ); + } + catch ( beans::IllegalTypeException& ) + { + // the container just has an unknown type, use current file format } catch ( uno::Exception& ) { - OSL_ENSURE( sal_False, "Can not retrieve storage media type!\n" ); + OSL_ENSURE( sal_False, "Can not retrieve target storage media type!\n" ); + } + + try + { + nOriginalStorageFormat = ::comphelper::OStorageHelper::GetXStorageFormat( m_xParentStorage ); + } + catch ( beans::IllegalTypeException& ) + { + // the container just has an unknown type, use current file format + } + catch ( uno::Exception& ) + { + OSL_ENSURE( sal_False, "Can not retrieve own storage media type!\n" ); } PostEvent_Impl( ::rtl::OUString::createFromAscii( "OnSaveAs" ) ); - // TODO/MAV: in case storage type is changed storing can be done only in running state + sal_Bool bSwitchBackToLoaded = sal_False; + + // Storing to different format can be done only in running state. if ( m_nObjectState == embed::EmbedStates::LOADED ) - m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName ); + { + // TODO/LATER: copiing is not legal for documents with relative links. + if ( nTargetStorageFormat == nOriginalStorageFormat ) + m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName ); + else + { + changeState( embed::EmbedStates::RUNNING ); + bSwitchBackToLoaded = sal_True; + } + } uno::Reference< embed::XStorage > xSubStorage = xStorage->openStorageElement( sEntName, embed::ElementModes::READWRITE ); @@ -1087,7 +1154,9 @@ void SAL_CALL OCommonEmbeddedObject::storeAsEntry( const uno::Reference< embed:: if ( m_nObjectState != embed::EmbedStates::LOADED ) { // TODO/LATER: support hierarchical name for embedded objects in embedded objects - StoreDocToStorage_Impl( xSubStorage, nStorageFormat, GetBaseURLFrom_Impl( lArguments, lObjArgs ), sEntName ); + StoreDocToStorage_Impl( xSubStorage, nTargetStorageFormat, GetBaseURLFrom_Impl( lArguments, lObjArgs ), sEntName ); + if ( bSwitchBackToLoaded ) + changeState( embed::EmbedStates::LOADED ); } m_bWaitSaveCompleted = sal_True; @@ -1280,6 +1349,10 @@ void SAL_CALL OCommonEmbeddedObject::storeOwn() try { nStorageFormat = ::comphelper::OStorageHelper::GetXStorageFormat( m_xParentStorage ); } + catch ( beans::IllegalTypeException& ) + { + // the container just has an unknown type, use current file format + } catch ( uno::Exception& ) { OSL_ENSURE( sal_False, "Can not retrieve storage media type!\n" ); |