diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-01-06 21:34:53 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2010-01-06 21:34:53 +0100 |
commit | af7c6403dc669c0565be7530d50fef3445ad5e39 (patch) | |
tree | 671c4832159c9d81d3161a1c5df6d69b16949997 /sfx2 | |
parent | 3b2321d5120d8c9d654120312819bf1459941a20 (diff) |
autorecovery: allow creating SFX-based documents which do not support the XDocumentRecovery interface
For this purpose, the SFX document factory methods got an additional parameter respectively flag
("DocumentRecoverySupport" resp. SFXMODEL_DISABLE_DOCUMENT_RECOVERY). This flag is used by database
documents to remove the interface from sub documents (aka forms/reports).
In this course, some of the functionality around those SFXMODELL_* flags, previously duplicated in
all applications, has been consolidated into a new SfxObjectShell constructor.
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/objsh.hxx | 1 | ||||
-rw-r--r-- | sfx2/inc/sfx2/sfxbasemodel.hxx | 1 | ||||
-rw-r--r-- | sfx2/inc/sfx2/sfxmodelfactory.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/objxtor.cxx | 51 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 41 | ||||
-rw-r--r-- | sfx2/source/doc/sfxmodelfactory.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/inc/objshimp.hxx | 1 |
7 files changed, 71 insertions, 35 deletions
diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 94d04c20a040..f9af74d9c82f 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -236,6 +236,7 @@ private: protected: SfxObjectShell(SfxObjectCreateMode); + SfxObjectShell( const sal_uInt64 i_nCreationFlags ); // see sfxmodelfactory.hxx virtual ~SfxObjectShell(); virtual void ModifyChanged(); diff --git a/sfx2/inc/sfx2/sfxbasemodel.hxx b/sfx2/inc/sfx2/sfxbasemodel.hxx index fd2c73bfd323..a276d7996b82 100644 --- a/sfx2/inc/sfx2/sfxbasemodel.hxx +++ b/sfx2/inc/sfx2/sfxbasemodel.hxx @@ -1555,6 +1555,7 @@ private: IMPL_SfxBaseModel_DataContainer* m_pData ; // cannot be held in m_pData, since it needs to be accessed in non-threadsafe context const bool m_bSupportEmbeddedScripts; + const bool m_bSupportDocRecovery; } ; // class SfxBaseModel diff --git a/sfx2/inc/sfx2/sfxmodelfactory.hxx b/sfx2/inc/sfx2/sfxmodelfactory.hxx index 4b7d29efc95a..7553a968e2e9 100644 --- a/sfx2/inc/sfx2/sfxmodelfactory.hxx +++ b/sfx2/inc/sfx2/sfxmodelfactory.hxx @@ -43,8 +43,10 @@ namespace sfx2 { //........................................................................ + #define SFXMODEL_STANDARD (sal_uInt64)(0x0000) #define SFXMODEL_EMBEDDED_OBJECT (sal_uInt64)(0x0001) #define SFXMODEL_DISABLE_EMBEDDED_SCRIPTS (sal_uInt64)(0x0002) + #define SFXMODEL_DISABLE_DOCUMENT_RECOVERY (sal_uInt64)(0x0004) typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > ( SAL_CALL * SfxModelFactoryFunc ) ( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory, diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index c5fdd41e4a82..4d1dd31ff23c 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -65,6 +65,7 @@ #include <sfx2/objsh.hxx> #include <sfx2/signaturestate.hxx> +#include <sfx2/sfxmodelfactory.hxx> #ifndef _BASIC_SBUNO_HXX #include <basic/sbuno.hxx> @@ -188,7 +189,7 @@ TYPEINIT1(SfxObjectShell, SfxShell); //-------------------------------------------------------------------- SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) -:mpObjectContainer(0) + :mpObjectContainer(0) ,pBasicManager( new SfxBasicManagerHolder ) ,rDocShell( _rDocShell ) ,aMacroMode( *this ) @@ -208,7 +209,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,bImportDone ( sal_False) ,bInPrepareClose( sal_False ) ,bPreparedForClose( sal_False ) - ,bWaitingForPicklist( sal_False ) + ,bWaitingForPicklist( sal_True ) ,bForbidReload( sal_False ) ,bBasicInitialized( sal_False ) ,bIsPrintJobCancelable( sal_True ) @@ -220,6 +221,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,bPreserveVersions( sal_True ) ,m_bMacroSignBroken( sal_False ) ,m_bNoBasicCapabilities( sal_False ) + ,m_bDocRecoverySupport( sal_True ) ,bQueryLoadTemplate( sal_True ) ,bLoadReadonly( sal_False ) ,bUseUserData( sal_True ) @@ -230,7 +232,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,nEventId ( 0) ,pReloadTimer ( 0) ,pMarkData( 0 ) - ,nLoadedFlags ( SFX_LOADED_MAINDOCUMENT ) + ,nLoadedFlags ( SFX_LOADED_ALL ) ,nFlagsInProgress( 0 ) ,bModalMode( sal_False ) ,bRunningMacro( sal_False ) @@ -249,6 +251,10 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,m_bIsInit( sal_False ) ,m_bIncomplEncrWarnShown( sal_False ) { + SfxObjectShell* pDoc = &_rDocShell; + SfxObjectShellArr_Impl &rArr = SFX_APP()->GetObjectShells_Impl(); + rArr.C40_INSERT( SfxObjectShell, pDoc, rArr.Count() ); + bInList = sal_True; } //-------------------------------------------------------------------- @@ -258,6 +264,28 @@ SfxObjectShell_Impl::~SfxObjectShell_Impl() delete pBasicManager; } +//-------------------------------------------------------------------- + +SfxObjectShell::SfxObjectShell( const sal_uInt64 i_nCreationFlags ) + : pImp( new SfxObjectShell_Impl( *this ) ) + , pMedium(0) + , pStyleSheetPool(0) + , eCreateMode( ( i_nCreationFlags & SFXMODEL_EMBEDDED_OBJECT ) ? SFX_CREATE_MODE_EMBEDDED : SFX_CREATE_MODE_STANDARD ) + , bHasName( sal_False ) +{ + DBG_CTOR(SfxObjectShell, 0); + + const bool bScriptSupport = ( i_nCreationFlags & SFXMODEL_DISABLE_EMBEDDED_SCRIPTS ) == 0; + if ( !bScriptSupport ) + SetHasNoBasic(); + + const bool bDocRecovery = ( i_nCreationFlags & SFXMODEL_DISABLE_DOCUMENT_RECOVERY ) == 0; + if ( !bDocRecovery ) + pImp->m_bDocRecoverySupport = sal_False; +} + +//-------------------------------------------------------------------- + // initializes a document from a file-description SfxObjectShell::SfxObjectShell @@ -291,23 +319,10 @@ SfxObjectShell::SfxObjectShell : pImp( new SfxObjectShell_Impl( *this ) ), pMedium(0), pStyleSheetPool(0), - eCreateMode(eMode) + eCreateMode(eMode), + bHasName( sal_False ) { DBG_CTOR(SfxObjectShell, 0); - - bHasName = sal_False; - - pImp->bWaitingForPicklist = sal_True; - - // Aggregation InPlaceObject+Automation -//(mba) AddInterface( SvDispatch::ClassFactory() ); - - SfxObjectShell *pThis = this; - SfxObjectShellArr_Impl &rArr = SFX_APP()->GetObjectShells_Impl(); - rArr.C40_INSERT( SfxObjectShell, pThis, rArr.Count() ); - pImp->bInList = sal_True; - pImp->nLoadedFlags = SFX_LOADED_ALL; -//REMOVE SetObjectShell( TRUE ); } //-------------------------------------------------------------------- diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 7c420779409c..9e3a306cc3ad 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -151,6 +151,9 @@ using ::com::sun::star::frame::XController2; using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::io::IOException; using ::com::sun::star::lang::WrappedTargetException; +using ::com::sun::star::uno::Type; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::document::XDocumentRecovery; /** This Listener is used to get notified when the XDocumentProperties of the XModel change. @@ -537,6 +540,7 @@ SfxBaseModel::SfxBaseModel( SfxObjectShell *pObjectShell ) : BaseMutex() , m_pData( new IMPL_SfxBaseModel_DataContainer( m_aMutex, pObjectShell ) ) , m_bSupportEmbeddedScripts( pObjectShell && pObjectShell->Get_Impl() ? !pObjectShell->Get_Impl()->m_bNoBasicCapabilities : false ) +, m_bSupportDocRecovery( pObjectShell && pObjectShell->Get_Impl() ? pObjectShell->Get_Impl()->m_bDocRecoverySupport : false ) { DBG_CTOR(sfx2_SfxBaseModel,NULL); if ( pObjectShell != NULL ) @@ -560,7 +564,9 @@ SfxBaseModel::~SfxBaseModel() uno::Any SAL_CALL SfxBaseModel::queryInterface( const UNOTYPE& rType ) throw( uno::RuntimeException ) { - if ( !m_bSupportEmbeddedScripts && rType.equals( XEMBEDDEDSCRIPTS::static_type() ) ) + if ( ( !m_bSupportEmbeddedScripts && rType.equals( XEMBEDDEDSCRIPTS::static_type() ) ) + || ( !m_bSupportDocRecovery && rType.equals( XDocumentRecovery::static_type() ) ) + ) return Any(); return SfxBaseModel_Base::queryInterface( rType ); @@ -596,21 +602,31 @@ void SAL_CALL SfxBaseModel::release() throw( ) // XTypeProvider //________________________________________________________________________________________________________ -uno::Sequence< UNOTYPE > SAL_CALL SfxBaseModel::getTypes() throw( uno::RuntimeException ) +namespace { - uno::Sequence< UNOTYPE > aTypes( SfxBaseModel_Base::getTypes() ); - if ( !m_bSupportEmbeddedScripts ) + void lcl_stripType( Sequence< Type >& io_rTypes, const Type& i_rTypeToStrip ) { - // remove XEmbeddedScripts type from the sequence - Sequence< UNOTYPE > aStrippedTypes( aTypes.getLength() - 1 ); + Sequence< UNOTYPE > aStrippedTypes( io_rTypes.getLength() - 1 ); ::std::remove_copy_if( - aTypes.getConstArray(), - aTypes.getConstArray() + aTypes.getLength(), + io_rTypes.getConstArray(), + io_rTypes.getConstArray() + io_rTypes.getLength(), aStrippedTypes.getArray(), - ::std::bind2nd( ::std::equal_to< UNOTYPE >(), XEMBEDDEDSCRIPTS::static_type() ) + ::std::bind2nd( ::std::equal_to< Type >(), i_rTypeToStrip ) ); - aTypes = aStrippedTypes; + io_rTypes = aStrippedTypes; } +} + +uno::Sequence< UNOTYPE > SAL_CALL SfxBaseModel::getTypes() throw( uno::RuntimeException ) +{ + uno::Sequence< UNOTYPE > aTypes( SfxBaseModel_Base::getTypes() ); + + if ( !m_bSupportEmbeddedScripts ) + lcl_stripType( aTypes, XEMBEDDEDSCRIPTS::static_type() ); + + if ( !m_bSupportDocRecovery ) + lcl_stripType( aTypes, XDocumentRecovery::static_type() ); + return aTypes; } @@ -1709,10 +1725,7 @@ void SAL_CALL SfxBaseModel::load( const uno::Sequence< beans::PropertyValue >& ::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - // do not use the SfxModelGuard, it would throw, since we're not yet initialized - if ( IsDisposed() ) - throw ::com::sun::star::lang::DisposedException( ::rtl::OUString(), *this ); + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); if ( IsInitialized() ) throw ::com::sun::star::frame::DoubleInitializationException( ::rtl::OUString(), *this ); diff --git a/sfx2/source/doc/sfxmodelfactory.cxx b/sfx2/source/doc/sfxmodelfactory.cxx index e35bc41000c9..40b9ffceca2d 100644 --- a/sfx2/source/doc/sfxmodelfactory.cxx +++ b/sfx2/source/doc/sfxmodelfactory.cxx @@ -152,7 +152,8 @@ namespace sfx2 static bool isSpecialArgumentName( const ::rtl::OUString& _rValueName ) { return _rValueName.equalsAscii( "EmbeddedObject" ) - || _rValueName.equalsAscii( "EmbeddedScriptSupport" ); + || _rValueName.equalsAscii( "EmbeddedScriptSupport" ) + || _rValueName.equalsAscii( "DocumentRecoverySupport" ); } bool operator()( const Any& _rArgument ) const @@ -174,15 +175,17 @@ namespace sfx2 ::comphelper::NamedValueCollection aArgs( _rArguments ); const sal_Bool bEmbeddedObject = aArgs.getOrDefault( "EmbeddedObject", sal_False ); const sal_Bool bScriptSupport = aArgs.getOrDefault( "EmbeddedScriptSupport", sal_True ); + const sal_Bool bDocRecoverySupport = aArgs.getOrDefault( "DocumentRecoverySupport", sal_True ); sal_uInt64 nCreationFlags = ( bEmbeddedObject ? SFXMODEL_EMBEDDED_OBJECT : 0 ) - | ( bScriptSupport ? 0 : SFXMODEL_DISABLE_EMBEDDED_SCRIPTS ); + | ( bScriptSupport ? 0 : SFXMODEL_DISABLE_EMBEDDED_SCRIPTS ) + | ( bDocRecoverySupport ? 0 : SFXMODEL_DISABLE_DOCUMENT_RECOVERY ); Reference< XInterface > xInstance( impl_createInstance( nCreationFlags ) ); // to mimic the bahaviour of the default factory's createInstanceWithArguments, we initialize - // the object with the given arguments, stripped by the two special ones + // the object with the given arguments, stripped by the three special ones Sequence< Any > aStrippedArguments( _rArguments.getLength() ); Any* pStrippedArgs = aStrippedArguments.getArray(); Any* pStrippedArgsEnd = ::std::remove_copy_if( diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx index 5fbfd1f1716b..49c9bca4306c 100644 --- a/sfx2/source/inc/objshimp.hxx +++ b/sfx2/source/inc/objshimp.hxx @@ -105,6 +105,7 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess bPreserveVersions:1, m_bMacroSignBroken:1, // whether the macro signature was explicitly broken m_bNoBasicCapabilities:1, + m_bDocRecoverySupport:1, bQueryLoadTemplate:1, bLoadReadonly:1, bUseUserData:1, |