LCOV - code coverage report
Current view: top level - sfx2/source/control - dispatch.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 688 920 74.8 %
Date: 2012-08-25 Functions: 67 83 80.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 651 1334 48.8 %

           Branch data     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/beans/XPropertySet.hpp>
      21                 :            : #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
      22                 :            : #include <com/sun/star/frame/XLayoutManager.hpp>
      23                 :            : #include <svl/itempool.hxx>
      24                 :            : #include <svl/itemiter.hxx>
      25                 :            : #include <svl/whiter.hxx>
      26                 :            : #include <svl/intitem.hxx>
      27                 :            : #include <svl/eitem.hxx>
      28                 :            : #include <svl/undo.hxx>
      29                 :            : #include <vcl/wrkwin.hxx>
      30                 :            : #include <stdio.h>
      31                 :            : #include <stdarg.h>
      32                 :            : #include <stdlib.h>  // due to bsearch
      33                 :            : 
      34                 :            : #include <svtools/helpopt.hxx>
      35                 :            : 
      36                 :            : // due to nAutoPageID
      37                 :            : #include "appdata.hxx"
      38                 :            : #include "sfx2/sfxhelp.hxx"
      39                 :            : #include <sfx2/dispatch.hxx>
      40                 :            : #include <sfx2/minstack.hxx>
      41                 :            : #include <sfx2/msg.hxx>
      42                 :            : #include <sfx2/objface.hxx>
      43                 :            : #include <sfx2/bindings.hxx>
      44                 :            : #include <sfx2/request.hxx>
      45                 :            : #include <sfx2/app.hxx>
      46                 :            : #include <sfx2/hintpost.hxx>
      47                 :            : #include "slotserv.hxx"
      48                 :            : #include <sfx2/ipclient.hxx>
      49                 :            : #include "sfxtypes.hxx"
      50                 :            : #include <sfx2/viewfrm.hxx>
      51                 :            : #include <sfx2/viewsh.hxx>
      52                 :            : #include <sfx2/childwin.hxx>
      53                 :            : #include <sfx2/docfac.hxx>
      54                 :            : #include <sfx2/msgpool.hxx>
      55                 :            : #include <sfx2/module.hxx>
      56                 :            : #include <sfx2/sfxuno.hxx>
      57                 :            : #include <sfx2/docfile.hxx>
      58                 :            : #include <sfx2/mnumgr.hxx>
      59                 :            : #include "workwin.hxx"
      60                 :            : #include <rtl/strbuf.hxx>
      61                 :            : 
      62                 :            : #include <deque>
      63                 :            : #include <boost/ptr_container/ptr_vector.hpp>
      64                 :            : 
      65                 :            : DBG_NAME(SfxDispatcherFlush)
      66                 :            : DBG_NAME(SfxDispatcherFillState)
      67                 :            : 
      68                 :            : typedef boost::ptr_vector<SfxRequest> SfxRequestPtrArray;
      69                 :            : 
      70                 :    3742451 : DECL_PTRSTACK(SfxShellStack_Impl, SfxShell*, 8, 4 );
      71                 :            : 
      72                 :            : struct SfxToDo_Impl
      73                 :            : {
      74                 :            :     SfxShell*  pCluster;
      75                 :            :     bool       bPush;
      76                 :            :     bool       bDelete;
      77                 :            :     bool       bUntil;
      78                 :            : 
      79                 :            :     SfxToDo_Impl()
      80                 :            :         : pCluster(0)
      81                 :            :         , bPush(false)
      82                 :            :         , bDelete(false)
      83                 :            :         , bUntil(false)
      84                 :            :                 {}
      85                 :      28213 :     SfxToDo_Impl( bool bOpPush, bool bOpDelete, bool bOpUntil, SfxShell& rCluster )
      86                 :            :         : pCluster(&rCluster)
      87                 :            :         , bPush(bOpPush)
      88                 :            :         , bDelete(bOpDelete)
      89                 :      28213 :         , bUntil(bOpUntil)
      90                 :      28213 :                 {}
      91                 :      70559 :     ~SfxToDo_Impl(){}
      92                 :            : 
      93                 :            :     bool operator==( const SfxToDo_Impl& rWith ) const
      94                 :            :     { return pCluster==rWith.pCluster && bPush==rWith.bPush; }
      95                 :            : };
      96                 :            : 
      97                 :      46228 : struct SfxObjectBars_Impl
      98                 :            : {
      99                 :            :     sal_uInt32     nResId;  // Resource - and ConfigId of the Toolbox
     100                 :            :     sal_uInt16     nMode;   // special visibility flags
     101                 :            :     String         aName;
     102                 :            :     SfxInterface*  pIFace;
     103                 :            : 
     104                 :      50544 :     SfxObjectBars_Impl() :
     105                 :      50544 :         nResId( 0 )
     106                 :      50544 :     {}
     107                 :            : };
     108                 :            : 
     109                 :            : //------------------------------------------------------------------
     110                 :            : 
     111 [ +  - ][ +  + ]:     100494 : struct SfxDispatcher_Impl
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
           [ #  #  #  # ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
         [ +  + ][ +  - ]
           [ #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
     112                 :            : {
     113                 :            :     SfxRequestPtrArray   aReqArr;
     114                 :            :     const SfxSlotServer* pCachedServ1;  // last called message
     115                 :            :     const SfxSlotServer* pCachedServ2;  // penultimate called Message
     116                 :            :     SfxShellStack_Impl   aStack;        // active functionality
     117                 :            :     Timer                aTimer;        // for Flush
     118                 :            :     std::deque<SfxToDo_Impl> aToDoStack;    // not processed Push/Pop
     119                 :            :     SfxViewFrame*        pFrame;        // NULL or associated Frame
     120                 :            :     SfxDispatcher*       pParent;       // AppDispatcher, NULL if possible
     121                 :            :     SfxHintPosterRef     xPoster;       // Execute asynchronous
     122                 :            :     sal_Bool             bFlushing;     // sal_True during Flush //?
     123                 :            :     sal_Bool             bUpdated;      // Update_Impl has run
     124                 :            :     sal_Bool             bLocked;       // No Execute
     125                 :            :     sal_Bool     bInvalidateOnUnlock;   // because someone asked
     126                 :            :     sal_Bool             bActive;       // not to be confused with set!
     127                 :            :     sal_Bool*       pInCallAliveFlag;   // view the Destructor Stack
     128                 :            :     SfxObjectBars_Impl   aObjBars[SFX_OBJECTBAR_MAX];
     129                 :            :     SfxObjectBars_Impl   aFixedObjBars[SFX_OBJECTBAR_MAX];
     130                 :            :     std::vector<sal_uInt32> aChildWins;
     131                 :            :     sal_uInt32           nEventId;      // EventId UserEvent
     132                 :            :     sal_Bool             bNoUI;         // UI only from Parent Dispatcher
     133                 :            :     sal_Bool             bReadOnly;     // Document is ReadOnly
     134                 :            :     sal_Bool             bQuiet;        // Only use parent dispatcher
     135                 :            :     sal_Bool             bModal;        // Only slots from parent dispatcher
     136                 :            : 
     137                 :            :     sal_Bool           bFilterEnabling; // sal_True=filter enabled slots,
     138                 :            :                                         // 2==ReadOnlyDoc overturned
     139                 :            :     sal_uInt16           nFilterCount;  // Number of SIDs in pFilterSIDs
     140                 :            :     const sal_uInt16*    pFilterSIDs;   // sorted Array of SIDs
     141                 :            :     sal_uInt16           nStandardMode; // ExecuteMode from PlugInDispatcher
     142                 :            :     std::vector<sal_uInt16>* pDisableList;
     143                 :            :     sal_uInt32           nDisableFlags;
     144                 :            : };
     145                 :            : 
     146                 :            : //------------------------------------------------------------------
     147                 :            : 
     148                 :            : #define SFX_FLUSH_TIMEOUT    50
     149                 :            : 
     150                 :            : //====================================================================
     151                 :     270800 : sal_Bool SfxDispatcher::IsLocked( sal_uInt16 ) const
     152                 :            : 
     153                 :            : /*  [Description]
     154                 :            : 
     155                 :            :     With this method it can be determined whether the SfxDispatcher is
     156                 :            :     locked or unlocked. A locked SfxDispatcher does not perform <SfxRequest>s
     157                 :            :     and no longer provides any status information. It behaves as if all the
     158                 :            :     slots are disabled.
     159                 :            : 
     160                 :            :     The dispatcher is also marked as blocked, if all Dispatcher are locked
     161                 :            :     (<SfxApplication::LockDispatcher()>) or the associated top frame is in the
     162                 :            :     modal-mode and if the specified slot are handled as frame-specific
     163                 :            :     (ie, not served by the application).
     164                 :            : */
     165                 :            : 
     166                 :            : {
     167                 :     270800 :     return pImp->bLocked;
     168                 :            : }
     169                 :            : 
     170                 :            : //--------------------------------------------------------------------
     171                 :      15397 : sal_Bool SfxDispatcher::IsAppDispatcher() const
     172                 :            : 
     173                 :            : /*  [Description]
     174                 :            : 
     175                 :            :     With this method it can be determined if the SfxDispacher is the
     176                 :            :     applications dispatcher.
     177                 :            : 
     178                 :            :     [Return value]
     179                 :            : 
     180                 :            :     sal_Bool   sal_True       it is the application dispatcher.
     181                 :            :                sal_Fals       it is a SfxViewFrame dispatcher.
     182                 :            : */
     183                 :            : 
     184                 :            : {
     185                 :      15397 :     return !pImp->pFrame;
     186                 :            : }
     187                 :            : 
     188                 :            : //--------------------------------------------------------------------
     189                 :        917 : int SfxDispatcher::Call_Impl( SfxShell& rShell, const SfxSlot &rSlot, SfxRequest &rReq, sal_Bool bRecord )
     190                 :            : 
     191                 :            : /*  [Description]
     192                 :            : 
     193                 :            :     Helper function to check whether a slot can be executed and
     194                 :            :     check the execution itself
     195                 :            : */
     196                 :            : 
     197                 :            : {
     198                 :            :     SFX_STACK(SfxDispatcher::Call_Impl);
     199                 :            : 
     200                 :            :     // The slot may be called (meaning enabled)
     201 [ +  - ][ +  - ]:        917 :     if ( rSlot.IsMode(SFX_SLOT_FASTCALL) || rShell.CanExecuteSlot_Impl(rSlot) )
                 [ +  - ]
     202                 :            :     {
     203         [ +  - ]:        917 :         if ( GetFrame() )
     204                 :            :         {
     205                 :            :             // Recording may start
     206                 :            :             com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame(
     207 [ +  - ][ +  - ]:        917 :                     GetFrame()->GetFrame().GetFrameInterface(),
     208 [ +  - ][ +  - ]:        917 :                     com::sun::star::uno::UNO_QUERY);
     209                 :            : 
     210                 :            :             com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(
     211                 :            :                     xFrame,
     212         [ +  - ]:        917 :                     com::sun::star::uno::UNO_QUERY);
     213                 :            : 
     214         [ +  - ]:        917 :             if ( xSet.is() )
     215                 :            :             {
     216 [ +  - ][ +  - ]:        917 :                 com::sun::star::uno::Any aProp = xSet->getPropertyValue(::rtl::OUString("DispatchRecorderSupplier"));
     217                 :        917 :                 com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorderSupplier > xSupplier;
     218                 :        917 :                 com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > xRecorder;
     219         [ +  - ]:        917 :                 aProp >>= xSupplier;
     220         [ +  + ]:        917 :                 if(xSupplier.is())
     221 [ +  - ][ +  - ]:          2 :                     xRecorder = xSupplier->getDispatchRecorder();
                 [ +  - ]
     222                 :            : 
     223 [ +  + ][ +  + ]:        917 :                 if ( bRecord && xRecorder.is() && !rSlot.IsMode(SFX_SLOT_NORECORD) )
         [ +  - ][ +  + ]
     224 [ +  - ][ +  - ]:        917 :                     rReq.Record_Impl( rShell, rSlot, xRecorder, GetFrame() );
     225                 :        917 :             }
     226                 :            :         }
     227                 :            :         // Get all that is needed, because the slot may not have survived the
     228                 :            :         // Execute if it is a 'pseudo slot' for macros or verbs.
     229                 :        917 :         sal_Bool bAutoUpdate = rSlot.IsMode(SFX_SLOT_AUTOUPDATE);
     230                 :            : 
     231                 :            :         // API-call parentheses and document-lock during the calls
     232                 :            :         {
     233                 :            :             // 'this' must respond in the Destructor
     234                 :        917 :             sal_Bool bThisDispatcherAlive = sal_True;
     235                 :        917 :             sal_Bool *pOldInCallAliveFlag = pImp->pInCallAliveFlag;
     236                 :        917 :             pImp->pInCallAliveFlag = &bThisDispatcherAlive;
     237                 :            : 
     238         [ +  - ]:        917 :             SfxViewFrame* pView = GetFrame();
     239         [ -  + ]:        917 :             if ( !pView )
     240         [ #  # ]:          0 :                 pView = SfxViewFrame::Current();
     241         [ +  - ]:        917 :             if ( pView )
     242                 :            :             {
     243                 :        917 :                 rtl::OString aCmd(".uno:");
     244                 :        917 :                 aCmd += rSlot.GetUnoName();
     245 [ +  - ][ +  - ]:        917 :                 SfxHelp::OpenHelpAgent( &pView->GetFrame(), aCmd );
     246                 :            :             }
     247                 :            : 
     248                 :        917 :             SfxExecFunc pFunc = rSlot.GetExecFnc();
     249         [ +  - ]:        917 :             rShell.CallExec( pFunc, rReq );
     250                 :            : 
     251                 :            :             // If 'this' is still alive
     252         [ +  - ]:        917 :             if ( bThisDispatcherAlive )
     253                 :        917 :                 pImp->pInCallAliveFlag = pOldInCallAliveFlag;
     254                 :            :             else
     255                 :            :             {
     256         [ #  # ]:          0 :                 if ( pOldInCallAliveFlag )
     257                 :            :                 {
     258                 :            :                     // also protect nested stack frames
     259                 :          0 :                     *pOldInCallAliveFlag = sal_False;
     260                 :            :                 }
     261                 :            : 
     262                 :            :                 // do nothing after this object is dead
     263         [ #  # ]:          0 :                 return rReq.IsDone();
     264                 :            :             }
     265                 :            :         }
     266                 :            : 
     267         [ +  + ]:        917 :         if ( rReq.IsDone() )
     268                 :            :         {
     269                 :        176 :             SfxBindings *pBindings = GetBindings();
     270                 :            : 
     271                 :            :             // When AutoUpdate update immediately; "Pseudoslots" must not be
     272                 :            :             // Autoupdate!
     273 [ +  - ][ +  + ]:        176 :             if ( bAutoUpdate && pBindings )
     274                 :            :             {
     275                 :          6 :                 const SfxSlot* pSlave = rSlot.GetLinkedSlot();
     276         [ -  + ]:          6 :                 if (pSlave)
     277                 :            :                 {
     278                 :            :                     // When enum slots take any bound slave slot
     279 [ #  # ][ #  # ]:          0 :                     while (!pBindings->IsBound(pSlave->GetSlotId()) && pSlave != &rSlot )
                 [ #  # ]
     280                 :          0 :                         pSlave = pSlave->GetLinkedSlot();
     281                 :          0 :                     pBindings->Invalidate(pSlave->GetSlotId());
     282                 :          0 :                     pBindings->Update(pSlave->GetSlotId());
     283                 :            :                 }
     284                 :            :                 else
     285                 :            :                 {
     286                 :          6 :                     pBindings->Invalidate(rSlot.GetSlotId());
     287                 :          6 :                     pBindings->Update(rSlot.GetSlotId());
     288                 :            :                 }
     289                 :            :             }
     290                 :            : 
     291                 :        176 :             return sal_True;
     292                 :            :         }
     293                 :            :     }
     294                 :            : 
     295                 :        917 :     return sal_False;
     296                 :            : }
     297                 :            : 
     298                 :            : //====================================================================
     299                 :       1944 : void SfxDispatcher::Construct_Impl( SfxDispatcher* pParent )
     300                 :            : {
     301 [ +  - ][ +  - ]:       1944 :     pImp = new SfxDispatcher_Impl;
     302                 :       1944 :     bFlushed = sal_True;
     303         [ +  - ]:       1944 :     SfxApplication *pSfxApp = SFX_APP();
     304                 :            : 
     305                 :       1944 :     pImp->pCachedServ1 = 0;
     306                 :       1944 :     pImp->pCachedServ2 = 0;
     307                 :       1944 :     pImp->bFlushing = sal_False;
     308                 :       1944 :     pImp->bUpdated = sal_False;
     309                 :       1944 :     pImp->bLocked = sal_False;
     310                 :       1944 :     pImp->bActive = sal_False;
     311                 :       1944 :     pImp->pParent = NULL;
     312                 :       1944 :     pImp->bNoUI = sal_False;
     313                 :       1944 :     pImp->bReadOnly = sal_False;
     314                 :       1944 :     pImp->bQuiet = sal_False;
     315                 :       1944 :     pImp->bModal = sal_False;
     316                 :       1944 :     pImp->pInCallAliveFlag = 0;
     317                 :       1944 :     pImp->bFilterEnabling = sal_False;
     318                 :       1944 :     pImp->nFilterCount = 0;
     319                 :       1944 :     pImp->pFilterSIDs = 0;
     320                 :       1944 :     pImp->nStandardMode = 0;
     321         [ +  - ]:       1944 :     pImp->pDisableList = pSfxApp->GetDisabledSlotList_Impl();
     322                 :       1944 :     pImp->nDisableFlags = 0;
     323                 :            : 
     324                 :       1944 :     pImp->pParent = pParent;
     325                 :            : 
     326                 :       1944 :     pImp->bInvalidateOnUnlock = sal_False;
     327                 :            : 
     328         [ +  + ]:      27216 :     for (sal_uInt16 n=0; n<SFX_OBJECTBAR_MAX; n++)
     329                 :      25272 :         pImp->aObjBars[n].nResId = 0;
     330                 :            : 
     331         [ +  - ]:       1944 :     GenLink aGenLink( LINK(this, SfxDispatcher, PostMsgHandler) );
     332                 :            : 
     333 [ +  - ][ +  - ]:       1944 :     pImp->xPoster = new SfxHintPoster(aGenLink);
                 [ +  - ]
     334                 :            : 
     335         [ +  - ]:       1944 :     pImp->aTimer.SetTimeout(SFX_FLUSH_TIMEOUT);
     336         [ +  - ]:       1944 :     pImp->aTimer.SetTimeoutHdl( LINK(this, SfxDispatcher, EventHdl_Impl ) );
     337                 :       1944 : }
     338                 :            : 
     339                 :        233 : SfxDispatcher::SfxDispatcher( SfxDispatcher* pParent )
     340                 :            : {
     341                 :        233 :     Construct_Impl( pParent );
     342                 :        233 :     pImp->pFrame = 0;
     343                 :        233 : }
     344                 :            : 
     345                 :       1711 : SfxDispatcher::SfxDispatcher( SfxViewFrame *pViewFrame )
     346                 :            : 
     347                 :            : /*  [Description]
     348                 :            : 
     349                 :            :     The constructor of the SfxDispatcher class places a stack of empty
     350                 :            :     <SfxShell> pointers. It is not initially locked and is considered flushed.
     351                 :            : */
     352                 :            : 
     353                 :            : {
     354         [ +  - ]:       1711 :     if ( pViewFrame )
     355                 :            :     {
     356                 :       1711 :         SfxViewFrame *pFrame = pViewFrame->GetParentViewFrame();
     357         [ -  + ]:       1711 :         if ( pFrame )
     358                 :          0 :             Construct_Impl(  pFrame->GetDispatcher() );
     359                 :            :         else
     360                 :       1711 :             Construct_Impl( 0 );
     361                 :            :     }
     362                 :            :     else
     363                 :          0 :         Construct_Impl( 0 );
     364                 :       1711 :     pImp->pFrame = pViewFrame;
     365                 :       1711 : }
     366                 :            : 
     367                 :            : //====================================================================
     368                 :       3556 : SfxDispatcher::~SfxDispatcher()
     369                 :            : 
     370                 :            : /*  [Description]
     371                 :            : 
     372                 :            :     The destructor of the SfxDispatcher class should not be called when the
     373                 :            :     SfxDispatcher instance is active. It may, however, still be a <SfxShell>
     374                 :            :     pointer on the stack.
     375                 :            : */
     376                 :            : 
     377                 :            : {
     378                 :            : #ifdef DBG_UTIL
     379                 :            :     rtl::OStringBuffer sTemp(RTL_CONSTASCII_STRINGPARAM("Delete Dispatcher "));
     380                 :            :     sTemp.append(reinterpret_cast<sal_Int64>(this));
     381                 :            :     OSL_TRACE("%s", sTemp.getStr());
     382                 :            :     DBG_ASSERT( !pImp->bActive, "deleting active Dispatcher" );
     383                 :            : #endif
     384                 :            : 
     385                 :            :     // So that no timer by Reschedule in PlugComm strikes the LeaveRegistrations
     386                 :       1778 :     pImp->aTimer.Stop();
     387         [ +  - ]:       1778 :     pImp->xPoster->SetEventHdl( Link() );
     388                 :            : 
     389                 :            :     // Notify the stack varialbles in Call_Impl
     390         [ -  + ]:       1778 :     if ( pImp->pInCallAliveFlag )
     391                 :          0 :         *pImp->pInCallAliveFlag = sal_False;
     392                 :            : 
     393                 :            :     // Get bindings and application
     394                 :       1778 :     SfxApplication *pSfxApp = SFX_APP();
     395                 :       1778 :     SfxBindings* pBindings = GetBindings();
     396                 :            : 
     397                 :            :     // When not flushed, revive the bindings
     398 [ +  - ][ +  - ]:       1778 :     if ( pBindings && !pSfxApp->IsDowning() && !bFlushed )
         [ +  + ][ +  + ]
     399                 :       1620 :         pBindings->DLEAVEREGISTRATIONS();
     400                 :            : 
     401                 :            :     // may unregister the bindings
     402         [ +  + ]:       3398 :     while ( pBindings )
     403                 :            :     {
     404         [ +  - ]:       1620 :         if ( pBindings->GetDispatcher_Impl() == this)
     405                 :       1620 :             pBindings->SetDispatcher(0);
     406                 :       1620 :         pBindings = pBindings->GetSubBindings_Impl();
     407                 :            :     }
     408                 :            : 
     409         [ +  - ]:       1778 :     delete pImp;
     410         [ -  + ]:       3556 : }
     411                 :            : 
     412                 :            : //====================================================================
     413                 :      20635 : void SfxDispatcher::Pop
     414                 :            : (
     415                 :            :     SfxShell&   rShell,  /* the stack to take the SfxShell instance. */
     416                 :            : 
     417                 :            :     sal_uInt16   nMode   /* SFX_SHELL_POP_UNTIL
     418                 :            :                             Also all 'rShell' of SfxShells are taken from the
     419                 :            :                             stack.
     420                 :            : 
     421                 :            :                             SFX_SHELL_POP_DELETE
     422                 :            :                             All SfxShells actually taken from the stack
     423                 :            :                             will be deleted.
     424                 :            : 
     425                 :            :                             SFX_SHELL_PUSH (InPlace use only)
     426                 :            :                             The Shell is pushed. */
     427                 :            : )
     428                 :            : /*  [Description]
     429                 :            : 
     430                 :            :     With this method, one or more <SfxShell> are poped from the SfxDispatcher.
     431                 :            :     The SfxShell is marked for popping and a timer is set up. Only when the
     432                 :            :     timer has reached the end, the pop is actually performed
     433                 :            :     ( <SfxDispatcher::Flush()> ) and the <SfxBindings> is invalidated.
     434                 :            :     While the timer is running the opposing push and pop commands on one
     435                 :            :     SfxShell cancel each other out.
     436                 :            : */
     437                 :            : 
     438                 :            : {
     439                 :            :     DBG_ASSERT( rShell.GetInterface(),
     440                 :            :                 "pushing SfxShell without previous RegisterInterface()" );
     441                 :            : 
     442                 :      20635 :     bool bDelete = (nMode & SFX_SHELL_POP_DELETE) == SFX_SHELL_POP_DELETE;
     443                 :      20635 :     bool bUntil = (nMode & SFX_SHELL_POP_UNTIL) == SFX_SHELL_POP_UNTIL;
     444                 :      20635 :     bool bPush = (nMode & SFX_SHELL_PUSH) == SFX_SHELL_PUSH;
     445                 :            : 
     446                 :      20635 :     SfxApplication *pSfxApp = SFX_APP();
     447                 :            : 
     448                 :            :     SAL_INFO(
     449                 :            :         "sfx2",
     450                 :            :         "-SfxDispatcher(" << this << (bPush ? ")::Push(" : ")::Pop(")
     451                 :            :             << (rShell.GetInterface()
     452                 :            :                 ? rShell.GetInterface()->GetClassName() : SAL_STREAM(&rShell))
     453                 :            :             << (bDelete ? ") with delete" : ")")
     454                 :            :             << (bUntil ? " (up to)" : ""));
     455                 :            : 
     456                 :            :     // same shell as on top of the to-do stack?
     457 [ +  + ][ +  + ]:      20635 :     if(pImp->aToDoStack.size() && pImp->aToDoStack.front().pCluster == &rShell)
                 [ +  + ]
     458                 :            :     {
     459                 :            :         // cancel inverse actions
     460         [ +  - ]:          4 :         if ( pImp->aToDoStack.front().bPush != bPush )
     461                 :          4 :             pImp->aToDoStack.pop_front();
     462                 :            :         else
     463                 :            :         {
     464                 :            :             DBG_ASSERT( bPush, "SfxInterface pushed more than once" );
     465                 :            :             DBG_ASSERT( !bPush, "SfxInterface popped more than once" );
     466                 :            :         }
     467                 :            :     }
     468                 :            :     else
     469                 :            :     {
     470                 :            :         // Remember ::com::sun::star::chaos::Action
     471         [ +  - ]:      20631 :         pImp->aToDoStack.push_front( SfxToDo_Impl(bPush, bDelete, bUntil, rShell) );
     472         [ +  + ]:      20631 :         if ( bFlushed )
     473                 :            :         {
     474                 :            :             OSL_TRACE("Unflushed dispatcher!");
     475                 :      10728 :             bFlushed = sal_False;
     476                 :      10728 :             pImp->bUpdated = sal_False;
     477                 :            : 
     478                 :            :             // Put bindings to sleep
     479                 :      10728 :             SfxBindings* pBindings = GetBindings();
     480         [ +  + ]:      10728 :             if ( pBindings )
     481                 :      10337 :                 pBindings->DENTERREGISTRATIONS();
     482                 :            :         }
     483                 :            :     }
     484                 :            : 
     485 [ +  - ][ +  - ]:      20635 :     if(!pSfxApp->IsDowning() && !pImp->aToDoStack.empty())
                 [ +  - ]
     486                 :            :     {
     487                 :            :         // No immediate update is requested
     488                 :      20635 :         pImp->aTimer.SetTimeout(SFX_FLUSH_TIMEOUT);
     489                 :      20635 :         pImp->aTimer.SetTimeoutHdl( LINK(this, SfxDispatcher, EventHdl_Impl ) );
     490                 :      20635 :         pImp->aTimer.Start();
     491                 :            :     }
     492                 :            :     else
     493                 :            :     {
     494                 :            :         // but to do nothing
     495                 :          0 :         pImp->aTimer.Stop();
     496                 :            : 
     497                 :            :         // Bindings may wake up again
     498         [ #  # ]:          0 :         if(pImp->aToDoStack.empty())
     499                 :            :         {
     500                 :          0 :             SfxBindings* pBindings = GetBindings();
     501         [ #  # ]:          0 :             if ( pBindings )
     502                 :          0 :                 pBindings->DLEAVEREGISTRATIONS();
     503                 :            :         }
     504                 :            :     }
     505                 :      20635 : }
     506                 :            : 
     507                 :            : //--------------------------------------------------------------------
     508                 :            : 
     509                 :          0 : IMPL_LINK_INLINE_START( SfxDispatcher, EventHdl_Impl, void *, pvoid )
     510                 :            : 
     511                 :            : /*  [Description]
     512                 :            : 
     513                 :            :     This handler is called after <SfxDispatcher::Invalidate()> or after
     514                 :            :     changes on the stack (<SfxDispatcher::Push()> and <SfxDispatcher::Pop())
     515                 :            : 
     516                 :            :     It flushes the Stack, if it is dirty, thus it actually excecutes the
     517                 :            :     pending Push and Pop commands.
     518                 :            : */
     519                 :            : 
     520                 :            : {
     521                 :            :     (void)pvoid; // unused
     522                 :            : 
     523                 :          0 :     Flush();
     524                 :          0 :     Update_Impl();
     525                 :          0 :     SfxBindings* pBindings = GetBindings();
     526         [ #  # ]:          0 :     if ( pBindings )
     527                 :          0 :         pBindings->StartUpdate_Impl(sal_False);
     528                 :          0 :     return 0;
     529                 :            : }
     530                 :          0 : IMPL_LINK_INLINE_END( SfxDispatcher, EventHdl_Impl, void *, pvoid )
     531                 :            : 
     532                 :            : //--------------------------------------------------------------------
     533                 :       2995 : sal_Bool SfxDispatcher::CheckVirtualStack( const SfxShell& rShell, sal_Bool bDeep )
     534                 :            : 
     535                 :            : /*  [Description]
     536                 :            : 
     537                 :            :     With this method it can be tested whether the <SfxShell> rShell is on the
     538                 :            :     stack, when it was flushed. This way the SfxDispatcher is not actually
     539                 :            :     flushed.
     540                 :            : 
     541                 :            :     This method is intended among other things to make assertions possible
     542                 :            :     without the side effect of having to flush the SfxDispathcer.
     543                 :            : */
     544                 :            : 
     545                 :            : {
     546                 :            :     SFX_STACK(SfxDispatcher::CheckVirtualStack);
     547                 :            : 
     548         [ +  - ]:       2995 :     SfxShellStack_Impl aStack( pImp->aStack );
     549 [ #  # ][ +  - ]:       2995 :     for(std::deque<SfxToDo_Impl>::reverse_iterator i = pImp->aToDoStack.rbegin(); i != pImp->aToDoStack.rend(); ++i)
                 [ -  + ]
     550                 :            :     {
     551 [ #  # ][ #  # ]:          0 :         if(i->bPush)
     552 [ #  # ][ #  # ]:          0 :             aStack.Push(i->pCluster);
     553                 :            :         else
     554                 :            :         {
     555                 :          0 :             SfxShell* pPopped(NULL);
     556 [ #  # ][ #  # ]:          0 :             do
                 [ #  # ]
     557                 :            :             {
     558                 :            :                 DBG_ASSERT( aStack.Count(), "popping from empty stack" );
     559         [ #  # ]:          0 :                 pPopped = aStack.Pop();
     560                 :            :             }
     561 [ #  # ][ #  # ]:          0 :             while(i->bUntil && pPopped != i->pCluster);
     562                 :            :             DBG_ASSERT(pPopped == i->pCluster, "popping unpushed SfxInterface");
     563                 :            :         }
     564                 :            :     }
     565                 :            : 
     566                 :            :     sal_Bool bReturn;
     567         [ +  - ]:       2995 :     if ( bDeep )
     568         [ +  - ]:       2995 :         bReturn = aStack.Contains(&rShell);
     569                 :            :     else
     570                 :          0 :         bReturn = aStack.Top() == &rShell;
     571         [ +  - ]:       2995 :     return bReturn;
     572                 :            : }
     573                 :            : 
     574                 :            : //--------------------------------------------------------------------
     575                 :       2021 : sal_uInt16 SfxDispatcher::GetShellLevel( const SfxShell& rShell )
     576                 :            : 
     577                 :            : /*  [Description]
     578                 :            : 
     579                 :            :     Determines the position of a given SfxShell in the stack of the dispatcher.
     580                 :            :     If possible this is flushed before.
     581                 :            : 
     582                 :            :     [Return value]
     583                 :            : 
     584                 :            :     sal_uInt16                  == USRT_MAX
     585                 :            :                                 The SfxShell is not on this SfxDispatcher.
     586                 :            : 
     587                 :            :                                 < USHRT_MAX
     588                 :            :                                 Position of the SfxShell on the Dispatcher
     589                 :            :                                 from the top count stating with 0.
     590                 :            : */
     591                 :            : 
     592                 :            : {
     593                 :            :     SFX_STACK(SfxDispatcher::GetShellLevel);
     594                 :       2021 :     Flush();
     595                 :            : 
     596         [ +  - ]:       5957 :     for ( sal_uInt16 n = 0; n < pImp->aStack.Count(); ++n )
     597         [ +  + ]:       5957 :         if ( pImp->aStack.Top( n ) == &rShell )
     598                 :       2021 :             return n;
     599         [ #  # ]:          0 :     if ( pImp->pParent )
     600                 :            :     {
     601                 :          0 :         sal_uInt16 nRet = pImp->pParent->GetShellLevel(rShell);
     602         [ #  # ]:          0 :         if ( nRet == USHRT_MAX )
     603                 :          0 :             return nRet;
     604                 :          0 :         return  nRet + pImp->aStack.Count();
     605                 :            :     }
     606                 :            : 
     607                 :       2021 :     return USHRT_MAX;
     608                 :            : }
     609                 :            : 
     610                 :            : //--------------------------------------------------------------------
     611                 :     786878 : SfxShell *SfxDispatcher::GetShell(sal_uInt16 nIdx) const
     612                 :            : 
     613                 :            : /*  [Description]
     614                 :            : 
     615                 :            :     Returns a pointer to the <SfxShell> which is at the position nIdx
     616                 :            :     (from the top, last pushed is 0) on the stack.
     617                 :            : 
     618                 :            :     Thus the SfxDispatcher is not flushed.
     619                 :            : 
     620                 :            :     Is the stack not deep enough a NULL-Pointer is returned.
     621                 :            : */
     622                 :            : 
     623                 :            : {
     624                 :     786878 :     sal_uInt16 nShellCount = pImp->aStack.Count();
     625         [ +  - ]:     786878 :     if ( nIdx < nShellCount )
     626                 :     786878 :         return pImp->aStack.Top(nIdx);
     627         [ #  # ]:          0 :     else if ( pImp->pParent )
     628                 :          0 :         return pImp->pParent->GetShell( nIdx - nShellCount );
     629                 :     786878 :     return 0;
     630                 :            : }
     631                 :            : 
     632                 :            : //--------------------------------------------------------------------
     633                 :      77484 : SfxBindings* SfxDispatcher::GetBindings() const
     634                 :            : 
     635                 :            : /*  [Description]
     636                 :            : 
     637                 :            :     This method returns a pointer to the <SfxBinding> Instance on which the
     638                 :            :     SfxDispatcher is curretly bound. A SfxDispatcher is only bound to
     639                 :            :     the SfxBindings when it is <UI-aktiv>. If it is not UI-active,
     640                 :            :     a NULL-pointer is returned.
     641                 :            : 
     642                 :            :     The returned pointer is only valid in the immediate context of the method
     643                 :            :     call.
     644                 :            : */
     645                 :            : 
     646                 :            : {
     647         [ +  + ]:      77484 :     if ( pImp->pFrame )
     648                 :      76311 :         return &pImp->pFrame->GetBindings();
     649                 :            :     else
     650                 :      77484 :         return NULL;
     651                 :            : }
     652                 :            : 
     653                 :            : //--------------------------------------------------------------------
     654                 :     242221 : SfxViewFrame* SfxDispatcher::GetFrame() const
     655                 :            : 
     656                 :            : /*  [Description]
     657                 :            : 
     658                 :            :     Returns a pointer to the <SfxViewFrame> instance, which belongs to
     659                 :            :     this SfxDispatcher. If it is about the application dispatcher,
     660                 :            :     a NULL-pointer is returned.
     661                 :            : */
     662                 :            : 
     663                 :            : {
     664                 :     242221 :     return pImp->pFrame;
     665                 :            : }
     666                 :            : 
     667                 :            : //--------------------------------------------------------------------
     668                 :       1928 : void SfxDispatcher::DoActivate_Impl( sal_Bool bMDI, SfxViewFrame* /* pOld */ )
     669                 :            : 
     670                 :            : /*  [Description]
     671                 :            : 
     672                 :            :     This method controls the activation of a dispatcher.
     673                 :            : 
     674                 :            :     Since the application dispatcher is always active, either as a sub
     675                 :            :     dispatcher of the <SfxViewFrame> dispatcher or as itself, it is never
     676                 :            :     activated as a whole, instead only its individual <SfxShell>s at
     677                 :            :     <SfxDispatcher::Push(SfxShell&)>.
     678                 :            : 
     679                 :            :     When activating a SfxDispatcher all of the SfxShells located on its stack
     680                 :            :     are called with the handler <SfxShell::Activate(sal_Bool)>, starting with
     681                 :            :     the lowest.
     682                 :            : */
     683                 :            : 
     684                 :            : {
     685                 :            :     SFX_STACK(SfxDispatcher::DoActivate);
     686         [ +  - ]:       1928 :     if ( bMDI )
     687                 :            :     {
     688                 :            : #ifdef DBG_UTIL
     689                 :            :         rtl::OStringBuffer sTemp(
     690                 :            :             RTL_CONSTASCII_STRINGPARAM("Activate Dispatcher "));
     691                 :            :         sTemp.append(reinterpret_cast<sal_Int64>(this));
     692                 :            :         OSL_TRACE("%s", sTemp.getStr());
     693                 :            :         DBG_ASSERT( !pImp->bActive, "Activation error" );
     694                 :            : #endif
     695                 :       1928 :         pImp->bActive = sal_True;
     696                 :       1928 :         pImp->bUpdated = sal_False;
     697                 :       1928 :         SfxBindings* pBindings = GetBindings();
     698         [ +  + ]:       1928 :         if ( pBindings )
     699                 :            :         {
     700                 :       1695 :             pBindings->SetDispatcher(this);
     701         [ +  - ]:       1695 :             pBindings->SetActiveFrame( pImp->pFrame->GetFrame().GetFrameInterface() );
     702                 :            :         }
     703                 :            :     }
     704                 :            :     else
     705                 :            :     {
     706                 :            : #ifdef DBG_UTIL
     707                 :            :         rtl::OStringBuffer sTemp(
     708                 :            :             RTL_CONSTASCII_STRINGPARAM("Non-MDI-Activate Dispatcher"));
     709                 :            :         sTemp.append(reinterpret_cast<sal_Int64>(this));
     710                 :            :         OSL_TRACE("%s", sTemp.getStr());
     711                 :            : #endif
     712                 :            :     }
     713                 :            : 
     714         [ +  + ]:       1928 :     if ( IsAppDispatcher() )
     715                 :       1928 :         return;
     716                 :            : 
     717         [ +  + ]:      11077 :     for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i )
     718                 :       9382 :         pImp->aStack.Top( (sal_uInt16) i )->DoActivate_Impl(pImp->pFrame, bMDI);
     719                 :            : 
     720 [ +  - ][ +  - ]:       1695 :     if ( bMDI && pImp->pFrame )
     721                 :            :     {
     722                 :       1695 :         SfxBindings *pBind = GetBindings();
     723         [ +  + ]:       3390 :         while ( pBind )
     724                 :            :         {
     725                 :       1695 :             pBind->HidePopupCtrls_Impl( sal_False );
     726                 :       1695 :             pBind = pBind->GetSubBindings_Impl();
     727                 :            :         }
     728                 :            : 
     729                 :       1695 :         pImp->pFrame->GetFrame().GetWorkWindow_Impl()->HidePopups_Impl( sal_False, sal_False, 1 );
     730                 :            :     }
     731                 :            : 
     732         [ -  + ]:       1695 :     if(!pImp->aToDoStack.empty())
     733                 :            :     {
     734                 :            :         // No immediate update is requested
     735                 :          0 :         pImp->aTimer.SetTimeout(SFX_FLUSH_TIMEOUT);
     736                 :          0 :         pImp->aTimer.SetTimeoutHdl( LINK(this, SfxDispatcher, EventHdl_Impl ) );
     737                 :          0 :         pImp->aTimer.Start();
     738                 :            :     }
     739                 :            : }
     740                 :            : 
     741                 :          0 : void SfxDispatcher::DoParentActivate_Impl()
     742                 :            : {
     743         [ #  # ]:          0 :     for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i )
     744                 :          0 :         pImp->aStack.Top( (sal_uInt16) i )->ParentActivate();
     745                 :          0 : }
     746                 :            : 
     747                 :            : //--------------------------------------------------------------------
     748                 :       1849 : void SfxDispatcher::DoDeactivate_Impl( sal_Bool bMDI, SfxViewFrame* pNew )
     749                 :            : 
     750                 :            : /*  [Description]
     751                 :            : 
     752                 :            :     This method controls the deactivation of a dispatcher.
     753                 :            : 
     754                 :            :     Since the application dispatcher is always active, either as a sub
     755                 :            :     dispatcher of the <SfxViewFrame> dispatcher or as itself, it is never
     756                 :            :     deactivated as a whole, instead only its individual <SfxShell>s at
     757                 :            :     <SfxDispatcher::Pop(SfxShell&)>.
     758                 :            : 
     759                 :            :     When deactivating a SfxDispatcher all of the SfxShells located on its stack
     760                 :            :     are called with the handler <SfxShell::Deactivate(sal_Bool)>, starting with
     761                 :            :     the lowest.
     762                 :            : */
     763                 :            : 
     764                 :            : {
     765                 :            :     SFX_STACK(SfxDispatcher::DoDeactivate);
     766                 :            : 
     767                 :       1849 :     SfxApplication *pSfxApp = SFX_APP();
     768                 :            : 
     769         [ +  - ]:       1849 :     if ( bMDI )
     770                 :            :     {
     771                 :            :         OSL_TRACE(rtl::OStringBuffer(RTL_CONSTASCII_STRINGPARAM("Deactivate Dispatcher")).append(reinterpret_cast<sal_Int64>(this)).getStr());
     772                 :            :         DBG_ASSERT( pImp->bActive, "Deactivate error" );
     773                 :       1849 :         pImp->bActive = sal_False;
     774                 :            : 
     775 [ +  + ][ +  - ]:       1849 :         if ( pImp->pFrame && !(pImp->pFrame->GetObjectShell()->IsInPlaceActive() ) )
                 [ +  + ]
     776                 :            :         {
     777                 :       1691 :             SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl();
     778         [ +  - ]:       1691 :             if ( pWorkWin )
     779                 :            :             {
     780         [ +  + ]:      60972 :                 for (size_t n=0; n<pImp->aChildWins.size();)
     781                 :            :                 {
     782                 :      59281 :                     SfxChildWindow *pWin = pWorkWin->GetChildWindow_Impl( (sal_uInt16) ( pImp->aChildWins[n] & 0xFFFF ) );
     783 [ +  - ][ -  + ]:      59281 :                     if (!pWin || (pWin && pWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT))
         [ +  + ][ +  + ]
     784 [ +  - ][ +  - ]:      59264 :                         pImp->aChildWins.erase(pImp->aChildWins.begin()+n);
     785                 :            :                     else
     786                 :         17 :                         n++;
     787                 :            :                 }
     788                 :            :             }
     789                 :            :         }
     790                 :            :     }
     791                 :            :     else {
     792                 :            :         OSL_TRACE(rtl::OStringBuffer(RTL_CONSTASCII_STRINGPARAM("Non-MDI-DeActivate Dispatcher")).append(reinterpret_cast<sal_Int64>(this)).getStr());
     793                 :            :     }
     794                 :            : 
     795 [ +  + ][ -  + ]:       1849 :     if ( IsAppDispatcher() && !pSfxApp->IsDowning() )
                 [ -  + ]
     796                 :       1849 :         return;
     797                 :            : 
     798         [ +  + ]:      14663 :     for ( sal_uInt16 i = 0; i < pImp->aStack.Count(); ++i )
     799                 :      12814 :         pImp->aStack.Top(i)->DoDeactivate_Impl(pImp->pFrame, bMDI);
     800                 :            : 
     801 [ +  - ][ +  + ]:       1849 :     sal_Bool bHidePopups = bMDI && pImp->pFrame;
     802 [ +  + ][ +  - ]:       1849 :     if ( pNew && pImp->pFrame )
     803                 :            :     {
     804                 :            :         com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xOldFrame(
     805 [ +  - ][ +  - ]:        116 :             pNew->GetFrame().GetFrameInterface()->getCreator(), com::sun::star::uno::UNO_QUERY );
         [ +  - ][ +  - ]
                 [ +  - ]
     806                 :            : 
     807                 :            :         com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xMyFrame(
     808 [ +  - ][ +  - ]:        116 :             GetFrame()->GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY );
         [ +  - ][ +  - ]
     809                 :            : 
     810 [ -  + ][ +  - ]:        116 :         if ( xOldFrame == xMyFrame )
     811                 :        116 :             bHidePopups = sal_False;
     812                 :            :     }
     813                 :            : 
     814         [ +  + ]:       1849 :     if ( bHidePopups )
     815                 :            :     {
     816                 :       1691 :         SfxBindings *pBind = GetBindings();
     817         [ +  + ]:       3382 :         while ( pBind )
     818                 :            :         {
     819                 :       1691 :             pBind->HidePopupCtrls_Impl( sal_True );
     820                 :       1691 :             pBind = pBind->GetSubBindings_Impl();
     821                 :            :         }
     822                 :            : 
     823                 :       1691 :         pImp->pFrame->GetFrame().GetWorkWindow_Impl()->HidePopups_Impl( sal_True, sal_False, 1 );
     824                 :            :     }
     825                 :            : 
     826                 :       1849 :     Flush();
     827                 :            : }
     828                 :            : 
     829                 :          0 : void SfxDispatcher::DoParentDeactivate_Impl()
     830                 :            : {
     831         [ #  # ]:          0 :     for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i )
     832                 :          0 :         pImp->aStack.Top( (sal_uInt16) i )->ParentDeactivate();
     833                 :          0 : }
     834                 :            : 
     835                 :            : //--------------------------------------------------------------------
     836                 :     105113 : int SfxDispatcher::GetShellAndSlot_Impl
     837                 :            : (
     838                 :            :     sal_uInt16      nSlot,    // the searchable Slot-Id
     839                 :            :     SfxShell**      ppShell,  // the SfxShell, which are currently handled
     840                 :            :                               // the nSlot
     841                 :            :     const SfxSlot** ppSlot,   // the SfxSlot, which are currently handled
     842                 :            :                               // the nSlot
     843                 :            :     sal_Bool        bOwnShellsOnly,
     844                 :            :     sal_Bool        bModal,   // ModalMode
     845                 :            :     sal_Bool        bRealSlot
     846                 :            : )
     847                 :            : 
     848                 :            : /*  [Description]
     849                 :            : 
     850                 :            :     This method searches in SfxDispatcher after <SfxShell> , from the Slot Id
     851                 :            :     nSlot currently being handled. For this, the dispatcher is first flushed.
     852                 :            : 
     853                 :            :     [Return value]
     854                 :            : 
     855                 :            :     int              sal_True
     856                 :            :                      The SfxShell was found, ppShell and ppSlot are valid.
     857                 :            : 
     858                 :            :                      sal_False
     859                 :            :                      The SfxShell was not found, ppShell and ppSlot are invalid.
     860                 :            : */
     861                 :            : 
     862                 :            : {
     863                 :            :     SFX_STACK(SfxDispatcher::GetShellAndSlot_Impl);
     864                 :            : 
     865         [ +  - ]:     105113 :     Flush();
     866                 :     105113 :     SfxSlotServer aSvr;
     867 [ +  + ][ +  - ]:     105113 :     if ( _FindServer(nSlot, aSvr, bModal) )
     868                 :            :     {
     869 [ -  + ][ #  # ]:     103325 :         if ( bOwnShellsOnly && aSvr.GetShellLevel() >= pImp->aStack.Count() )
                 [ -  + ]
     870                 :          0 :             return sal_False;
     871                 :            : 
     872         [ +  - ]:     103325 :         *ppShell = GetShell(aSvr.GetShellLevel());
     873                 :     103325 :         *ppSlot = aSvr.GetSlot();
     874 [ #  # ][ -  + ]:     103325 :         if ( 0 == (*ppSlot)->GetExecFnc() && bRealSlot )
                 [ -  + ]
     875 [ #  # ][ #  # ]:          0 :             *ppSlot = (*ppShell)->GetInterface()->GetRealSlot(*ppSlot);
     876                 :            :         // Check only real slots as enum slots don't have an execute function!
     877 [ +  + ][ +  - ]:     103325 :         if ( bRealSlot && ((0 == *ppSlot) || (0 == (*ppSlot)->GetExecFnc()) ))
         [ -  + ][ -  + ]
     878                 :          0 :             return sal_False;
     879                 :            : 
     880                 :     103325 :         return sal_True;
     881                 :            :     }
     882                 :            : 
     883                 :     105113 :     return sal_False;
     884                 :            : }
     885                 :            : 
     886                 :            : //--------------------------------------------------------------------
     887                 :        948 : void SfxDispatcher::_Execute
     888                 :            : (
     889                 :            :     SfxShell&       rShell,    // to the calling <SfxShell>
     890                 :            :     const SfxSlot&  rSlot,     // to the calling <SfxSlot>
     891                 :            :     SfxRequest&     rReq,      // function to be performed
     892                 :            :                                // (Id and optional parameters)
     893                 :            :     SfxCallMode     eCallMode  // Synchronously, asynchronously or as shown in
     894                 :            :                                // the slot
     895                 :            : )
     896                 :            : 
     897                 :            : /*  [Description]
     898                 :            : 
     899                 :            :     This method performs a request for a cached <Slot-Server>.
     900                 :            : */
     901                 :            : 
     902                 :            : {
     903                 :            :     DBG_ASSERT( !pImp->bFlushing, "recursive call to dispatcher" );
     904                 :            :     DBG_ASSERT( pImp->aToDoStack.empty(), "unprepared InPlace _Execute" );
     905                 :            : 
     906         [ -  + ]:        948 :     if ( IsLocked( rSlot.GetSlotId() ) )
     907                 :          0 :         return;
     908                 :            : 
     909         [ +  + ]:       1002 :     if ( (eCallMode & SFX_CALLMODE_ASYNCHRON) ||
           [ +  +  +  + ]
                 [ +  + ]
     910                 :        182 :          ( !(eCallMode & SFX_CALLMODE_SYNCHRON) &&
     911                 :         54 :            rSlot.IsMode(SFX_SLOT_ASYNCHRON) ) )
     912                 :            :     {
     913                 :        786 :         SfxDispatcher *pDispat = this;
     914         [ +  - ]:        786 :         while ( pDispat )
     915                 :            :         {
     916                 :        786 :             sal_uInt16 nShellCount = pDispat->pImp->aStack.Count();
     917         [ +  - ]:        888 :             for ( sal_uInt16 n=0; n<nShellCount; n++ )
     918                 :            :             {
     919         [ +  + ]:        888 :                 if ( &rShell == pDispat->pImp->aStack.Top(n) )
     920                 :            :                 {
     921         [ +  + ]:        786 :                     if ( eCallMode & SFX_CALLMODE_RECORD )
     922                 :        770 :                         rReq.AllowRecording( sal_True );
     923         [ +  - ]:        786 :                     pDispat->pImp->xPoster->Post(new SfxRequest(rReq));
     924                 :        786 :                     return;
     925                 :            :                 }
     926                 :            :             }
     927                 :            : 
     928                 :          0 :             pDispat = pDispat->pImp->pParent;
     929                 :            :         }
     930                 :            :     }
     931                 :            :     else
     932                 :        948 :         Call_Impl( rShell, rSlot, rReq, SFX_CALLMODE_RECORD==(eCallMode&SFX_CALLMODE_RECORD) );
     933                 :            : }
     934                 :            : 
     935                 :            : //--------------------------------------------------------------------
     936                 :        726 : void MappedPut_Impl( SfxAllItemSet &rSet, const SfxPoolItem &rItem )
     937                 :            : 
     938                 :            : /*  [Description]
     939                 :            : 
     940                 :            :     Helper function to put from rItem below the Which-ID in the pool of the
     941                 :            :     Item Sets rSet.
     942                 :            : */
     943                 :            : 
     944                 :            : {
     945                 :            :     // Put with mapped Which-Id if possible
     946                 :        726 :     const SfxItemPool *pPool = rSet.GetPool();
     947                 :        726 :     sal_uInt16 nWhich = rItem.Which();
     948         [ +  - ]:        726 :     if ( pPool->IsSlot(nWhich) )
     949                 :        726 :         nWhich = pPool->GetWhich(nWhich);
     950                 :        726 :     rSet.Put( rItem, nWhich );
     951                 :        726 : }
     952                 :            : 
     953                 :            : //--------------------------------------------------------------------
     954                 :            : 
     955                 :            : #ifndef SFX_USE_BINDINGS
     956                 :            : #define SFX_USE_BINDINGS 0x8000
     957                 :            : #endif
     958                 :            : 
     959                 :       3774 : const SfxSlot* SfxDispatcher::GetSlot( const String& rCommand )
     960                 :            : {
     961                 :            :     // Count the number of Shells on the linked Dispatcher
     962                 :       3774 :     Flush();
     963                 :       3774 :     sal_uInt16 nTotCount = pImp->aStack.Count();
     964         [ -  + ]:       3774 :     if ( pImp->pParent )
     965                 :            :     {
     966                 :          0 :         SfxDispatcher *pParent = pImp->pParent;
     967         [ #  # ]:          0 :         while ( pParent )
     968                 :            :         {
     969                 :          0 :             nTotCount = nTotCount + pParent->pImp->aStack.Count();
     970                 :          0 :             pParent = pParent->pImp->pParent;
     971                 :            :         }
     972                 :            :     }
     973                 :            : 
     974                 :       3774 :     const SfxSlot *pSlot=NULL;
     975                 :       3774 :     sal_uInt16 nFirstShell = 0;
     976         [ +  + ]:       7440 :     for ( sal_uInt16 i = nFirstShell; i < nTotCount; ++i )
     977                 :            :     {
     978                 :       3774 :         SfxShell *pObjShell = GetShell(i);
     979                 :       3774 :         SfxInterface *pIFace = pObjShell->GetInterface();
     980                 :       3774 :         pSlot = pIFace->GetSlot( rCommand );
     981         [ +  + ]:       3774 :         if ( pSlot )
     982                 :        108 :             return pSlot;
     983                 :            :     }
     984                 :            : 
     985                 :       3774 :     return 0;
     986                 :            : }
     987                 :            : 
     988                 :            : //--------------------------------------------------------------------
     989                 :         12 : const SfxPoolItem*  SfxDispatcher::Execute(
     990                 :            :     sal_uInt16 nSlot,
     991                 :            :     SfxCallMode nCall,
     992                 :            :     SfxItemSet* pArgs,
     993                 :            :     SfxItemSet* pInternalArgs,
     994                 :            :     sal_uInt16 nModi)
     995                 :            : {
     996 [ +  - ][ -  + ]:         12 :     if ( IsLocked(nSlot) )
     997                 :          0 :         return 0;
     998                 :            : 
     999                 :         12 :     SfxShell *pShell = 0;
    1000                 :         12 :     const SfxSlot *pSlot = 0;
    1001         [ +  - ]:         12 :     if ( GetShellAndSlot_Impl( nSlot,  &pShell, &pSlot, sal_False,
    1002         [ +  - ]:         12 :                                SFX_CALLMODE_MODAL==(nCall&SFX_CALLMODE_MODAL) ) )
    1003                 :            :     {
    1004         [ +  - ]:         12 :         SfxAllItemSet aSet( pShell->GetPool() );
    1005         [ +  - ]:         12 :         if ( pArgs )
    1006                 :            :         {
    1007         [ +  - ]:         12 :             SfxItemIter aIter(*pArgs);
    1008 [ +  - ][ +  + ]:         24 :             for ( const SfxPoolItem *pArg = aIter.FirstItem();
    1009                 :            :                 pArg;
    1010                 :            :                 pArg = aIter.NextItem() )
    1011 [ +  - ][ +  - ]:         24 :                 MappedPut_Impl( aSet, *pArg );
    1012                 :            :         }
    1013         [ +  - ]:         12 :         SfxRequest aReq( nSlot, nCall, aSet );
    1014         [ +  - ]:         12 :         if (pInternalArgs)
    1015 [ +  - ][ +  - ]:         12 :             aReq.SetInternalArgs_Impl( *pInternalArgs );
                 [ +  - ]
    1016         [ +  - ]:         12 :         aReq.SetModifier( nModi );
    1017                 :            : 
    1018         [ +  - ]:         12 :         _Execute( *pShell, *pSlot, aReq, nCall );
    1019 [ +  - ][ +  - ]:         12 :         return aReq.GetReturnValue();
                 [ +  - ]
    1020                 :            :     }
    1021                 :         12 :     return 0;
    1022                 :            : }
    1023                 :            : 
    1024                 :            : //--------------------------------------------------------------------
    1025                 :        372 : const SfxPoolItem* SfxDispatcher::Execute
    1026                 :            : (
    1027                 :            :     sal_uInt16 nSlot,                 // the Id of the executing function
    1028                 :            :     SfxCallMode eCall,                // SFX_CALLMODE_SYNCRHON, ..._ASYNCHRON
    1029                 :            :                                       // or ..._SLOT
    1030                 :            :     const SfxPoolItem **pArgs,        // Zero teminated C-Array of Parameters
    1031                 :            :     sal_uInt16 nModi,
    1032                 :            :     const SfxPoolItem **pInternalArgs // Zero terminated C-Array of Parameters
    1033                 :            : )
    1034                 :            : 
    1035                 :            : /*  [Description]
    1036                 :            : 
    1037                 :            :     Method to excecute a <SfxSlot>s over the Slot-Id.
    1038                 :            : 
    1039                 :            :     [Return value]
    1040                 :            : 
    1041                 :            :     const SfxPoolItem*      Pointer to the SfxPoolItem valid to the next run
    1042                 :            :                             though the Message-Loop, which contains the return
    1043                 :            :                             value.
    1044                 :            : 
    1045                 :            :                             Or a NULL-Pointer, when the function was not
    1046                 :            :                             executed (for example canceled by the user).
    1047                 :            : */
    1048                 :            : 
    1049                 :            : {
    1050 [ +  - ][ -  + ]:        372 :     if ( IsLocked(nSlot) )
    1051                 :          0 :         return 0;
    1052                 :            : 
    1053                 :        372 :     SfxShell *pShell = 0;
    1054                 :        372 :     const SfxSlot *pSlot = 0;
    1055         [ +  + ]:        372 :     if ( GetShellAndSlot_Impl( nSlot,  &pShell, &pSlot, sal_False,
    1056         [ +  - ]:        372 :                                SFX_CALLMODE_MODAL==(eCall&SFX_CALLMODE_MODAL) ) )
    1057                 :            :     {
    1058                 :            :         SfxRequest* pReq;
    1059 [ -  + ][ #  # ]:        172 :         if ( pArgs && *pArgs )
    1060                 :            :         {
    1061         [ #  # ]:          0 :             SfxAllItemSet aSet( pShell->GetPool() );
    1062         [ #  # ]:          0 :             for ( const SfxPoolItem **pArg = pArgs; *pArg; ++pArg )
    1063         [ #  # ]:          0 :                 MappedPut_Impl( aSet, **pArg );
    1064 [ #  # ][ #  # ]:          0 :             pReq = new SfxRequest( nSlot, eCall, aSet );
                 [ #  # ]
    1065                 :            :         }
    1066                 :            :         else
    1067 [ +  - ][ +  - ]:        172 :             pReq =  new SfxRequest( nSlot, eCall, pShell->GetPool() );
    1068         [ +  - ]:        172 :         pReq->SetModifier( nModi );
    1069 [ -  + ][ #  # ]:        172 :         if( pInternalArgs && *pInternalArgs)
    1070                 :            :         {
    1071 [ #  # ][ #  # ]:          0 :             SfxAllItemSet aSet( SFX_APP()->GetPool() );
    1072         [ #  # ]:          0 :             for ( const SfxPoolItem **pArg = pInternalArgs; *pArg; ++pArg )
    1073         [ #  # ]:          0 :                 aSet.Put( **pArg );
    1074 [ #  # ][ #  # ]:          0 :             pReq->SetInternalArgs_Impl( aSet );
    1075                 :            :         }
    1076         [ +  - ]:        172 :         _Execute( *pShell, *pSlot, *pReq, eCall );
    1077         [ +  - ]:        172 :         const SfxPoolItem* pRet = pReq->GetReturnValue();
    1078 [ +  - ][ +  - ]:        172 :         delete pReq; return pRet;
    1079                 :            :     }
    1080                 :        372 :     return 0;
    1081                 :            : }
    1082                 :            : 
    1083                 :            : //--------------------------------------------------------------------
    1084                 :          0 : const SfxPoolItem* SfxDispatcher::Execute
    1085                 :            : (
    1086                 :            :     sal_uInt16 nSlot,        // the Id of the executing function
    1087                 :            :     SfxCallMode eCall,       // SFX_CALLMODE_SYNCRHON, ..._ASYNCHRON or ..._SLOT
    1088                 :            :     const SfxItemSet &rArgs  // <SfxItemSet> with the parameters
    1089                 :            : )
    1090                 :            : 
    1091                 :            : /*  [Description]
    1092                 :            : 
    1093                 :            :     Method to excecute a <SfxSlot>s over the Slot-Id.
    1094                 :            : 
    1095                 :            :     [Return value]
    1096                 :            : 
    1097                 :            :     const SfxPoolItem*      Pointer to the SfxPoolItem valid to the next run
    1098                 :            :                             though the Message-Loop, which contains the return
    1099                 :            :                             value.
    1100                 :            : 
    1101                 :            :                             Or a NULL-Pointer, when the function was not
    1102                 :            :                             executed (for example canceled by the user).
    1103                 :            : */
    1104                 :            : 
    1105                 :            : {
    1106                 :          0 :     return Execute( nSlot, eCall, 0, rArgs );
    1107                 :            : }
    1108                 :            : 
    1109                 :            : //--------------------------------------------------------------------
    1110                 :          0 : const SfxPoolItem*  SfxDispatcher::Execute
    1111                 :            : (
    1112                 :            :     sal_uInt16 nSlot,
    1113                 :            :     SfxCallMode eCall,
    1114                 :            :     sal_uInt16 nModi,
    1115                 :            :     const SfxItemSet &rArgs
    1116                 :            : )
    1117                 :            : {
    1118 [ #  # ][ #  # ]:          0 :     if ( IsLocked(nSlot) )
    1119                 :          0 :         return 0;
    1120                 :            : 
    1121                 :          0 :     SfxShell *pShell = 0;
    1122                 :          0 :     const SfxSlot *pSlot = 0;
    1123         [ #  # ]:          0 :     if ( GetShellAndSlot_Impl( nSlot,  &pShell, &pSlot, sal_False,
    1124         [ #  # ]:          0 :                                SFX_CALLMODE_MODAL==(eCall&SFX_CALLMODE_MODAL) ) )
    1125                 :            :     {
    1126         [ #  # ]:          0 :         SfxAllItemSet aSet( pShell->GetPool() );
    1127         [ #  # ]:          0 :         SfxItemIter aIter(rArgs);
    1128 [ #  # ][ #  # ]:          0 :         for ( const SfxPoolItem *pArg = aIter.FirstItem();
    1129                 :            :               pArg;
    1130                 :            :               pArg = aIter.NextItem() )
    1131         [ #  # ]:          0 :             MappedPut_Impl( aSet, *pArg );
    1132         [ #  # ]:          0 :         SfxRequest aReq( nSlot, eCall, aSet );
    1133         [ #  # ]:          0 :         aReq.SetModifier( nModi );
    1134         [ #  # ]:          0 :         _Execute( *pShell, *pSlot, aReq, eCall );
    1135 [ #  # ][ #  # ]:          0 :         return aReq.GetReturnValue();
         [ #  # ][ #  # ]
    1136                 :            :     }
    1137                 :          0 :     return 0;
    1138                 :            : }
    1139                 :            : 
    1140                 :            : //--------------------------------------------------------------------
    1141                 :       1015 : const SfxPoolItem* SfxDispatcher::Execute
    1142                 :            : (
    1143                 :            :     sal_uInt16          nSlot,  // the Id of the executing function
    1144                 :            :     SfxCallMode         eCall,  // SFX_CALLMODE_SYNCRHON, ..._ASYNCHRON or
    1145                 :            :                                 // ..._SLOT
    1146                 :            :     const SfxPoolItem*  pArg1,  // First parameter
    1147                 :            :     ...                         // Zero terminated list of parameters
    1148                 :            : )
    1149                 :            : 
    1150                 :            : /*  [Description]
    1151                 :            : 
    1152                 :            :     Method to excecute a <SfxSlot>s over the Slot-Id.
    1153                 :            : 
    1154                 :            :     [Note]
    1155                 :            : 
    1156                 :            :     The parameters are copied, can therefore be passed on as the address
    1157                 :            :     of stack objects.
    1158                 :            : 
    1159                 :            :     [Return value]
    1160                 :            : 
    1161                 :            :     const SfxPoolItem*      Pointer to the SfxPoolItem valid to the next run
    1162                 :            :                             though the Message-Loop, which contains the return
    1163                 :            :                             value.
    1164                 :            : 
    1165                 :            :                             Or a NULL-Pointer, when the function was not
    1166                 :            :                             executed (for example canceled by the user).
    1167                 :            : 
    1168                 :            :     [Example]
    1169                 :            : 
    1170                 :            :     pDispatcher->Execute( SID_OPENDOCUMENT, SFX_CALLMODE_SYNCHRON,
    1171                 :            :         &SfxStringItem( SID_FILE_NAME, "\\tmp\\temp.sdd" ),
    1172                 :            :         &SfxStringItem( SID_FILTER_NAME, "StarDraw Presentation" ),
    1173                 :            :         &SfxBoolItem( SID_DOC_READONLY, sal_False ),
    1174                 :            :         0L );
    1175                 :            : */
    1176                 :            : 
    1177                 :            : {
    1178 [ +  - ][ -  + ]:       1015 :     if ( IsLocked(nSlot) )
    1179                 :          0 :         return 0;
    1180                 :            : 
    1181                 :       1015 :     SfxShell *pShell = 0;
    1182                 :       1015 :     const SfxSlot *pSlot = 0;
    1183         [ +  + ]:       1015 :     if ( GetShellAndSlot_Impl( nSlot, &pShell, &pSlot, sal_False,
    1184         [ +  - ]:       1015 :                                SFX_CALLMODE_MODAL==(eCall&SFX_CALLMODE_MODAL) ) )
    1185                 :            :     {
    1186         [ +  - ]:        714 :        SfxAllItemSet aSet( pShell->GetPool() );
    1187                 :            : 
    1188                 :            :        va_list pVarArgs;
    1189                 :        714 :        va_start( pVarArgs, pArg1 );
    1190         [ +  + ]:       1428 :        for ( const SfxPoolItem *pArg = pArg1;
    1191                 :            :              pArg;
    1192                 :        714 :              pArg = va_arg( pVarArgs, const SfxPoolItem* ) )
    1193         [ +  - ]:        714 :            MappedPut_Impl( aSet, *pArg );
    1194                 :        714 :        va_end(pVarArgs);
    1195                 :            : 
    1196         [ +  - ]:        714 :        SfxRequest aReq( nSlot, eCall, aSet );
    1197         [ +  - ]:        714 :        _Execute( *pShell, *pSlot, aReq, eCall );
    1198 [ +  - ][ +  - ]:        714 :        return aReq.GetReturnValue();
                 [ +  - ]
    1199                 :            :     }
    1200                 :       1015 :     return 0;
    1201                 :            : }
    1202                 :            : 
    1203                 :            : //--------------------------------------------------------------------
    1204                 :            : 
    1205                 :        755 : IMPL_LINK( SfxDispatcher, PostMsgHandler, SfxRequest*, pReq )
    1206                 :            : 
    1207                 :            : /*  [Description]
    1208                 :            : 
    1209                 :            :     Helper method to receive the asynchronously executed <SfxRequest>s.
    1210                 :            : */
    1211                 :            : 
    1212                 :            : {
    1213                 :            :     DBG_ASSERT( !pImp->bFlushing, "recursive call to dispatcher" );
    1214                 :            :     SFX_STACK(SfxDispatcher::PostMsgHandler);
    1215                 :            : 
    1216                 :            :     // Has also the Pool not yet died?
    1217         [ +  - ]:        755 :     if ( !pReq->IsCancelled() )
    1218                 :            :     {
    1219         [ +  - ]:        755 :         if ( !IsLocked(pReq->GetSlot()) )
    1220                 :            :         {
    1221         [ +  - ]:        755 :             Flush();
    1222                 :        755 :             SfxSlotServer aSvr;
    1223 [ +  - ][ +  - ]:        755 :             if ( _FindServer(pReq->GetSlot(), aSvr, HACK(x) sal_True ) )
    1224                 :            :             {
    1225                 :        755 :                 const SfxSlot *pSlot = aSvr.GetSlot();
    1226         [ +  - ]:        755 :                 SfxShell *pSh = GetShell(aSvr.GetShellLevel());
    1227                 :            : 
    1228                 :            :                 DBG( SfxApplication *pSfxApp = SFX_APP() );
    1229                 :            :                 DBG( pSfxApp->EnterAsynchronCall_Impl() );
    1230                 :            : 
    1231                 :            :                 // When the pSlot is a "Pseudoslot" for macros or Verbs, it can
    1232                 :            :                 // be destroyed in the Call_Impl, thus do not use it anymore!
    1233         [ +  - ]:        755 :                 pReq->SetSynchronCall( sal_False );
    1234 [ +  - ][ +  - ]:        755 :                 Call_Impl( *pSh, *pSlot, *pReq, pReq->AllowsRecording() ); //! why bRecord?
    1235                 :            :                 DBG( pSfxApp->LeaveAsynchronCall_Impl() );
    1236                 :            :             }
    1237                 :            :         }
    1238                 :            :         else
    1239                 :            :         {
    1240         [ #  # ]:          0 :             if ( pImp->bLocked )
    1241         [ #  # ]:          0 :                 pImp->aReqArr.push_back(new SfxRequest(*pReq));
    1242                 :            :             else
    1243         [ #  # ]:          0 :                 pImp->xPoster->Post(new SfxRequest(*pReq));
    1244                 :            :         }
    1245                 :            :     }
    1246                 :            : 
    1247         [ +  - ]:        755 :     delete pReq;
    1248                 :        755 :     return 0;
    1249                 :            : }
    1250                 :            : //--------------------------------------------------------------------
    1251                 :       4633 : void SfxDispatcher::SetMenu_Impl()
    1252                 :            : {
    1253         [ +  - ]:       4633 :     if ( pImp->pFrame )
    1254                 :            :     {
    1255                 :       4633 :         SfxViewFrame* pTop = pImp->pFrame->GetTopViewFrame();
    1256 [ +  - ][ +  - ]:       4633 :         if ( pTop && pTop->GetBindings().GetDispatcher() == this )
                 [ +  - ]
    1257                 :            :         {
    1258                 :       4633 :             SfxFrame& rFrame = pTop->GetFrame();
    1259         [ +  - ]:       4633 :             if ( rFrame.IsMenuBarOn_Impl() )
    1260                 :            :             {
    1261 [ +  - ][ +  - ]:       4633 :                 com::sun::star::uno::Reference < com::sun::star::beans::XPropertySet > xPropSet( rFrame.GetFrameInterface(), com::sun::star::uno::UNO_QUERY );
    1262         [ +  - ]:       4633 :                 if ( xPropSet.is() )
    1263                 :            :                 {
    1264                 :       4633 :                     com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
    1265 [ +  - ][ +  - ]:       4633 :                     com::sun::star::uno::Any aValue = xPropSet->getPropertyValue( rtl::OUString( "LayoutManager" ));
    1266         [ +  - ]:       4633 :                     aValue >>= xLayoutManager;
    1267         [ +  - ]:       4633 :                     if ( xLayoutManager.is() )
    1268                 :            :                     {
    1269                 :       4633 :                         rtl::OUString aMenuBarURL( "private:resource/menubar/menubar" );
    1270 [ +  - ][ +  + ]:       4633 :                         if ( !xLayoutManager->isElementVisible( aMenuBarURL ) )
                 [ +  - ]
    1271 [ +  - ][ +  - ]:       4633 :                             xLayoutManager->createElement( aMenuBarURL );
    1272                 :       4633 :                     }
    1273                 :       4633 :                 }
    1274                 :            :             }
    1275                 :            :         }
    1276                 :            :     }
    1277                 :       4633 : }
    1278                 :            : 
    1279                 :            : //--------------------------------------------------------------------
    1280                 :      10282 : void SfxDispatcher::Update_Impl( sal_Bool bForce )
    1281                 :            : {
    1282                 :            :     SFX_STACK(SfxDispatcher::Update_Impl);
    1283                 :            : 
    1284         [ +  - ]:      10282 :     Flush();
    1285                 :            : 
    1286         [ +  - ]:      10282 :     if ( !pImp->pFrame )
    1287                 :            :         return;
    1288                 :            : 
    1289         [ +  - ]:      10282 :     SFX_APP();  // -Wall is this required???
    1290                 :      10282 :     SfxDispatcher *pDisp = this;
    1291                 :      10282 :     sal_Bool bUpdate = bForce;
    1292 [ +  + ][ +  - ]:      20564 :     while ( pDisp && pDisp->pImp->pFrame )
                 [ +  + ]
    1293                 :            :     {
    1294 [ +  - ][ +  - ]:      10282 :         SfxWorkWindow *pWork = pDisp->pImp->pFrame->GetFrame().GetWorkWindow_Impl();
    1295                 :      10282 :         SfxDispatcher *pAct = pWork->GetBindings().GetDispatcher_Impl();
    1296 [ #  # ][ -  + ]:      10282 :         if ( pAct == pDisp || pAct == this )
    1297                 :            :         {
    1298         [ +  + ]:      10282 :             if ( !bUpdate )
    1299                 :       7467 :                 bUpdate = !pDisp->pImp->bUpdated;
    1300                 :      10282 :             pDisp->pImp->bUpdated = sal_True;
    1301                 :            :         }
    1302                 :            :         else
    1303                 :          0 :             break;
    1304                 :            : 
    1305                 :      10282 :         pDisp = pDisp->pImp->pParent;
    1306                 :            :     }
    1307                 :            : 
    1308 [ +  + ][ +  - ]:      10282 :     if ( !bUpdate || pImp->pFrame->GetFrame().IsClosing_Impl() )
         [ +  - ][ -  + ]
                 [ +  + ]
    1309                 :            :         return;
    1310                 :            : 
    1311 [ +  - ][ +  - ]:       4633 :     SfxViewFrame* pTop = pImp->pFrame ? pImp->pFrame->GetTopViewFrame() : NULL;
    1312 [ +  - ][ +  - ]:       4633 :     sal_Bool bUIActive = pTop && pTop->GetBindings().GetDispatcher() == this;
    1313                 :            : 
    1314 [ -  + ][ #  # ]:       4633 :     if ( !bUIActive && pTop && GetBindings() == &pTop->GetBindings() )
         [ #  # ][ #  # ]
                 [ -  + ]
    1315                 :            :         // keep own tools internally for collecting
    1316         [ #  # ]:          0 :         GetBindings()->GetDispatcher()->pImp->bUpdated = sal_False;
    1317                 :            : 
    1318         [ +  - ]:       4633 :     SfxBindings* pBindings = GetBindings();
    1319         [ +  - ]:       4633 :     if ( pBindings )
    1320         [ +  - ]:       4633 :         pBindings->DENTERREGISTRATIONS();
    1321                 :            : 
    1322         [ +  - ]:       4633 :     com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame = pBindings->GetActiveFrame();
    1323         [ +  - ]:       4633 :     com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, com::sun::star::uno::UNO_QUERY );
    1324                 :       4633 :     com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
    1325         [ +  - ]:       4633 :     if ( xPropSet.is() )
    1326                 :            :     {
    1327                 :            :         try
    1328                 :            :         {
    1329 [ +  - ][ +  - ]:       4633 :             com::sun::star::uno::Any aValue = xPropSet->getPropertyValue( rtl::OUString( "LayoutManager" ) );
    1330 [ #  # ][ +  - ]:       4633 :             aValue >>= xLayoutManager;
    1331                 :            :         }
    1332         [ #  # ]:          0 :         catch (const com::sun::star::uno::Exception&)
    1333                 :            :         {
    1334                 :            :         }
    1335                 :            :     }
    1336                 :            : 
    1337         [ +  - ]:       4633 :     if ( xLayoutManager.is() )
    1338 [ +  - ][ +  - ]:       4633 :         xLayoutManager->lock();
    1339                 :            : 
    1340 [ +  - ][ +  - ]:       4633 :     sal_Bool bIsIPActive = pImp->pFrame && pImp->pFrame->GetObjectShell()->IsInPlaceActive();
         [ +  - ][ -  + ]
    1341 [ +  - ][ +  - ]:       4633 :     SfxInPlaceClient *pClient = pImp->pFrame ? pImp->pFrame->GetViewShell()->GetUIActiveClient() : NULL;
                 [ +  - ]
    1342 [ +  - ][ -  + ]:       4633 :     if ( bUIActive && /* !bIsIPActive && */ ( !pClient || !pClient->IsObjectUIActive() ) )
         [ #  # ][ #  # ]
                 [ +  - ]
    1343         [ +  - ]:       4633 :         SetMenu_Impl();
    1344                 :            : 
    1345 [ +  - ][ +  - ]:       4633 :     SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl();
    1346 [ +  - ][ +  - ]:       4633 :     SfxWorkWindow *pTaskWin = pImp->pFrame->GetTopFrame().GetWorkWindow_Impl();
    1347         [ +  - ]:       4633 :     pTaskWin->ResetStatusBar_Impl();
    1348                 :            : 
    1349                 :       4633 :     SfxDispatcher *pDispat = this;
    1350         [ +  + ]:       9266 :     while ( pDispat )
    1351                 :            :     {
    1352 [ +  - ][ +  - ]:       4633 :         SfxWorkWindow *pWork = pDispat->pImp->pFrame->GetFrame().GetWorkWindow_Impl();
    1353                 :       4633 :         SfxDispatcher *pAct = pWork->GetBindings().GetDispatcher_Impl();
    1354 [ #  # ][ -  + ]:       4633 :         if ( pAct == pDispat || pAct == this )
    1355                 :            :         {
    1356         [ +  - ]:       4633 :             pWork->ResetObjectBars_Impl();
    1357         [ +  - ]:       4633 :             pWork->ResetChildWindows_Impl();
    1358                 :            :         }
    1359                 :            : 
    1360                 :       4633 :         pDispat = pDispat->pImp->pParent;
    1361                 :            :     }
    1362                 :            : 
    1363                 :       4633 :     sal_Bool bIsActive = sal_False;
    1364                 :       4633 :     SfxDispatcher *pActDispat = pWorkWin->GetBindings().GetDispatcher_Impl();
    1365                 :       4633 :     pDispat = this;
    1366 [ +  + ][ +  - ]:       9266 :     while ( pActDispat && !bIsActive )
                 [ +  + ]
    1367                 :            :     {
    1368         [ +  - ]:       4633 :         if ( pDispat == pActDispat )
    1369                 :       4633 :             bIsActive = sal_True;
    1370                 :       4633 :         pActDispat = pActDispat->pImp->pParent;
    1371                 :            :     }
    1372                 :            : 
    1373         [ +  - ]:       4633 :     _Update_Impl( bUIActive, !bIsIPActive, bIsIPActive, pTaskWin );
    1374 [ -  + ][ #  # ]:       4633 :     if ( bUIActive || bIsActive )
    1375         [ +  - ]:       4633 :         pWorkWin->UpdateObjectBars_Impl();
    1376                 :            : 
    1377         [ +  - ]:       4633 :     if ( pBindings )
    1378         [ +  - ]:       4633 :         pBindings->DLEAVEREGISTRATIONS();
    1379                 :            : 
    1380         [ +  - ]:       4633 :     if ( xLayoutManager.is() )
    1381 [ +  - ][ +  - ]:       4633 :         xLayoutManager->unlock();
    1382                 :            : 
    1383                 :      10282 :     return;
    1384                 :            : }
    1385                 :            : 
    1386                 :       4633 : void SfxDispatcher::_Update_Impl( sal_Bool bUIActive, sal_Bool bIsMDIApp, sal_Bool bIsIPOwner, SfxWorkWindow *pTaskWin )
    1387                 :            : {
    1388                 :       4633 :     SFX_APP();
    1389                 :       4633 :     SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl();
    1390                 :       4633 :     sal_Bool bIsActive = sal_False;
    1391                 :       4633 :     sal_Bool bIsTaskActive = sal_False;
    1392                 :       4633 :     SfxDispatcher *pActDispat = pWorkWin->GetBindings().GetDispatcher_Impl();
    1393                 :       4633 :     SfxDispatcher *pDispat = this;
    1394 [ +  + ][ +  - ]:       9266 :     while ( pActDispat && !bIsActive )
                 [ +  + ]
    1395                 :            :     {
    1396         [ +  - ]:       4633 :         if ( pDispat == pActDispat )
    1397                 :       4633 :             bIsActive = sal_True;
    1398                 :       4633 :         pActDispat = pActDispat->pImp->pParent;
    1399                 :            :     }
    1400                 :            : 
    1401 [ -  + ][ #  # ]:       4633 :     if ( pImp->pParent && !pImp->bQuiet /* && bUIActive */ )
    1402                 :          0 :         pImp->pParent->_Update_Impl( bUIActive, bIsMDIApp, bIsIPOwner, pTaskWin );
    1403                 :            : 
    1404         [ +  + ]:      64862 :     for (sal_uInt16 n=0; n<SFX_OBJECTBAR_MAX; n++)
    1405                 :      60229 :         pImp->aObjBars[n].nResId = 0;
    1406                 :       4633 :     pImp->aChildWins.clear();
    1407                 :            : 
    1408                 :            :     // bQuiet : own shells aren't considered for UI and SlotServer
    1409                 :            :     // bNoUI: own Shells aren't considered fors UI
    1410 [ +  - ][ +  - ]:       4633 :     if ( pImp->bQuiet || pImp->bNoUI || (pImp->pFrame && pImp->pFrame->GetObjectShell()->IsPreview()) )
         [ -  + ][ -  + ]
                 [ +  - ]
    1411                 :       4633 :         return;
    1412                 :            : 
    1413                 :       4633 :     sal_uInt32 nStatBarId=0;
    1414                 :       4633 :     SfxShell *pStatusBarShell = NULL;
    1415                 :            : 
    1416                 :       4633 :     SfxSlotPool* pSlotPool = &SfxSlotPool::GetSlotPool( GetFrame() );
    1417                 :       4633 :     sal_uInt16 nTotCount = pImp->aStack.Count();
    1418         [ +  + ]:      37400 :     for ( sal_uInt16 nShell = nTotCount; nShell > 0; --nShell )
    1419                 :            :     {
    1420                 :      32767 :         SfxShell *pShell = GetShell( nShell-1 );
    1421                 :      32767 :         SfxInterface *pIFace = pShell->GetInterface();
    1422                 :            : 
    1423                 :            :         // don't consider shells if "Hidden" oder "Quiet"
    1424                 :      32767 :         sal_Bool bReadOnlyShell = IsReadOnlyShell_Impl( nShell-1 );
    1425                 :            :         sal_uInt16 nNo;
    1426 [ +  - ][ +  + ]:      72890 :         for ( nNo = 0; pIFace && nNo<pIFace->GetObjectBarCount(); ++nNo )
                 [ +  + ]
    1427                 :            :         {
    1428                 :      40123 :             sal_uInt16 nPos = pIFace->GetObjectBarPos(nNo);
    1429 [ +  + ][ +  + ]:      40123 :             if ( bReadOnlyShell && !( nPos & SFX_VISIBILITY_READONLYDOC ) )
    1430                 :         82 :                 continue;
    1431                 :            : 
    1432                 :            :             // check whether toolbar needs activation of a special feature
    1433                 :      40041 :             sal_uInt32 nFeature = pIFace->GetObjectBarFeature(nNo);
    1434 [ +  + ][ +  + ]:      40041 :             if ( nFeature && !pShell->HasUIFeature( nFeature ) )
                 [ +  + ]
    1435                 :       9771 :                 continue;
    1436                 :            : 
    1437                 :            :             // check for toolboxes that are exclusively for a viewer
    1438         [ +  - ]:      30270 :             if ( pImp->pFrame)
    1439                 :            :             {
    1440                 :      30270 :                 sal_Bool bViewerTbx = SFX_VISIBILITY_VIEWER == ( nPos & SFX_VISIBILITY_VIEWER );
    1441                 :      30270 :                 SfxObjectShell* pSh = pImp->pFrame->GetObjectShell();
    1442                 :      30270 :                 SFX_ITEMSET_ARG( pSh->GetMedium()->GetItemSet(), pItem, SfxBoolItem, SID_VIEWONLY, sal_False );
    1443 [ #  # ][ -  + ]:      30270 :                 sal_Bool bIsViewer = pItem && pItem->GetValue();
    1444         [ +  + ]:      30270 :                 if ( bIsViewer != bViewerTbx )
    1445                 :       4171 :                     continue;
    1446                 :            :             }
    1447                 :            : 
    1448                 :            :             // always register toolbars, allows to switch them on
    1449                 :      26099 :             sal_Bool bVisible = pIFace->IsObjectBarVisible(nNo);
    1450         [ -  + ]:      26099 :             if ( !bVisible )
    1451                 :          0 :                 nPos &= SFX_POSITION_MASK;
    1452                 :            : 
    1453                 :      26099 :             SfxObjectBars_Impl& rBar = pImp->aObjBars[nPos & SFX_POSITION_MASK];
    1454                 :      26099 :             rBar.nMode = nPos;
    1455                 :      26099 :             rBar.nResId = pIFace->GetObjectBarResId(nNo).GetId();
    1456                 :      26099 :             const String *pName = pIFace->GetObjectBarName(nNo);
    1457         [ +  - ]:      26099 :             if ( pName )
    1458                 :      26099 :                 rBar.aName = *pName;
    1459                 :            :             else
    1460                 :          0 :                 rBar.aName.Erase();
    1461                 :      26099 :             rBar.pIFace = pIFace;
    1462                 :            : 
    1463 [ -  + ][ #  # ]:      26099 :             if ( bUIActive || bIsActive )
    1464                 :            :             {
    1465                 :            :                 pWorkWin->SetObjectBar_Impl(
    1466                 :      26099 :                     nPos, rBar.nResId, rBar.pIFace, &rBar.aName );
    1467                 :            :             }
    1468                 :            : 
    1469         [ -  + ]:      26099 :             if ( !bVisible )
    1470                 :          0 :                 rBar.nResId = 0;
    1471                 :            :         }
    1472                 :            : 
    1473 [ +  - ][ +  + ]:     200510 :         for ( nNo=0; pIFace && nNo<pIFace->GetChildWindowCount(); nNo++ )
                 [ +  + ]
    1474                 :            :         {
    1475         [ +  - ]:     167743 :             sal_uInt32 nId = pIFace->GetChildWindowId(nNo);
    1476         [ +  - ]:     167743 :             const SfxSlot *pSlot = pSlotPool->GetSlot( (sal_uInt16) nId );
    1477                 :            :             DBG_ASSERT( pSlot, "Childwindow slot missing!");
    1478         [ +  + ]:     167743 :             if ( bReadOnlyShell )
    1479                 :            :             {
    1480                 :            :                 // only show ChildWindows if their slot is allowed for readonly documents
    1481 [ +  - ][ +  + ]:        492 :                 if ( pSlot && !pSlot->IsMode( SFX_SLOT_READONLYDOC ) )
                 [ +  + ]
    1482                 :        318 :                     continue;
    1483                 :            :             }
    1484                 :            : 
    1485         [ +  - ]:     167425 :             sal_uInt32 nFeature = pIFace->GetChildWindowFeature(nNo);
    1486 [ +  + ][ +  - ]:     167425 :             if ( nFeature && !pShell->HasUIFeature( nFeature ) )
         [ +  + ][ +  + ]
    1487                 :      19940 :                 continue;
    1488                 :            : 
    1489                 :            :             // slot decides whether a ChildWindow is shown when document is OLE server or OLE client
    1490                 :     147485 :             sal_uInt16 nMode = SFX_VISIBILITY_STANDARD;
    1491         [ +  - ]:     147485 :             if( pSlot )
    1492                 :            :             {
    1493         [ +  + ]:     147485 :                 if ( pSlot->IsMode(SFX_SLOT_CONTAINER) )
    1494                 :            :                 {
    1495 [ +  - ][ +  - ]:      22979 :                     if ( pWorkWin->IsVisible_Impl( SFX_VISIBILITY_CLIENT ) )
    1496                 :      22979 :                         nMode |= SFX_VISIBILITY_CLIENT;
    1497                 :            :                 }
    1498                 :            :                 else
    1499                 :            :                 {
    1500 [ +  - ][ +  - ]:     124506 :                     if ( pWorkWin->IsVisible_Impl( SFX_VISIBILITY_SERVER ) )
    1501                 :     124506 :                         nMode |= SFX_VISIBILITY_SERVER;
    1502                 :            :                 }
    1503                 :            :             }
    1504                 :            : 
    1505 [ -  + ][ #  # ]:     147485 :             if ( bUIActive || bIsActive )
    1506         [ +  - ]:     147485 :                 pWorkWin->SetChildWindowVisible_Impl( nId, sal_True, nMode );
    1507 [ -  + ][ #  # ]:     147485 :             if ( bUIActive || bIsActive || !pWorkWin->IsFloating( (sal_uInt16) ( nId & 0xFFFF ) ) )
         [ #  # ][ #  # ]
                 [ +  - ]
    1508         [ +  - ]:     167743 :                 pImp->aChildWins.push_back( nId );
    1509                 :            :         }
    1510                 :            : 
    1511 [ -  + ][ #  # ]:      32767 :         if ( bIsMDIApp || bIsIPOwner )
    1512                 :            :         {
    1513                 :      32767 :             sal_uInt32 nId = pIFace->GetStatusBarResId().GetId();
    1514         [ +  + ]:      32767 :             if ( nId )
    1515                 :            :             {
    1516                 :       9266 :                 nStatBarId = nId;
    1517                 :       9266 :                 pStatusBarShell =  pShell;
    1518                 :            :             }
    1519                 :            :         }
    1520                 :            :     }
    1521                 :            : 
    1522         [ +  + ]:      64862 :     for ( sal_uInt16 nPos=0; nPos<SFX_OBJECTBAR_MAX; nPos++ )
    1523                 :            :     {
    1524                 :      60229 :         SfxObjectBars_Impl& rFixed = pImp->aFixedObjBars[nPos];
    1525         [ -  + ]:      60229 :         if ( rFixed.nResId )
    1526                 :            :         {
    1527                 :          0 :             SfxObjectBars_Impl& rBar = pImp->aObjBars[nPos];
    1528                 :          0 :             rBar = rFixed;
    1529                 :            :             pWorkWin->SetObjectBar_Impl( rFixed.nMode,
    1530                 :          0 :                 rFixed.nResId, rFixed.pIFace, &rFixed.aName );
    1531                 :            :         }
    1532                 :            :     }
    1533                 :            : 
    1534 [ +  - ][ -  + ]:       4633 :     if ( pTaskWin && ( bIsMDIApp || bIsIPOwner ) )
                 [ #  # ]
    1535                 :            :     {
    1536                 :       4633 :         SfxDispatcher *pActDispatcher = pTaskWin->GetBindings().GetDispatcher_Impl();
    1537                 :       4633 :         SfxDispatcher *pDispatcher = this;
    1538 [ +  + ][ +  - ]:       9266 :         while ( pActDispatcher && !bIsTaskActive )
                 [ +  + ]
    1539                 :            :         {
    1540         [ +  - ]:       4633 :             if ( pDispatcher == pActDispatcher )
    1541                 :       4633 :                 bIsTaskActive = sal_True;
    1542                 :       4633 :             pActDispatcher = pActDispatcher->pImp->pParent;
    1543                 :            :         }
    1544                 :            : 
    1545 [ +  - ][ +  - ]:       4633 :         if ( bIsTaskActive && nStatBarId && pImp->pFrame )
                 [ +  - ]
    1546                 :            :         {
    1547                 :            :             // internal frames also may control statusbar
    1548                 :       4633 :             SfxBindings& rBindings = pImp->pFrame->GetBindings();
    1549                 :       4633 :             pImp->pFrame->GetFrame().GetWorkWindow_Impl()->SetStatusBar_Impl( nStatBarId, pStatusBarShell, rBindings );
    1550                 :            :         }
    1551                 :            :     }
    1552                 :            : }
    1553                 :            : 
    1554                 :            : //--------------------------------------------------------------------
    1555                 :       9108 : void SfxDispatcher::FlushImpl()
    1556                 :            : 
    1557                 :            : /*  [Description]
    1558                 :            : 
    1559                 :            :     Helper method to execute the outstanding push and pop commands.
    1560                 :            : */
    1561                 :            : 
    1562                 :            : {
    1563                 :            :     DBG_PROFSTART(SfxDispatcherFlush);
    1564                 :            :     SFX_STACK(SfxDispatcher::FlushImpl);
    1565                 :            : 
    1566                 :            :     OSL_TRACE("Flushing dispatcher!");
    1567                 :            : 
    1568         [ +  - ]:       9108 :     pImp->aTimer.Stop();
    1569                 :            : 
    1570         [ -  + ]:       9108 :     if ( pImp->pParent )
    1571         [ #  # ]:          0 :         pImp->pParent->Flush();
    1572                 :            : 
    1573                 :       9108 :     pImp->bFlushing = !pImp->bFlushing;
    1574         [ -  + ]:       9108 :     if ( !pImp->bFlushing )
    1575                 :            :     {
    1576                 :          0 :         pImp->bFlushing = sal_True;
    1577                 :            :         DBG_PROFSTOP(SfxDispatcherFlush);
    1578                 :       9108 :         return;
    1579                 :            :     }
    1580                 :            : 
    1581         [ +  - ]:       9108 :     SfxApplication *pSfxApp = SFX_APP();
    1582                 :            : 
    1583                 :            :     // Re-build the true stack in the first round
    1584         [ +  - ]:       9108 :     std::deque<SfxToDo_Impl> aToDoCopy;
    1585                 :       9108 :     sal_Bool bModify = sal_False;
    1586 [ +  - ][ +  - ]:      28115 :     for(std::deque<SfxToDo_Impl>::reverse_iterator i = pImp->aToDoStack.rbegin(); i != pImp->aToDoStack.rend(); ++i)
                 [ +  + ]
    1587                 :            :     {
    1588                 :      19007 :         bModify = sal_True;
    1589                 :            : 
    1590 [ +  - ][ +  + ]:      19007 :         if(i->bPush)
    1591                 :            :         {
    1592                 :            :             // Actually push
    1593                 :            :             DBG_ASSERT(!pImp->aStack.Contains(i->pCluster),
    1594                 :            :                        "pushed SfxShell already on stack" );
    1595 [ +  - ][ +  - ]:      14133 :             pImp->aStack.Push(i->pCluster);
    1596 [ +  - ][ +  - ]:      14133 :             i->pCluster->SetDisableFlags(pImp->nDisableFlags);
    1597                 :            : 
    1598                 :            :             // Mark the moved shell
    1599 [ +  - ][ +  - ]:      14133 :             aToDoCopy.push_front(*i);
    1600                 :            :         }
    1601                 :            :         else
    1602                 :            :         {
    1603                 :            :             // Actually pop
    1604                 :       4874 :             SfxShell* pPopped = 0;
    1605                 :       4874 :             bool bFound = false;
    1606 [ +  + ][ +  + ]:       7582 :             do
                 [ +  + ]
    1607                 :            :             {
    1608                 :            :                 DBG_ASSERT( pImp->aStack.Count(), "popping from empty stack" );
    1609         [ +  - ]:       7582 :                 pPopped = pImp->aStack.Pop();
    1610         [ +  - ]:       7582 :                 pPopped->SetDisableFlags( 0 );
    1611         [ +  - ]:       7582 :                 bFound = (pPopped == i->pCluster);
    1612                 :            : 
    1613                 :            :                 // Mark the moved Shell
    1614 [ +  - ][ +  - ]:       7582 :                 aToDoCopy.push_front(SfxToDo_Impl(sal_False, i->bDelete, sal_False, *pPopped));
    1615                 :            :             }
    1616         [ +  - ]:       7582 :             while(i->bUntil && !bFound);
    1617                 :            :             DBG_ASSERT( bFound, "wrong SfxShell popped" );
    1618                 :            :         }
    1619                 :            :     }
    1620                 :       9108 :     pImp->aToDoStack.clear();
    1621                 :            : 
    1622                 :            :     // Invalidate bindings, if possible
    1623 [ +  - ][ +  - ]:       9108 :     if ( !pSfxApp->IsDowning() )
    1624                 :            :     {
    1625         [ +  - ]:       9108 :         if ( bModify )
    1626                 :            :         {
    1627                 :       9108 :             pImp->pCachedServ1 = 0;
    1628                 :       9108 :             pImp->pCachedServ2 = 0;
    1629                 :            :         }
    1630                 :            : 
    1631         [ +  - ]:       9108 :         InvalidateBindings_Impl( bModify );
    1632                 :            :     }
    1633                 :            : 
    1634                 :       9108 :     pImp->bFlushing = sal_False;
    1635                 :       9108 :     pImp->bUpdated = sal_False; // not only when bModify, if Doc/Template-Config
    1636                 :       9108 :     bFlushed = sal_True;
    1637                 :            :     OSL_TRACE("Successfully flushed dispatcher!");
    1638                 :            : 
    1639                 :            :     // Activate the Shells and possible delete them in the 2nd round
    1640 [ +  - ][ +  - ]:      30823 :     for(std::deque<SfxToDo_Impl>::reverse_iterator i = aToDoCopy.rbegin(); i != aToDoCopy.rend(); ++i)
                 [ +  + ]
    1641                 :            :     {
    1642 [ +  - ][ +  + ]:      21715 :         if(i->bPush)
    1643                 :            :         {
    1644         [ +  + ]:      14133 :             if ( pImp->bActive )
    1645 [ +  - ][ +  - ]:       4408 :                 i->pCluster->DoActivate_Impl(pImp->pFrame, sal_True);
    1646                 :            :         }
    1647         [ +  + ]:       7582 :         else if ( pImp->bActive )
    1648 [ +  - ][ +  - ]:        214 :                 i->pCluster->DoDeactivate_Impl(pImp->pFrame, sal_True);
    1649                 :            :     }
    1650                 :            : 
    1651 [ +  - ][ +  - ]:      30823 :     for(std::deque<SfxToDo_Impl>::reverse_iterator i = aToDoCopy.rbegin(); i != aToDoCopy.rend(); ++i)
                 [ +  + ]
    1652                 :            :     {
    1653 [ +  - ][ +  + ]:      21715 :         if(i->bDelete)
    1654 [ +  - ][ +  - ]:       3712 :             delete i->pCluster;
                 [ +  - ]
    1655                 :            :     }
    1656                 :       9108 :     sal_Bool bAwakeBindings = !aToDoCopy.empty();
    1657         [ +  - ]:       9108 :     if( bAwakeBindings )
    1658                 :       9108 :         aToDoCopy.clear();
    1659                 :            : 
    1660                 :            :     // If more changes have occured on the stach when
    1661                 :            :     // Activate/Deactivate/Delete:
    1662         [ -  + ]:       9108 :     if (!bFlushed)
    1663                 :            :         // If Push/Pop hs been called by someone, theb also EnterReg was called!
    1664         [ #  # ]:          0 :         FlushImpl();
    1665                 :            : 
    1666 [ +  - ][ +  - ]:       9108 :     if( bAwakeBindings && GetBindings() )
         [ +  + ][ +  + ]
    1667 [ +  - ][ +  - ]:       8717 :         GetBindings()->DLEAVEREGISTRATIONS();
    1668                 :            :     DBG_PROFSTOP(SfxDispatcherFlush);
    1669                 :            : 
    1670         [ +  + ]:     127512 :     for (sal_uInt16 n=0; n<SFX_OBJECTBAR_MAX; n++)
    1671                 :     118404 :         pImp->aFixedObjBars[n].nResId = 0;
    1672                 :            : 
    1673                 :       9108 :     SAL_INFO("sfx2", "SfxDispatcher(" << this << ")::Flush() done");
    1674                 :            : }
    1675                 :            : 
    1676                 :            : //--------------------------------------------------------------------
    1677                 :        132 : void SfxDispatcher::SetSlotFilter
    1678                 :            : (
    1679                 :            :     HACK(hier muss mal ein enum rein)
    1680                 :            :     sal_Bool           bEnable,  /* sal_True:
    1681                 :            :                                     only enable specified slots,
    1682                 :            :                                     disable all other
    1683                 :            : 
    1684                 :            :                                     sal_False:
    1685                 :            :                                     disable specified slots,
    1686                 :            :                                     first enable all other
    1687                 :            :                                  */
    1688                 :            :     sal_uInt16         nCount,   // Number of SIDs in the following Array
    1689                 :            :     const sal_uInt16*  pSIDs     // sorted Array of 'nCount' SIDs
    1690                 :            : )
    1691                 :            : 
    1692                 :            : /*  [Description]
    1693                 :            : 
    1694                 :            :     With this method a filter set, the target slots can be enabled or disabled.
    1695                 :            :     The passed array must be retained until the destructor or the next
    1696                 :            :     <SetSlotFilter()>, it is not deleted from the dispatcher, so it can thus be
    1697                 :            :     static.
    1698                 :            : 
    1699                 :            :     In read-only documents the quasi ReadOnlyDoc Flag of slots can be
    1700                 :            :     overturned by the use of 'bEnable == 2', so this will be displayed again.
    1701                 :            :     On the other slots it has no effect.
    1702                 :            : 
    1703                 :            :     [Example]
    1704                 :            : 
    1705                 :            :     Targeted disabling of Slots 1, 2 and 3:
    1706                 :            : 
    1707                 :            :         static sal_uInt16 const pSIDs[] = { 1, 2, 3 };
    1708                 :            :         pDisp->SetSlotFilter( sal_False, sizeof(pSIDs)/sizeof(sal_uInt16), pSIDs );
    1709                 :            : 
    1710                 :            :     only permit Slots 5, 6 and 7:
    1711                 :            : 
    1712                 :            :         static sal_uInt16 const pSIDs[] = { 5, 6, 7 };
    1713                 :            :         pDisp->SetSlotFilter( sal_True, sizeof(pSIDs)/sizeof(sal_uInt16), pSIDs );
    1714                 :            : 
    1715                 :            :     Turn-off Filter:
    1716                 :            : 
    1717                 :            :         pDisp->SetSlotFilter();
    1718                 :            : */
    1719                 :            : 
    1720                 :            : {
    1721                 :            : #ifdef DBG_UTIL
    1722                 :            :     // Check Array
    1723                 :            :     for ( sal_uInt16 n = 1; n < nCount; ++n )
    1724                 :            :         DBG_ASSERT( pSIDs[n] > pSIDs[n-1], "SetSlotFilter: SIDs not sorted" );
    1725                 :            : #endif
    1726                 :            : 
    1727         [ -  + ]:        132 :     if ( pImp->pFilterSIDs )
    1728                 :          0 :         pImp->pFilterSIDs = 0;
    1729                 :            : 
    1730                 :        132 :     pImp->bFilterEnabling = bEnable;
    1731                 :        132 :     pImp->nFilterCount = nCount;
    1732                 :        132 :     pImp->pFilterSIDs = pSIDs;
    1733                 :            : 
    1734                 :        132 :     GetBindings()->InvalidateAll(sal_True);
    1735                 :        132 : }
    1736                 :            : 
    1737                 :            : //--------------------------------------------------------------------
    1738                 :            : EXTERN_C
    1739                 :            : #ifdef WNT
    1740                 :            : int _cdecl
    1741                 :            : #else
    1742                 :            : int
    1743                 :            : #endif
    1744                 :            : 
    1745                 :          0 : SfxCompareSIDs_Impl( const void* pSmaller, const void* pBigger )
    1746                 :            : {
    1747                 :          0 :     return ( (long) *((sal_uInt16*)pSmaller) ) - ( (long) *((sal_uInt16*)pBigger) );
    1748                 :            : }
    1749                 :            : 
    1750                 :            : //--------------------------------------------------------------------
    1751                 :     209880 : sal_Bool SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) const
    1752                 :            : 
    1753                 :            : /*  [Description]
    1754                 :            : 
    1755                 :            :     Searches for 'nSID' in the Filter set by <SetSlotFilter()> and
    1756                 :            :     returns sal_True, if the SIDis allowed, or sal_False, if it is
    1757                 :            :     disabled by the Filter.
    1758                 :            : 
    1759                 :            :     [Return value]
    1760                 :            :     sal_Bool            0       =>      disabled
    1761                 :            :                         1       =>      enabled
    1762                 :            :                         2       =>      enabled even if ReadOnlyDoc
    1763                 :            : */
    1764                 :            : 
    1765                 :            : {
    1766                 :            :     // no filter?
    1767         [ +  - ]:     209880 :     if ( 0 == pImp->nFilterCount )
    1768                 :            :         // => all SIDs allowed
    1769                 :     209880 :         return sal_True;
    1770                 :            : 
    1771                 :            :     // search
    1772                 :            :     sal_Bool bFound = 0 != bsearch( &nSID, pImp->pFilterSIDs, pImp->nFilterCount,
    1773                 :          0 :                                 sizeof(sal_uInt16), SfxCompareSIDs_Impl );
    1774                 :            : 
    1775                 :            :     // even if ReadOnlyDoc
    1776         [ #  # ]:          0 :     if ( 2 == pImp->bFilterEnabling )
    1777         [ #  # ]:          0 :         return bFound ? 2 : 1;
    1778                 :            :     // Otherwise after Negative/Positive Filter
    1779         [ #  # ]:     209880 :     return pImp->bFilterEnabling ? bFound : !bFound;
    1780                 :            : }
    1781                 :            : 
    1782                 :            : //--------------------------------------------------------------------
    1783                 :          0 : sal_Bool SfxDispatcher::_TryIntercept_Impl
    1784                 :            : (
    1785                 :            :     sal_uInt16      nSlot,    // Slot-Id to search for
    1786                 :            :     SfxSlotServer&  rServer,  // <SfxSlotServer>-Instance to fill
    1787                 :            :     sal_Bool        bSelf
    1788                 :            : )
    1789                 :            : {
    1790                 :            :     // Maybe the parent is also belongs to a component
    1791                 :          0 :     SfxDispatcher *pParent = pImp->pParent;
    1792                 :          0 :     sal_uInt16 nLevels = pImp->aStack.Count();
    1793 [ #  # ][ #  # ]:          0 :     while ( pParent && pParent->pImp->pFrame )
                 [ #  # ]
    1794                 :            :     {
    1795         [ #  # ]:          0 :         if ( pParent->pImp->pFrame->GetFrame().HasComponent() )
    1796                 :            :         {
    1797                 :            :             // Components may be intercepted
    1798         [ #  # ]:          0 :             if ( pParent->_TryIntercept_Impl( nSlot, rServer, sal_True ) )
    1799                 :            :             {
    1800                 :            :                 // The own shells are added to the Shell Level
    1801                 :          0 :                 rServer.SetShellLevel( rServer.GetShellLevel() + nLevels );
    1802                 :          0 :                 return sal_True;
    1803                 :            :             }
    1804                 :            :             else
    1805                 :            :                 // No further Interception
    1806                 :          0 :                 break;
    1807                 :            :         }
    1808                 :            :         else
    1809                 :          0 :             nLevels = nLevels + pParent->pImp->aStack.Count();
    1810                 :            : 
    1811                 :          0 :         pParent = pParent->pImp->pParent;
    1812                 :            :     }
    1813                 :            : 
    1814         [ #  # ]:          0 :     if ( bSelf )
    1815                 :            :     {
    1816                 :            :         // Query the ComponentViewShell
    1817                 :          0 :         Flush();
    1818                 :          0 :         SfxShell *pObjShell = GetShell(0);
    1819                 :          0 :         SfxInterface *pIFace = pObjShell->GetInterface();
    1820                 :          0 :         const SfxSlot *pSlot = pIFace->GetSlot(nSlot);
    1821                 :            : 
    1822         [ #  # ]:          0 :         if ( pSlot )
    1823                 :            :         {
    1824                 :          0 :             rServer.SetSlot(pSlot);
    1825                 :          0 :             rServer.SetShellLevel(0);
    1826                 :          0 :             return sal_True;
    1827                 :            :         }
    1828                 :            :     }
    1829                 :            : 
    1830                 :          0 :     return sal_False;
    1831                 :            : }
    1832                 :            : 
    1833                 :     209976 : sal_Bool SfxDispatcher::_FindServer
    1834                 :            : (
    1835                 :            :     sal_uInt16      nSlot,     // Slot-Id to search for
    1836                 :            :     SfxSlotServer&  rServer,   // <SfxSlotServer>-Instance to fill
    1837                 :            :     sal_Bool        bModal     // Dispite ModalMode
    1838                 :            : )
    1839                 :            : 
    1840                 :            : /*  [Description]
    1841                 :            : 
    1842                 :            :     This helper method searches for the <Slot-Server> which currently serves
    1843                 :            :     the nSlot. As the result, rServe is filled accordingly.
    1844                 :            : 
    1845                 :            :     If known the SfxInterface which is currently served by nSlot can be
    1846                 :            :     passed along.
    1847                 :            : 
    1848                 :            :     The SfxDispatcher is flushed while searching for nSlot.
    1849                 :            : 
    1850                 :            :     [Return value]
    1851                 :            : 
    1852                 :            : 
    1853                 :            :     sal_Bool            sal_True
    1854                 :            :                         The Slot was found, rServer is valid.
    1855                 :            : 
    1856                 :            :                         sal_False
    1857                 :            :                         The Slot is currently not served, rServer is invalid.
    1858                 :            : */
    1859                 :            : 
    1860                 :            : {
    1861                 :            :     SFX_STACK(SfxDispatcher::_FindServer);
    1862                 :            : 
    1863                 :            :     // Dispatcher locked? (nevertheless let SID_HELP_PI through)
    1864         [ -  + ]:     209976 :     if ( IsLocked(nSlot) )
    1865                 :            :     {
    1866                 :          0 :         pImp->bInvalidateOnUnlock = sal_True;
    1867                 :          0 :         return sal_False;
    1868                 :            :     }
    1869                 :            : 
    1870                 :            :     // Count the number of Shells in the linked dispatchers.
    1871                 :     209976 :     Flush();
    1872                 :     209976 :     sal_uInt16 nTotCount = pImp->aStack.Count();
    1873         [ -  + ]:     209976 :     if ( pImp->pParent )
    1874                 :            :     {
    1875                 :          0 :         SfxDispatcher *pParent = pImp->pParent;
    1876         [ #  # ]:          0 :         while ( pParent )
    1877                 :            :         {
    1878                 :          0 :             nTotCount = nTotCount + pParent->pImp->aStack.Count();
    1879                 :          0 :             pParent = pParent->pImp->pParent;
    1880                 :            :         }
    1881                 :            :     }
    1882                 :            : 
    1883                 :            :     // Verb-Slot?
    1884 [ +  + ][ -  + ]:     209976 :     if (nSlot >= SID_VERB_START && nSlot <= SID_VERB_END)
    1885                 :            :     {
    1886                 :          0 :         for ( sal_uInt16 nShell = 0;; ++nShell )
    1887                 :            :         {
    1888                 :          0 :             SfxShell *pSh = GetShell(nShell);
    1889         [ #  # ]:          0 :             if ( pSh == NULL )
    1890                 :          0 :                 return false;
    1891         [ #  # ]:          0 :             if ( pSh->ISA(SfxViewShell) )
    1892                 :            :             {
    1893                 :          0 :                 const SfxSlot* pSlot = pSh->GetVerbSlot_Impl(nSlot);
    1894         [ #  # ]:          0 :                 if ( pSlot )
    1895                 :            :                 {
    1896                 :          0 :                     rServer.SetShellLevel(nShell);
    1897                 :          0 :                     rServer.SetSlot( pSlot );
    1898                 :          0 :                     return true;
    1899                 :            :                 }
    1900                 :            :             }
    1901                 :            :         }
    1902                 :            :     }
    1903                 :            : 
    1904                 :            :     // SID check against set filter
    1905                 :     209976 :     sal_uInt16 nSlotEnableMode=0;
    1906         [ +  + ]:     209976 :     if ( pImp->pFrame )
    1907                 :            :     {
    1908                 :     209880 :         nSlotEnableMode = IsSlotEnabledByFilter_Impl( nSlot );
    1909         [ -  + ]:     209880 :         if ( 0 == nSlotEnableMode )
    1910                 :          0 :             return sal_False;
    1911                 :            :     }
    1912                 :            : 
    1913                 :            :     // In Quiet-Mode only Parent-Dispatcher
    1914         [ -  + ]:     209976 :     if ( pImp->bQuiet )
    1915                 :            :     {
    1916         [ #  # ]:          0 :         if ( pImp->pParent )
    1917                 :            :         {
    1918                 :          0 :             sal_Bool bRet = pImp->pParent->_FindServer( nSlot, rServer, bModal );
    1919                 :            :             rServer.SetShellLevel
    1920                 :          0 :                 ( rServer.GetShellLevel() + pImp->aStack.Count() );
    1921                 :          0 :             return bRet;
    1922                 :            :         }
    1923                 :            :         else
    1924                 :          0 :             return sal_False;
    1925                 :            :     }
    1926                 :            : 
    1927 [ +  - ][ +  + ]:     209976 :     sal_Bool bReadOnly = ( 2 != nSlotEnableMode && pImp->bReadOnly );
    1928                 :            : 
    1929                 :            :     // search through all the shells of the chained dispatchers
    1930                 :            :     // from top to bottom
    1931 [ -  + ][ #  # ]:     209976 :     sal_uInt16 nFirstShell = pImp->bModal && !bModal ? pImp->aStack.Count() : 0;
    1932         [ +  + ]:     512265 :     for ( sal_uInt16 i = nFirstShell; i < nTotCount; ++i )
    1933                 :            :     {
    1934                 :     508734 :         SfxShell *pObjShell = GetShell(i);
    1935                 :     508734 :         SfxInterface *pIFace = pObjShell->GetInterface();
    1936                 :     508734 :         const SfxSlot *pSlot = pIFace->GetSlot(nSlot);
    1937                 :            : 
    1938 [ +  + ][ -  + ]:     508734 :         if ( pSlot && pSlot->nDisableFlags && ( pSlot->nDisableFlags & pObjShell->GetDisableFlags() ) != 0 )
         [ -  + ][ +  + ]
    1939                 :          0 :             return sal_False;
    1940                 :            : 
    1941 [ +  + ][ +  + ]:     508734 :         if ( pSlot && !( pSlot->nFlags & SFX_SLOT_READONLYDOC ) && bReadOnly )
                 [ +  + ]
    1942                 :         82 :             return sal_False;
    1943                 :            : 
    1944         [ +  + ]:     508652 :         if ( pSlot )
    1945                 :            :         {
    1946                 :            :             // Slot belongs to Container?
    1947                 :     206364 :             bool bIsContainerSlot = pSlot->IsMode(SFX_SLOT_CONTAINER);
    1948 [ -  + ][ +  + ]:     206364 :             bool bIsInPlace = pImp->pFrame && pImp->pFrame->GetObjectShell()->IsInPlaceActive();
    1949                 :            : 
    1950                 :            :             // Shell belongs to Server?
    1951                 :            :             // AppDispatcher or IPFrame-Dispatcher
    1952 [ +  + ][ -  + ]:     206364 :             bool bIsServerShell = !pImp->pFrame || bIsInPlace;
    1953                 :            : 
    1954                 :            :             // Of course ShellServer-Slots are also executable even when it is
    1955                 :            :             // excecuted on a container dispatcher without a IPClient.
    1956         [ +  + ]:     206364 :             if ( !bIsServerShell )
    1957                 :            :             {
    1958                 :     206268 :                 SfxViewShell *pViewSh = pImp->pFrame->GetViewShell();
    1959 [ +  + ][ +  - ]:     206268 :                 bIsServerShell = !pViewSh || !pViewSh->GetUIActiveClient();
    1960                 :            :             }
    1961                 :            : 
    1962                 :            :             // Shell belongs to Container?
    1963                 :            :             // AppDispatcher or no IPFrameDispatcher
    1964 [ +  + ][ +  - ]:     206364 :             bool bIsContainerShell = !pImp->pFrame || !bIsInPlace;
    1965                 :            :             // Shell and Slot match
    1966         [ +  + ]:     206364 :             if ( !( ( bIsContainerSlot && bIsContainerShell ) ||
    1967 [ -  + ][ +  - ]:     206364 :                     ( !bIsContainerSlot && bIsServerShell ) ) )
                 [ +  + ]
    1968                 :          1 :                 pSlot = 0;
    1969                 :            :         }
    1970                 :            : 
    1971 [ +  + ][ -  + ]:     508652 :         if ( pSlot && !IsAllowed( nSlot ) )
                 [ -  + ]
    1972                 :            :         {
    1973                 :          0 :             pSlot = NULL;
    1974                 :            :         }
    1975                 :            : 
    1976         [ +  + ]:     508652 :         if ( pSlot )
    1977                 :            :         {
    1978                 :     206363 :             rServer.SetSlot(pSlot);
    1979                 :     206363 :             rServer.SetShellLevel(i);
    1980                 :     206363 :             return sal_True;
    1981                 :            :         }
    1982                 :            :     }
    1983                 :            : 
    1984                 :     209976 :     return sal_False;
    1985                 :            : }
    1986                 :            : 
    1987                 :            : //--------------------------------------------------------------------
    1988                 :      33892 : sal_Bool SfxDispatcher::_FillState
    1989                 :            : (
    1990                 :            :     const SfxSlotServer&  rSvr,      // <Slot-Server> to query
    1991                 :            :     SfxItemSet&           rState,    // <SfxItemSet> to be filled
    1992                 :            :     const SfxSlot*        pRealSlot  // The actual Slot if possible
    1993                 :            : )
    1994                 :            : 
    1995                 :            : /*  [Description]
    1996                 :            : 
    1997                 :            :     Helper method to obtain the status of the <Slot-Server>s rSvr.
    1998                 :            :     The required slots IDs (partly converted to Which-IDs of the pool)
    1999                 :            :     must be present in rstate.
    2000                 :            : 
    2001                 :            :     The SfxDispatcher is flushed before the query.
    2002                 :            : */
    2003                 :            : 
    2004                 :            : {
    2005                 :            :     SFX_STACK(SfxDispatcher::_FillState);
    2006                 :            : 
    2007                 :            :     DBG_PROFSTART(SfxDispatcherFillState);
    2008                 :            : 
    2009                 :      33892 :     const SfxSlot *pSlot = rSvr.GetSlot();
    2010 [ -  + ][ -  + ]:      33892 :     if ( pSlot && IsLocked( pSlot->GetSlotId() ) )
                 [ +  - ]
    2011                 :            :     {
    2012                 :          0 :         pImp->bInvalidateOnUnlock = sal_True;
    2013                 :            :         DBG_PROFSTOP(SfxDispatcherFillState);
    2014                 :          0 :         return sal_False;
    2015                 :            :     }
    2016                 :            : 
    2017         [ +  - ]:      33892 :     if ( pSlot )
    2018                 :            :     {
    2019                 :            :         DBG_ASSERT(bFlushed, "Dispatcher not flushed after retrieving slot servers!");
    2020         [ -  + ]:      33892 :         if ( !bFlushed )
    2021                 :          0 :             return sal_False;
    2022                 :            : 
    2023                 :            :         // Determine the object and call the Message of this object
    2024                 :      33892 :         SfxShell *pSh = GetShell(rSvr.GetShellLevel());
    2025                 :            :         DBG_ASSERT(pSh, "ObjektShell not found");
    2026                 :            : 
    2027                 :            :         SfxStateFunc pFunc;
    2028                 :            : 
    2029         [ +  - ]:      33892 :         if (pRealSlot)
    2030                 :      33892 :             pFunc = pRealSlot->GetStateFnc();
    2031                 :            :         else
    2032                 :          0 :             pFunc = pSlot->GetStateFnc();
    2033                 :            : 
    2034                 :      33892 :         pSh->CallState( pFunc, rState );
    2035                 :            : #ifdef DBG_UTIL
    2036                 :            :         // To examine the conformity of IDL (SlotMap) and current Items
    2037                 :            :         if ( DbgIsAssertWarning() && rState.Count() )
    2038                 :            :         {
    2039                 :            :             SfxInterface *pIF = pSh->GetInterface();
    2040                 :            :             SfxItemIter aIter( rState );
    2041                 :            :             for ( const SfxPoolItem *pItem = aIter.FirstItem();
    2042                 :            :                   pItem;
    2043                 :            :                   pItem = aIter.NextItem() )
    2044                 :            :             {
    2045                 :            :                 if ( !IsInvalidItem(pItem) && !pItem->ISA(SfxVoidItem) )
    2046                 :            :                 {
    2047                 :            :                     sal_uInt16 nSlotId = rState.GetPool()->GetSlotId(pItem->Which());
    2048                 :            :                     if ( !pItem->IsA(pIF->GetSlot(nSlotId)->GetType()->Type()) )
    2049                 :            :                     {
    2050                 :            :                         rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM(
    2051                 :            :                             "item-type unequal to IDL (=> no BASIC)"));
    2052                 :            :                         aMsg.append(RTL_CONSTASCII_STRINGPARAM("\nwith SID: "));
    2053                 :            :                         aMsg.append(static_cast<sal_Int32>(nSlotId));
    2054                 :            :                         aMsg.append(RTL_CONSTASCII_STRINGPARAM("\nin "));
    2055                 :            :                         aMsg.append(pIF->GetClassName());
    2056                 :            :                         DbgOut(aMsg.getStr(), DBG_OUT_ERROR, __FILE__, __LINE__);
    2057                 :            :                     }
    2058                 :            :                 }
    2059                 :            :             }
    2060                 :            :         }
    2061                 :            : #endif
    2062                 :            : 
    2063                 :            :         DBG_PROFSTOP(SfxDispatcherFillState);
    2064                 :      33892 :         return sal_True;
    2065                 :            :     }
    2066                 :            : 
    2067                 :            :     DBG_PROFSTOP(SfxDispatcherFillState);
    2068                 :      33892 :     return sal_False;
    2069                 :            : }
    2070                 :            : 
    2071                 :          0 : SfxPopupMenuManager* SfxDispatcher::Popup( sal_uInt16 nConfigId,Window *pWin, const Point *pPos )
    2072                 :            : {
    2073                 :          0 :     SfxDispatcher &rDisp = *SFX_APP()->GetDispatcher_Impl();
    2074                 :          0 :     sal_uInt16 nShLevel = 0;
    2075                 :            :     SfxShell *pSh;
    2076                 :          0 :     nShLevel=0;
    2077                 :            : 
    2078         [ #  # ]:          0 :     if ( rDisp.pImp->bQuiet )
    2079                 :            :     {
    2080                 :          0 :         nConfigId = 0;
    2081                 :          0 :         nShLevel = rDisp.pImp->aStack.Count();
    2082                 :            :     }
    2083                 :            : 
    2084         [ #  # ]:          0 :     Window *pWindow = pWin ? pWin : rDisp.pImp->pFrame->GetFrame().GetWorkWindow_Impl()->GetWindow();
    2085         [ #  # ]:          0 :     for ( pSh = rDisp.GetShell(nShLevel); pSh; ++nShLevel, pSh = rDisp.GetShell(nShLevel) )
    2086                 :            :     {
    2087                 :          0 :         const ResId& rResId = pSh->GetInterface()->GetPopupMenuResId();
    2088 [ #  # ][ #  # ]:          0 :         if ( ( nConfigId == 0 && rResId.GetId() ) || ( nConfigId != 0 && rResId.GetId() == nConfigId ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2089                 :            :         {
    2090 [ #  # ][ #  # ]:          0 :                 return SfxPopupMenuManager::Popup( rResId, rDisp.GetFrame(), pPos ? *pPos : pWindow->GetPointerPosPixel(), pWindow );
                 [ #  # ]
    2091                 :            :         }
    2092                 :            :     }
    2093                 :          0 :     return 0;
    2094                 :            : }
    2095                 :            : 
    2096                 :            : 
    2097                 :            : //----------------------------------------------------------------------
    2098                 :          0 : void SfxDispatcher::ExecutePopup( sal_uInt16 nConfigId, Window *pWin, const Point *pPos )
    2099                 :            : {
    2100                 :          0 :     SfxDispatcher &rDisp = *SFX_APP()->GetDispatcher_Impl();
    2101                 :          0 :     sal_uInt16 nShLevel = 0;
    2102                 :            :     SfxShell *pSh;
    2103                 :            : 
    2104                 :          0 :     nShLevel=0;
    2105         [ #  # ]:          0 :     if ( rDisp.pImp->bQuiet )
    2106                 :            :     {
    2107                 :          0 :         nConfigId = 0;
    2108                 :          0 :         nShLevel = rDisp.pImp->aStack.Count();
    2109                 :            :     }
    2110                 :            : 
    2111         [ #  # ]:          0 :     Window *pWindow = pWin ? pWin : rDisp.pImp->pFrame->GetFrame().GetWorkWindow_Impl()->GetWindow();
    2112         [ #  # ]:          0 :     for ( pSh = rDisp.GetShell(nShLevel); pSh; ++nShLevel, pSh = rDisp.GetShell(nShLevel) )
    2113                 :            :     {
    2114                 :          0 :         const ResId& rResId = pSh->GetInterface()->GetPopupMenuResId();
    2115 [ #  # ][ #  # ]:          0 :         if ( ( nConfigId == 0 && rResId.GetId() ) || ( nConfigId != 0 && rResId.GetId() == nConfigId ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2116                 :            :         {
    2117 [ #  # ][ #  # ]:          0 :             SfxPopupMenuManager::ExecutePopup( rResId, rDisp.GetFrame(), pPos ? *pPos : pWindow->GetPointerPosPixel(), pWindow );
                 [ #  # ]
    2118                 :          0 :             return;
    2119                 :            :         }
    2120                 :            :     }
    2121                 :            : }
    2122                 :            : 
    2123                 :            : //----------------------------------------------------------------------
    2124                 :          0 : void SfxDispatcher::ExecutePopup( const ResId &rId, Window *pWin, const Point *pPos )
    2125                 :            : {
    2126         [ #  # ]:          0 :     Window *pWindow = pWin ? pWin : pImp->pFrame->GetFrame().GetWorkWindow_Impl()->GetWindow();
    2127 [ #  # ][ #  # ]:          0 :     SfxPopupMenuManager::ExecutePopup( rId, GetFrame(), pPos ? *pPos : pWindow->GetPointerPosPixel(), pWindow );
                 [ #  # ]
    2128                 :          0 : }
    2129                 :            : 
    2130                 :            : //--------------------------------------------------------------------
    2131                 :       7537 : void SfxDispatcher::Lock( sal_Bool bLock )
    2132                 :            : 
    2133                 :            : /*  [Description]
    2134                 :            : 
    2135                 :            :     With this method the SfxDispatcher can be locked and released. A locked
    2136                 :            :     SfxDispatcher does not perform <SfxRequest>s and does no longer provide
    2137                 :            :     status information. It behaves as if all the slots were disabled.
    2138                 :            : */
    2139                 :            : 
    2140                 :            : {
    2141                 :       7537 :     SfxBindings* pBindings = GetBindings();
    2142 [ +  + ][ -  + ]:       7537 :     if ( !bLock && pImp->bLocked && pImp->bInvalidateOnUnlock )
                 [ +  + ]
    2143                 :            :     {
    2144         [ #  # ]:          0 :         if ( pBindings )
    2145                 :          0 :             pBindings->InvalidateAll(sal_True);
    2146                 :          0 :         pImp->bInvalidateOnUnlock = sal_False;
    2147                 :            :     }
    2148         [ +  - ]:       7537 :     else if ( pBindings )
    2149                 :       7537 :         pBindings->InvalidateAll(sal_False);
    2150                 :       7537 :     pImp->bLocked = bLock;
    2151         [ +  + ]:       7537 :     if ( !bLock )
    2152                 :            :     {
    2153         [ -  + ]:       3821 :         for(size_t i = 0; i < pImp->aReqArr.size(); ++i)
    2154                 :          0 :             pImp->xPoster->Post(&pImp->aReqArr[i]);
    2155                 :       3821 :         pImp->aReqArr.clear();
    2156                 :            :     }
    2157                 :       7537 : }
    2158                 :            : 
    2159                 :          4 : sal_uInt32 SfxDispatcher::GetObjectBarId( sal_uInt16 nPos ) const
    2160                 :            : {
    2161                 :          4 :     return pImp->aObjBars[nPos].nResId;
    2162                 :            : }
    2163                 :            : 
    2164                 :            : //-------------------------------------------------------------------------
    2165                 :       1707 : void SfxDispatcher::HideUI( sal_Bool bHide )
    2166                 :            : {
    2167                 :       1707 :     sal_Bool bWasHidden = pImp->bNoUI;
    2168                 :       1707 :     pImp->bNoUI = bHide;
    2169         [ +  - ]:       1707 :     if ( pImp->pFrame )
    2170                 :            :     {
    2171                 :       1707 :         SfxViewFrame* pTop = pImp->pFrame->GetTopViewFrame();
    2172 [ +  - ][ +  - ]:       1707 :         if ( pTop && pTop->GetBindings().GetDispatcher() == this )
                 [ +  - ]
    2173                 :            :         {
    2174                 :       1707 :             SfxFrame& rFrame = pTop->GetFrame();
    2175         [ +  - ]:       1707 :             if ( rFrame.IsMenuBarOn_Impl() )
    2176                 :            :             {
    2177 [ +  - ][ +  - ]:       1707 :                 com::sun::star::uno::Reference < com::sun::star::beans::XPropertySet > xPropSet( rFrame.GetFrameInterface(), com::sun::star::uno::UNO_QUERY );
    2178         [ +  - ]:       1707 :                 if ( xPropSet.is() )
    2179                 :            :                 {
    2180                 :       1707 :                     com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
    2181 [ +  - ][ +  - ]:       1707 :                     com::sun::star::uno::Any aValue = xPropSet->getPropertyValue( rtl::OUString( "LayoutManager" ));
    2182         [ +  - ]:       1707 :                     aValue >>= xLayoutManager;
    2183         [ +  - ]:       1707 :                     if ( xLayoutManager.is() )
    2184 [ +  - ][ +  - ]:       1707 :                         xLayoutManager->setVisible( !bHide );
    2185                 :       1707 :                 }
    2186                 :            :             }
    2187                 :            :         }
    2188                 :            :     }
    2189                 :            : 
    2190         [ -  + ]:       1707 :     if ( bHide != bWasHidden )
    2191                 :          0 :         Update_Impl( sal_True );
    2192                 :       1707 : }
    2193                 :            : 
    2194                 :       1711 : void SfxDispatcher::SetReadOnly_Impl( sal_Bool bOn )
    2195                 :            : {
    2196                 :       1711 :     pImp->bReadOnly = bOn;
    2197                 :       1711 : }
    2198                 :            : 
    2199                 :         18 : sal_Bool SfxDispatcher::GetReadOnly_Impl() const
    2200                 :            : {
    2201                 :         18 :     return pImp->bReadOnly;
    2202                 :            : }
    2203                 :            : 
    2204                 :            : //-------------------------------------------------------------------------
    2205                 :          0 : void SfxDispatcher::SetQuietMode_Impl( sal_Bool bOn )
    2206                 :            : 
    2207                 :            : /*  [Description]
    2208                 :            : 
    2209                 :            :     With 'bOn' the Dispatcher is quasi dead and transfers everything to the
    2210                 :            :     Parent-Dispatcher.
    2211                 :            : */
    2212                 :            : 
    2213                 :            : {
    2214                 :          0 :     pImp->bQuiet = bOn;
    2215                 :          0 :     SfxBindings* pBindings = GetBindings();
    2216         [ #  # ]:          0 :     if ( pBindings )
    2217                 :          0 :         pBindings->InvalidateAll(sal_True);
    2218                 :          0 : }
    2219                 :            : 
    2220                 :          0 : void SfxDispatcher::SetExecuteMode( sal_uInt16 nMode )
    2221                 :            : {
    2222                 :          0 :     pImp->nStandardMode = nMode;
    2223                 :          0 : }
    2224                 :            : 
    2225                 :        583 : SfxItemState SfxDispatcher::QueryState( sal_uInt16 nSlot, const SfxPoolItem* &rpState )
    2226                 :            : {
    2227                 :        583 :     SfxShell *pShell = 0;
    2228                 :        583 :     const SfxSlot *pSlot = 0;
    2229 [ +  - ][ +  + ]:        583 :     if ( GetShellAndSlot_Impl( nSlot, &pShell, &pSlot, sal_False, sal_False ) )
    2230                 :            :     {
    2231         [ +  - ]:        540 :         rpState = pShell->GetSlotState(nSlot);
    2232         [ +  + ]:        540 :         if ( !rpState )
    2233                 :          4 :             return SFX_ITEM_DISABLED;
    2234                 :            :         else
    2235                 :        536 :             return SFX_ITEM_AVAILABLE;
    2236                 :            :     }
    2237                 :            : 
    2238                 :        583 :     return SFX_ITEM_DISABLED;
    2239                 :            : }
    2240                 :            : 
    2241                 :     103069 : SfxItemState SfxDispatcher::QueryState( sal_uInt16 nSID, ::com::sun::star::uno::Any& rAny )
    2242                 :            : {
    2243                 :     103069 :     SfxShell *pShell = 0;
    2244                 :     103069 :     const SfxSlot *pSlot = 0;
    2245 [ +  - ][ +  + ]:     103069 :     if ( GetShellAndSlot_Impl( nSID, &pShell, &pSlot, sal_False, sal_False ) )
    2246                 :            :     {
    2247                 :     101825 :         const SfxPoolItem* pItem( 0 );
    2248                 :            : 
    2249         [ +  - ]:     101825 :         pItem = pShell->GetSlotState( nSID );
    2250         [ +  + ]:     101825 :         if ( !pItem )
    2251                 :      12908 :             return SFX_ITEM_DISABLED;
    2252                 :            :         else
    2253                 :            :         {
    2254                 :      88917 :             ::com::sun::star::uno::Any aState;
    2255 [ +  - ][ +  + ]:      88917 :             if ( !pItem->ISA(SfxVoidItem) )
                 [ +  - ]
    2256                 :            :             {
    2257                 :      59931 :                 sal_uInt16 nSubId( 0 );
    2258                 :      59931 :                 SfxItemPool& rPool = pShell->GetPool();
    2259         [ +  - ]:      59931 :                 sal_uInt16 nWhich = rPool.GetWhich( nSID );
    2260 [ +  - ][ +  + ]:      59931 :                 if ( rPool.GetMetric( nWhich ) == SFX_MAPUNIT_TWIP )
    2261                 :      48149 :                     nSubId |= CONVERT_TWIPS;
    2262         [ +  - ]:      59931 :                 pItem->QueryValue( aState, (sal_uInt8)nSubId );
    2263                 :            :             }
    2264                 :      88917 :             rAny = aState;
    2265                 :            : 
    2266                 :      88917 :             return SFX_ITEM_AVAILABLE;
    2267                 :            :         }
    2268                 :            :     }
    2269                 :            : 
    2270                 :     103069 :     return SFX_ITEM_DISABLED;
    2271                 :            : }
    2272                 :            : 
    2273                 :      32767 : sal_Bool SfxDispatcher::IsReadOnlyShell_Impl( sal_uInt16 nShell ) const
    2274                 :            : {
    2275                 :      32767 :     sal_uInt16 nShellCount = pImp->aStack.Count();
    2276         [ +  - ]:      32767 :     if ( nShell < nShellCount )
    2277                 :            :     {
    2278                 :      32767 :         SfxShell* pShell = pImp->aStack.Top( nShell );
    2279 [ +  + ][ +  + ]:      32767 :         if( pShell->ISA( SfxModule ) || pShell->ISA( SfxApplication ) || pShell->ISA( SfxViewFrame ) )
         [ +  + ][ +  + ]
    2280                 :      13899 :             return sal_False;
    2281                 :            :         else
    2282                 :      18868 :             return pImp->bReadOnly;
    2283                 :            :     }
    2284         [ #  # ]:          0 :     else if ( pImp->pParent )
    2285                 :          0 :         return pImp->pParent->IsReadOnlyShell_Impl( nShell - nShellCount );
    2286                 :      32767 :     return sal_True;
    2287                 :            : }
    2288                 :            : 
    2289                 :            : // A dirty trick, to get hold of the methods of the private base class
    2290                 :            : // SfxShellStack_Impl
    2291                 :            : class StackAccess_Impl : public SfxShellStack_Implarr_
    2292                 :            : {};
    2293                 :            : 
    2294                 :       2512 : void SfxDispatcher::RemoveShell_Impl( SfxShell& rShell )
    2295                 :            : {
    2296                 :       2512 :     Flush();
    2297                 :            : 
    2298                 :            :     // The cast is because SfxShellStack_Impl member has non of its own
    2299                 :       2512 :     StackAccess_Impl& rStack = *((StackAccess_Impl*) (&pImp->aStack));
    2300                 :       2512 :     sal_uInt16 nCount = rStack.Count();
    2301         [ +  - ]:      10318 :     for ( sal_uInt16 n=0; n<nCount; ++n )
    2302                 :            :     {
    2303         [ +  + ]:      10318 :         if ( rStack[n] == &rShell )
    2304                 :            :         {
    2305                 :       2512 :             rStack.Remove( n );
    2306                 :       2512 :             rShell.SetDisableFlags( 0 );
    2307                 :       2512 :             rShell.DoDeactivate_Impl(pImp->pFrame, sal_True);
    2308                 :       2512 :             break;
    2309                 :            :         }
    2310                 :            :     }
    2311                 :            : 
    2312         [ +  - ]:       2512 :     if ( !SFX_APP()->IsDowning() )
    2313                 :            :     {
    2314                 :       2512 :         pImp->bUpdated = sal_False;
    2315                 :       2512 :         pImp->pCachedServ1 = 0;
    2316                 :       2512 :         pImp->pCachedServ2 = 0;
    2317                 :       2512 :         InvalidateBindings_Impl(sal_True);
    2318                 :            :     }
    2319                 :       2512 : }
    2320                 :            : 
    2321                 :     206363 : sal_Bool SfxDispatcher::IsAllowed
    2322                 :            : (
    2323                 :            :     sal_uInt16 nSlot
    2324                 :            : ) const
    2325                 :            : /*
    2326                 :            :     [Description]
    2327                 :            : 
    2328                 :            :     The method checks whether the access is allowed on this interface.
    2329                 :            :  */
    2330                 :            : {
    2331         [ +  - ]:     206363 :     if ( !pImp->pDisableList )
    2332                 :            :     {
    2333                 :     206363 :         return sal_True;
    2334                 :            :     }
    2335                 :            : 
    2336                 :            :     // BinSearch in the disable list
    2337                 :          0 :     std::vector<sal_uInt16>& rList = *pImp->pDisableList;
    2338                 :          0 :     sal_uInt16 nCount = rList.size();
    2339                 :          0 :     sal_uInt16 nLow = 0, nMid = 0, nHigh;
    2340                 :          0 :     sal_Bool bFound = sal_False;
    2341                 :          0 :     nHigh = nCount - 1;
    2342                 :            : 
    2343 [ #  # ][ #  # ]:          0 :     while ( !bFound && nLow <= nHigh )
                 [ #  # ]
    2344                 :            :     {
    2345                 :          0 :         nMid = (nLow + nHigh) >> 1;
    2346                 :            :         DBG_ASSERT( nMid < nCount, "bsearch is buggy" );
    2347                 :            : 
    2348                 :          0 :         int nDiff = (int) nSlot - (int) rList[nMid];
    2349         [ #  # ]:          0 :         if ( nDiff < 0)
    2350                 :            :         {
    2351         [ #  # ]:          0 :             if ( nMid == 0 )
    2352                 :          0 :                 break;
    2353                 :          0 :             nHigh = nMid - 1;
    2354                 :            :         }
    2355         [ #  # ]:          0 :         else if ( nDiff > 0 )
    2356                 :            :         {
    2357                 :          0 :             nLow = nMid + 1;
    2358         [ #  # ]:          0 :             if ( nLow == 0 )
    2359                 :          0 :                 break;
    2360                 :            :         }
    2361                 :            :         else
    2362                 :          0 :             bFound = sal_True;
    2363                 :            :     }
    2364                 :            : 
    2365                 :            : #ifdef _DEBUG
    2366                 :            :     // Slot found in the List?
    2367                 :            :     sal_uInt16 nPos = bFound ? nMid : nLow;
    2368                 :            : 
    2369                 :            :     DBG_ASSERT( nPos <= nCount, "" );
    2370                 :            :     DBG_ASSERT( nPos == nCount || nSlot <= rList[nPos], "" );
    2371                 :            :     DBG_ASSERT( nPos == 0 || nSlot > rList[nPos-1], "" );
    2372                 :            :     DBG_ASSERT( ( (nPos+1) >= nCount ) || nSlot < rList[nPos+1], "" );
    2373                 :            : #endif
    2374                 :            : 
    2375                 :     206363 :     return !bFound;
    2376                 :            : }
    2377                 :            : 
    2378                 :      11620 : void SfxDispatcher::InvalidateBindings_Impl( sal_Bool bModify )
    2379                 :            : {
    2380                 :            :     // App-Dispatcher?
    2381         [ +  + ]:      11620 :     if ( IsAppDispatcher() )
    2382                 :            :     {
    2383         [ -  + ]:        391 :         for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst();
    2384                 :            :                 pFrame;
    2385                 :            :                 pFrame = SfxViewFrame::GetNext( *pFrame ) )
    2386                 :          0 :             pFrame->GetBindings().InvalidateAll(bModify);
    2387                 :            :     }
    2388                 :            :     else
    2389                 :            :     {
    2390                 :      11229 :         SfxDispatcher *pDisp = GetBindings()->GetDispatcher_Impl();
    2391         [ +  - ]:      11229 :         while ( pDisp )
    2392                 :            :         {
    2393         [ +  - ]:      11229 :             if ( pDisp == this )
    2394                 :            :             {
    2395                 :      11229 :                 GetBindings()->InvalidateAll( bModify );
    2396                 :      11229 :                 break;
    2397                 :            :             }
    2398                 :            : 
    2399                 :          0 :             pDisp = pDisp->pImp->pParent;
    2400                 :            :         }
    2401                 :            :     }
    2402                 :      11620 : }
    2403                 :            : 
    2404                 :          0 : sal_Bool SfxDispatcher::IsUpdated_Impl() const
    2405                 :            : {
    2406                 :          0 :     return pImp->bUpdated;
    2407                 :            : }
    2408                 :            : 
    2409                 :       3350 : void SfxDispatcher::SetDisableFlags( sal_uInt32 nFlags )
    2410                 :            : {
    2411                 :       3350 :     pImp->nDisableFlags = nFlags;
    2412         [ +  + ]:      13513 :     for ( int i = int(pImp->aStack.Count()) - 1; i >= 0; --i )
    2413                 :      10163 :         pImp->aStack.Top( (sal_uInt16) i )->SetDisableFlags( nFlags );
    2414                 :       3350 : }
    2415                 :            : 
    2416                 :      39106 : sal_uInt32 SfxDispatcher::GetDisableFlags() const
    2417                 :            : {
    2418                 :      39106 :     return pImp->nDisableFlags;
    2419                 :            : }
    2420                 :            : 
    2421                 :          0 : SfxModule* SfxDispatcher::GetModule() const
    2422                 :            : {
    2423                 :          0 :     for ( sal_uInt16 nShell = 0;; ++nShell )
    2424                 :            :     {
    2425                 :          0 :         SfxShell *pSh = GetShell(nShell);
    2426         [ #  # ]:          0 :         if ( pSh == NULL )
    2427                 :          0 :             return 0;
    2428         [ #  # ]:          0 :         if ( pSh->ISA(SfxModule) )
    2429                 :          0 :             return (SfxModule*) pSh;
    2430                 :            :     }
    2431                 :            : }
    2432                 :            : 
    2433                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10