/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
if ( bSlotDirty )
{ // get the SlotServer; we need it for internal controllers anyway, but also in most cases
rDispat.FindServer_( nId, aSlotServ );
DBG_ASSERT( !mxDispatch.is(), "Old Dispatch not removed!" );
// we don't need to check the dispatch provider if we only have an internal controller if ( xProv.is() )
{ const SfxSlot* pSlot = aSlotServ.GetSlot(); if ( !pSlot ) // get the slot - even if it is disabled on the dispatcher
pSlot = SfxSlotPool::GetSlotPool( rDispat.GetFrame() ).GetSlot( nId );
// create the dispatch URL from the slot data
css::util::URL aURL;
OUString aCmd = u".uno:"_ustr;
aURL.Protocol = aCmd;
aURL.Path = pSlot->GetUnoName();
aCmd += aURL.Path;
aURL.Complete = aCmd;
aURL.Main = aCmd;
// try to get a dispatch object for this command
css::uno::Reference< css::frame::XDispatch > xDisp = xProv->queryDispatch( aURL, OUString(), 0 ); if ( xDisp.is() )
{ // test the dispatch object if it is just a wrapper for a SfxDispatcher if (auto pDisp = dynamic_cast<SfxOfficeDispatch*>(xDisp.get()))
{ // The intercepting object is an SFX component // If this dispatch object does not use the wanted dispatcher or the AppDispatcher, it's treated like any other UNO component // (intercepting by internal dispatches)
SfxDispatcher *pDispatcher = pDisp->GetDispatcher_Impl(); if ( pDispatcher == &rDispat || pDispatcher == SfxGetpApp()->GetAppDispatcher_Impl() )
{ // so we can use it directly
bSlotDirty = false;
bCtrlDirty = true; return aSlotServ.GetSlot()? &aSlotServ: nullptr;
}
}
// so the dispatch object isn't a SfxDispatcher wrapper or it is one, but it uses another dispatcher, but not rDispat
mxDispatch = new BindDispatch_Impl( xDisp, aURL, this, pSlot );
// flags must be set before adding StatusListener because the dispatch object will set the state
bSlotDirty = false;
bCtrlDirty = true;
xDisp->addStatusListener( mxDispatch, aURL );
} elseif ( rDispat.GetFrame() )
{
css::uno::Reference < css::frame::XDispatchProvider > xFrameProv(
rDispat.GetFrame()->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY ); if ( xFrameProv != xProv ) return GetSlotServer( rDispat, xFrameProv );
}
}
bSlotDirty = false;
bCtrlDirty = true;
}
// we *always* return a SlotServer (if there is one); but in case of an external dispatch we might not use it // for the "real" (non internal) controllers return aSlotServ.GetSlot()? &aSlotServ: nullptr;
}
This method distributes the status of all of this SID bound <SfxControllerItem>s. If the value is the same as before, and if neither controller was registered nor invalidated inbetween, then no value is passed. This way the flickering is for example avoided in ListBoxes.
*/
{
SetState_Impl( eState, pState, bMaybeDirty );
}
bItemVisible = bShow; if ( bShow )
{ // tdf#164745 also need to do this when disabled item if ( nullptr == pLastItem || IsInvalidItem(pLastItem) || IsDisabledItem(pLastItem) )
{
pState = new SfxVoidItem( nId );
bDeleteItem = true;
} else
pState = pLastItem;
if ( pInternalController )
pInternalController->StateChangedAtToolBoxControl( nId, eState, pState );
if ( bDeleteItem ) delete pState;
}
void SfxStateCache::SetState_Impl
(
SfxItemState eState, // <SfxItemState> from 'pState' const SfxPoolItem* pState, // Slot Status, 0 or -1 bool bMaybeDirty
)
{ // If a hard update occurs between enter- and leave-registrations is a // can also intermediate Cached exist without controller. if ( !pController && !pInternalController ) return;
DBG_ASSERT( bMaybeDirty || !bSlotDirty, "setting state of dirty message" );
DBG_ASSERT( SfxControllerItem::GetItemState(pState) == eState, "invalid SfxItemState" );
// does the controller have to be notified at all? bool bNotify = bItemDirty; if ( !bItemDirty )
{
bNotify = !SfxPoolItem::areSame(pLastItem, pState) || (eState != eLastState);
}
// Only update if cached item exists and also able to process. // (If the State is sent, it must be ensured that a SlotServer is present, // see SfxControllerItem:: GetCoreMetric()) if ( !(bAlways || ( !bItemDirty && !bSlotDirty )) ) return;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.