From af173db727b060d49733bd15fb210fd2f58598f1 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Mon, 3 Jan 2011 13:40:23 +0100 Subject: fwk162: #i115902# review usage of SfxObjectShellRef, SfxObjecShellLock; remove unused some methods --- sfx2/source/view/frmload.cxx | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) (limited to 'sfx2/source/view/frmload.cxx') diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index df252b831803..5544e2e8fde2 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -263,25 +263,6 @@ sal_Bool SfxFrameLoader_Impl::impl_createNewDocWithSlotParam( const USHORT _nSlo return lcl_getDispatchResult( SFX_APP()->ExecuteSlot( aRequest ) ); } -// -------------------------------------------------------------------------------------------------------------------- -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 ) - 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; -} - // -------------------------------------------------------------------------------------------------------------------- void SfxFrameLoader_Impl::impl_determineFilter( ::comphelper::NamedValueCollection& io_rDescriptor ) const { @@ -332,7 +313,7 @@ void SfxFrameLoader_Impl::impl_determineFilter( ::comphelper::NamedValueCollecti } // -------------------------------------------------------------------------------------------------------------------- -SfxObjectShellLock SfxFrameLoader_Impl::impl_findObjectShell( const Reference< XModel2 >& i_rxDocument ) const +SfxObjectShellRef SfxFrameLoader_Impl::impl_findObjectShell( const Reference< XModel2 >& i_rxDocument ) const { for ( SfxObjectShell* pDoc = SfxObjectShell::GetFirst( NULL, FALSE ); pDoc; pDoc = SfxObjectShell::GetNext( *pDoc, NULL, FALSE ) ) { @@ -636,15 +617,12 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA // tell the doc its (current) load args. impl_removeLoaderArguments( aDescriptor ); xModel->attachResource( xModel->getURL(), aDescriptor.getPropertyValues() ); - // TODO: not sure this is correct. The original, pre-refactoring code did it this way. However, I could - // imagine scenarios where it is *not* correct to overrule the *existing* model args (XModel::getArgs) - // with the ones passed to the loader here. For instance, what about the MacroExecutionMode? The document - // might have a mode other than the one passed to the loader, and we always overwrite the former with - // the latter. } // get the SfxObjectShell (still needed at the moment) - const SfxObjectShellLock xDoc = impl_findObjectShell( xModel ); + // SfxObjectShellRef is used here ( instead of ...Lock ) since the model is closed below if necessary + // SfxObjectShellLock would be even dangerous here, since the lifetime control should be done outside in case of success + const SfxObjectShellRef xDoc = impl_findObjectShell( xModel ); ENSURE_OR_THROW( xDoc.Is(), "no SfxObjectShell for the given model" ); // ensure the ID of the to-be-created view is in the descriptor, if possible @@ -652,16 +630,6 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA const sal_Int16 nViewNo = xDoc->GetFactory().GetViewNo_Impl( nViewId, 0 ); const ::rtl::OUString sViewName( xDoc->GetFactory().GetViewFactory( nViewNo ).GetAPIViewName() ); - // 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 - // object is closed (DoClose). The impl_lockHiddenDocument is to prevent exactly that premature - // closing. However, a *Ref object wouldn't close, anyway. And in case of unsuccessfull loading, the - // code at the very end of this method cares for closing the XModel, which should also close the - // ObjectShell. - // plug the document into the frame impl_createDocumentView( xModel, _rTargetFrame, aViewCreationArgs, sViewName ); bLoadSuccess = sal_True; -- cgit From 3f4e9b4c3cd9028744ea6ed5e93c41c51a15d229 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Mon, 10 Jan 2011 16:07:18 +0100 Subject: removetooltypes01: #i112600# remove tooltypes from sfx2 --- sfx2/source/view/frmload.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sfx2/source/view/frmload.cxx') diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index a4707f03d364..1a578643e443 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -252,13 +252,13 @@ namespace } // -------------------------------------------------------------------------------------------------------------------- -sal_Bool SfxFrameLoader_Impl::impl_createNewDocWithSlotParam( const USHORT _nSlotID, const Reference< XFrame >& i_rxFrame, +sal_Bool SfxFrameLoader_Impl::impl_createNewDocWithSlotParam( const sal_uInt16 _nSlotID, const Reference< XFrame >& i_rxFrame, const bool i_bHidden ) { SfxRequest aRequest( _nSlotID, SFX_CALLMODE_SYNCHRON, SFX_APP()->GetPool() ); aRequest.AppendItem( SfxUnoFrameItem( SID_FILLFRAME, i_rxFrame ) ); if ( i_bHidden ) - aRequest.AppendItem( SfxBoolItem( SID_HIDDEN, TRUE ) ); + aRequest.AppendItem( SfxBoolItem( SID_HIDDEN, sal_True ) ); return lcl_getDispatchResult( SFX_APP()->ExecuteSlot( aRequest ) ); } @@ -277,8 +277,8 @@ void SfxFrameLoader_Impl::impl_lockHiddenDocument( SfxObjectShell& i_rDocument, // 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; + i_rDocument.OwnerLock( sal_True ); + i_rDocument.Get_Impl()->bHiddenLockedByAPI = sal_True; } // -------------------------------------------------------------------------------------------------------------------- @@ -333,7 +333,7 @@ void SfxFrameLoader_Impl::impl_determineFilter( ::comphelper::NamedValueCollecti // -------------------------------------------------------------------------------------------------------------------- SfxObjectShellLock SfxFrameLoader_Impl::impl_findObjectShell( const Reference< XModel2 >& i_rxDocument ) const { - for ( SfxObjectShell* pDoc = SfxObjectShell::GetFirst( NULL, FALSE ); pDoc; pDoc = SfxObjectShell::GetNext( *pDoc, NULL, FALSE ) ) + for ( SfxObjectShell* pDoc = SfxObjectShell::GetFirst( NULL, sal_False ); pDoc; pDoc = SfxObjectShell::GetNext( *pDoc, NULL, sal_False ) ) { if ( i_rxDocument == pDoc->GetModel() ) { @@ -391,7 +391,7 @@ bool SfxFrameLoader_Impl::impl_determineTemplateDocument( ::comphelper::NamedVal } // -------------------------------------------------------------------------------------------------------------------- -USHORT SfxFrameLoader_Impl::impl_findSlotParam( const ::rtl::OUString& i_rFactoryURL ) const +sal_uInt16 SfxFrameLoader_Impl::impl_findSlotParam( const ::rtl::OUString& i_rFactoryURL ) const { ::rtl::OUString sSlotParam; const sal_Int32 nParamPos = i_rFactoryURL.indexOf( '?' ); @@ -404,7 +404,7 @@ USHORT SfxFrameLoader_Impl::impl_findSlotParam( const ::rtl::OUString& i_rFactor } if ( sSlotParam.getLength() ) - return USHORT( sSlotParam.toInt32() ); + return sal_uInt16( sSlotParam.toInt32() ); return 0; } @@ -571,7 +571,7 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rA { const ::rtl::OUString sFactory = sURL.copy( sizeof( "private:factory/" ) -1 ); // special handling for some weird factory URLs a la private:factory/swriter?slot=21053 - const USHORT nSlotParam = impl_findSlotParam( sFactory ); + const sal_uInt16 nSlotParam = impl_findSlotParam( sFactory ); if ( nSlotParam != 0 ) { return impl_createNewDocWithSlotParam( nSlotParam, _rTargetFrame, aDescriptor.getOrDefault( "Hidden", false ) ); -- cgit