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