LCOV - code coverage report
Current view: top level - sfx2/source/control - shell.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 219 304 72.0 %
Date: 2015-06-13 12:38:46 Functions: 45 62 72.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/embed/VerbDescriptor.hpp>
      21             : #include <com/sun/star/embed/VerbAttributes.hpp>
      22             : #include <basic/sbstar.hxx>
      23             : #include <officecfg/Office/Common.hxx>
      24             : #include <rtl/ustring.hxx>
      25             : #include <sal/log.hxx>
      26             : #include <svl/itempool.hxx>
      27             : #include <svl/undo.hxx>
      28             : #include "itemdel.hxx"
      29             : #include <svtools/asynclink.hxx>
      30             : #include <basic/sbx.hxx>
      31             : 
      32             : #include <sfx2/app.hxx>
      33             : #include <sfx2/shell.hxx>
      34             : #include <sfx2/bindings.hxx>
      35             : #include <sfx2/dispatch.hxx>
      36             : #include <sfx2/viewfrm.hxx>
      37             : #include <sfx2/objface.hxx>
      38             : #include <sfx2/objsh.hxx>
      39             : #include <sfx2/viewsh.hxx>
      40             : #include "sfxtypes.hxx"
      41             : #include <sfx2/request.hxx>
      42             : #include <sfx2/mnumgr.hxx>
      43             : #include "statcach.hxx"
      44             : #include <sfx2/msgpool.hxx>
      45             : #include <sidebar/ContextChangeBroadcaster.hxx>
      46             : #include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
      47             : 
      48             : #include <boost/ptr_container/ptr_map.hpp>
      49             : #include <boost/ptr_container/ptr_vector.hpp>
      50             : 
      51             : // Maps the Which() field to a pointer to a SfxPoolItem
      52             : typedef boost::ptr_map<sal_uInt16, SfxPoolItem> SfxItemPtrMap;
      53             : 
      54      349982 : TYPEINIT0(SfxShell);
      55             : 
      56             : typedef boost::ptr_vector<SfxSlot> SfxVerbSlotArr_Impl;
      57             : 
      58             : using namespace com::sun::star;
      59             : 
      60             : struct SfxShell_Impl: public SfxBroadcaster
      61             : {
      62             :     OUString                 aObjectName;   // Name of Sbx-Objects
      63             :     SfxItemPtrMap            aItems;        // Data exchange on Item level
      64             :     SfxViewShell*            pViewSh;       // SfxViewShell if Shell is
      65             :                                             // ViewFrame/ViewShell/SubShell list
      66             :     SfxViewFrame*            pFrame;        // Frame, if  <UI-active>
      67             :     SfxRepeatTarget*         pRepeatTarget; // SbxObjectRef xParent;
      68             :     bool                        bActive;
      69             :     sal_uIntPtr                 nDisableFlags;
      70             :     sal_uIntPtr                 nHelpId;
      71             :     svtools::AsynchronLink*     pExecuter;
      72             :     svtools::AsynchronLink*     pUpdater;
      73             :     SfxVerbSlotArr_Impl         aSlotArr;
      74             : 
      75             :     com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor > aVerbList;
      76             :     ::sfx2::sidebar::ContextChangeBroadcaster maContextChangeBroadcaster;
      77             : 
      78       24840 :     SfxShell_Impl()
      79             :         : pViewSh(0)
      80             :         , pFrame(0)
      81             :         , pRepeatTarget(0)
      82             :         , bActive(false)
      83             :         , nDisableFlags(0)
      84             :         , nHelpId(0)
      85             :         , pExecuter(0)
      86       24840 :         , pUpdater(0)
      87             :     {
      88       24840 :     }
      89             : 
      90       48882 :     virtual ~SfxShell_Impl() { delete pExecuter; delete pUpdater;}
      91             : };
      92             : 
      93             : 
      94           0 : void SfxShell::EmptyExecStub(SfxShell *, SfxRequest &)
      95             : {
      96           0 : }
      97             : 
      98       10954 : void SfxShell::EmptyStateStub(SfxShell *, SfxItemSet &)
      99             : {
     100       10954 : }
     101             : 
     102        8671 : SfxShell::SfxShell()
     103             : :   pImp(0),
     104             :     pPool(0),
     105        8671 :     pUndoMgr(0)
     106             : {
     107        8671 :     pImp = new SfxShell_Impl;
     108        8671 : }
     109             : 
     110       16169 : SfxShell::SfxShell( SfxViewShell *pViewSh )
     111             : :   pImp(0),
     112             :     pPool(0),
     113       16169 :     pUndoMgr(0)
     114             : {
     115       16169 :     pImp = new SfxShell_Impl;
     116       16169 :     pImp->pViewSh = pViewSh;
     117       16169 : }
     118             : 
     119       48882 : SfxShell::~SfxShell()
     120             : {
     121       24441 :     delete pImp;
     122       24441 : }
     123             : 
     124       43826 : void SfxShell::SetName( const OUString &rName )
     125             : {
     126       43826 :     pImp->aObjectName = rName;
     127       43826 : }
     128             : 
     129       17101 : const OUString& SfxShell::GetName() const
     130             : {
     131       17101 :     return pImp->aObjectName;
     132             : }
     133             : 
     134       15598 : SfxDispatcher* SfxShell::GetDispatcher() const
     135             : {
     136       15598 :     return pImp->pFrame ? pImp->pFrame->GetDispatcher() : 0;
     137             : }
     138             : 
     139      573109 : SfxViewShell* SfxShell::GetViewShell() const
     140             : {
     141      573109 :     return pImp->pViewSh;
     142             : }
     143             : 
     144       56237 : SfxViewFrame* SfxShell::GetFrame() const
     145             : {
     146       56237 :     if ( pImp->pFrame )
     147       22040 :         return pImp->pFrame;
     148       34197 :     if ( pImp->pViewSh )
     149       22525 :         return pImp->pViewSh->GetViewFrame();
     150       11672 :     return 0;
     151             : }
     152             : 
     153       25160 : const SfxPoolItem* SfxShell::GetItem
     154             : (
     155             :     sal_uInt16  nSlotId         // Slot-Id of the querying <SfxPoolItem>s
     156             : )   const
     157             : {
     158       25160 :     SfxItemPtrMap::const_iterator it = pImp->aItems.find( nSlotId );
     159       25160 :     if( it != pImp->aItems.end() )
     160       21777 :         return it->second;
     161        3383 :     return 0;
     162             : }
     163             : 
     164       30561 : void SfxShell::PutItem
     165             : (
     166             :     const SfxPoolItem&  rItem  /* Instance, of which a copy is created,
     167             :                                   which is stored in the SfxShell in a list. */
     168             : )
     169             : {
     170             :     DBG_ASSERT( !rItem.ISA(SfxSetItem), "SetItems aren't allowed here" );
     171             :     DBG_ASSERT( SfxItemPool::IsSlot( rItem.Which() ),
     172             :                 "items with Which-Ids aren't allowed here" );
     173             : 
     174             :     // MSC made a mess here of WNT/W95, beware of changes
     175       30561 :     SfxPoolItem *pItem = rItem.Clone();
     176       30561 :     SfxPoolItemHint aItemHint( pItem );
     177       30561 :     sal_uInt16 nWhich = rItem.Which();
     178             : 
     179       30561 :     SfxItemPtrMap::iterator it = pImp->aItems.find( nWhich );
     180       30561 :     if( it != pImp->aItems.end() )
     181             :     {
     182             :         // Replace Item
     183        3687 :         pImp->aItems.erase( it );
     184        3687 :         pImp->aItems.insert( nWhich, pItem );
     185             : 
     186             :         // if active, notify Bindings
     187        3687 :         SfxDispatcher *pDispat = GetDispatcher();
     188        3687 :         if ( pDispat )
     189             :         {
     190         556 :             SfxBindings* pBindings = pDispat->GetBindings();
     191         556 :             pBindings->Broadcast( aItemHint );
     192         556 :             sal_uInt16 nSlotId = nWhich; //pItem->GetSlotId();
     193         556 :             SfxStateCache* pCache = pBindings->GetStateCache( nSlotId );
     194         556 :             if ( pCache )
     195             :             {
     196           2 :                 pCache->SetState( SfxItemState::DEFAULT, pItem, true );
     197           2 :                 pCache->SetCachedState( true );
     198             :             }
     199             :         }
     200       34248 :         return;
     201             :     }
     202             :     else
     203             :     {
     204       26874 :         Broadcast( aItemHint );
     205       26874 :         pImp->aItems.insert( nWhich, pItem );
     206       26874 :     }
     207             : }
     208             : 
     209           0 : SfxInterface* SfxShell::GetInterface() const
     210             : {
     211           0 :     return GetStaticInterface();
     212             : }
     213             : 
     214        2517 : ::svl::IUndoManager* SfxShell::GetUndoManager()
     215             : {
     216        2517 :     return pUndoMgr;
     217             : }
     218             : 
     219       10558 : void SfxShell::SetUndoManager( ::svl::IUndoManager *pNewUndoMgr )
     220             : {
     221             :     OSL_ENSURE( ( pUndoMgr == NULL ) || ( pNewUndoMgr == NULL ) || ( pUndoMgr == pNewUndoMgr ),
     222             :         "SfxShell::SetUndoManager: exchanging one non-NULL manager with another non-NULL manager? Suspicious!" );
     223             :     // there's at least one client of our UndoManager - the DocumentUndoManager at the SfxBaseModel - which
     224             :     // caches the UndoManager, and registers itself as listener. If exchanging non-NULL UndoManagers is really
     225             :     // a supported scenario (/me thinks it is not), then we would need to notify all such clients instances.
     226             : 
     227       10558 :     pUndoMgr = pNewUndoMgr;
     228       10558 :     if ( pUndoMgr )
     229             :         pUndoMgr->SetMaxUndoActionCount(
     230        7502 :             officecfg::Office::Common::Undo::Steps::get());
     231       10558 : }
     232             : 
     233         592 : SfxRepeatTarget* SfxShell::GetRepeatTarget() const
     234             : {
     235         592 :     return pImp->pRepeatTarget;
     236             : }
     237             : 
     238        1054 : void SfxShell::SetRepeatTarget( SfxRepeatTarget *pTarget )
     239             : {
     240        1054 :     pImp->pRepeatTarget = pTarget;
     241        1054 : }
     242             : 
     243       19150 : void SfxShell::Invalidate
     244             : (
     245             :     sal_uInt16          nId     /* Invalidated Slot-Id or Which-Id.
     246             :                                If these are 0 (default), then all
     247             :                                by this Shell currently handled Slot-Ids are
     248             :                                invalidated. */
     249             : )
     250             : {
     251       19150 :     if ( !GetViewShell() )
     252             :     {
     253             :         OSL_FAIL( "wrong Invalidate method called!" );
     254       19150 :         return;
     255             :     }
     256             : 
     257       19150 :     Invalidate_Impl( GetViewShell()->GetViewFrame()->GetBindings(), nId );
     258             : }
     259             : 
     260       21156 : void SfxShell::Invalidate_Impl( SfxBindings& rBindings, sal_uInt16 nId )
     261             : {
     262       21156 :     if ( nId == 0 )
     263             :     {
     264         591 :         rBindings.InvalidateShell( *this, false );
     265             :     }
     266             :     else
     267             :     {
     268       20565 :         const SfxInterface *pIF = GetInterface();
     269         888 :         do
     270             :         {
     271       20565 :             const SfxSlot *pSlot = pIF->GetSlot(nId);
     272       20565 :             if ( pSlot )
     273             :             {
     274             :                 // At Enum-Slots invalidate the Master-Slot
     275       19677 :                 if ( SFX_KIND_ENUM == pSlot->GetKind() )
     276           0 :                     pSlot = pSlot->GetLinkedSlot();
     277             : 
     278             :                 // Invalidate the Slot itself and possible also all Slave-Slots
     279       19677 :                 rBindings.Invalidate( pSlot->GetSlotId() );
     280       39354 :                 for ( const SfxSlot *pSlave = pSlot->GetLinkedSlot();
     281       19677 :                       pSlave && pIF->ContainsSlot_Impl( pSlave ) &&
     282           0 :                         pSlave->GetLinkedSlot() == pSlot;
     283             :                       ++pSlave )
     284           0 :                     rBindings.Invalidate( pSlave->GetSlotId() );
     285             : 
     286       40833 :                 return;
     287             :             }
     288             : 
     289         888 :             pIF = pIF->GetGenoType();
     290             :         }
     291             : 
     292             :         while ( pIF );
     293             : 
     294             :         DBG_WARNING( "W3: invalidating slot-id unknown in shell" );
     295             :     }
     296             : }
     297             : 
     298           0 : void SfxShell::HandleOpenXmlFilterSettings(SfxRequest & rReq)
     299             : {
     300             :     try
     301             :     {
     302           0 :         uno::Reference < ui::dialogs::XExecutableDialog > xDialog = ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() );
     303           0 :         xDialog->execute();
     304             :     }
     305           0 :     catch (const uno::Exception&)
     306             :     {
     307             :     }
     308           0 :     rReq.Ignore ();
     309           0 : }
     310             : 
     311       25446 : void SfxShell::DoActivate_Impl( SfxViewFrame *pFrame, bool bMDI )
     312             : {
     313             : #ifdef DBG_UTIL
     314             :     const SfxInterface *p_IF = GetInterface();
     315             :     if ( !p_IF )
     316             :         return;
     317             : #endif
     318             :     SAL_INFO(
     319             :         "sfx.control",
     320             :         "SfxShell::DoActivate() " << this << "  " << GetInterface()->GetClassName()
     321             :             << " bMDI " << (bMDI ? "MDI" : ""));
     322             : 
     323       25446 :     if ( bMDI )
     324             :     {
     325             :         // Remember Frame, in which it was activated
     326       25446 :         pImp->pFrame = pFrame;
     327       25446 :         pImp->bActive = true;
     328             :     }
     329             : 
     330             :     // Notify Subclass
     331       25446 :     Activate(bMDI);
     332       25446 : }
     333             : 
     334       28786 : void SfxShell::DoDeactivate_Impl( SfxViewFrame *pFrame, bool bMDI )
     335             : {
     336             : #ifdef DBG_UTIL
     337             :     const SfxInterface *p_IF = GetInterface();
     338             :     if ( !p_IF )
     339             :         return;
     340             : #endif
     341             :     SAL_INFO(
     342             :         "sfx.control",
     343             :         "SfxShell::DoDeactivate()" << this << "  " << GetInterface()->GetClassName()
     344             :             << " bMDI " << (bMDI ? "MDI" : ""));
     345             : 
     346             :     // Only when it comes from a Frame
     347             :     // (not when for instance by poping BASIC-IDE from AppDisp)
     348       28786 :     if ( bMDI && pImp->pFrame == pFrame )
     349             :     {
     350             :         // deliver
     351       25543 :         pImp->pFrame = 0;
     352       25543 :         pImp->bActive = false;
     353             :     }
     354             : 
     355             :     // Notify Subclass
     356       28786 :     Deactivate(bMDI);
     357       28786 : }
     358             : 
     359        9854 : bool SfxShell::IsActive() const
     360             : {
     361        9854 :     return pImp->bActive;
     362             : }
     363             : 
     364       18742 : void SfxShell::Activate
     365             : (
     366             :     bool    /*bMDI*/        /*  TRUE
     367             :                             the <SfxDispatcher>, on which the SfxShell is
     368             :                             located, is activated or the SfxShell instance
     369             :                             was pushed on an active SfxDispatcher.
     370             :                             (compare with SystemWindow::IsMDIActivate())
     371             : 
     372             :                             FALSE
     373             :                             the <SfxViewFrame>, on which SfxDispatcher
     374             :                             the SfxShell instance is located, was
     375             :                             activated. (for example by a closing dialoge) */
     376             : )
     377             : {
     378       18742 :     BroadcastContextForActivation(true);
     379       18742 : }
     380             : 
     381       22888 : void SfxShell::Deactivate
     382             : (
     383             :     bool    /*bMDI*/        /*  TRUE
     384             :                             the <SfxDispatcher>, on which the SfxShell is
     385             :                             located, is inactivated or the SfxShell instance
     386             :                             was popped on an active SfxDispatcher.
     387             :                             (compare with SystemWindow::IsMDIActivate())
     388             : 
     389             :                             FALSE
     390             :                             the <SfxViewFrame>, on which SfxDispatcher
     391             :                             the SfxShell instance is located, was
     392             :                             deactivated. (for example by a dialoge) */
     393             : )
     394             : {
     395       22888 :     BroadcastContextForActivation(false);
     396       22888 : }
     397             : 
     398         528 : bool SfxShell::CanExecuteSlot_Impl( const SfxSlot &rSlot )
     399             : {
     400             :     // Get Slot status
     401         528 :     SfxItemPool &rPool = GetPool();
     402         528 :     const sal_uInt16 nId = rSlot.GetWhich( rPool );
     403         528 :     SfxItemSet aSet(rPool, nId, nId);
     404         528 :     SfxStateFunc pFunc = rSlot.GetStateFnc();
     405         528 :     CallState( pFunc, aSet );
     406         528 :     return aSet.GetItemState(nId) != SfxItemState::DISABLED;
     407             : }
     408             : 
     409           0 : sal_IntPtr ShellCall_Impl( void* pObj, void* pArg )
     410             : {
     411           0 :     static_cast<SfxShell*>(pObj)->ExecuteSlot( *static_cast<SfxRequest*>(pArg), nullptr );
     412           0 :     return 0;
     413             : }
     414             : 
     415           0 : const SfxPoolItem* SfxShell::ExecuteSlot( SfxRequest& rReq, bool bAsync )
     416             : {
     417           0 :     if( !bAsync )
     418           0 :         return ExecuteSlot( rReq, nullptr );
     419             :     else
     420             :     {
     421           0 :         if( !pImp->pExecuter )
     422             :             pImp->pExecuter = new svtools::AsynchronLink(
     423           0 :                 Link<>( this, ShellCall_Impl ) );
     424           0 :         pImp->pExecuter->Call( new SfxRequest( rReq ) );
     425           0 :         return 0;
     426             :     }
     427             : }
     428             : 
     429         427 : const SfxPoolItem* SfxShell::ExecuteSlot
     430             : (
     431             :     SfxRequest          &rReq,  // the relayed <SfxRequest>
     432             :     const SfxInterface* pIF     // default = 0 means get virtually
     433             : )
     434             : {
     435         427 :     if ( !pIF )
     436         427 :         pIF = GetInterface();
     437             : 
     438         427 :     sal_uInt16 nSlot = rReq.GetSlot();
     439         427 :     const SfxSlot* pSlot = NULL;
     440         427 :     if ( nSlot >= SID_VERB_START && nSlot <= SID_VERB_END )
     441           0 :         pSlot = GetVerbSlot_Impl(nSlot);
     442         427 :     if ( !pSlot )
     443         427 :         pSlot = pIF->GetSlot(nSlot);
     444             :     DBG_ASSERT( pSlot, "slot not supported" );
     445             : 
     446         427 :     SfxExecFunc pFunc = pSlot->GetExecFnc();
     447         427 :     if ( pFunc )
     448         427 :         CallExec( pFunc, rReq );
     449             : 
     450         427 :     return rReq.GetReturnValue();
     451             : }
     452             : 
     453       97697 : const SfxPoolItem* SfxShell::GetSlotState
     454             : (
     455             :     sal_uInt16              nSlotId,    // Slot-Id to the Slots in question
     456             :     const SfxInterface* pIF,        // default = 0 means get virtually
     457             :     SfxItemSet*         pStateSet   // SfxItemSet of the Slot-State method
     458             : )
     459             : {
     460             :     // Get Slot on the given Interface
     461       97697 :     if ( !pIF )
     462       94956 :         pIF = GetInterface();
     463       97697 :     SfxItemState eState = SfxItemState::UNKNOWN;
     464       97697 :     SfxItemPool &rPool = GetPool();
     465             : 
     466       97697 :     const SfxSlot* pSlot = NULL;
     467       97697 :     if ( nSlotId >= SID_VERB_START && nSlotId <= SID_VERB_END )
     468           0 :         pSlot = GetVerbSlot_Impl(nSlotId);
     469       97697 :     if ( !pSlot )
     470       97697 :         pSlot = pIF->GetSlot(nSlotId);
     471       97697 :     if ( pSlot )
     472             :         // Map on Which-Id if possible
     473       97697 :         nSlotId = pSlot->GetWhich( rPool );
     474             : 
     475             :     // Get Item and Item status
     476       97697 :     const SfxPoolItem *pItem = NULL;
     477       97697 :     SfxItemSet aSet( rPool, nSlotId, nSlotId ); // else pItem dies too soon
     478       97697 :     if ( pSlot )
     479             :     {
     480             :         // Call Status method
     481       97697 :         SfxStateFunc pFunc = pSlot->GetStateFnc();
     482       97697 :         if ( pFunc )
     483       96378 :             CallState( pFunc, aSet );
     484       97697 :         eState = aSet.GetItemState( nSlotId, true, &pItem );
     485             : 
     486             :         // get default Item if possible
     487       97697 :         if ( eState == SfxItemState::DEFAULT )
     488             :         {
     489       37501 :             if ( SfxItemPool::IsWhich(nSlotId) )
     490        6340 :                 pItem = &rPool.GetDefaultItem(nSlotId);
     491             :             else
     492       31161 :                 eState = SfxItemState::DONTCARE;
     493             :         }
     494             :     }
     495             :     else
     496           0 :         eState = SfxItemState::UNKNOWN;
     497             : 
     498             :     // Evaluate Item and item status and possibly maintain them in pStateSet
     499       97697 :     SfxPoolItem *pRetItem = 0;
     500       97697 :     if ( eState <= SfxItemState::DISABLED )
     501             :     {
     502        8349 :         if ( pStateSet )
     503         662 :             pStateSet->DisableItem(nSlotId);
     504        8349 :         return 0;
     505             :     }
     506       89348 :     else if ( eState == SfxItemState::DONTCARE )
     507             :     {
     508       31161 :         if ( pStateSet )
     509        1314 :             pStateSet->ClearItem(nSlotId);
     510       31161 :         pRetItem = new SfxVoidItem(0);
     511             :     }
     512             :     else
     513             :     {
     514       58187 :         if ( pStateSet && pStateSet->Put( *pItem ) )
     515        2020 :             return &pStateSet->Get( pItem->Which() );
     516       56167 :         pRetItem = pItem->Clone();
     517             :     }
     518       87328 :     DeleteItemOnIdle(pRetItem);
     519             : 
     520       87328 :     return pRetItem;
     521             : }
     522             : 
     523           0 : SFX_EXEC_STUB(SfxShell, VerbExec)
     524           0 : void SfxStubSfxShellVerbState(SfxShell *, SfxItemSet& rSet)
     525             : {
     526           0 :     SfxShell::VerbState( rSet );
     527           0 : }
     528             : 
     529         638 : void SfxShell::SetVerbs(const com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor >& aVerbs)
     530             : {
     531         638 :     SfxViewShell *pViewSh = PTR_CAST ( SfxViewShell, this);
     532             : 
     533             :     DBG_ASSERT(pViewSh, "Only call SetVerbs at the ViewShell!");
     534         638 :     if ( !pViewSh )
     535         638 :         return;
     536             : 
     537             :     // First make all Statecaches dirty, so that no-one no longer tries to use
     538             :     // the Slots
     539             :     {
     540             :         SfxBindings *pBindings =
     541         638 :             pViewSh->GetViewFrame()->GetDispatcher()->GetBindings();
     542         638 :         sal_uInt16 nCount = pImp->aSlotArr.size();
     543         638 :         for (sal_uInt16 n1=0; n1<nCount ; n1++)
     544             :         {
     545           0 :             sal_uInt16 nId = SID_VERB_START + n1;
     546           0 :             pBindings->Invalidate(nId, false, true);
     547             :         }
     548             :     }
     549             : 
     550         638 :     sal_uInt16 nr=0;
     551         638 :     for (sal_Int32 n=0; n<aVerbs.getLength(); n++)
     552             :     {
     553           0 :         sal_uInt16 nSlotId = SID_VERB_START + nr++;
     554             :         DBG_ASSERT(nSlotId <= SID_VERB_END, "To many Verbs!");
     555           0 :         if (nSlotId > SID_VERB_END)
     556           0 :             break;
     557             : 
     558           0 :         SfxSlot *pNewSlot = new SfxSlot;
     559           0 :         pNewSlot->nSlotId = nSlotId;
     560           0 :         pNewSlot->nGroupId = 0;
     561             : 
     562             :         // Verb slots must be executed asynchronously, so that they can be
     563             :         // destroyed while executing.
     564           0 :         pNewSlot->nFlags = SfxSlotMode::ASYNCHRON | SfxSlotMode::CONTAINER;
     565           0 :         pNewSlot->nMasterSlotId = 0;
     566           0 :         pNewSlot->nValue = 0;
     567           0 :         pNewSlot->fnExec = SFX_STUB_PTR(SfxShell,VerbExec);
     568           0 :         pNewSlot->fnState = SFX_STUB_PTR(SfxShell,VerbState);
     569           0 :         pNewSlot->pType = 0; // HACK(SFX_TYPE(SfxVoidItem)) ???
     570           0 :         pNewSlot->pLinkedSlot = 0;
     571           0 :         pNewSlot->nArgDefCount = 0;
     572           0 :         pNewSlot->pFirstArgDef = 0;
     573           0 :         pNewSlot->pUnoName = 0;
     574             : 
     575           0 :         if (!pImp->aSlotArr.empty())
     576             :         {
     577           0 :             SfxSlot& rSlot = pImp->aSlotArr[0];
     578           0 :             pNewSlot->pNextSlot = rSlot.pNextSlot;
     579           0 :             rSlot.pNextSlot = pNewSlot;
     580             :         }
     581             :         else
     582           0 :             pNewSlot->pNextSlot = pNewSlot;
     583             : 
     584           0 :         pImp->aSlotArr.insert(pImp->aSlotArr.begin() + (sal_uInt16) n, pNewSlot);
     585             :     }
     586             : 
     587         638 :     pImp->aVerbList = aVerbs;
     588             : 
     589         638 :     if (pViewSh)
     590             :     {
     591             :         // The status of SID_OBJECT is collected in the controller directly on
     592             :         // the Shell, it is thus enough to encourage a new status update
     593             :         SfxBindings *pBindings = pViewSh->GetViewFrame()->GetDispatcher()->
     594         638 :                 GetBindings();
     595         638 :         pBindings->Invalidate( SID_OBJECT, true, true );
     596             :     }
     597             : }
     598             : 
     599           7 : const com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor >& SfxShell::GetVerbs() const
     600             : {
     601           7 :     return pImp->aVerbList;
     602             : }
     603             : 
     604           0 : void SfxShell::VerbExec(SfxRequest& rReq)
     605             : {
     606           0 :     sal_uInt16 nId = rReq.GetSlot();
     607           0 :     SfxViewShell *pViewShell = GetViewShell();
     608           0 :     if ( pViewShell )
     609             :     {
     610           0 :         bool bReadOnly = pViewShell->GetObjectShell()->IsReadOnly();
     611           0 :         com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor > aList = pViewShell->GetVerbs();
     612           0 :         for (sal_Int32 n=0, nVerb=0; n<aList.getLength(); n++)
     613             :         {
     614             :             // check for ReadOnly verbs
     615           0 :             if ( bReadOnly && !(aList[n].VerbAttributes & embed::VerbAttributes::MS_VERBATTR_NEVERDIRTIES) )
     616           0 :                 continue;
     617             : 
     618             :             // check for verbs that shouldn't appear in the menu
     619           0 :             if ( !(aList[n].VerbAttributes & embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU) )
     620           0 :                 continue;
     621             : 
     622           0 :             if (nId == SID_VERB_START + nVerb++)
     623             :             {
     624           0 :                 pViewShell->DoVerb(aList[n].VerbID);
     625           0 :                 rReq.Done();
     626           0 :                 return;
     627             :             }
     628           0 :         }
     629             :     }
     630             : }
     631             : 
     632           0 : void SfxShell::VerbState(SfxItemSet& )
     633             : {
     634           0 : }
     635             : 
     636           0 : const SfxSlot* SfxShell::GetVerbSlot_Impl(sal_uInt16 nId) const
     637             : {
     638           0 :     com::sun::star::uno::Sequence < com::sun::star::embed::VerbDescriptor > rList = pImp->aVerbList;
     639             : 
     640             :     DBG_ASSERT(nId >= SID_VERB_START && nId <= SID_VERB_END,"Wrong VerbId!");
     641           0 :     sal_uInt16 nIndex = nId - SID_VERB_START;
     642             :     DBG_ASSERT(nIndex < rList.getLength(),"Wrong VerbId!");
     643             : 
     644           0 :     if (nIndex < rList.getLength())
     645           0 :         return &pImp->aSlotArr[nIndex];
     646             :     else
     647           0 :         return 0;
     648             : }
     649             : 
     650       11919 : void SfxShell::SetHelpId(sal_uIntPtr nId)
     651             : {
     652       11919 :     pImp->nHelpId = nId;
     653       11919 : }
     654             : 
     655         130 : sal_uIntPtr SfxShell::GetHelpId() const
     656             : {
     657         130 :     return pImp->nHelpId;
     658             : }
     659             : 
     660         684 : SfxObjectShell* SfxShell::GetObjectShell()
     661             : {
     662         684 :     if ( GetViewShell() )
     663         684 :         return GetViewShell()->GetViewFrame()->GetObjectShell();
     664             :     else
     665           0 :         return NULL;
     666             : }
     667             : 
     668           0 : bool SfxShell::HasUIFeature( sal_uInt32 )
     669             : {
     670           0 :     return false;
     671             : }
     672             : 
     673         473 : sal_IntPtr DispatcherUpdate_Impl( void*, void* pArg )
     674             : {
     675         473 :     static_cast<SfxDispatcher*>(pArg)->Update_Impl( true );
     676         473 :     static_cast<SfxDispatcher*>(pArg)->GetBindings()->InvalidateAll(false);
     677         473 :     return 0;
     678             : }
     679             : 
     680        3511 : void SfxShell::UIFeatureChanged()
     681             : {
     682        3511 :     SfxViewFrame *pFrame = GetFrame();
     683        3511 :     if ( pFrame && pFrame->IsVisible() )
     684             :     {
     685             :         // Also force an update, if dispatcher is already updated otherwise
     686             :         // something my get stuck in the bunkered tools. Asynchronous call to
     687             :         // prevent recursion.
     688        2743 :         if ( !pImp->pUpdater )
     689        2608 :             pImp->pUpdater = new svtools::AsynchronLink( Link<>( this, DispatcherUpdate_Impl ) );
     690             : 
     691             :         // Multiple views allowed
     692        2743 :         pImp->pUpdater->Call( pFrame->GetDispatcher(), true );
     693             :     }
     694        3511 : }
     695             : 
     696       65844 : void SfxShell::SetDisableFlags( sal_uIntPtr nFlags )
     697             : {
     698       65844 :     pImp->nDisableFlags = nFlags;
     699       65844 : }
     700             : 
     701       62330 : sal_uIntPtr SfxShell::GetDisableFlags() const
     702             : {
     703       62330 :     return pImp->nDisableFlags;
     704             : }
     705             : 
     706           0 : SfxItemSet* SfxShell::CreateItemSet( sal_uInt16 )
     707             : {
     708           0 :     return NULL;
     709             : }
     710             : 
     711           0 : void SfxShell::ApplyItemSet( sal_uInt16, const SfxItemSet& )
     712             : {
     713           0 : }
     714             : 
     715        3881 : void SfxShell::SetContextName (const ::rtl::OUString& rsContextName)
     716             : {
     717        3881 :     pImp->maContextChangeBroadcaster.Initialize(rsContextName);
     718        3881 : }
     719             : 
     720       14699 : void SfxShell::SetViewShell_Impl( SfxViewShell* pView )
     721             : {
     722       14699 :     pImp->pViewSh = pView;
     723       14699 : }
     724             : 
     725       41630 : void SfxShell::BroadcastContextForActivation (const bool bIsActivated)
     726             : {
     727       41630 :     SfxViewFrame* pViewFrame = GetFrame();
     728       41630 :     if (pViewFrame != NULL)
     729             :     {
     730       31569 :         if (bIsActivated)
     731       18742 :             pImp->maContextChangeBroadcaster.Activate(pViewFrame->GetFrame().GetFrameInterface());
     732             :         else
     733       12827 :             pImp->maContextChangeBroadcaster.Deactivate(pViewFrame->GetFrame().GetFrameInterface());
     734             :    }
     735       41630 : }
     736             : 
     737        1062 : bool SfxShell::SetContextBroadcasterEnabled (const bool bIsEnabled)
     738             : {
     739        1062 :     return pImp->maContextChangeBroadcaster.SetBroadcasterEnabled(bIsEnabled);
     740         648 : }
     741             : 
     742             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11