diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2009-12-04 21:29:53 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2009-12-04 21:29:53 +0100 |
commit | 3faf9628e68cdfe16f32be7ff02d66ed7637626b (patch) | |
tree | 0079a24345b6bc780efc62aa629efe8505186dc8 /sfx2 | |
parent | aafbcb76ec238c947a304a71e44ac1e856136ca3 (diff) |
autorecovery: replace some calls to SfxViewFrame::CreateViewFrame with calls to the (newly introduced) SfxViewFrame::LoadHiddenDocument
This way, we got rid of some more clients of InsertDocument_Impl. Final goal is to remove SfxViewFrame::CreateViewFrame
completely, so the UNO loader is the only (indirect) client of InsertDocument_Impl.
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/viewfrm.hxx | 7 | ||||
-rw-r--r-- | sfx2/source/view/frmload.cxx | 24 | ||||
-rw-r--r-- | sfx2/source/view/topfrm.cxx | 7 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 31 |
4 files changed, 47 insertions, 22 deletions
diff --git a/sfx2/inc/sfx2/viewfrm.hxx b/sfx2/inc/sfx2/viewfrm.hxx index 6d816164f39e..c738da419baf 100644 --- a/sfx2/inc/sfx2/viewfrm.hxx +++ b/sfx2/inc/sfx2/viewfrm.hxx @@ -168,6 +168,7 @@ public: static SfxViewFrame* CreateViewFrame( SfxObjectShell& rDoc, USHORT nViewId=0, BOOL bHidden = FALSE ); static SfxViewFrame* Create( SfxFrame& i_rFrame, SfxObjectShell& i_rDoc, const USHORT i_nViewId ); + static SfxViewFrame* LoadHiddenDocument( SfxObjectShell& i_rDoc, const USHORT i_nViewId ); static SfxViewFrame* LoadDocument( SfxObjectShell& i_rDoc, const SfxFrame* i_pTargetFrame, const USHORT i_nViewId = 0 ); static SfxViewFrame* LoadDocument( SfxObjectShell& i_rDoc, const SfxFrameItem* i_pFrameItem, const USHORT i_nViewId = 0 ); @@ -350,7 +351,8 @@ private: const SfxObjectShell& i_rDoc, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rLoadArgs, - const USHORT i_nViewId + const USHORT i_nViewId, + const bool i_bHidden ); /** loads the given existing document into the given frame @@ -373,7 +375,8 @@ private: SAL_DLLPRIVATE static SfxViewFrame* LoadViewIntoFrame_Impl_NoThrow( const SfxObjectShell& i_rDoc, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, - const USHORT i_nViewId + const USHORT i_nViewId, + const bool i_bHidden ); }; diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index f62ff590cdc3..fae80950d925 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -291,12 +291,19 @@ sal_Bool SfxFrameLoader_Impl::impl_createNewDocWithSlotParam( const USHORT _nSlo void SfxFrameLoader_Impl::impl_lockHiddenDocument( SfxObjectShell& i_rDocument, const ::comphelper::NamedValueCollection& i_rDescriptor ) const { const sal_Bool bHidden = i_rDescriptor.getOrDefault( "Hidden", sal_False ); - if ( bHidden ) - { - i_rDocument.RestoreNoDelete(); - i_rDocument.OwnerLock( TRUE ); - i_rDocument.Get_Impl()->bHiddenLockedByAPI = TRUE; - } + if ( !bHidden ) + return; + + const SfxViewFrame* pExistingViewFrame = SfxViewFrame::GetFirst( &i_rDocument ); + if ( pExistingViewFrame ) + return; + + // the document is to be loaded hidden, and it is not yet displayed in any other frame + // To prevent it from being closed when the loader returns, increase its OwnerLock + // (the OwnerLock is normally increased by every frame in which the document is displayed, and by this loader) + i_rDocument.RestoreNoDelete(); + i_rDocument.OwnerLock( TRUE ); + i_rDocument.Get_Impl()->bHiddenLockedByAPI = TRUE; } // -------------------------------------------------------------------------------------------------------------------- @@ -590,9 +597,8 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA SfxObjectShellLock xDoc = impl_findObjectShell( xModel ); ENSURE_OR_THROW( xDoc.Is(), "no SfxObjectShell for the given model" ); - // if the document is created hidden, prevent it being deleted until it is shown or disposed - if ( !bExternalModel ) - impl_lockHiddenDocument( *xDoc, aDescriptor ); + // if the document is created hidden, prevent it from being deleted until it is shown or disposed + impl_lockHiddenDocument( *xDoc, aDescriptor ); // TODO; if we wouldn't use a SfxObjectShellLock instance for xDoc, but a simple SfxObjectShellRef, // then this would not be necessary, /me thinks. That is, the *Lock classes inc/dec a "Lock" counter // (additional to the ref counter) in their ctor/dtor, and if the lock counter goes to 0, the diff --git a/sfx2/source/view/topfrm.cxx b/sfx2/source/view/topfrm.cxx index a9cdf3441508..93f79a49208f 100644 --- a/sfx2/source/view/topfrm.cxx +++ b/sfx2/source/view/topfrm.cxx @@ -816,11 +816,12 @@ sal_Bool SfxFrame::InsertDocument_Impl( SfxObjectShell& rDoc, const SfxItemSet& pViewFrame->GetWindow().SetBorderStyle( WINDOW_BORDER_NOBORDER ); } - OSL_ENSURE( ( rDoc.Get_Impl()->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ) == SFX_LOADED_MAINDOCUMENT, + OSL_ENSURE( ( ( rDoc.Get_Impl()->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ) == SFX_LOADED_MAINDOCUMENT ) + || ( pJumpItem == NULL ), "SfxFrame::InsertDocument_Impl: so this code wasn't dead?" ); - // Before CWS autorecovery, there was code which postponed setting the ViewData/Mark to a later time + // Before CWS autorecovery, there was code which postponed jumping to the Mark to a later time // (SfxObjectShell::PositionView_Impl), but it seems this branch was never used, since this method - // here is never called before the load process finished. + // here is never called before the load process finished. At least not with a jump item != NULL. if( pJumpItem ) { pViewFrame->GetViewShell()->JumpToMark( pJumpItem->GetValue() ); diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 1f395bfd887c..269237d596cd 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -769,7 +769,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) { while ( !aViewFrames.empty() ) { - LoadViewIntoFrame_Impl( *xNewObj, aViewFrames.front().first, aLoadArgs, aViewFrames.front().second ); + LoadViewIntoFrame_Impl( *xNewObj, aViewFrames.front().first, aLoadArgs, aViewFrames.front().second, false ); aViewFrames.pop_front(); } } @@ -2042,8 +2042,12 @@ Reference< XController2 > SfxViewFrame::LoadDocument_Impl( //-------------------------------------------------------------------- SfxViewFrame* SfxViewFrame::LoadViewIntoFrame_Impl_NoThrow( const SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rFrame, - const USHORT i_nViewId ) + const USHORT i_nViewId, const bool i_bHidden ) { + OSL_PRECOND( !i_bHidden || !i_rFrame.is(), + "SfxViewFrame::LoadViewIntoFrame_Impl_NoThrow: loading *hidden* into an *existing* frame is not supported!" ); + // Care for this frame's visibility yourself, please + Reference< XFrame > xFrame( i_rFrame ); bool bOwnFrame = false; bool bSuccess = false; @@ -2057,10 +2061,10 @@ SfxViewFrame* SfxViewFrame::LoadViewIntoFrame_Impl_NoThrow( const SfxObjectShell bOwnFrame = true; } - LoadViewIntoFrame_Impl( i_rDoc, xFrame, Sequence< PropertyValue >(), i_nViewId ); + LoadViewIntoFrame_Impl( i_rDoc, xFrame, Sequence< PropertyValue >(), i_nViewId, i_bHidden ); bSuccess = true; - if ( bOwnFrame ) + if ( bOwnFrame && !i_bHidden ) { // ensure the frame/window is visible Reference< XWindow > xContainerWindow( xFrame->getContainerWindow(), UNO_SET_THROW ); @@ -2092,13 +2096,17 @@ SfxViewFrame* SfxViewFrame::LoadViewIntoFrame_Impl_NoThrow( const SfxObjectShell //-------------------------------------------------------------------- void SfxViewFrame::LoadViewIntoFrame_Impl( const SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rFrame, - const Sequence< PropertyValue >& i_rLoadArgs, const USHORT i_nViewId ) + const Sequence< PropertyValue >& i_rLoadArgs, const USHORT i_nViewId, + const bool i_bHidden ) { Reference< XModel > xDocument( i_rDoc.GetModel(), UNO_SET_THROW ); ::comphelper::NamedValueCollection aTransformLoadArgs( i_rLoadArgs.getLength() ? i_rLoadArgs : xDocument->getArgs() ); aTransformLoadArgs.put( "Model", xDocument ); - aTransformLoadArgs.put( "ViewId", sal_Int16( i_nViewId ) ); + if ( i_nViewId ) + aTransformLoadArgs.put( "ViewId", sal_Int16( i_nViewId ) ); + if ( i_bHidden ) + aTransformLoadArgs.put( "Hidden", i_bHidden ); ::rtl::OUString sURL( xDocument->getURL() ); if ( !sURL.getLength() ) @@ -2138,13 +2146,20 @@ SfxViewShell* SfxViewFrame::LoadNewSfxView_Impl( const USHORT i_nViewId, SfxView //-------------------------------------------------------------------- +SfxViewFrame* SfxViewFrame::LoadHiddenDocument( SfxObjectShell& i_rDoc, const USHORT i_nViewId ) +{ + return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, Reference< XFrame >(), i_nViewId, true ); +} + +//-------------------------------------------------------------------- + SfxViewFrame* SfxViewFrame::LoadDocument( SfxObjectShell& i_rDoc, const SfxFrame* i_pTargetFrame, const USHORT i_nViewId ) { Reference< XFrame > xFrame; if ( i_pTargetFrame ) xFrame = i_pTargetFrame->GetFrameInterface(); - return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, xFrame, i_nViewId ); + return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, xFrame, i_nViewId, false ); } //-------------------------------------------------------------------- @@ -2440,7 +2455,7 @@ void SfxViewFrame::ExecView_Impl if ( pFrameItem ) pFrameItem->GetValue() >>= xFrame; - LoadViewIntoFrame_Impl_NoThrow( *GetObjectShell(), xFrame, nViewId ); + LoadViewIntoFrame_Impl_NoThrow( *GetObjectShell(), xFrame, nViewId, false ); rReq.Done(); break; |