2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 11:22:20 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 11:22:20 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 11:22:20 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 11:22:20 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 11:22:20 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 11:22:20 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2011-11-22 09:34:46 +01:00
|
|
|
#include "sal/config.h"
|
|
|
|
|
|
|
|
#include <iomanip>
|
2006-09-17 15:25:51 +00:00
|
|
|
|
2011-02-05 13:18:52 +01:00
|
|
|
#include <boost/unordered_map.hpp>
|
2011-11-23 15:45:43 +01:00
|
|
|
#include <sal/log.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/itempool.hxx>
|
|
|
|
#include <svl/itemiter.hxx>
|
|
|
|
#include <svl/eitem.hxx>
|
|
|
|
#include <svl/aeitem.hxx>
|
|
|
|
#include <svl/intitem.hxx>
|
|
|
|
#include <svl/stritem.hxx>
|
|
|
|
#include <svl/visitem.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <com/sun/star/util/XURLTransformer.hpp>
|
|
|
|
#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
|
|
|
|
#include <com/sun/star/frame/XDispatch.hpp>
|
|
|
|
#include <com/sun/star/frame/XDispatchProvider.hpp>
|
|
|
|
#include <com/sun/star/frame/XStatusListener.hpp>
|
|
|
|
#include <com/sun/star/frame/FrameSearchFlag.hpp>
|
|
|
|
#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
|
|
|
|
#include <com/sun/star/frame/FeatureStateEvent.hpp>
|
|
|
|
#include <com/sun/star/frame/DispatchDescriptor.hpp>
|
|
|
|
#include <com/sun/star/frame/XController.hpp>
|
2000-10-23 11:26:53 +00:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2000-10-20 16:10:51 +00:00
|
|
|
#include <svtools/itemdel.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
//Includes below due to nInReschedule
|
2006-05-02 15:27:22 +00:00
|
|
|
#include "appdata.hxx"
|
2007-06-27 22:05:21 +00:00
|
|
|
#include <sfx2/bindings.hxx>
|
|
|
|
#include <sfx2/msg.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "statcach.hxx"
|
2007-06-27 22:05:21 +00:00
|
|
|
#include <sfx2/ctrlitem.hxx>
|
|
|
|
#include <sfx2/app.hxx>
|
|
|
|
#include <sfx2/dispatch.hxx>
|
|
|
|
#include <sfx2/request.hxx>
|
|
|
|
#include <sfx2/objface.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "sfxtypes.hxx"
|
|
|
|
#include "workwin.hxx"
|
2007-06-27 22:05:21 +00:00
|
|
|
#include <sfx2/unoctitm.hxx>
|
|
|
|
#include <sfx2/sfx.hrc>
|
|
|
|
#include <sfx2/sfxuno.hxx>
|
2009-11-30 12:56:04 +01:00
|
|
|
#include <sfx2/viewfrm.hxx>
|
2007-06-27 22:05:21 +00:00
|
|
|
#include <sfx2/objsh.hxx>
|
|
|
|
#include <sfx2/msgpool.hxx>
|
2008-11-19 16:40:06 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/frame/XModuleManager.hpp>
|
2008-07-17 14:31:31 +00:00
|
|
|
|
2011-05-25 22:11:49 -04:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-01-18 15:07:16 +00:00
|
|
|
using namespace ::com::sun::star;
|
2000-09-18 16:07:07 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
|
2006-06-19 21:16:10 +00:00
|
|
|
DBG_NAME(SfxBindingsMsgPos)
|
|
|
|
DBG_NAME(SfxBindingsUpdateServers)
|
|
|
|
DBG_NAME(SfxBindingsCreateSet)
|
|
|
|
DBG_NAME(SfxBindingsUpdateCtrl1)
|
|
|
|
DBG_NAME(SfxBindingsUpdateCtrl2)
|
|
|
|
DBG_NAME(SfxBindingsNextJob_Impl0)
|
|
|
|
DBG_NAME(SfxBindingsNextJob_Impl)
|
|
|
|
DBG_NAME(SfxBindingsUpdate_Impl)
|
|
|
|
DBG_NAME(SfxBindingsInvalidateAll)
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
|
2011-01-07 17:14:47 +01:00
|
|
|
static sal_uInt16 nTimeOut = 300;
|
2003-09-19 06:58:46 +00:00
|
|
|
|
|
|
|
#define TIMEOUT_FIRST nTimeOut
|
|
|
|
#define TIMEOUT_UPDATING 20
|
2000-09-18 16:07:07 +00:00
|
|
|
#define TIMEOUT_IDLE 2500
|
|
|
|
|
2011-03-12 18:57:32 -06:00
|
|
|
typedef boost::unordered_map< sal_uInt16, bool > InvalidateSlotMap;
|
2004-07-23 10:10:14 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
//====================================================================
|
|
|
|
|
2006-06-19 21:16:10 +00:00
|
|
|
DECL_PTRARRAY(SfxStateCacheArr_Impl, SfxStateCache*, 32, 16)
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
|
2002-06-27 06:56:58 +00:00
|
|
|
class SfxAsyncExec_Impl
|
|
|
|
{
|
|
|
|
::com::sun::star::util::URL aCommand;
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDisp;
|
|
|
|
Timer aTimer;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
SfxAsyncExec_Impl( const ::com::sun::star::util::URL& rCmd, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& rDisp )
|
|
|
|
: aCommand( rCmd )
|
|
|
|
, xDisp( rDisp )
|
|
|
|
{
|
|
|
|
aTimer.SetTimeoutHdl( LINK(this, SfxAsyncExec_Impl, TimerHdl) );
|
|
|
|
aTimer.SetTimeout( 0 );
|
|
|
|
aTimer.Start();
|
|
|
|
}
|
|
|
|
|
|
|
|
DECL_LINK( TimerHdl, Timer*);
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPL_LINK(SfxAsyncExec_Impl, TimerHdl, Timer*, pTimer)
|
|
|
|
{
|
2006-06-19 21:16:10 +00:00
|
|
|
(void)pTimer; // unused
|
2002-06-27 06:56:58 +00:00
|
|
|
aTimer.Stop();
|
|
|
|
|
2008-07-17 14:31:31 +00:00
|
|
|
Sequence<beans::PropertyValue> aSeq;
|
2002-06-27 06:56:58 +00:00
|
|
|
xDisp->dispatch( aCommand, aSeq );
|
|
|
|
|
|
|
|
delete this;
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
class SfxBindings_Impl
|
|
|
|
{
|
|
|
|
public:
|
2002-05-21 06:45:40 +00:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchRecorder > xRecorder;
|
2000-09-18 16:07:07 +00:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > xProv;
|
|
|
|
SfxUnoControllerArr_Impl*
|
|
|
|
pUnoCtrlArr;
|
|
|
|
SfxWorkWindow* pWorkWin;
|
|
|
|
SfxBindings* pSubBindings;
|
|
|
|
SfxBindings* pSuperBindings;
|
2011-01-26 21:04:40 +00:00
|
|
|
SfxStateCacheArr_Impl* pCaches; // One chache for each binding
|
|
|
|
sal_uInt16 nCachedFunc1; // index for the last one called
|
|
|
|
sal_uInt16 nCachedFunc2; // index for the second last called
|
|
|
|
sal_uInt16 nMsgPos; // Message-Position relative the one to be updated
|
|
|
|
SfxPopupAction ePopupAction; // Checked in DeleteFloatinWindow()
|
|
|
|
sal_Bool bContextChanged;
|
|
|
|
sal_Bool bMsgDirty; // Has a MessageServer been invalidated?
|
|
|
|
sal_Bool bAllMsgDirty; // Has a MessageServer been invalidated?
|
|
|
|
sal_Bool bAllDirty; // After InvalidateAll
|
|
|
|
sal_Bool bCtrlReleased; // while EnterRegistrations
|
|
|
|
AutoTimer aTimer; // for volatile Slots
|
|
|
|
sal_Bool bInUpdate; // for Assertions
|
|
|
|
sal_Bool bInNextJob; // for Assertions
|
|
|
|
sal_Bool bFirstRound; // First round in Update
|
|
|
|
sal_uInt16 nFirstShell; // Shell, the first round is prefered
|
|
|
|
sal_uInt16 nOwnRegLevel; // Counts the real Locks, exept those of the Super Bindings
|
|
|
|
InvalidateSlotMap m_aInvalidateSlots; // store slots which are invalidated while in update
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct SfxFoundCache_Impl
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
sal_uInt16 nSlotId; // the Slot-Id
|
|
|
|
sal_uInt16 nWhichId; // If available: Which-Id, else: nSlotId
|
|
|
|
const SfxSlot* pSlot; // Pointer to <Master-Slot>
|
|
|
|
SfxStateCache* pCache; // Pointer to StatusCache, if possible NULL
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
SfxFoundCache_Impl():
|
|
|
|
nSlotId(0),
|
|
|
|
nWhichId(0),
|
|
|
|
pSlot(0),
|
|
|
|
pCache(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
SfxFoundCache_Impl(SfxFoundCache_Impl&r):
|
|
|
|
nSlotId(r.nSlotId),
|
|
|
|
nWhichId(r.nWhichId),
|
|
|
|
pSlot(r.pSlot),
|
|
|
|
pCache(r.pCache)
|
|
|
|
{}
|
|
|
|
|
|
|
|
SfxFoundCache_Impl(sal_uInt16 nS, sal_uInt16 nW, const SfxSlot *pS, SfxStateCache *pC ):
|
|
|
|
nSlotId(nS),
|
|
|
|
nWhichId(nW),
|
|
|
|
pSlot(pS),
|
|
|
|
pCache(pC)
|
|
|
|
{}
|
|
|
|
|
|
|
|
int operator<( const SfxFoundCache_Impl &r ) const
|
2008-10-10 13:02:43 +00:00
|
|
|
{ return nWhichId < r.nWhichId; }
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2008-10-10 13:02:43 +00:00
|
|
|
int operator==( const SfxFoundCache_Impl &r ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{ return nWhichId== r.nWhichId; }
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
2012-01-21 15:21:16 +01:00
|
|
|
SV_DECL_PTRARR_SORT_DEL(SfxFoundCacheArr_Impl, SfxFoundCache_Impl*, 16)
|
2000-09-18 16:07:07 +00:00
|
|
|
SV_IMPL_OP_PTRARR_SORT(SfxFoundCacheArr_Impl, SfxFoundCache_Impl*);
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
SfxBindings::SfxBindings()
|
|
|
|
: pImp(new SfxBindings_Impl),
|
|
|
|
pDispatcher(0),
|
2011-01-26 21:04:40 +00:00
|
|
|
nRegLevel(1) // first becomes 0, when the Dispatcher is set
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
pImp->nMsgPos = 0;
|
|
|
|
pImp->bAllMsgDirty = sal_True;
|
2002-09-18 15:10:39 +00:00
|
|
|
pImp->bContextChanged = sal_False;
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->bMsgDirty = sal_True;
|
|
|
|
pImp->bAllDirty = sal_True;
|
|
|
|
pImp->ePopupAction = SFX_POPUP_DELETE;
|
|
|
|
pImp->nCachedFunc1 = 0;
|
|
|
|
pImp->nCachedFunc2 = 0;
|
|
|
|
pImp->bCtrlReleased = sal_False;
|
|
|
|
pImp->bFirstRound = sal_False;
|
|
|
|
pImp->bInNextJob = sal_False;
|
|
|
|
pImp->bInUpdate = sal_False;
|
|
|
|
pImp->pSubBindings = NULL;
|
|
|
|
pImp->pSuperBindings = NULL;
|
|
|
|
pImp->pWorkWin = NULL;
|
|
|
|
pImp->pUnoCtrlArr = NULL;
|
|
|
|
pImp->nOwnRegLevel = nRegLevel;
|
|
|
|
|
|
|
|
// all caches are valid (no pending invalidate-job)
|
|
|
|
// create the list of caches
|
|
|
|
pImp->pCaches = new SfxStateCacheArr_Impl;
|
|
|
|
pImp->aTimer.SetTimeoutHdl( LINK(this, SfxBindings, NextJob_Impl) );
|
|
|
|
}
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
|
|
|
|
SfxBindings::~SfxBindings()
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
/* [Description]
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
Destructor of the SfxBindings class. The one, for each <SfxApplication>
|
2011-03-10 16:47:00 +05:30
|
|
|
existing Instance is automatically destroyed by the <SfxApplication>
|
2011-01-26 21:04:40 +00:00
|
|
|
after the execution of <SfxApplication::Exit()>.
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
The still existing <SfxControllerItem> instances, which are registered
|
|
|
|
by the SfxBindings instance, are automatically destroyed in the Destructor.
|
|
|
|
These are usually the Floating-Toolboxen, Value-Sets
|
|
|
|
etc. Arrays of SfxControllerItems may at this time no longer exist.
|
2000-09-18 16:07:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// The SubBindings should not be locked!
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->pSubBindings = NULL;
|
|
|
|
|
|
|
|
ENTERREGISTRATIONS();
|
|
|
|
|
|
|
|
pImp->aTimer.Stop();
|
|
|
|
DeleteControllers_Impl();
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Delete Caches
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_uInt16 nCount = pImp->pCaches->Count();
|
|
|
|
for ( sal_uInt16 nCache = 0; nCache < nCount; ++nCache )
|
|
|
|
delete pImp->pCaches->GetObject(nCache);
|
|
|
|
|
2002-04-24 07:13:43 +00:00
|
|
|
DELETEZ( pImp->pWorkWin );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
delete pImp->pCaches;
|
|
|
|
delete pImp;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::DeleteControllers_Impl()
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// in the first round delete SfxPopupWindows
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_uInt16 nCount = pImp->pCaches->Count();
|
|
|
|
sal_uInt16 nCache;
|
|
|
|
for ( nCache = 0; nCache < nCount; ++nCache )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Remember were you are
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxStateCache *pCache = pImp->pCaches->GetObject(nCache);
|
|
|
|
sal_uInt16 nSlotId = pCache->GetId();
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Delete SfxPopupWindow
|
2000-09-18 16:07:07 +00:00
|
|
|
pCache->DeleteFloatingWindows();
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Re-align, because the cache may have been reduced
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_uInt16 nNewCount = pImp->pCaches->Count();
|
|
|
|
if ( nNewCount < nCount )
|
|
|
|
{
|
|
|
|
nCache = GetSlotPos(nSlotId);
|
|
|
|
if ( nCache >= nNewCount ||
|
|
|
|
nSlotId != pImp->pCaches->GetObject(nCache)->GetId() )
|
|
|
|
--nCache;
|
|
|
|
nCount = nNewCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Delete all Caches
|
2000-09-18 16:07:07 +00:00
|
|
|
for ( nCache = pImp->pCaches->Count(); nCache > 0; --nCache )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Get Cache via ::com::sun::star::sdbcx::Index
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxStateCache *pCache = pImp->pCaches->GetObject(nCache-1);
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// unbind all controllers in the cache
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxControllerItem *pNext;
|
|
|
|
for ( SfxControllerItem *pCtrl = pCache->GetItemLink();
|
|
|
|
pCtrl; pCtrl = pNext )
|
|
|
|
{
|
|
|
|
pNext = pCtrl->GetItemLink();
|
|
|
|
pCtrl->UnBind();
|
|
|
|
}
|
|
|
|
|
2005-01-18 15:07:16 +00:00
|
|
|
if ( pCache->GetInternalController() )
|
|
|
|
pCache->GetInternalController()->UnBind();
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Delete Cache
|
2000-09-18 16:07:07 +00:00
|
|
|
if( nCache-1 < pImp->pCaches->Count() )
|
|
|
|
delete (*pImp->pCaches)[nCache-1];
|
|
|
|
pImp->pCaches->Remove(nCache-1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pImp->pUnoCtrlArr )
|
|
|
|
{
|
2006-06-19 21:16:10 +00:00
|
|
|
sal_uInt16 nCtrlCount = pImp->pUnoCtrlArr->Count();
|
|
|
|
for ( sal_uInt16 n=nCtrlCount; n>0; n-- )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
SfxUnoControllerItem *pCtrl = (*pImp->pUnoCtrlArr)[n-1];
|
|
|
|
pCtrl->ReleaseBindings();
|
|
|
|
}
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
DBG_ASSERT( !pImp->pUnoCtrlArr->Count(), "Do not remove UnoControllerItems!" );
|
2000-09-18 16:07:07 +00:00
|
|
|
DELETEZ( pImp->pUnoCtrlArr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
2006-10-12 14:50:26 +00:00
|
|
|
void SfxBindings::HidePopups( bool bHide )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Hide SfxPopupWindows
|
2000-09-18 16:07:07 +00:00
|
|
|
HidePopupCtrls_Impl( bHide );
|
|
|
|
SfxBindings *pSub = pImp->pSubBindings;
|
|
|
|
while ( pSub )
|
|
|
|
{
|
|
|
|
pImp->pSubBindings->HidePopupCtrls_Impl( bHide );
|
|
|
|
pSub = pSub->pImp->pSubBindings;
|
|
|
|
}
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Hide SfxChildWindows
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_ASSERT( pDispatcher, "HidePopups not allowed without dispatcher" );
|
|
|
|
if ( pImp->pWorkWin )
|
|
|
|
pImp->pWorkWin->HidePopups_Impl( bHide, sal_True );
|
|
|
|
}
|
|
|
|
|
2010-10-05 07:57:54 -05:00
|
|
|
void SfxBindings::HidePopupCtrls_Impl( bool bHide )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( bHide )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Hide SfxPopupWindows
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->ePopupAction = SFX_POPUP_HIDE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Show SfxPopupWindows
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->ePopupAction = SFX_POPUP_SHOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( sal_uInt16 nCache = 0; nCache < pImp->pCaches->Count(); ++nCache )
|
|
|
|
pImp->pCaches->GetObject(nCache)->DeleteFloatingWindows();
|
|
|
|
pImp->ePopupAction = SFX_POPUP_DELETE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::Update_Impl
|
|
|
|
(
|
2011-01-26 21:04:40 +00:00
|
|
|
SfxStateCache* pCache // The up to date SfxStatusCache
|
2000-09-18 16:07:07 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
if( pCache->GetDispatch().is() && pCache->GetItemLink() )
|
|
|
|
{
|
2011-01-07 17:14:47 +01:00
|
|
|
pCache->SetCachedState(sal_True);
|
2005-01-18 15:07:16 +00:00
|
|
|
if ( !pCache->GetInternalController() )
|
|
|
|
return;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !pDispatcher )
|
|
|
|
return;
|
|
|
|
DBG_PROFSTART(SfxBindingsUpdate_Impl);
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// gather together all with the same status method which are dirty
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxDispatcher &rDispat = *pDispatcher;
|
|
|
|
const SfxSlot *pRealSlot = 0;
|
|
|
|
const SfxSlotServer* pMsgServer = 0;
|
|
|
|
SfxFoundCacheArr_Impl aFound;
|
|
|
|
SfxItemSet *pSet = CreateSet_Impl( pCache, pRealSlot, &pMsgServer, aFound );
|
|
|
|
sal_Bool bUpdated = sal_False;
|
|
|
|
if ( pSet )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Query Status
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( rDispat._FillState( *pMsgServer, *pSet, pRealSlot ) )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Post Status
|
2000-09-18 16:07:07 +00:00
|
|
|
const SfxInterface *pInterface =
|
|
|
|
rDispat.GetShell(pMsgServer->GetShellLevel())->GetInterface();
|
|
|
|
for ( sal_uInt16 nPos = 0; nPos < aFound.Count(); ++nPos )
|
|
|
|
{
|
|
|
|
const SfxFoundCache_Impl *pFound = aFound[nPos];
|
|
|
|
sal_uInt16 nWhich = pFound->nWhichId;
|
|
|
|
const SfxPoolItem *pItem = 0;
|
|
|
|
SfxItemState eState = pSet->GetItemState(nWhich, sal_True, &pItem);
|
|
|
|
if ( eState == SFX_ITEM_DEFAULT && SfxItemPool::IsWhich(nWhich) )
|
|
|
|
pItem = &pSet->Get(nWhich);
|
|
|
|
UpdateControllers_Impl( pInterface, aFound[nPos], pItem, eState );
|
|
|
|
}
|
|
|
|
bUpdated = sal_True;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete pSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bUpdated && pCache )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// When pCache == NULL and no SlotServer
|
|
|
|
// (for example due to locked Dispatcher! ),
|
|
|
|
// obviously do not try to update
|
2006-06-19 21:16:10 +00:00
|
|
|
SfxFoundCache_Impl aFoundCache(
|
|
|
|
pCache->GetId(), 0,
|
|
|
|
pRealSlot, pCache );
|
|
|
|
UpdateControllers_Impl( 0, &aFoundCache, 0, SFX_ITEM_DISABLED);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DBG_PROFSTOP(SfxBindingsUpdate_Impl);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
2004-07-23 10:10:14 +00:00
|
|
|
void SfxBindings::InvalidateSlotsInMap_Impl()
|
|
|
|
{
|
|
|
|
InvalidateSlotMap::const_iterator pIter = pImp->m_aInvalidateSlots.begin();
|
|
|
|
while ( pIter != pImp->m_aInvalidateSlots.end() )
|
|
|
|
{
|
|
|
|
Invalidate( pIter->first );
|
|
|
|
++pIter;
|
|
|
|
}
|
|
|
|
pImp->m_aInvalidateSlots.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
2011-01-07 17:14:47 +01:00
|
|
|
void SfxBindings::AddSlotToInvalidateSlotsMap_Impl( sal_uInt16 nId )
|
2004-07-23 10:10:14 +00:00
|
|
|
{
|
|
|
|
pImp->m_aInvalidateSlots[nId] = sal_True;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SfxBindings::Update
|
|
|
|
(
|
2011-01-26 21:04:40 +00:00
|
|
|
sal_uInt16 nId // the bound and up-to-date Slot-Id
|
2000-09-18 16:07:07 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" );
|
|
|
|
|
|
|
|
if ( pDispatcher )
|
|
|
|
pDispatcher->Flush();
|
|
|
|
|
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
pImp->pSubBindings->Update( nId );
|
|
|
|
|
|
|
|
SfxStateCache* pCache = GetStateCache( nId );
|
|
|
|
if ( pCache )
|
|
|
|
{
|
|
|
|
pImp->bInUpdate = sal_True;
|
|
|
|
if ( pImp->bMsgDirty )
|
|
|
|
{
|
|
|
|
UpdateSlotServer_Impl();
|
|
|
|
pCache = GetStateCache( nId );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pCache)
|
|
|
|
{
|
2011-01-07 17:14:47 +01:00
|
|
|
sal_Bool bInternalUpdate = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
if( pCache->GetDispatch().is() && pCache->GetItemLink() )
|
|
|
|
{
|
2011-01-07 17:14:47 +01:00
|
|
|
pCache->SetCachedState(sal_True);
|
2005-01-18 15:07:16 +00:00
|
|
|
bInternalUpdate = ( pCache->GetInternalController() != 0 );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2005-01-18 15:07:16 +00:00
|
|
|
|
|
|
|
if ( bInternalUpdate )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Query Status
|
2000-10-20 16:10:51 +00:00
|
|
|
const SfxSlotServer* pMsgServer = pCache->GetSlotServer(*pDispatcher, pImp->xProv);
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !pCache->IsControllerDirty() &&
|
|
|
|
( !pMsgServer ||
|
|
|
|
!pMsgServer->GetSlot()->IsMode(SFX_SLOT_VOLATILE) ) )
|
|
|
|
{
|
|
|
|
pImp->bInUpdate = sal_False;
|
2004-07-23 10:10:14 +00:00
|
|
|
InvalidateSlotsInMap_Impl();
|
2000-09-18 16:07:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!pMsgServer)
|
|
|
|
{
|
|
|
|
pCache->SetState(SFX_ITEM_DISABLED, 0);
|
|
|
|
pImp->bInUpdate = sal_False;
|
2004-07-23 10:10:14 +00:00
|
|
|
InvalidateSlotsInMap_Impl();
|
2000-09-18 16:07:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Update_Impl(pCache);
|
|
|
|
}
|
|
|
|
|
|
|
|
pImp->bAllDirty = sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
pImp->bInUpdate = sal_False;
|
2004-07-23 10:10:14 +00:00
|
|
|
InvalidateSlotsInMap_Impl();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::Update()
|
|
|
|
{
|
|
|
|
DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" );
|
|
|
|
|
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
pImp->pSubBindings->Update();
|
|
|
|
|
|
|
|
if ( pDispatcher )
|
|
|
|
{
|
|
|
|
if ( nRegLevel )
|
|
|
|
return;
|
|
|
|
|
|
|
|
pImp->bInUpdate = sal_True;
|
|
|
|
pDispatcher->Flush();
|
|
|
|
pDispatcher->Update_Impl();
|
|
|
|
while ( !NextJob_Impl(0) )
|
|
|
|
; // loop
|
|
|
|
pImp->bInUpdate = sal_False;
|
2004-07-23 10:10:14 +00:00
|
|
|
InvalidateSlotsInMap_Impl();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::SetState
|
|
|
|
(
|
2011-01-26 21:04:40 +00:00
|
|
|
const SfxItemSet& rSet // status values to be set
|
2000-09-18 16:07:07 +00:00
|
|
|
)
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// when locked then only invalidate
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nRegLevel )
|
|
|
|
{
|
|
|
|
SfxItemIter aIter(rSet);
|
|
|
|
for ( const SfxPoolItem *pItem = aIter.FirstItem();
|
|
|
|
pItem;
|
|
|
|
pItem = aIter.NextItem() )
|
|
|
|
Invalidate( pItem->Which() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Status may be accepted only if all slot-pointers are set
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pImp->bMsgDirty )
|
|
|
|
UpdateSlotServer_Impl();
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Iterate over the itemset, update if the slot bound
|
|
|
|
//! Bug: Use WhichIter and possibly send VoidItems up
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxItemIter aIter(rSet);
|
|
|
|
for ( const SfxPoolItem *pItem = aIter.FirstItem();
|
|
|
|
pItem;
|
|
|
|
pItem = aIter.NextItem() )
|
|
|
|
{
|
|
|
|
SfxStateCache* pCache =
|
|
|
|
GetStateCache( rSet.GetPool()->GetSlotId(pItem->Which()) );
|
|
|
|
if ( pCache )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Update status
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !pCache->IsControllerDirty() )
|
|
|
|
pCache->Invalidate(sal_False);
|
|
|
|
pCache->SetState( SFX_ITEM_AVAILABLE, pItem );
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
//! Not implemented: Updates from EnumSlots via master slots
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::SetState
|
|
|
|
(
|
2011-01-26 21:04:40 +00:00
|
|
|
const SfxPoolItem& rItem // Status value to be set
|
2000-09-18 16:07:07 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
if ( nRegLevel )
|
|
|
|
{
|
|
|
|
Invalidate( rItem.Which() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Status may be accepted only if all slot-pointers are set
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pImp->bMsgDirty )
|
|
|
|
UpdateSlotServer_Impl();
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
//update if the slot bound
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_ASSERT( SfxItemPool::IsSlot( rItem.Which() ),
|
|
|
|
"cannot set items with which-id" );
|
|
|
|
SfxStateCache* pCache = GetStateCache( rItem.Which() );
|
|
|
|
if ( pCache )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Update Status
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !pCache->IsControllerDirty() )
|
|
|
|
pCache->Invalidate(sal_False);
|
|
|
|
pCache->SetState( SFX_ITEM_AVAILABLE, &rItem );
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
//! Not implemented: Updates from EnumSlots via master slots
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
SfxStateCache* SfxBindings::GetAnyStateCache_Impl( sal_uInt16 nId )
|
|
|
|
{
|
|
|
|
SfxStateCache* pCache = GetStateCache( nId );
|
|
|
|
if ( !pCache && pImp->pSubBindings )
|
|
|
|
return pImp->pSubBindings->GetAnyStateCache_Impl( nId );
|
|
|
|
return pCache;
|
|
|
|
}
|
|
|
|
|
|
|
|
SfxStateCache* SfxBindings::GetStateCache
|
|
|
|
(
|
2011-01-26 21:04:40 +00:00
|
|
|
sal_uInt16 nId, /* Slot-Id, which SfxStatusCache is to be found */
|
|
|
|
sal_uInt16* pPos /* NULL for instance the position from which the
|
|
|
|
bindings are to be searched binary. Returns the
|
|
|
|
position back for where the nId was found,
|
|
|
|
or where it was inserted. */
|
2000-09-18 16:07:07 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" );
|
|
|
|
// is the specified function bound?
|
|
|
|
const sal_uInt16 nStart = ( pPos ? *pPos : 0 );
|
|
|
|
const sal_uInt16 nPos = GetSlotPos( nId, nStart );
|
|
|
|
|
|
|
|
if ( nPos < pImp->pCaches->Count() &&
|
|
|
|
(*pImp->pCaches)[nPos]->GetId() == nId )
|
|
|
|
{
|
|
|
|
if ( pPos )
|
|
|
|
*pPos = nPos;
|
|
|
|
return (*pImp->pCaches)[nPos];
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::InvalidateAll
|
|
|
|
(
|
2011-01-26 21:04:40 +00:00
|
|
|
sal_Bool bWithMsg /* sal_True Mark Slot Server as invalid
|
|
|
|
sal_False Slot Server remains valid */
|
2000-09-18 16:07:07 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
DBG_PROFSTART(SfxBindingsInvalidateAll);
|
|
|
|
DBG_ASSERT( !pImp->bInUpdate, "SfxBindings::Invalidate while in update" );
|
|
|
|
|
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
pImp->pSubBindings->InvalidateAll( bWithMsg );
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// everything is already set dirty or downing => nothing to do
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !pDispatcher ||
|
|
|
|
( pImp->bAllDirty && ( !bWithMsg || pImp->bAllMsgDirty ) ) ||
|
|
|
|
SFX_APP()->IsDowning() )
|
|
|
|
{
|
|
|
|
DBG_PROFSTOP(SfxBindingsInvalidateAll);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pImp->bAllMsgDirty = pImp->bAllMsgDirty || bWithMsg;
|
|
|
|
pImp->bMsgDirty = pImp->bMsgDirty || pImp->bAllMsgDirty || bWithMsg;
|
|
|
|
pImp->bAllDirty = sal_True;
|
|
|
|
|
|
|
|
for ( sal_uInt16 n = 0; n < pImp->pCaches->Count(); ++n )
|
|
|
|
pImp->pCaches->GetObject(n)->Invalidate(bWithMsg);
|
2002-03-07 17:07:50 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->nMsgPos = 0;
|
|
|
|
if ( !nRegLevel )
|
|
|
|
{
|
2003-09-19 06:58:46 +00:00
|
|
|
pImp->aTimer.Stop();
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->aTimer.SetTimeout(TIMEOUT_FIRST);
|
|
|
|
pImp->aTimer.Start();
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG_PROFSTOP(SfxBindingsInvalidateAll);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::Invalidate
|
|
|
|
(
|
2011-01-26 21:04:40 +00:00
|
|
|
const sal_uInt16* pIds /* numerically sorted NULL-terminated array of
|
|
|
|
slot IDs (individual, not as a couple!) */
|
2000-09-18 16:07:07 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
DBG_PROFSTART(SfxBindingsInvalidateAll);
|
|
|
|
|
2004-07-23 10:10:14 +00:00
|
|
|
if ( pImp->bInUpdate )
|
|
|
|
{
|
|
|
|
sal_Int32 i = 0;
|
|
|
|
while ( pIds[i] != 0 )
|
|
|
|
AddSlotToInvalidateSlotsMap_Impl( pIds[i++] );
|
|
|
|
|
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
pImp->pSubBindings->Invalidate( pIds );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
pImp->pSubBindings->Invalidate( pIds );
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// everything is already set dirty or downing => nothing to do
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !pDispatcher || pImp->bAllDirty || SFX_APP()->IsDowning() )
|
|
|
|
return;
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Search binary in always smaller areas
|
2000-09-18 16:07:07 +00:00
|
|
|
for ( sal_uInt16 n = GetSlotPos(*pIds);
|
|
|
|
*pIds && n < pImp->pCaches->Count();
|
|
|
|
n = GetSlotPos(*pIds, n) )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// If SID is ever bound, then invalidate the cache
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxStateCache *pCache = pImp->pCaches->GetObject(n);
|
|
|
|
if ( pCache->GetId() == *pIds )
|
|
|
|
pCache->Invalidate(sal_False);
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Next SID
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !*++pIds )
|
|
|
|
break;
|
|
|
|
DBG_ASSERT( *pIds > *(pIds-1), "pIds unsorted" );
|
|
|
|
}
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// if not enticed to start update timer
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->nMsgPos = 0;
|
|
|
|
if ( !nRegLevel )
|
|
|
|
{
|
2003-09-19 06:58:46 +00:00
|
|
|
pImp->aTimer.Stop();
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->aTimer.SetTimeout(TIMEOUT_FIRST);
|
|
|
|
pImp->aTimer.Start();
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG_PROFSTOP(SfxBindingsInvalidateAll);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::InvalidateShell
|
|
|
|
(
|
2011-01-26 21:04:40 +00:00
|
|
|
const SfxShell& rSh, /* <SfxShell>, which Slot-Ids should be
|
|
|
|
invalidated */
|
|
|
|
sal_Bool bDeep /* sal_True
|
|
|
|
also inherited slot IDs of SfxShell are invalidert
|
|
|
|
|
|
|
|
sal_False
|
|
|
|
the inherited and not overloaded Slot-Ids were
|
|
|
|
invalidiert */
|
2011-03-10 16:47:00 +05:30
|
|
|
// for now always bDeep
|
2000-09-18 16:07:07 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
DBG_ASSERT( !pImp->bInUpdate, "SfxBindings::Invalidate while in update" );
|
|
|
|
|
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
pImp->pSubBindings->InvalidateShell( rSh, bDeep );
|
|
|
|
|
|
|
|
if ( !pDispatcher || pImp->bAllDirty || SFX_APP()->IsDowning() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
DBG_PROFSTART(SfxBindingsInvalidateAll);
|
|
|
|
|
2011-03-10 16:47:00 +05:30
|
|
|
// flush now already, it is done in GetShellLevel (rsh) anyway,
|
|
|
|
// important so that is set correctly: pimp-> ball(Msg)Dirty
|
2000-09-18 16:07:07 +00:00
|
|
|
pDispatcher->Flush();
|
|
|
|
|
|
|
|
if ( !pDispatcher ||
|
|
|
|
( pImp->bAllDirty && pImp->bAllMsgDirty ) ||
|
|
|
|
SFX_APP()->IsDowning() )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// if the next one is anyway, then all the servers are collected
|
2000-09-18 16:07:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Find Level
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_uInt16 nLevel = pDispatcher->GetShellLevel(rSh);
|
|
|
|
if ( nLevel != USHRT_MAX )
|
|
|
|
{
|
|
|
|
for ( sal_uInt16 n = 0; n < pImp->pCaches->Count(); ++n )
|
|
|
|
{
|
|
|
|
SfxStateCache *pCache = pImp->pCaches->GetObject(n);
|
|
|
|
const SfxSlotServer *pMsgServer =
|
|
|
|
pCache->GetSlotServer(*pDispatcher, pImp->xProv);
|
|
|
|
if ( pMsgServer && pMsgServer->GetShellLevel() == nLevel )
|
|
|
|
pCache->Invalidate(sal_False);
|
|
|
|
}
|
|
|
|
pImp->nMsgPos = 0;
|
|
|
|
if ( !nRegLevel )
|
|
|
|
{
|
2003-09-19 06:58:46 +00:00
|
|
|
pImp->aTimer.Stop();
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->aTimer.SetTimeout(TIMEOUT_FIRST);
|
|
|
|
pImp->aTimer.Start();
|
|
|
|
pImp->bFirstRound = sal_True;
|
|
|
|
pImp->nFirstShell = nLevel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG_PROFSTOP(SfxBindingsInvalidateAll);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::Invalidate
|
|
|
|
(
|
2011-01-26 21:04:40 +00:00
|
|
|
sal_uInt16 nId // Status value to be set
|
2000-09-18 16:07:07 +00:00
|
|
|
)
|
|
|
|
{
|
2004-07-23 10:10:14 +00:00
|
|
|
if ( pImp->bInUpdate )
|
|
|
|
{
|
|
|
|
AddSlotToInvalidateSlotsMap_Impl( nId );
|
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
pImp->pSubBindings->Invalidate( nId );
|
|
|
|
return;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
pImp->pSubBindings->Invalidate( nId );
|
|
|
|
|
|
|
|
if ( !pDispatcher || pImp->bAllDirty || SFX_APP()->IsDowning() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
SfxStateCache* pCache = GetStateCache(nId);
|
|
|
|
if ( pCache )
|
|
|
|
{
|
|
|
|
pCache->Invalidate(sal_False);
|
|
|
|
pImp->nMsgPos = Min(GetSlotPos(nId), pImp->nMsgPos);
|
|
|
|
if ( !nRegLevel )
|
|
|
|
{
|
2003-09-19 06:58:46 +00:00
|
|
|
pImp->aTimer.Stop();
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->aTimer.SetTimeout(TIMEOUT_FIRST);
|
|
|
|
pImp->aTimer.Start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::Invalidate
|
|
|
|
(
|
2011-01-26 21:04:40 +00:00
|
|
|
sal_uInt16 nId, // Status value to be set
|
|
|
|
sal_Bool bWithItem, // Clear StateCache?
|
|
|
|
sal_Bool bWithMsg // Get new SlotServer?
|
2000-09-18 16:07:07 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
DBG_ASSERT( !pImp->bInUpdate, "SfxBindings::Invalidate while in update" );
|
|
|
|
|
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
pImp->pSubBindings->Invalidate( nId, bWithItem, bWithMsg );
|
|
|
|
|
|
|
|
if ( SFX_APP()->IsDowning() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
SfxStateCache* pCache = GetStateCache(nId);
|
|
|
|
if ( pCache )
|
|
|
|
{
|
|
|
|
if ( bWithItem )
|
|
|
|
pCache->ClearCache();
|
|
|
|
pCache->Invalidate(bWithMsg);
|
|
|
|
|
|
|
|
if ( !pDispatcher || pImp->bAllDirty )
|
|
|
|
return;
|
|
|
|
|
|
|
|
pImp->nMsgPos = Min(GetSlotPos(nId), pImp->nMsgPos);
|
|
|
|
if ( !nRegLevel )
|
|
|
|
{
|
2003-09-19 06:58:46 +00:00
|
|
|
pImp->aTimer.Stop();
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->aTimer.SetTimeout(TIMEOUT_FIRST);
|
|
|
|
pImp->aTimer.Start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Bool SfxBindings::IsBound( sal_uInt16 nSlotId, sal_uInt16 nStartSearchAt )
|
|
|
|
{
|
|
|
|
DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" );
|
|
|
|
return GetStateCache(nSlotId, &nStartSearchAt ) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_uInt16 SfxBindings::GetSlotPos( sal_uInt16 nId, sal_uInt16 nStartSearchAt )
|
|
|
|
{
|
|
|
|
DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" );
|
|
|
|
DBG_PROFSTART(SfxBindingsMsgPos);
|
|
|
|
|
|
|
|
// answer immediately if a function-seek comes repeated
|
|
|
|
if ( pImp->nCachedFunc1 < pImp->pCaches->Count() &&
|
|
|
|
(*pImp->pCaches)[pImp->nCachedFunc1]->GetId() == nId )
|
|
|
|
{
|
|
|
|
DBG_PROFSTOP(SfxBindingsMsgPos);
|
|
|
|
return pImp->nCachedFunc1;
|
|
|
|
}
|
|
|
|
if ( pImp->nCachedFunc2 < pImp->pCaches->Count() &&
|
|
|
|
(*pImp->pCaches)[pImp->nCachedFunc2]->GetId() == nId )
|
|
|
|
{
|
|
|
|
// swap the caches
|
|
|
|
sal_uInt16 nTemp = pImp->nCachedFunc1;
|
|
|
|
pImp->nCachedFunc1 = pImp->nCachedFunc2;
|
|
|
|
pImp->nCachedFunc2 = nTemp;
|
|
|
|
DBG_PROFSTOP(SfxBindingsMsgPos);
|
|
|
|
return pImp->nCachedFunc1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// binary search, if not found, seek to target-position
|
|
|
|
if ( pImp->pCaches->Count() <= nStartSearchAt )
|
|
|
|
{
|
|
|
|
DBG_PROFSTOP(SfxBindingsMsgPos);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if ( pImp->pCaches->Count() == (nStartSearchAt+1) )
|
|
|
|
{
|
|
|
|
DBG_PROFSTOP(SfxBindingsMsgPos);
|
|
|
|
return (*pImp->pCaches)[nStartSearchAt]->GetId() >= nId ? 0 : 1;
|
|
|
|
}
|
2006-10-12 14:50:26 +00:00
|
|
|
sal_uInt16 nLow = nStartSearchAt;
|
|
|
|
sal_uInt16 nMid = 0;
|
|
|
|
sal_uInt16 nHigh = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_Bool bFound = sal_False;
|
|
|
|
nHigh = pImp->pCaches->Count() - 1;
|
|
|
|
while ( !bFound && nLow <= nHigh )
|
|
|
|
{
|
|
|
|
nMid = (nLow + nHigh) >> 1;
|
2011-01-26 21:04:40 +00:00
|
|
|
DBG_ASSERT( nMid < pImp->pCaches->Count(), "bsearch is buggy" );
|
2000-09-18 16:07:07 +00:00
|
|
|
int nDiff = (int) nId - (int) ( ((*pImp->pCaches)[nMid])->GetId() );
|
|
|
|
if ( nDiff < 0)
|
|
|
|
{ if ( nMid == 0 )
|
|
|
|
break;
|
|
|
|
nHigh = nMid - 1;
|
|
|
|
}
|
|
|
|
else if ( nDiff > 0 )
|
|
|
|
{ nLow = nMid + 1;
|
|
|
|
if ( nLow == 0 )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bFound = sal_True;
|
|
|
|
}
|
|
|
|
sal_uInt16 nPos = bFound ? nMid : nLow;
|
|
|
|
DBG_ASSERT( nPos <= pImp->pCaches->Count(), "" );
|
|
|
|
DBG_ASSERT( nPos == pImp->pCaches->Count() ||
|
|
|
|
nId <= (*pImp->pCaches)[nPos]->GetId(), "" );
|
|
|
|
DBG_ASSERT( nPos == nStartSearchAt ||
|
|
|
|
nId > (*pImp->pCaches)[nPos-1]->GetId(), "" );
|
|
|
|
DBG_ASSERT( ( (nPos+1) >= pImp->pCaches->Count() ) ||
|
|
|
|
nId < (*pImp->pCaches)[nPos+1]->GetId(), "" );
|
|
|
|
pImp->nCachedFunc2 = pImp->nCachedFunc1;
|
|
|
|
pImp->nCachedFunc1 = nPos;
|
|
|
|
DBG_PROFSTOP(SfxBindingsMsgPos);
|
|
|
|
return nPos;
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------
|
2005-01-18 15:07:16 +00:00
|
|
|
void SfxBindings::RegisterInternal_Impl( SfxControllerItem& rItem )
|
|
|
|
{
|
2011-01-07 17:14:47 +01:00
|
|
|
Register_Impl( rItem, sal_True );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-01-18 15:07:16 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-01-18 15:07:16 +00:00
|
|
|
void SfxBindings::Register( SfxControllerItem& rItem )
|
|
|
|
{
|
2011-01-07 17:14:47 +01:00
|
|
|
Register_Impl( rItem, sal_False );
|
2005-01-18 15:07:16 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-07 17:14:47 +01:00
|
|
|
void SfxBindings::Register_Impl( SfxControllerItem& rItem, sal_Bool bInternal )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( nRegLevel > 0, "registration without EnterRegistrations" );
|
|
|
|
DBG_ASSERT( !pImp->bInNextJob, "SfxBindings::Register while status-updating" );
|
|
|
|
|
2005-01-18 15:07:16 +00:00
|
|
|
// insert new cache if it does not already exist
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_uInt16 nId = rItem.GetId();
|
|
|
|
sal_uInt16 nPos = GetSlotPos(nId);
|
|
|
|
if ( nPos >= pImp->pCaches->Count() ||
|
|
|
|
(*pImp->pCaches)[nPos]->GetId() != nId )
|
|
|
|
{
|
|
|
|
SfxStateCache* pCache = new SfxStateCache(nId);
|
|
|
|
pImp->pCaches->Insert( nPos, pCache );
|
|
|
|
DBG_ASSERT( nPos == 0 ||
|
|
|
|
(*pImp->pCaches)[nPos]->GetId() >
|
|
|
|
(*pImp->pCaches)[nPos-1]->GetId(), "" );
|
|
|
|
DBG_ASSERT( (nPos == pImp->pCaches->Count()-1) ||
|
|
|
|
(*pImp->pCaches)[nPos]->GetId() <
|
|
|
|
(*pImp->pCaches)[nPos+1]->GetId(), "" );
|
|
|
|
pImp->bMsgDirty = sal_True;
|
|
|
|
}
|
|
|
|
|
|
|
|
// enqueue the new binding
|
2005-01-18 15:07:16 +00:00
|
|
|
if ( bInternal )
|
|
|
|
{
|
|
|
|
(*pImp->pCaches)[nPos]->SetInternalController( &rItem );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SfxControllerItem *pOldItem = (*pImp->pCaches)[nPos]->ChangeItemLink(&rItem);
|
|
|
|
rItem.ChangeItemLink(pOldItem);
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2005-01-18 15:07:16 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::Release( SfxControllerItem& rItem )
|
|
|
|
{
|
|
|
|
DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" );
|
|
|
|
DBG_ASSERT( !pImp->bInNextJob, "SfxBindings::Release while status-updating" );
|
|
|
|
ENTERREGISTRATIONS();
|
|
|
|
|
|
|
|
// find the bound function
|
|
|
|
sal_uInt16 nId = rItem.GetId();
|
|
|
|
sal_uInt16 nPos = GetSlotPos(nId);
|
|
|
|
SfxStateCache* pCache = (*pImp->pCaches)[nPos];
|
|
|
|
if ( pCache->GetId() == nId )
|
|
|
|
{
|
2005-01-18 15:07:16 +00:00
|
|
|
if ( pCache->GetInternalController() == &rItem )
|
|
|
|
{
|
|
|
|
pCache->ReleaseInternalController();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
{
|
2005-01-18 15:07:16 +00:00
|
|
|
// is this the first binding in the list?
|
|
|
|
SfxControllerItem* pItem = pCache->GetItemLink();
|
|
|
|
if ( pItem == &rItem )
|
|
|
|
pCache->ChangeItemLink( rItem.GetItemLink() );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// search the binding in the list
|
|
|
|
while ( pItem && pItem->GetItemLink() != &rItem )
|
|
|
|
pItem = pItem->GetItemLink();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2005-01-18 15:07:16 +00:00
|
|
|
// unlink it if it was found
|
|
|
|
if ( pItem )
|
|
|
|
pItem->ChangeItemLink( rItem.GetItemLink() );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2005-01-18 15:07:16 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// was this the last controller?
|
2005-01-18 15:07:16 +00:00
|
|
|
if ( pCache->GetItemLink() == 0 && !pCache->GetInternalController() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-02-07 17:05:48 +01:00
|
|
|
pImp->bCtrlReleased = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LEAVEREGISTRATIONS();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2000-10-20 16:10:51 +00:00
|
|
|
const SfxPoolItem* SfxBindings::ExecuteSynchron( sal_uInt16 nId, const SfxPoolItem** ppItems, sal_uInt16 nModi,
|
|
|
|
const SfxPoolItem **ppInternalArgs )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-10-20 16:10:51 +00:00
|
|
|
DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" );
|
|
|
|
|
|
|
|
if( !nId || !pDispatcher )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return Execute_Impl( nId, ppItems, nModi, SFX_CALLMODE_SYNCHRON, ppInternalArgs );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2000-10-20 16:10:51 +00:00
|
|
|
sal_Bool SfxBindings::Execute( sal_uInt16 nId, const SfxPoolItem** ppItems, sal_uInt16 nModi, SfxCallMode nCallMode,
|
|
|
|
const SfxPoolItem **ppInternalArgs )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" );
|
|
|
|
|
|
|
|
if( !nId || !pDispatcher )
|
|
|
|
return sal_False;
|
|
|
|
|
2000-10-20 16:10:51 +00:00
|
|
|
const SfxPoolItem* pRet = Execute_Impl( nId, ppItems, nModi, nCallMode, ppInternalArgs );
|
|
|
|
return ( pRet != 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
const SfxPoolItem* SfxBindings::Execute_Impl( sal_uInt16 nId, const SfxPoolItem** ppItems, sal_uInt16 nModi, SfxCallMode nCallMode,
|
2011-01-07 17:14:47 +01:00
|
|
|
const SfxPoolItem **ppInternalArgs, sal_Bool bGlobalOnly )
|
2000-10-20 16:10:51 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxStateCache *pCache = GetStateCache( nId );
|
|
|
|
if ( !pCache )
|
|
|
|
{
|
|
|
|
SfxBindings *pBind = pImp->pSubBindings;
|
|
|
|
while ( pBind )
|
|
|
|
{
|
|
|
|
if ( pBind->GetStateCache( nId ) )
|
2003-05-28 12:25:06 +00:00
|
|
|
return pBind->Execute_Impl( nId, ppItems, nModi, nCallMode, ppInternalArgs, bGlobalOnly );
|
2000-09-18 16:07:07 +00:00
|
|
|
pBind = pBind->pImp->pSubBindings;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
SfxDispatcher &rDispatcher = *pDispatcher;
|
|
|
|
rDispatcher.Flush();
|
2004-09-08 14:38:39 +00:00
|
|
|
rDispatcher.GetFrame(); // -Wall is this required???
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-06-03 08:32:42 +00:00
|
|
|
// get SlotServer (Slot+ShellLevel) and Shell from cache
|
2011-05-25 22:11:49 -04:00
|
|
|
::boost::scoped_ptr<SfxStateCache> xCache;
|
2000-10-20 16:10:51 +00:00
|
|
|
if ( !pCache )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-06-03 08:32:42 +00:00
|
|
|
// Execution of non cached slots (Accelerators don't use Controllers)
|
|
|
|
// slot is uncached, use SlotCache to handle external dispatch providers
|
2011-05-25 22:11:49 -04:00
|
|
|
xCache.reset(new SfxStateCache(nId));
|
|
|
|
pCache = xCache.get();
|
2000-09-18 16:07:07 +00:00
|
|
|
pCache->GetSlotServer( rDispatcher, pImp->xProv );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pCache && pCache->GetDispatch().is() )
|
|
|
|
{
|
2009-02-19 08:26:23 +00:00
|
|
|
DBG_ASSERT( !ppInternalArgs, "Internal args get lost when dispatched!" );
|
|
|
|
|
|
|
|
SfxItemPool &rPool = GetDispatcher()->GetFrame()->GetObjectShell()->GetPool();
|
|
|
|
SfxRequest aReq( nId, nCallMode, rPool );
|
|
|
|
aReq.SetModifier( nModi );
|
|
|
|
if( ppItems )
|
|
|
|
while( *ppItems )
|
|
|
|
aReq.AppendItem( **ppItems++ );
|
|
|
|
|
2002-06-03 08:32:42 +00:00
|
|
|
// cache binds to an external dispatch provider
|
2009-02-19 08:26:23 +00:00
|
|
|
pCache->Dispatch( aReq.GetArgs(), nCallMode == SFX_CALLMODE_SYNCHRON );
|
2000-10-20 16:10:51 +00:00
|
|
|
SfxPoolItem *pVoid = new SfxVoidItem( nId );
|
|
|
|
DeleteItemOnIdle( pVoid );
|
|
|
|
return pVoid;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-06-03 08:32:42 +00:00
|
|
|
// slot is handled internally by SfxDispatcher
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pImp->bMsgDirty )
|
|
|
|
UpdateSlotServer_Impl();
|
|
|
|
|
|
|
|
SfxShell *pShell=0;
|
|
|
|
const SfxSlot *pSlot=0;
|
|
|
|
|
2002-06-03 08:32:42 +00:00
|
|
|
// if slot was uncached, we should have created a cache in this method!
|
|
|
|
DBG_ASSERT( pCache, "This code needs a cache!");
|
2000-09-18 16:07:07 +00:00
|
|
|
const SfxSlotServer* pServer = pCache ? pCache->GetSlotServer( rDispatcher, pImp->xProv ) : 0;
|
|
|
|
if ( !pServer )
|
|
|
|
{
|
2002-06-03 08:32:42 +00:00
|
|
|
return NULL;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pShell = rDispatcher.GetShell( pServer->GetShellLevel() );
|
|
|
|
pSlot = pServer->GetSlot();
|
|
|
|
}
|
|
|
|
|
2003-05-28 12:25:06 +00:00
|
|
|
if ( bGlobalOnly )
|
|
|
|
if ( !pShell->ISA(SfxModule) && !pShell->ISA(SfxApplication) && !pShell->ISA(SfxViewFrame) )
|
|
|
|
return NULL;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxItemPool &rPool = pShell->GetPool();
|
|
|
|
SfxRequest aReq( nId, nCallMode, rPool );
|
|
|
|
aReq.SetModifier( nModi );
|
|
|
|
if( ppItems )
|
|
|
|
while( *ppItems )
|
|
|
|
aReq.AppendItem( **ppItems++ );
|
|
|
|
if ( ppInternalArgs )
|
|
|
|
{
|
|
|
|
SfxAllItemSet aSet( rPool );
|
|
|
|
for ( const SfxPoolItem **pArg = ppInternalArgs; *pArg; ++pArg )
|
|
|
|
aSet.Put( **pArg );
|
|
|
|
aReq.SetInternalArgs_Impl( aSet );
|
|
|
|
}
|
|
|
|
|
2001-10-11 08:12:09 +00:00
|
|
|
Execute_Impl( aReq, pSlot, pShell );
|
|
|
|
|
|
|
|
const SfxPoolItem* pRet = aReq.GetReturnValue();
|
|
|
|
if ( !pRet )
|
|
|
|
{
|
|
|
|
SfxPoolItem *pVoid = new SfxVoidItem( nId );
|
|
|
|
DeleteItemOnIdle( pVoid );
|
|
|
|
pRet = pVoid;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SfxBindings::Execute_Impl( SfxRequest& aReq, const SfxSlot* pSlot, SfxShell* pShell )
|
|
|
|
{
|
|
|
|
SfxItemPool &rPool = pShell->GetPool();
|
2005-03-23 13:24:06 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( SFX_KIND_ENUM == pSlot->GetKind() )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// for Enum-Slots, the Master has to be excecuted with the value
|
2011-03-10 16:47:00 +05:30
|
|
|
// of the enums
|
2000-09-18 16:07:07 +00:00
|
|
|
const SfxSlot *pRealSlot = pShell->GetInterface()->GetRealSlot(pSlot);
|
|
|
|
const sal_uInt16 nSlotId = pRealSlot->GetSlotId();
|
|
|
|
aReq.SetSlot( nSlotId );
|
2001-10-11 08:12:09 +00:00
|
|
|
aReq.AppendItem( SfxAllEnumItem( rPool.GetWhich(nSlotId), pSlot->GetValue() ) );
|
2002-04-05 10:32:19 +00:00
|
|
|
pDispatcher->_Execute( *pShell, *pRealSlot, aReq, aReq.GetCallMode() | SFX_CALLMODE_RECORD );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if ( SFX_KIND_ATTR == pSlot->GetKind() )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Which value has to be mapped for Attribute slots
|
2000-09-18 16:07:07 +00:00
|
|
|
const sal_uInt16 nSlotId = pSlot->GetSlotId();
|
|
|
|
aReq.SetSlot( nSlotId );
|
|
|
|
if ( pSlot->IsMode(SFX_SLOT_TOGGLE) )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// The value is attached to a toggleable attribute (Bools)
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_uInt16 nWhich = pSlot->GetWhich(rPool);
|
|
|
|
SfxItemSet aSet(rPool, nWhich, nWhich, 0);
|
|
|
|
SfxStateFunc aFunc = pSlot->GetStateFnc();
|
|
|
|
pShell->CallState( aFunc, aSet );
|
|
|
|
const SfxPoolItem *pOldItem;
|
|
|
|
SfxItemState eState = aSet.GetItemState(nWhich, sal_True, &pOldItem);
|
2005-02-21 15:59:23 +00:00
|
|
|
if ( eState == SFX_ITEM_DISABLED )
|
|
|
|
return;
|
|
|
|
|
2006-10-12 14:50:26 +00:00
|
|
|
if ( SFX_ITEM_AVAILABLE == eState && SfxItemPool::IsWhich(nWhich) )
|
|
|
|
pOldItem = &aSet.Get(nWhich);
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( SFX_ITEM_SET == eState ||
|
|
|
|
( SFX_ITEM_AVAILABLE == eState &&
|
|
|
|
SfxItemPool::IsWhich(nWhich) &&
|
2006-10-12 14:50:26 +00:00
|
|
|
pOldItem ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( pOldItem->ISA(SfxBoolItem) )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// we can toggle Bools
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_Bool bOldValue = ((const SfxBoolItem *)pOldItem)->GetValue();
|
|
|
|
SfxBoolItem *pNewItem = (SfxBoolItem*) (pOldItem->Clone());
|
|
|
|
pNewItem->SetValue( !bOldValue );
|
|
|
|
aReq.AppendItem( *pNewItem );
|
|
|
|
delete pNewItem;
|
|
|
|
}
|
|
|
|
else if ( pOldItem->ISA(SfxEnumItemInterface) &&
|
|
|
|
((SfxEnumItemInterface *)pOldItem)->HasBoolValue())
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// and Enums with Bool-Interface
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxEnumItemInterface *pNewItem =
|
|
|
|
(SfxEnumItemInterface*) (pOldItem->Clone());
|
|
|
|
pNewItem->SetBoolValue(!((SfxEnumItemInterface *)pOldItem)->GetBoolValue());
|
|
|
|
aReq.AppendItem( *pNewItem );
|
|
|
|
delete pNewItem;
|
|
|
|
}
|
2008-04-22 14:41:14 +00:00
|
|
|
else {
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "Toggle only for Enums and Bools allowed" );
|
2008-04-22 14:41:14 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if ( SFX_ITEM_DONTCARE == eState )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Create one Status-Item for each Factory
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxPoolItem *pNewItem = pSlot->GetType()->CreateItem();
|
2011-03-10 16:47:00 +05:30
|
|
|
DBG_ASSERT( pNewItem, "Toggle to slot without ItemFactory" );
|
2000-09-18 16:07:07 +00:00
|
|
|
pNewItem->SetWhich( nWhich );
|
|
|
|
|
|
|
|
if ( pNewItem->ISA(SfxBoolItem) )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// we can toggle Bools
|
2000-09-18 16:07:07 +00:00
|
|
|
((SfxBoolItem*)pNewItem)->SetValue( sal_True );
|
|
|
|
aReq.AppendItem( *pNewItem );
|
|
|
|
}
|
|
|
|
else if ( pNewItem->ISA(SfxEnumItemInterface) &&
|
|
|
|
((SfxEnumItemInterface *)pNewItem)->HasBoolValue())
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// and Enums with Bool-Interface
|
2000-09-18 16:07:07 +00:00
|
|
|
((SfxEnumItemInterface*)pNewItem)->SetBoolValue(sal_True);
|
|
|
|
aReq.AppendItem( *pNewItem );
|
|
|
|
}
|
2008-04-22 14:41:14 +00:00
|
|
|
else {
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "Toggle only for Enums and Bools allowed" );
|
2008-04-22 14:41:14 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
delete pNewItem;
|
|
|
|
}
|
2008-04-22 14:41:14 +00:00
|
|
|
else {
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "suspicious Toggle-Slot" );
|
2008-04-22 14:41:14 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2000-10-20 16:10:51 +00:00
|
|
|
|
2002-04-05 10:32:19 +00:00
|
|
|
pDispatcher->_Execute( *pShell, *pSlot, aReq, aReq.GetCallMode() | SFX_CALLMODE_RECORD );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
2002-04-05 10:32:19 +00:00
|
|
|
pDispatcher->_Execute( *pShell, *pSlot, aReq, aReq.GetCallMode() | SFX_CALLMODE_RECORD );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::UpdateSlotServer_Impl()
|
|
|
|
{
|
|
|
|
DBG_PROFSTART(SfxBindingsUpdateServers);
|
|
|
|
DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" );
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// synchronize
|
2000-09-18 16:07:07 +00:00
|
|
|
pDispatcher->Flush();
|
|
|
|
|
2002-09-18 15:10:39 +00:00
|
|
|
if ( pImp->bAllMsgDirty )
|
|
|
|
{
|
|
|
|
if ( !nRegLevel )
|
|
|
|
{
|
|
|
|
::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame
|
2009-12-15 23:07:57 +01:00
|
|
|
( pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY );
|
2011-01-07 17:14:47 +01:00
|
|
|
pImp->bContextChanged = sal_False;
|
2002-09-18 15:10:39 +00:00
|
|
|
}
|
|
|
|
else
|
2011-01-07 17:14:47 +01:00
|
|
|
pImp->bContextChanged = sal_True;
|
2002-09-18 15:10:39 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
const sal_uInt16 nCount = pImp->pCaches->Count();
|
|
|
|
for(sal_uInt16 i = 0; i < nCount; ++i)
|
|
|
|
{
|
|
|
|
SfxStateCache *pCache = pImp->pCaches->GetObject(i);
|
|
|
|
pCache->GetSlotServer(*pDispatcher, pImp->xProv);
|
|
|
|
}
|
|
|
|
pImp->bMsgDirty = pImp->bAllMsgDirty = sal_False;
|
|
|
|
|
|
|
|
Broadcast( SfxSimpleHint(SFX_HINT_DOCCHANGED) );
|
|
|
|
|
|
|
|
DBG_PROFSTOP(SfxBindingsUpdateServers);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
SfxItemSet* SfxBindings::CreateSet_Impl
|
|
|
|
(
|
2011-01-26 21:04:40 +00:00
|
|
|
SfxStateCache*& pCache, // in: Status-Cache from nId
|
|
|
|
const SfxSlot*& pRealSlot, // out: RealSlot to nId
|
|
|
|
const SfxSlotServer** pMsgServer, // out: Slot-Server to nId
|
|
|
|
SfxFoundCacheArr_Impl& rFound // out: List of Caches for Siblings
|
2000-09-18 16:07:07 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" );
|
|
|
|
|
2011-03-10 16:47:00 +05:30
|
|
|
DBG_ASSERT( !pImp->bMsgDirty, "CreateSet_Impl with dirty MessageServer" );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
const SfxSlotServer* pMsgSvr = pCache->GetSlotServer(*pDispatcher, pImp->xProv);
|
|
|
|
if(!pMsgSvr || !pDispatcher)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
DBG_PROFSTART(SfxBindingsCreateSet);
|
|
|
|
pRealSlot = 0;
|
|
|
|
*pMsgServer = pMsgSvr;
|
|
|
|
|
|
|
|
sal_uInt16 nShellLevel = pMsgSvr->GetShellLevel();
|
|
|
|
SfxShell *pShell = pDispatcher->GetShell( nShellLevel );
|
2011-01-26 21:04:40 +00:00
|
|
|
if ( !pShell ) // rare GPF when browsing through update from Inet-Notify
|
2000-09-18 16:07:07 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
SfxItemPool &rPool = pShell->GetPool();
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// get the status method, which is served by the pCache
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxStateFunc pFnc = 0;
|
|
|
|
const SfxInterface *pInterface = pShell->GetInterface();
|
|
|
|
if ( SFX_KIND_ENUM == pMsgSvr->GetSlot()->GetKind() )
|
|
|
|
{
|
|
|
|
pRealSlot = pInterface->GetRealSlot(pMsgSvr->GetSlot());
|
|
|
|
pCache = GetStateCache( pRealSlot->GetSlotId() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pRealSlot = pMsgSvr->GetSlot();
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Note: pCache can be NULL!
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
pFnc = pRealSlot->GetStateFnc();
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// the RealSlot is always on
|
2000-09-18 16:07:07 +00:00
|
|
|
const SfxFoundCache_Impl *pFound = new SfxFoundCache_Impl(
|
|
|
|
pRealSlot->GetSlotId(), pRealSlot->GetWhich(rPool), pRealSlot, pCache );
|
|
|
|
rFound.Insert( pFound );
|
|
|
|
|
2011-01-07 17:14:47 +01:00
|
|
|
sal_uInt16 nSlot = pRealSlot->GetSlotId();
|
2011-02-07 17:05:48 +01:00
|
|
|
if ( !(nSlot >= SID_VERB_START && nSlot <= SID_VERB_END) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-08-24 06:58:53 +00:00
|
|
|
pInterface = pInterface->GetRealInterfaceForSlot( pRealSlot );
|
2011-01-26 21:04:40 +00:00
|
|
|
DBG_ASSERT (pInterface,"Slot in the given shell is not found");
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Search through the bindings for slots served by the same function. This , // will only affect slots which are present in the found interface.
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// The position of the Statecaches in StateCache-Array
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_uInt16 nCachePos = pImp->nMsgPos;
|
|
|
|
const SfxSlot *pSibling = pRealSlot->GetNextSlot();
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// the Slots odf a interfaces ar linked in a circle
|
2000-09-18 16:07:07 +00:00
|
|
|
while ( pSibling > pRealSlot )
|
|
|
|
{
|
|
|
|
SfxStateFunc pSiblingFnc=0;
|
|
|
|
SfxStateCache *pSiblingCache =
|
|
|
|
GetStateCache( pSibling->GetSlotId(), &nCachePos );
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Is the slot cached ?
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pSiblingCache )
|
|
|
|
{
|
|
|
|
const SfxSlotServer *pServ = pSiblingCache->GetSlotServer(*pDispatcher, pImp->xProv);
|
|
|
|
if ( pServ && pServ->GetShellLevel() == nShellLevel )
|
|
|
|
pSiblingFnc = pServ->GetSlot()->GetStateFnc();
|
|
|
|
}
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Does the slot have to be updated at all?
|
2010-10-05 07:57:54 -05:00
|
|
|
bool bInsert = pSiblingCache && pSiblingCache->IsControllerDirty();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-03-28 12:38:06 +02:00
|
|
|
// It is not enough to ask for the same shell!!
|
2010-10-05 07:57:54 -05:00
|
|
|
bool bSameMethod = pSiblingCache && pFnc == pSiblingFnc;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// If the slot is a non-dirty master slot, then maybe one of his slaves
|
|
|
|
// is dirty? Then the master slot is still inserted.
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( !bInsert && bSameMethod && pSibling->GetLinkedSlot() )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Also check slave slots for Binding
|
2000-09-18 16:07:07 +00:00
|
|
|
const SfxSlot* pFirstSlave = pSibling->GetLinkedSlot();
|
|
|
|
for ( const SfxSlot *pSlaveSlot = pFirstSlave;
|
|
|
|
!bInsert;
|
|
|
|
pSlaveSlot = pSlaveSlot->GetNextSlot())
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// the slaves points to its master
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_ASSERT(pSlaveSlot->GetLinkedSlot() == pSibling,
|
2011-01-26 21:04:40 +00:00
|
|
|
"Wrong Master/Slave relationship!");
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
sal_uInt16 nCurMsgPos = pImp->nMsgPos;
|
|
|
|
const SfxStateCache *pSlaveCache =
|
|
|
|
GetStateCache( pSlaveSlot->GetSlotId(), &nCurMsgPos );
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Is the slave slot chached and dirty ?
|
2000-09-18 16:07:07 +00:00
|
|
|
bInsert = pSlaveCache && pSlaveCache->IsControllerDirty();
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Slaves are chained together in a circle
|
2000-09-18 16:07:07 +00:00
|
|
|
if (pSlaveSlot->GetNextSlot() == pFirstSlave)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bInsert && bSameMethod )
|
|
|
|
{
|
2006-06-19 21:16:10 +00:00
|
|
|
const SfxFoundCache_Impl *pFoundCache = new SfxFoundCache_Impl(
|
2000-09-18 16:07:07 +00:00
|
|
|
pSibling->GetSlotId(), pSibling->GetWhich(rPool),
|
|
|
|
pSibling, pSiblingCache );
|
|
|
|
|
2006-06-19 21:16:10 +00:00
|
|
|
rFound.Insert( pFoundCache );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pSibling = pSibling->GetNextSlot();
|
|
|
|
}
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Create a Set from the ranges
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_uInt16 *pRanges = new sal_uInt16[rFound.Count() * 2 + 1];
|
|
|
|
int j = 0;
|
2011-01-07 17:14:47 +01:00
|
|
|
sal_uInt16 i = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
while ( i < rFound.Count() )
|
|
|
|
{
|
|
|
|
pRanges[j++] = rFound[i]->nWhichId;
|
2011-01-26 21:04:40 +00:00
|
|
|
// consecutive numbers
|
2000-09-18 16:07:07 +00:00
|
|
|
for ( ; i < rFound.Count()-1; ++i )
|
|
|
|
if ( rFound[i]->nWhichId+1 != rFound[i+1]->nWhichId )
|
|
|
|
break;
|
|
|
|
pRanges[j++] = rFound[i++]->nWhichId;
|
|
|
|
}
|
2011-01-26 21:04:40 +00:00
|
|
|
pRanges[j] = 0; // terminating NULL
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxItemSet *pSet = new SfxItemSet(rPool, pRanges);
|
2002-07-23 12:48:12 +00:00
|
|
|
delete [] pRanges;
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_PROFSTOP(SfxBindingsCreateSet);
|
|
|
|
return pSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::UpdateControllers_Impl
|
|
|
|
(
|
2011-01-26 21:04:40 +00:00
|
|
|
const SfxInterface* pIF, // Id of the current serving Interface
|
2000-09-18 16:07:07 +00:00
|
|
|
const SfxFoundCache_Impl* pFound, // Cache, Slot, Which etc.
|
|
|
|
const SfxPoolItem* pItem, // item to send to controller
|
|
|
|
SfxItemState eState // state of item
|
|
|
|
)
|
|
|
|
{
|
|
|
|
DBG_ASSERT( !pFound->pSlot || SFX_KIND_ENUM != pFound->pSlot->GetKind(),
|
|
|
|
"direct update of enum slot isn't allowed" );
|
|
|
|
DBG_PROFSTART(SfxBindingsUpdateCtrl1);
|
|
|
|
|
|
|
|
SfxStateCache* pCache = pFound->pCache;
|
|
|
|
const SfxSlot* pSlot = pFound->pSlot;
|
|
|
|
DBG_ASSERT( !pCache || !pSlot || pCache->GetId() == pSlot->GetSlotId(), "SID mismatch" );
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// bound until now, the Controller to update the Slot.
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pCache && pCache->IsControllerDirty() )
|
|
|
|
{
|
2000-10-20 16:10:51 +00:00
|
|
|
if ( SFX_ITEM_DONTCARE == eState )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// ambiguous
|
2000-10-20 16:10:51 +00:00
|
|
|
pCache->SetState( SFX_ITEM_DONTCARE, (SfxPoolItem *)-1 );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2000-10-20 16:10:51 +00:00
|
|
|
else if ( SFX_ITEM_DEFAULT == eState &&
|
|
|
|
pFound->nWhichId > SFX_WHICH_MAX )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// no Status or Default but without Pool
|
2000-10-20 16:10:51 +00:00
|
|
|
SfxVoidItem aVoid(0);
|
|
|
|
pCache->SetState( SFX_ITEM_UNKNOWN, &aVoid );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2000-10-20 16:10:51 +00:00
|
|
|
else if ( SFX_ITEM_DISABLED == eState )
|
|
|
|
pCache->SetState(SFX_ITEM_DISABLED, 0);
|
|
|
|
else
|
|
|
|
pCache->SetState(SFX_ITEM_AVAILABLE, pItem);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DBG_PROFSTOP(SfxBindingsUpdateCtrl1);
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Update the slots for so far available and bound Controllers for
|
|
|
|
// Slave-Slots (Enum-value)
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_PROFSTART(SfxBindingsUpdateCtrl2);
|
|
|
|
DBG_ASSERT( !pSlot || 0 == pSlot->GetLinkedSlot() || !pItem ||
|
|
|
|
pItem->ISA(SfxEnumItemInterface),
|
|
|
|
"master slot with non-enum-type found" );
|
|
|
|
const SfxSlot *pFirstSlave = pSlot ? pSlot->GetLinkedSlot() : 0;
|
|
|
|
if ( pIF && pFirstSlave)
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Items cast on EnumItem
|
2000-09-18 16:07:07 +00:00
|
|
|
const SfxEnumItemInterface *pEnumItem =
|
|
|
|
PTR_CAST(SfxEnumItemInterface,pItem);
|
|
|
|
if ( eState == SFX_ITEM_AVAILABLE && !pEnumItem )
|
|
|
|
eState = SFX_ITEM_DONTCARE;
|
|
|
|
else
|
|
|
|
eState = SfxControllerItem::GetItemState( pEnumItem );
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Iterate over all Slaves-Slots
|
2003-03-27 10:29:38 +00:00
|
|
|
for ( const SfxSlot *pSlave = pFirstSlave; pSlave; pSlave = pSlave->GetNextSlot() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
DBG_ASSERT(pSlave, "Wrong SlaveSlot binding!");
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_ASSERT(SFX_KIND_ENUM == pSlave->GetKind(),"non enum slaves aren't allowed");
|
2011-03-10 16:47:00 +05:30
|
|
|
DBG_ASSERT(pSlave->GetMasterSlotId() == pSlot->GetSlotId(),"Wrong MasterSlot!");
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Binding exist for function ?
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxStateCache *pEnumCache = GetStateCache( pSlave->GetSlotId() );
|
|
|
|
if ( pEnumCache )
|
|
|
|
{
|
|
|
|
pEnumCache->Invalidate(sal_False);
|
|
|
|
|
|
|
|
HACK(CONTROL/SELECT Kram)
|
|
|
|
if ( eState == SFX_ITEM_DONTCARE && pFound->nWhichId == 10144 )
|
|
|
|
{
|
|
|
|
SfxVoidItem aVoid(0);
|
|
|
|
pEnumCache->SetState( SFX_ITEM_UNKNOWN, &aVoid );
|
|
|
|
|
|
|
|
if (pSlave->GetNextSlot() == pFirstSlave)
|
|
|
|
break;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2003-03-27 10:29:38 +00:00
|
|
|
if ( SFX_ITEM_DISABLED == eState || !pEnumItem->IsEnabled( pSlave->GetSlotId()) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
// disabled
|
|
|
|
pEnumCache->SetState(SFX_ITEM_DISABLED, 0);
|
|
|
|
}
|
|
|
|
else if ( SFX_ITEM_AVAILABLE == eState )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Determine enum value
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_uInt16 nValue = pEnumItem->GetEnumValue();
|
|
|
|
SfxBoolItem aBool( pFound->nWhichId, pSlave->GetValue() == nValue );
|
|
|
|
pEnumCache->SetState(SFX_ITEM_AVAILABLE, &aBool);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// ambiguous
|
2000-09-18 16:07:07 +00:00
|
|
|
pEnumCache->SetState( SFX_ITEM_DONTCARE, (SfxPoolItem *)-1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pSlave->GetNextSlot() == pFirstSlave)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG_PROFSTOP(SfxBindingsUpdateCtrl2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
IMPL_LINK( SfxBindings, NextJob_Impl, Timer *, pTimer )
|
|
|
|
{
|
2005-03-23 13:24:06 +00:00
|
|
|
#ifdef DBG_UTIL
|
2011-01-26 21:04:40 +00:00
|
|
|
// on Windows very often C++ Exceptions (GPF etc.) are caught by MSVCRT
|
|
|
|
// or another MS library try to get them here
|
2005-03-23 13:24:06 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
#endif
|
2006-06-19 21:16:10 +00:00
|
|
|
const unsigned MAX_INPUT_DELAY = 200;
|
2004-11-16 14:26:34 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" );
|
|
|
|
|
|
|
|
DBG_PROFSTART(SfxBindingsNextJob_Impl0);
|
2004-11-16 14:26:34 +00:00
|
|
|
|
2005-01-27 10:14:33 +00:00
|
|
|
if ( Application::GetLastInputInterval() < MAX_INPUT_DELAY && pTimer )
|
2004-11-16 14:26:34 +00:00
|
|
|
{
|
|
|
|
pImp->aTimer.SetTimeout(TIMEOUT_UPDATING);
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxApplication *pSfxApp = SFX_APP();
|
|
|
|
|
|
|
|
if( pDispatcher )
|
|
|
|
pDispatcher->Update_Impl();
|
|
|
|
|
|
|
|
// modifying the SfxObjectInterface-stack without SfxBindings => nothing to do
|
|
|
|
SfxViewFrame* pFrame = pDispatcher->GetFrame();
|
2009-11-16 13:48:33 +01:00
|
|
|
if ( (pFrame && !pFrame->GetObjectShell()->AcceptStateUpdate()) || pSfxApp->IsDowning() || !pImp->pCaches->Count() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
DBG_PROFSTOP(SfxBindingsNextJob_Impl0);
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
if ( !pDispatcher || !pDispatcher->IsFlushed() )
|
|
|
|
{
|
|
|
|
DBG_PROFSTOP(SfxBindingsNextJob_Impl0);
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// if possible Update all server / happens in its own time slice
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pImp->bMsgDirty )
|
|
|
|
{
|
|
|
|
UpdateSlotServer_Impl();
|
|
|
|
DBG_PROFSTOP(SfxBindingsNextJob_Impl0);
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG_PROFSTOP(SfxBindingsNextJob_Impl0);
|
|
|
|
DBG_PROFSTART(SfxBindingsNextJob_Impl);
|
|
|
|
pImp->bAllDirty = sal_False;
|
|
|
|
pImp->aTimer.SetTimeout(TIMEOUT_UPDATING);
|
|
|
|
|
|
|
|
// at least 10 loops and further if more jobs are available but no input
|
2010-10-05 07:57:54 -05:00
|
|
|
bool bPreEmptive = pTimer && !pSfxApp->Get_Impl()->nInReschedule;
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_uInt16 nLoops = 10;
|
|
|
|
pImp->bInNextJob = sal_True;
|
|
|
|
const sal_uInt16 nCount = pImp->pCaches->Count();
|
|
|
|
while ( pImp->nMsgPos < nCount )
|
|
|
|
{
|
|
|
|
// iterate through the bound functions
|
|
|
|
sal_Bool bJobDone = sal_False;
|
|
|
|
while ( !bJobDone )
|
2011-03-09 14:56:21 +01:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxStateCache* pCache = (*pImp->pCaches)[pImp->nMsgPos];
|
|
|
|
DBG_ASSERT( pCache, "invalid SfxStateCache-position in job queue" );
|
|
|
|
sal_Bool bWasDirty = pCache->IsControllerDirty();
|
|
|
|
if ( bWasDirty )
|
|
|
|
{
|
|
|
|
Update_Impl( pCache );
|
|
|
|
DBG_ASSERT( nCount == pImp->pCaches->Count(),
|
|
|
|
"Reschedule in StateChanged => buff" );
|
|
|
|
}
|
|
|
|
|
|
|
|
// skip to next function binding
|
|
|
|
++pImp->nMsgPos;
|
|
|
|
|
|
|
|
// keep job if it is not completed, but any input is available
|
|
|
|
bJobDone = pImp->nMsgPos >= nCount;
|
|
|
|
if ( bJobDone && pImp->bFirstRound )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
|
|
|
|
// Update of the preferred shell has been done, now may
|
|
|
|
// also the others shells be updated
|
2000-09-18 16:07:07 +00:00
|
|
|
bJobDone = sal_False;
|
|
|
|
pImp->bFirstRound = sal_False;
|
|
|
|
pImp->nMsgPos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bWasDirty && !bJobDone && bPreEmptive && (--nLoops == 0) )
|
|
|
|
{
|
|
|
|
DBG_PROFSTOP(SfxBindingsNextJob_Impl);
|
|
|
|
pImp->bInNextJob = sal_False;
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pImp->nMsgPos = 0;
|
2009-09-18 10:15:03 +00:00
|
|
|
|
|
|
|
// check for volatile slots
|
|
|
|
bool bVolatileSlotsPresent = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
for ( sal_uInt16 n = 0; n < nCount; ++n )
|
|
|
|
{
|
|
|
|
SfxStateCache* pCache = (*pImp->pCaches)[n];
|
|
|
|
const SfxSlotServer *pSlotServer = pCache->GetSlotServer(*pDispatcher, pImp->xProv);
|
2009-09-18 10:15:03 +00:00
|
|
|
if ( pSlotServer && pSlotServer->GetSlot()->IsMode(SFX_SLOT_VOLATILE) )
|
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
pCache->Invalidate(sal_False);
|
2009-09-18 10:15:03 +00:00
|
|
|
bVolatileSlotsPresent = true;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2009-09-18 10:15:03 +00:00
|
|
|
if (bVolatileSlotsPresent)
|
|
|
|
pImp->aTimer.SetTimeout(TIMEOUT_IDLE);
|
|
|
|
else
|
|
|
|
pImp->aTimer.Stop();
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Update round is finished
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->bInNextJob = sal_False;
|
|
|
|
Broadcast(SfxSimpleHint(SFX_HINT_UPDATEDONE));
|
|
|
|
DBG_PROFSTOP(SfxBindingsNextJob_Impl);
|
|
|
|
return sal_True;
|
2005-03-23 13:24:06 +00:00
|
|
|
#ifdef DBG_UTIL
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL("C++ exception caught!");
|
2005-03-23 13:24:06 +00:00
|
|
|
pImp->bInNextJob = sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sal_False;
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
2006-06-19 21:16:10 +00:00
|
|
|
sal_uInt16 SfxBindings::EnterRegistrations(const char *pFile, int nLine)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-11-23 15:45:43 +01:00
|
|
|
SAL_INFO(
|
2011-11-22 09:34:46 +01:00
|
|
|
"sfx2",
|
|
|
|
std::setw(Min(nRegLevel, sal_uInt16(8))) << ' ' << "this = " << this
|
|
|
|
<< " Level = " << nRegLevel << " SfxBindings::EnterRegistrations "
|
|
|
|
<< (pFile
|
|
|
|
? SAL_STREAM("File: " << pFile << " Line: " << nLine) : ""));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// When bindings are locked, also lock sub bindings.
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
{
|
|
|
|
pImp->pSubBindings->ENTERREGISTRATIONS();
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// These EnterRegistrations are not "real" for the SubBindings
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->pSubBindings->pImp->nOwnRegLevel--;
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Synchronize Bindings
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->pSubBindings->nRegLevel = nRegLevel + pImp->pSubBindings->pImp->nOwnRegLevel + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
pImp->nOwnRegLevel++;
|
|
|
|
|
|
|
|
// check if this is the outer most level
|
|
|
|
if ( ++nRegLevel == 1 )
|
|
|
|
{
|
|
|
|
// stop background-processing
|
|
|
|
pImp->aTimer.Stop();
|
|
|
|
|
|
|
|
// flush the cache
|
|
|
|
pImp->nCachedFunc1 = 0;
|
|
|
|
pImp->nCachedFunc2 = 0;
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Mark if the all of the Caches have dissapered.
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->bCtrlReleased = sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nRegLevel;
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
2006-06-19 21:16:10 +00:00
|
|
|
void SfxBindings::LeaveRegistrations( sal_uInt16 nLevel, const char *pFile, int nLine )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2006-06-19 21:16:10 +00:00
|
|
|
(void)nLevel; // unused variable
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_ASSERT( nRegLevel, "Leave without Enter" );
|
|
|
|
DBG_ASSERT( nLevel == USHRT_MAX || nLevel == nRegLevel, "wrong Leave" );
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Only when the SubBindings are still locked by the Superbindings,
|
|
|
|
// remove this lock (i.e. if there are more locks than "real" ones)
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pImp->pSubBindings && pImp->pSubBindings->nRegLevel > pImp->pSubBindings->pImp->nOwnRegLevel )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Synchronize Bindings
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->pSubBindings->nRegLevel = nRegLevel + pImp->pSubBindings->pImp->nOwnRegLevel;
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// This LeaveRegistrations is not "real" for SubBindings
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->pSubBindings->pImp->nOwnRegLevel++;
|
|
|
|
pImp->pSubBindings->LEAVEREGISTRATIONS();
|
|
|
|
}
|
|
|
|
|
|
|
|
pImp->nOwnRegLevel--;
|
|
|
|
|
|
|
|
// check if this is the outer most level
|
|
|
|
if ( --nRegLevel == 0 && !SFX_APP()->IsDowning() )
|
|
|
|
{
|
2002-09-18 15:10:39 +00:00
|
|
|
if ( pImp->bContextChanged )
|
|
|
|
{
|
2011-01-07 17:14:47 +01:00
|
|
|
pImp->bContextChanged = sal_False;
|
2002-09-18 15:10:39 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxViewFrame* pFrame = pDispatcher->GetFrame();
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// If possible remove unused Caches, for example prepare PlugInInfo
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pImp->bCtrlReleased )
|
|
|
|
{
|
|
|
|
for ( sal_uInt16 nCache = pImp->pCaches->Count(); nCache > 0; --nCache )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Get Cache via ::com::sun::star::sdbcx::Index
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxStateCache *pCache = pImp->pCaches->GetObject(nCache-1);
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// No interested Controller present
|
2005-01-18 15:07:16 +00:00
|
|
|
if ( pCache->GetItemLink() == 0 && !pCache->GetInternalController() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
// Remove Cache. Safety: first remove and then delete
|
2005-03-15 08:37:42 +00:00
|
|
|
SfxStateCache* pSfxStateCache = (*pImp->pCaches)[nCache-1];
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->pCaches->Remove(nCache-1, 1);
|
2005-03-15 08:37:42 +00:00
|
|
|
delete pSfxStateCache;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-09 19:18:57 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// restart background-processing
|
|
|
|
pImp->nMsgPos = 0;
|
|
|
|
if ( !pFrame || !pFrame->GetObjectShell() )
|
|
|
|
return;
|
|
|
|
if ( pImp->pCaches && pImp->pCaches->Count() )
|
|
|
|
{
|
2003-09-19 06:58:46 +00:00
|
|
|
pImp->aTimer.Stop();
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->aTimer.SetTimeout(TIMEOUT_FIRST);
|
|
|
|
pImp->aTimer.Start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-23 15:45:43 +01:00
|
|
|
SAL_INFO(
|
2011-11-22 09:34:46 +01:00
|
|
|
"sfx2",
|
|
|
|
std::setw(Min(nRegLevel, sal_uInt16(8))) << ' ' << "this = " << this
|
|
|
|
<< " Level = " << nRegLevel << " SfxBindings::LeaveRegistrations "
|
2011-11-22 16:56:08 +01:00
|
|
|
<< (pFile
|
|
|
|
? SAL_STREAM("File: " << pFile << " Line: " << nLine) : ""));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
const SfxSlot* SfxBindings::GetSlot(sal_uInt16 nSlotId)
|
|
|
|
{
|
|
|
|
DBG_ASSERT( pImp->pCaches != 0, "SfxBindings not initialized" );
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// synchronizing
|
2000-09-18 16:07:07 +00:00
|
|
|
pDispatcher->Flush();
|
|
|
|
if ( pImp->bMsgDirty )
|
|
|
|
UpdateSlotServer_Impl();
|
|
|
|
|
|
|
|
// get the cache for the specified function; return if not bound
|
|
|
|
SfxStateCache* pCache = GetStateCache(nSlotId);
|
|
|
|
return pCache && pCache->GetSlotServer(*pDispatcher, pImp->xProv)?
|
|
|
|
pCache->GetSlotServer(*pDispatcher, pImp->xProv)->GetSlot(): 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::SetDispatcher( SfxDispatcher *pDisp )
|
|
|
|
{
|
|
|
|
SfxDispatcher *pOldDispat = pDispatcher;
|
|
|
|
if ( pDisp != pDispatcher )
|
|
|
|
{
|
|
|
|
if ( pOldDispat )
|
|
|
|
{
|
|
|
|
SfxBindings* pBind = pOldDispat->GetBindings();
|
|
|
|
while ( pBind )
|
|
|
|
{
|
|
|
|
if ( pBind->pImp->pSubBindings == this && pBind->pDispatcher != pDisp )
|
|
|
|
pBind->SetSubBindings_Impl( NULL );
|
|
|
|
pBind = pBind->pImp->pSubBindings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pDispatcher = pDisp;
|
2000-10-20 16:10:51 +00:00
|
|
|
|
|
|
|
::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatchProvider > xProv;
|
|
|
|
if ( pDisp )
|
|
|
|
xProv = ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatchProvider >
|
2009-12-15 23:07:57 +01:00
|
|
|
( pDisp->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY );
|
2000-10-20 16:10:51 +00:00
|
|
|
|
|
|
|
SetDispatchProvider_Impl( xProv );
|
2000-09-18 16:07:07 +00:00
|
|
|
InvalidateAll( sal_True );
|
|
|
|
InvalidateUnoControllers_Impl();
|
2000-10-20 16:10:51 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pDispatcher && !pOldDispat )
|
|
|
|
{
|
|
|
|
if ( pImp->pSubBindings && pImp->pSubBindings->pDispatcher != pOldDispat )
|
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "SubBindings already set before activating!" );
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->pSubBindings->ENTERREGISTRATIONS();
|
|
|
|
}
|
|
|
|
LEAVEREGISTRATIONS();
|
|
|
|
}
|
|
|
|
else if( !pDispatcher )
|
|
|
|
{
|
|
|
|
ENTERREGISTRATIONS();
|
|
|
|
if ( pImp->pSubBindings && pImp->pSubBindings->pDispatcher != pOldDispat )
|
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "SubBindings still set even when deactivating!" );
|
2000-09-18 16:07:07 +00:00
|
|
|
pImp->pSubBindings->LEAVEREGISTRATIONS();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
|
|
|
|
|
|
|
|
if ( pDisp )
|
|
|
|
{
|
|
|
|
SfxBindings* pBind = pDisp->GetBindings();
|
|
|
|
while ( pBind && pBind != this )
|
|
|
|
{
|
|
|
|
if ( !pBind->pImp->pSubBindings )
|
|
|
|
{
|
|
|
|
pBind->SetSubBindings_Impl( this );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pBind = pBind->pImp->pSubBindings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SfxBindings::ClearCache_Impl( sal_uInt16 nSlotId )
|
|
|
|
{
|
|
|
|
GetStateCache(nSlotId)->ClearCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SfxBindings::StartUpdate_Impl( sal_Bool bComplete )
|
|
|
|
{
|
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
pImp->pSubBindings->StartUpdate_Impl( bComplete );
|
|
|
|
|
|
|
|
if ( !bComplete )
|
2011-01-26 21:04:40 +00:00
|
|
|
// Update may be interrupted
|
2000-09-18 16:07:07 +00:00
|
|
|
NextJob_Impl(&pImp->aTimer);
|
|
|
|
else
|
2011-01-26 21:04:40 +00:00
|
|
|
// Update all slots in a row
|
2000-09-18 16:07:07 +00:00
|
|
|
NextJob_Impl(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SfxItemState SfxBindings::QueryState( sal_uInt16 nSlot, SfxPoolItem* &rpState )
|
|
|
|
{
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDisp;
|
|
|
|
SfxStateCache *pCache = GetStateCache( nSlot );
|
|
|
|
if ( pCache )
|
|
|
|
xDisp = pCache->GetDispatch();
|
2000-10-20 16:10:51 +00:00
|
|
|
if ( xDisp.is() || !pCache )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2006-05-02 15:27:22 +00:00
|
|
|
const SfxSlot* pSlot = SfxSlotPool::GetSlotPool( pDispatcher->GetFrame() ).GetSlot( nSlot );
|
2005-01-18 15:07:16 +00:00
|
|
|
if ( !pSlot || !pSlot->pUnoName )
|
|
|
|
return SFX_ITEM_DISABLED;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
::com::sun::star::util::URL aURL;
|
2006-08-01 08:54:45 +00:00
|
|
|
::rtl::OUString aCmd( DEFINE_CONST_UNICODE(".uno:"));
|
|
|
|
aURL.Protocol = aCmd;
|
|
|
|
aURL.Path = ::rtl::OUString::createFromAscii(pSlot->GetUnoName());
|
|
|
|
aCmd += aURL.Path;
|
2005-01-18 15:07:16 +00:00
|
|
|
aURL.Complete = aCmd;
|
2006-08-01 08:54:45 +00:00
|
|
|
aURL.Main = aCmd;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( !xDisp.is() )
|
|
|
|
xDisp = pImp->xProv->queryDispatch( aURL, ::rtl::OUString(), 0 );
|
|
|
|
|
|
|
|
if ( xDisp.is() )
|
|
|
|
{
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xTunnel( xDisp, ::com::sun::star::uno::UNO_QUERY );
|
|
|
|
SfxOfficeDispatch* pDisp = NULL;
|
|
|
|
if ( xTunnel.is() )
|
|
|
|
{
|
|
|
|
sal_Int64 nImplementation = xTunnel->getSomething(SfxOfficeDispatch::impl_getStaticIdentifier());
|
2006-06-19 21:16:10 +00:00
|
|
|
pDisp = reinterpret_cast< SfxOfficeDispatch* >( sal::static_int_cast< sal_IntPtr >( nImplementation ));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2005-01-18 15:07:16 +00:00
|
|
|
if ( !pDisp )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-07 17:14:47 +01:00
|
|
|
sal_Bool bDeleteCache = sal_False;
|
2003-12-01 10:58:10 +00:00
|
|
|
if ( !pCache )
|
|
|
|
{
|
|
|
|
pCache = new SfxStateCache( nSlot );
|
|
|
|
pCache->GetSlotServer( *GetDispatcher_Impl(), pImp->xProv );
|
2011-01-07 17:14:47 +01:00
|
|
|
bDeleteCache = sal_True;
|
2003-12-01 10:58:10 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxItemState eState = SFX_ITEM_SET;
|
|
|
|
SfxPoolItem *pItem=NULL;
|
2005-01-18 15:07:16 +00:00
|
|
|
BindDispatch_Impl *pBind = new BindDispatch_Impl( xDisp, aURL, pCache, pSlot );
|
2000-09-18 16:07:07 +00:00
|
|
|
pBind->acquire();
|
|
|
|
xDisp->addStatusListener( pBind, aURL );
|
|
|
|
if ( !pBind->GetStatus().IsEnabled )
|
2003-12-01 10:58:10 +00:00
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
eState = SFX_ITEM_DISABLED;
|
2003-12-01 10:58:10 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
::com::sun::star::uno::Any aAny = pBind->GetStatus().State;
|
|
|
|
::com::sun::star::uno::Type pType = aAny.getValueType();
|
|
|
|
|
|
|
|
if ( pType == ::getBooleanCppuType() )
|
|
|
|
{
|
2006-07-19 16:17:03 +00:00
|
|
|
sal_Bool bTemp = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
aAny >>= bTemp ;
|
|
|
|
pItem = new SfxBoolItem( nSlot, bTemp );
|
|
|
|
}
|
|
|
|
else if ( pType == ::getCppuType((const sal_uInt16*)0) )
|
|
|
|
{
|
2006-07-19 16:17:03 +00:00
|
|
|
sal_uInt16 nTemp = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
aAny >>= nTemp ;
|
|
|
|
pItem = new SfxUInt16Item( nSlot, nTemp );
|
|
|
|
}
|
|
|
|
else if ( pType == ::getCppuType((const sal_uInt32*)0) )
|
|
|
|
{
|
2006-11-21 16:47:45 +00:00
|
|
|
sal_uInt32 nTemp = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
aAny >>= nTemp ;
|
|
|
|
pItem = new SfxUInt32Item( nSlot, nTemp );
|
|
|
|
}
|
|
|
|
else if ( pType == ::getCppuType((const ::rtl::OUString*)0) )
|
|
|
|
{
|
|
|
|
::rtl::OUString sTemp ;
|
|
|
|
aAny >>= sTemp ;
|
|
|
|
pItem = new SfxStringItem( nSlot, sTemp );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pItem = new SfxVoidItem( nSlot );
|
|
|
|
}
|
|
|
|
|
2003-12-01 10:58:10 +00:00
|
|
|
xDisp->removeStatusListener( pBind, aURL );
|
2000-09-18 16:07:07 +00:00
|
|
|
pBind->Release();
|
|
|
|
rpState = pItem;
|
2003-12-01 10:58:10 +00:00
|
|
|
if ( bDeleteCache )
|
|
|
|
DELETEZ( pCache );
|
2000-09-18 16:07:07 +00:00
|
|
|
return eState;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-26 21:04:40 +00:00
|
|
|
// Then test at the dispatcher to check if the returned items from
|
|
|
|
// there are always DELETE_ON_IDLE, a copy of it has to be made in
|
|
|
|
// order to allow for transition of ownership.
|
2000-09-18 16:07:07 +00:00
|
|
|
const SfxPoolItem *pItem = NULL;
|
|
|
|
SfxItemState eState = pDispatcher->QueryState( nSlot, pItem );
|
|
|
|
if ( eState == SFX_ITEM_SET )
|
|
|
|
{
|
2011-01-26 21:04:40 +00:00
|
|
|
DBG_ASSERT( pItem, "SFX_ITEM_SET but no item!" );
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pItem )
|
|
|
|
rpState = pItem->Clone();
|
|
|
|
}
|
|
|
|
else if ( eState == SFX_ITEM_AVAILABLE && pItem )
|
|
|
|
{
|
|
|
|
rpState = pItem->Clone();
|
|
|
|
}
|
|
|
|
|
|
|
|
return eState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SfxBindings::SetSubBindings_Impl( SfxBindings *pSub )
|
|
|
|
{
|
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
{
|
|
|
|
pImp->pSubBindings->SetDispatchProvider_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > () );
|
|
|
|
pImp->pSubBindings->pImp->pSuperBindings = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pImp->pSubBindings = pSub;
|
|
|
|
|
|
|
|
if ( pSub )
|
|
|
|
{
|
|
|
|
pImp->pSubBindings->SetDispatchProvider_Impl( pImp->xProv );
|
|
|
|
pSub->pImp->pSuperBindings = this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SfxBindings* SfxBindings::GetSubBindings_Impl( sal_Bool bTop ) const
|
|
|
|
{
|
|
|
|
SfxBindings *pRet = pImp->pSubBindings;
|
|
|
|
if ( bTop )
|
|
|
|
{
|
|
|
|
while ( pRet->pImp->pSubBindings )
|
|
|
|
pRet = pRet->pImp->pSubBindings;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SfxBindings::SetWorkWindow_Impl( SfxWorkWindow* pWork )
|
|
|
|
{
|
|
|
|
pImp->pWorkWin = pWork;
|
|
|
|
}
|
|
|
|
|
|
|
|
SfxWorkWindow* SfxBindings::GetWorkWindow_Impl() const
|
|
|
|
{
|
|
|
|
return pImp->pWorkWin;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SfxBindings::RegisterUnoController_Impl( SfxUnoControllerItem* pControl )
|
|
|
|
{
|
|
|
|
if ( !pImp->pUnoCtrlArr )
|
|
|
|
pImp->pUnoCtrlArr = new SfxUnoControllerArr_Impl;
|
|
|
|
pImp->pUnoCtrlArr->Insert( pControl, pImp->pUnoCtrlArr->Count() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SfxBindings::ReleaseUnoController_Impl( SfxUnoControllerItem* pControl )
|
|
|
|
{
|
|
|
|
if ( pImp->pUnoCtrlArr )
|
|
|
|
{
|
|
|
|
sal_uInt16 nPos = pImp->pUnoCtrlArr->GetPos( pControl );
|
|
|
|
if ( nPos != 0xFFFF )
|
|
|
|
{
|
|
|
|
pImp->pUnoCtrlArr->Remove( nPos );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
pImp->pSubBindings->ReleaseUnoController_Impl( pControl );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SfxBindings::InvalidateUnoControllers_Impl()
|
|
|
|
{
|
|
|
|
if ( pImp->pUnoCtrlArr )
|
|
|
|
{
|
|
|
|
sal_uInt16 nCount = pImp->pUnoCtrlArr->Count();
|
|
|
|
for ( sal_uInt16 n=nCount; n>0; n-- )
|
|
|
|
{
|
|
|
|
SfxUnoControllerItem *pCtrl = (*pImp->pUnoCtrlArr)[n-1];
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > xRef( (::cppu::OWeakObject*)pCtrl, ::com::sun::star::uno::UNO_QUERY );
|
|
|
|
pCtrl->ReleaseDispatch();
|
|
|
|
pCtrl->GetNewDispatch();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
pImp->pSubBindings->InvalidateUnoControllers_Impl();
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SfxBindings::IsInUpdate() const
|
|
|
|
{
|
|
|
|
sal_Bool bInUpdate = pImp->bInUpdate;
|
|
|
|
if ( !bInUpdate && pImp->pSubBindings )
|
|
|
|
bInUpdate = pImp->pSubBindings->IsInUpdate();
|
|
|
|
return bInUpdate;
|
|
|
|
}
|
|
|
|
|
2004-11-17 12:35:03 +00:00
|
|
|
void SfxBindings::SetVisibleState( sal_uInt16 nId, sal_Bool bShow )
|
|
|
|
{
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDisp;
|
|
|
|
SfxStateCache *pCache = GetStateCache( nId );
|
|
|
|
if ( pCache )
|
|
|
|
pCache->SetVisibleState( bShow );
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SfxBindings::SetActiveFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & rFrame )
|
|
|
|
{
|
2000-11-07 15:55:25 +00:00
|
|
|
if ( rFrame.is() || !pDispatcher )
|
|
|
|
SetDispatchProvider_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > ( rFrame, ::com::sun::star::uno::UNO_QUERY ) );
|
|
|
|
else
|
|
|
|
SetDispatchProvider_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > (
|
2009-12-15 23:07:57 +01:00
|
|
|
pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2001-09-06 12:56:35 +00:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SfxBindings::GetActiveFrame() const
|
|
|
|
{
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( pImp->xProv, ::com::sun::star::uno::UNO_QUERY );
|
|
|
|
if ( xFrame.is() || !pDispatcher )
|
|
|
|
return xFrame;
|
|
|
|
else
|
2009-12-15 23:07:57 +01:00
|
|
|
return pDispatcher->GetFrame()->GetFrame().GetFrameInterface();
|
2001-09-06 12:56:35 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void SfxBindings::SetDispatchProvider_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > & rProv )
|
|
|
|
{
|
|
|
|
sal_Bool bInvalidate = ( rProv != pImp->xProv );
|
|
|
|
if ( bInvalidate )
|
|
|
|
{
|
|
|
|
pImp->xProv = rProv;
|
|
|
|
InvalidateAll( sal_True );
|
|
|
|
InvalidateUnoControllers_Impl();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pImp->pSubBindings )
|
|
|
|
pImp->pSubBindings->SetDispatchProvider_Impl( pImp->xProv );
|
|
|
|
}
|
|
|
|
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > & SfxBindings::GetDispatchProvider_Impl() const
|
|
|
|
{
|
|
|
|
return pImp->xProv;
|
|
|
|
}
|
|
|
|
|
|
|
|
SystemWindow* SfxBindings::GetSystemWindow() const
|
|
|
|
{
|
|
|
|
SfxViewFrame *pFrame = pDispatcher->GetFrame();
|
|
|
|
while ( pFrame->GetParentViewFrame_Impl() )
|
|
|
|
pFrame = pFrame->GetParentViewFrame_Impl();
|
2009-11-30 12:56:04 +01:00
|
|
|
SfxViewFrame* pTop = pFrame->GetTopViewFrame();
|
2009-12-15 23:07:57 +01:00
|
|
|
return pTop->GetFrame().GetTopWindow_Impl();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2001-05-10 07:07:33 +00:00
|
|
|
|
2011-01-07 17:14:47 +01:00
|
|
|
sal_Bool SfxBindings::ExecuteCommand_Impl( const String& rCommand )
|
2001-05-10 07:07:33 +00:00
|
|
|
{
|
|
|
|
::com::sun::star::util::URL aURL;
|
2001-12-21 12:33:43 +00:00
|
|
|
aURL.Complete = rCommand;
|
2010-11-20 23:37:30 +01:00
|
|
|
Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.URLTransformer"))), UNO_QUERY );
|
2001-05-10 07:07:33 +00:00
|
|
|
xTrans->parseStrict( aURL );
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDisp = pImp->xProv->queryDispatch( aURL, ::rtl::OUString(), 0 );
|
|
|
|
if ( xDisp.is() )
|
|
|
|
{
|
2002-06-27 06:56:58 +00:00
|
|
|
new SfxAsyncExec_Impl( aURL, xDisp );
|
2011-01-07 17:14:47 +01:00
|
|
|
return sal_True;
|
2001-05-10 07:07:33 +00:00
|
|
|
}
|
|
|
|
|
2011-01-07 17:14:47 +01:00
|
|
|
return sal_False;
|
2001-05-10 07:07:33 +00:00
|
|
|
}
|
2001-06-11 08:56:51 +00:00
|
|
|
|
2002-05-21 06:45:40 +00:00
|
|
|
com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > SfxBindings::GetRecorder() const
|
|
|
|
{
|
|
|
|
return pImp->xRecorder;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SfxBindings::SetRecorder_Impl( com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder >& rRecorder )
|
|
|
|
{
|
|
|
|
pImp->xRecorder = rRecorder;
|
|
|
|
}
|
|
|
|
|
2002-09-18 15:10:39 +00:00
|
|
|
void SfxBindings::ContextChanged_Impl()
|
|
|
|
{
|
|
|
|
if ( !pImp->bInUpdate && ( !pImp->bContextChanged || !pImp->bAllMsgDirty ) )
|
|
|
|
{
|
2011-01-07 17:14:47 +01:00
|
|
|
InvalidateAll( sal_True );
|
2002-09-18 15:10:39 +00:00
|
|
|
}
|
|
|
|
}
|
2005-01-18 15:07:16 +00:00
|
|
|
|
|
|
|
uno::Reference < frame::XDispatch > SfxBindings::GetDispatch( const SfxSlot* pSlot, const util::URL& aURL, sal_Bool bMasterCommand )
|
|
|
|
{
|
|
|
|
uno::Reference < frame::XDispatch > xRet;
|
|
|
|
SfxStateCache* pCache = GetStateCache( pSlot->nSlotId );
|
2005-01-27 14:30:27 +00:00
|
|
|
if ( pCache && !bMasterCommand )
|
2005-01-18 15:07:16 +00:00
|
|
|
xRet = pCache->GetInternalDispatch();
|
|
|
|
if ( !xRet.is() )
|
|
|
|
{
|
2005-02-21 15:59:23 +00:00
|
|
|
// dispatches for slaves are unbound, they don't have a state
|
|
|
|
SfxOfficeDispatch* pDispatch = bMasterCommand ?
|
|
|
|
new SfxOfficeDispatch( pDispatcher, pSlot, aURL ) :
|
|
|
|
new SfxOfficeDispatch( *this, pDispatcher, pSlot, aURL );
|
|
|
|
|
2005-01-18 15:07:16 +00:00
|
|
|
pDispatch->SetMasterUnoCommand( bMasterCommand );
|
|
|
|
xRet = uno::Reference < frame::XDispatch >( pDispatch );
|
|
|
|
if ( !pCache )
|
|
|
|
pCache = GetStateCache( pSlot->nSlotId );
|
|
|
|
|
|
|
|
DBG_ASSERT( pCache, "No cache for OfficeDispatch!" );
|
2005-01-27 14:30:27 +00:00
|
|
|
if ( pCache && !bMasterCommand )
|
2005-01-18 15:07:16 +00:00
|
|
|
pCache->SetInternalDispatch( xRet );
|
|
|
|
}
|
|
|
|
|
|
|
|
return xRet;
|
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|