LibreOffice Module sfx2 (master) 1
shell.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <com/sun/star/embed/VerbDescriptor.hpp>
21#include <com/sun/star/embed/VerbAttributes.hpp>
22#include <officecfg/Office/Common.hxx>
23#include <rtl/ustring.hxx>
24#include <sal/log.hxx>
25#include <osl/diagnose.h>
26#include <svl/itempool.hxx>
27#include <svl/setitem.hxx>
28#include <svl/undo.hxx>
29#include <itemdel.hxx>
30#include <svtools/asynclink.hxx>
32#include <comphelper/lok.hxx>
33#include <sfx2/shell.hxx>
34#include <sfx2/bindings.hxx>
35#include <sfx2/dispatch.hxx>
36#include <sfx2/viewfrm.hxx>
37#include <sfx2/objface.hxx>
38#include <sfx2/objsh.hxx>
39#include <sfx2/viewsh.hxx>
40#include <sfx2/request.hxx>
41#include <sfx2/sfxsids.hrc>
42#include <statcach.hxx>
44#include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
45#include <tools/debug.hxx>
46
47#include <memory>
48#include <vector>
49#include <map>
50
52
53using namespace com::sun::star;
54
56{
57 OUString aObjectName; // Name of Sbx-Objects
58 // Maps the Which() field to a pointer to a SfxPoolItem
59 std::map<sal_uInt16, std::unique_ptr<SfxPoolItem>>
60 m_Items; // Data exchange on Item level
61 SfxViewShell* pViewSh; // SfxViewShell if Shell is
62 // ViewFrame/ViewShell/SubShell list
63 SfxViewFrame* pFrame; // Frame, if <UI-active>
64 SfxRepeatTarget* pRepeatTarget; // SbxObjectRef xParent;
65 bool bActive;
67 std::unique_ptr<svtools::AsynchronLink> pExecuter;
68 std::unique_ptr<svtools::AsynchronLink> pUpdater;
69 std::vector<std::unique_ptr<SfxSlot> > aSlotArr;
70
71 css::uno::Sequence < css::embed::VerbDescriptor > aVerbList;
73
75 : pViewSh(nullptr)
76 , pFrame(nullptr)
77 , pRepeatTarget(nullptr)
78 , bActive(false)
80 {
81 }
82
83 virtual ~SfxShell_Impl() override { pExecuter.reset(); pUpdater.reset();}
84};
85
86
88{
89}
90
92{
93}
94
96: pImpl(new SfxShell_Impl),
97 pPool(nullptr),
98 pUndoMgr(nullptr)
99{
100}
101
103: pImpl(new SfxShell_Impl),
104 pPool(nullptr),
105 pUndoMgr(nullptr)
106{
107 pImpl->pViewSh = pViewSh;
108}
109
111{
112}
113
114void SfxShell::SetName( const OUString &rName )
115{
116 pImpl->aObjectName = rName;
117}
118
119const OUString& SfxShell::GetName() const
120{
121 return pImpl->aObjectName;
122}
123
125{
126 return pImpl->pFrame ? pImpl->pFrame->GetDispatcher() : nullptr;
127}
128
130{
131 return pImpl->pViewSh;
132}
133
135{
136 if ( pImpl->pFrame )
137 return pImpl->pFrame;
138 if ( pImpl->pViewSh )
139 return &pImpl->pViewSh->GetViewFrame();
140 return nullptr;
141}
142
144(
145 sal_uInt16 nSlotId // Slot-Id of the querying <SfxPoolItem>s
146) const
147{
148 auto const it = pImpl->m_Items.find( nSlotId );
149 if (it != pImpl->m_Items.end())
150 return it->second.get();
151 return nullptr;
152}
153
155(
156 const SfxPoolItem& rItem /* Instance, of which a copy is created,
157 which is stored in the SfxShell in a list. */
158)
159{
160 DBG_ASSERT( dynamic_cast< const SfxSetItem* >( &rItem) == nullptr, "SetItems aren't allowed here" );
162 "items with Which-Ids aren't allowed here" );
163
164 // MSC made a mess here of WNT/W95, beware of changes
165 SfxPoolItem *pItem = rItem.Clone();
166 SfxPoolItemHint aItemHint( pItem );
167 sal_uInt16 nWhich = rItem.Which();
168
169 auto const it = pImpl->m_Items.find(nWhich);
170 if (it != pImpl->m_Items.end())
171 {
172 // Replace Item
173 it->second = std::unique_ptr<SfxPoolItem>(pItem);
174
175 // if active, notify Bindings
176 SfxDispatcher *pDispat = GetDispatcher();
177 if ( pDispat )
178 {
179 SfxBindings* pBindings = pDispat->GetBindings();
180 pBindings->Broadcast( aItemHint );
181 sal_uInt16 nSlotId = nWhich; //pItem->GetSlotId();
182 SfxStateCache* pCache = pBindings->GetStateCache( nSlotId );
183 if ( pCache )
184 {
185 pCache->SetState( SfxItemState::DEFAULT, pItem, true );
186 pCache->SetCachedState( true );
187 }
188 }
189 return;
190 }
191 else
192 {
193 Broadcast( aItemHint );
194 pImpl->m_Items.insert(std::make_pair(nWhich, std::unique_ptr<SfxPoolItem>(pItem)));
195 }
196}
197
199{
200 return GetStaticInterface();
201}
202
204{
205 return pUndoMgr;
206}
207
209{
210 OSL_ENSURE( ( pUndoMgr == nullptr ) || ( pNewUndoMgr == nullptr ) || ( pUndoMgr == pNewUndoMgr ),
211 "SfxShell::SetUndoManager: exchanging one non-NULL manager with another non-NULL manager? Suspicious!" );
212 // there's at least one client of our UndoManager - the DocumentUndoManager at the SfxBaseModel - which
213 // caches the UndoManager, and registers itself as listener. If exchanging non-NULL UndoManagers is really
214 // a supported scenario (/me thinks it is not), then we would need to notify all such clients instances.
215
216 pUndoMgr = pNewUndoMgr;
218 {
220 officecfg::Office::Common::Undo::Steps::get());
221 }
222}
223
224SfxRepeatTarget* SfxShell::GetRepeatTarget() const
225{
226 return pImpl->pRepeatTarget;
227}
228
229void SfxShell::SetRepeatTarget( SfxRepeatTarget *pTarget )
230{
231 pImpl->pRepeatTarget = pTarget;
232}
233
235(
236 sal_uInt16 nId /* Invalidated Slot-Id or Which-Id.
237 If these are 0 (default), then all
238 by this Shell currently handled Slot-Ids are
239 invalidated. */
240)
241{
242 if ( !GetViewShell() )
243 {
244 OSL_FAIL( "wrong Invalidate method called!" );
245 return;
246 }
247
248 Invalidate_Impl( GetViewShell()->GetViewFrame().GetBindings(), nId );
249}
250
251void SfxShell::Invalidate_Impl( SfxBindings& rBindings, sal_uInt16 nId )
252{
253 if ( nId == 0 )
254 {
255 rBindings.InvalidateShell( *this );
256 }
257 else
258 {
259 const SfxInterface *pIF = GetInterface();
260 do
261 {
262 const SfxSlot *pSlot = pIF->GetSlot(nId);
263 if ( pSlot )
264 {
265 // Invalidate the Slot itself
266 rBindings.Invalidate( pSlot->GetSlotId() );
267 return;
268 }
269
270 pIF = pIF->GetGenoType();
271 }
272
273 while ( pIF );
274
275 SAL_INFO( "sfx.control", "W3: invalidating slot-id unknown in shell" );
276 }
277}
278
280{
281 try
282 {
283 uno::Reference < ui::dialogs::XExecutableDialog > xDialog = ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() );
284 xDialog->execute();
285 }
286 catch (const uno::Exception&)
287 {
288 }
289 rReq.Ignore ();
290}
291
292void SfxShell::DoActivate_Impl( SfxViewFrame *pFrame, bool bMDI )
293{
294 SfxObjectShell* pObjectShell = GetObjectShell();
295 if ( pObjectShell )
296 {
297 const OUString sActiveDocName = pObjectShell->GetTitle();
298 if( !pImpl->aObjectName.startsWith(sActiveDocName) )
299 {
301 }
302 }
303 else
304 {
306 }
307
308#ifdef DBG_UTIL
309 const SfxInterface *p_IF = GetInterface();
310 if ( !p_IF )
311 return;
312#endif
313 SAL_INFO(
314 "sfx.control",
315 "SfxShell::DoActivate() " << this << " " << GetInterface()->GetClassName()
316 << " bMDI " << (bMDI ? "MDI" : ""));
317
318 if ( bMDI )
319 {
320 // Remember Frame, in which it was activated
321 pImpl->pFrame = pFrame;
322 pImpl->bActive = true;
323 }
324
325 // Notify Subclass
326 Activate(bMDI);
327}
328
329void SfxShell::DoDeactivate_Impl( SfxViewFrame const *pFrame, bool bMDI )
330{
331#ifdef DBG_UTIL
332 const SfxInterface *p_IF = GetInterface();
333 if ( !p_IF )
334 return;
335#endif
336 SAL_INFO(
337 "sfx.control",
338 "SfxShell::DoDeactivate()" << this << " " << GetInterface()->GetClassName()
339 << " bMDI " << (bMDI ? "MDI" : ""));
340
341 // Only when it comes from a Frame
342 // (not when for instance by popping BASIC-IDE from AppDisp)
343 if ( bMDI && pImpl->pFrame == pFrame )
344 {
345 // deliver
346 pImpl->pFrame = nullptr;
347 pImpl->bActive = false;
348 }
349
350 // Notify Subclass
351 Deactivate(bMDI);
352}
353
355{
356 return pImpl->bActive;
357}
358
360(
361 bool /*bMDI*/ /* TRUE
362 the <SfxDispatcher>, on which the SfxShell is
363 located, is activated or the SfxShell instance
364 was pushed on an active SfxDispatcher.
365 (compare with SystemWindow::IsMDIActivate())
366
367 FALSE
368 the <SfxViewFrame>, on which SfxDispatcher
369 the SfxShell instance is located, was
370 activated. (for example by a closing dialog) */
371)
372{
374}
375
377(
378 bool /*bMDI*/ /* TRUE
379 the <SfxDispatcher>, on which the SfxShell is
380 located, is inactivated or the SfxShell instance
381 was popped on an active SfxDispatcher.
382 (compare with SystemWindow::IsMDIActivate())
383
384 FALSE
385 the <SfxViewFrame>, on which SfxDispatcher
386 the SfxShell instance is located, was
387 deactivated. (for example by a dialog) */
388)
389{
391}
392
394{
395 // Get Slot status
396 SfxItemPool &rPool = GetPool();
397 const sal_uInt16 nId = rSlot.GetWhich( rPool );
398 SfxItemSet aSet(rPool, nId, nId);
399 SfxStateFunc pFunc = rSlot.GetStateFnc();
400 (*pFunc)( this, aSet );
401 return aSet.GetItemState(nId) != SfxItemState::DISABLED;
402}
403
405{
406 sal_uInt16 nId = rReq.GetSlot();
407 bool bRet = false;
408
409 if (nId == SID_UNDO || nId == SID_REDO)
410 {
411 const SfxItemSet* pArgs = rReq.GetArgs();
412 if (pArgs && pArgs->HasItem(SID_REPAIRPACKAGE))
413 bRet = true;
414 }
415 return bRet;
416}
417
418
419static void ShellCall_Impl( void* pObj, void* pArg )
420{
421 static_cast<SfxShell*>(pObj)->ExecuteSlot( *static_cast<SfxRequest*>(pArg) );
422}
423
424void SfxShell::ExecuteSlot( SfxRequest& rReq, bool bAsync )
425{
426 if( !bAsync )
427 ExecuteSlot( rReq );
428 else
429 {
430 if( !pImpl->pExecuter )
431 pImpl->pExecuter.reset( new svtools::AsynchronLink(
432 Link<void*,void>( this, ShellCall_Impl ) ) );
433 pImpl->pExecuter->Call( new SfxRequest( rReq ) );
434 }
435}
436
438(
439 SfxRequest &rReq, // the relayed <SfxRequest>
440 const SfxInterface* pIF // default = 0 means get virtually
441)
442{
443 if ( !pIF )
444 pIF = GetInterface();
445
446 sal_uInt16 nSlot = rReq.GetSlot();
447 const SfxSlot* pSlot = nullptr;
448 if ( nSlot >= SID_VERB_START && nSlot <= SID_VERB_END )
449 pSlot = GetVerbSlot_Impl(nSlot);
450 if ( !pSlot )
451 pSlot = pIF->GetSlot(nSlot);
452 DBG_ASSERT( pSlot, "slot not supported" );
453
454 SfxExecFunc pFunc = pSlot->GetExecFnc();
455 if ( pFunc )
456 (*pFunc)( this, rReq );
457
458 return rReq.GetReturnValue();
459}
460
462(
463 sal_uInt16 nSlotId, // Slot-Id to the Slots in question
464 const SfxInterface* pIF, // default = 0 means get virtually
465 SfxItemSet* pStateSet // SfxItemSet of the Slot-State method
466)
467{
468 // Get Slot on the given Interface
469 if ( !pIF )
470 pIF = GetInterface();
471 SfxItemState eState(SfxItemState::DEFAULT);
472 bool bItemStateSet(false);
473 SfxItemPool &rPool = GetPool();
474
475 const SfxSlot* pSlot = nullptr;
476 if ( nSlotId >= SID_VERB_START && nSlotId <= SID_VERB_END )
477 pSlot = GetVerbSlot_Impl(nSlotId);
478 if ( !pSlot )
479 pSlot = pIF->GetSlot(nSlotId);
480 if ( pSlot )
481 // Map on Which-Id if possible
482 nSlotId = pSlot->GetWhich( rPool );
483
484 // Get Item and Item status
485 const SfxPoolItem *pItem = nullptr;
486 SfxItemSet aSet( rPool, nSlotId, nSlotId ); // else pItem dies too soon
487 if ( nullptr != pSlot )
488 {
489 // Call Status method
490 SfxStateFunc pFunc = pSlot->GetStateFnc();
491 if ( pFunc )
492 (*pFunc)( this, aSet );
493 eState = aSet.GetItemState( nSlotId, true, &pItem );
494 bItemStateSet = true;
495
496 // get default Item if possible
497 if ( eState == SfxItemState::DEFAULT )
498 {
499 if ( SfxItemPool::IsWhich(nSlotId) )
500 pItem = &rPool.GetDefaultItem(nSlotId);
501 else
502 eState = SfxItemState::DONTCARE;
503 }
504 }
505
506 // Evaluate Item and item status and possibly maintain them in pStateSet
507 std::unique_ptr<SfxPoolItem> pRetItem;
508 if ( !bItemStateSet || eState <= SfxItemState::DISABLED )
509 {
510 if ( pStateSet )
511 pStateSet->DisableItem(nSlotId);
512 return nullptr;
513 }
514 else if ( bItemStateSet && eState == SfxItemState::DONTCARE )
515 {
516 if ( pStateSet )
517 pStateSet->ClearItem(nSlotId);
518 pRetItem.reset( new SfxVoidItem(0) );
519 }
520 else // bItemStateSet && eState >= SfxItemState::DEFAULT
521 {
522 if ( pStateSet && pStateSet->Put( *pItem ) )
523 return &pStateSet->Get( pItem->Which() );
524 pRetItem.reset(pItem->Clone());
525 }
526 auto pTemp = pRetItem.get();
527 DeleteItemOnIdle(std::move(pRetItem));
528
529 return pTemp;
530}
531
532static SFX_EXEC_STUB(SfxShell, VerbExec)
533static void SfxStubSfxShellVerbState(SfxShell *, SfxItemSet& rSet)
534{
536}
537
538void SfxShell::SetVerbs(const css::uno::Sequence < css::embed::VerbDescriptor >& aVerbs)
539{
540 SfxViewShell *pViewSh = dynamic_cast<SfxViewShell*>( this );
541
542 DBG_ASSERT(pViewSh, "Only call SetVerbs at the ViewShell!");
543 if ( !pViewSh )
544 return;
545
546 // First make all Statecaches dirty, so that no-one no longer tries to use
547 // the Slots
548 {
549 SfxBindings *pBindings =
550 pViewSh->GetViewFrame().GetDispatcher()->GetBindings();
551 sal_uInt16 nCount = pImpl->aSlotArr.size();
552 for (sal_uInt16 n1=0; n1<nCount ; n1++)
553 {
554 sal_uInt16 nId = SID_VERB_START + n1;
555 pBindings->Invalidate(nId, false, true);
556 }
557 }
558
559 sal_uInt16 nr=0;
560 for (sal_Int32 n=0; n<aVerbs.getLength(); n++)
561 {
562 sal_uInt16 nSlotId = SID_VERB_START + nr++;
563 DBG_ASSERT(nSlotId <= SID_VERB_END, "Too many Verbs!");
564 if (nSlotId > SID_VERB_END)
565 break;
566
567 SfxSlot* pNewSlot = new SfxSlot(
568 nSlotId, SfxGroupId::NONE,
569 // Verb slots must be executed asynchronously, so that they can be
570 // destroyed while executing.
572 0, 0,
574 nullptr, // HACK(SFX_TYPE(SfxVoidItem)) ???
575 nullptr, nullptr, 0, SfxDisableFlags::NONE, "");
576
577 if (!pImpl->aSlotArr.empty())
578 {
579 SfxSlot& rSlot = *pImpl->aSlotArr[0];
580 pNewSlot->pNextSlot = rSlot.pNextSlot;
581 rSlot.pNextSlot = pNewSlot;
582 }
583 else
584 pNewSlot->pNextSlot = pNewSlot;
585
586 pImpl->aSlotArr.insert(pImpl->aSlotArr.begin() + static_cast<sal_uInt16>(n), std::unique_ptr<SfxSlot>(pNewSlot));
587 }
588
589 pImpl->aVerbList = aVerbs;
590
591 // The status of SID_OBJECT is collected in the controller directly on
592 // the Shell, it is thus enough to encourage a new status update
593 SfxBindings* pBindings = pViewSh->GetViewFrame().GetDispatcher()->GetBindings();
594 pBindings->Invalidate(SID_OBJECT, true, true);
595}
596
597const css::uno::Sequence < css::embed::VerbDescriptor >& SfxShell::GetVerbs() const
598{
599 return pImpl->aVerbList;
600}
601
603{
604 sal_uInt16 nId = rReq.GetSlot();
605 SfxViewShell *pViewShell = GetViewShell();
606 if ( !pViewShell )
607 return;
608
609 bool bReadOnly = pViewShell->GetObjectShell()->IsReadOnly();
610 const css::uno::Sequence < css::embed::VerbDescriptor > aList = pViewShell->GetVerbs();
611 sal_Int32 nVerb = 0;
612 for (const auto& rVerb : aList)
613 {
614 // check for ReadOnly verbs
615 if ( bReadOnly && !(rVerb.VerbAttributes & embed::VerbAttributes::MS_VERBATTR_NEVERDIRTIES) )
616 continue;
617
618 // check for verbs that shouldn't appear in the menu
619 if ( !(rVerb.VerbAttributes & embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU) )
620 continue;
621
622 if (nId == SID_VERB_START + nVerb++)
623 {
624 pViewShell->DoVerb(rVerb.VerbID);
625 rReq.Done();
626 return;
627 }
628 }
629}
630
632{
633}
634
635const SfxSlot* SfxShell::GetVerbSlot_Impl(sal_uInt16 nId) const
636{
637 css::uno::Sequence < css::embed::VerbDescriptor > rList = pImpl->aVerbList;
638
639 DBG_ASSERT(nId >= SID_VERB_START && nId <= SID_VERB_END,"Wrong VerbId!");
640 sal_uInt16 nIndex = nId - SID_VERB_START;
641 DBG_ASSERT(nIndex < rList.getLength(),"Wrong VerbId!");
642
643 if (nIndex < rList.getLength())
644 return pImpl->aSlotArr[nIndex].get();
645 else
646 return nullptr;
647}
648
650{
651 if ( GetViewShell() )
653 else
654 return nullptr;
655}
656
658{
659 return false;
660}
661
662static void DispatcherUpdate_Impl( void*, void* pArg )
663{
664 static_cast<SfxDispatcher*>(pArg)->Update_Impl( true );
665 static_cast<SfxDispatcher*>(pArg)->GetBindings()->InvalidateAll(false);
666}
667
669{
670 SfxViewFrame *pFrame = GetFrame();
671 if ( pFrame && pFrame->IsVisible() )
672 {
673 // Also force an update, if dispatcher is already updated otherwise
674 // something may get stuck in the bunkered tools. Asynchronous call to
675 // prevent recursion.
676 if ( !pImpl->pUpdater )
677 pImpl->pUpdater.reset( new svtools::AsynchronLink( Link<void*,void>( this, DispatcherUpdate_Impl ) ) );
678
679 // Multiple views allowed
680 pImpl->pUpdater->Call( pFrame->GetDispatcher(), true );
681 }
682}
683
685{
686 pImpl->nDisableFlags = nFlags;
687}
688
690{
691 return pImpl->nDisableFlags;
692}
693
694std::optional<SfxItemSet> SfxShell::CreateItemSet( sal_uInt16 )
695{
696 return {};
697}
698
699void SfxShell::ApplyItemSet( sal_uInt16, const SfxItemSet& )
700{
701}
702
703void SfxShell::SetContextName (const OUString& rsContextName)
704{
705 pImpl->maContextChangeBroadcaster.Initialize(rsContextName);
706}
707
709{
710 pImpl->pViewSh = pView;
711}
712
713void SfxShell::BroadcastContextForActivation (const bool bIsActivated)
714{
715 // Avoids activation and de-activation (can be seen on switching view) from causing
716 // the sidebar to re-build. Such switching can happen as we change view to render
717 // using LOK for example, and is un-necessary for Online.
719 return;
720
721 SfxViewFrame* pViewFrame = GetFrame();
722 if (pViewFrame != nullptr)
723 {
724 if (bIsActivated)
725 pImpl->maContextChangeBroadcaster.Activate(pViewFrame->GetFrame().GetFrameInterface());
726 else
727 pImpl->maContextChangeBroadcaster.Deactivate(pViewFrame->GetFrame().GetFrameInterface());
728 }
729}
730
731bool SfxShell::SetContextBroadcasterEnabled (const bool bIsEnabled)
732{
733 return pImpl->maContextChangeBroadcaster.SetBroadcasterEnabled(bIsEnabled);
734}
735
736/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void setActiveSfxObjectName(SAL_UNUSED_PARAMETER const OUString &)
SAL_DLLPRIVATE SfxStateCache * GetStateCache(sal_uInt16 nId, std::size_t *pPos)
Definition: bindings.cxx:474
void InvalidateShell(const SfxShell &rSh, bool bDeep=false)
Definition: bindings.cxx:585
void Invalidate(sal_uInt16 nId)
Definition: bindings.cxx:639
void InvalidateAll(bool bWithMsg)
Definition: bindings.cxx:498
void Broadcast(const SfxHint &rHint)
SfxBindings * GetBindings() const
This method returns a pointer to the <SfxBinding> Instance on which the SfxDispatcher is currently bo...
Definition: dispatch.cxx:545
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
Definition: frame.cxx:515
const SfxSlot * GetSlot(sal_uInt16 nSlotId) const
Definition: objface.cxx:187
const SfxInterface * GetGenoType() const
Definition: objface.hxx:85
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
static bool IsWhich(sal_uInt16 nId)
static bool IsSlot(sal_uInt16 nId)
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
bool IsReadOnly() const
Definition: objmisc.cxx:416
OUString GetTitle(sal_uInt16 nMaxLen=0) const
Definition: objmisc.cxx:710
sal_uInt16 Which() const
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
sal_uInt16 GetSlot() const
Definition: request.hxx:68
void Ignore()
Definition: request.cxx:521
const SfxPoolItem * GetReturnValue() const
Definition: request.cxx:429
const SfxItemSet * GetArgs() const
Definition: request.hxx:75
void Done(bool bRemove=false)
Definition: request.cxx:484
The class SfxShell is the base class for all classes, which provide the functionality of the form <Sl...
Definition: shell.hxx:128
void PutItem(const SfxPoolItem &rItem)
With this method, any objects of subclasses of <SfxPoolItem> can be made available.
Definition: shell.cxx:155
virtual void ApplyItemSet(sal_uInt16 nId, const SfxItemSet &rSet)
Definition: shell.cxx:699
const SfxPoolItem * GetSlotState(sal_uInt16 nSlotId, const SfxInterface *pIF=nullptr, SfxItemSet *pStateSet=nullptr)
This method returns the status of the slot with the specified slot ID on the specified interface.
Definition: shell.cxx:462
SfxShell()
The constructor of the SfxShell class initializes only simple types, the corresponding SbxObject is o...
Definition: shell.cxx:95
void SetUndoManager(SfxUndoManager *pNewUndoMgr)
Sets a <SfxUndoManager> for this <SfxShell> Instance.
Definition: shell.cxx:208
SAL_DLLPRIVATE bool CanExecuteSlot_Impl(const SfxSlot &rSlot)
This method determines by calling the status function whether 'rSlot' can be executed currently.
Definition: shell.cxx:393
SfxItemPool & GetPool() const
Each Subclass of SfxShell must reference a pool.
Definition: shell.hxx:511
void SetRepeatTarget(SfxRepeatTarget *pTarget)
Sets the <SfxRepeatTarget> instance that is used in SID_REPEAT as RepeatTarget, when the current supp...
Definition: shell.cxx:229
virtual void Activate(bool bMDI)
Virtual method that is called when enabling the SfxShell instance, in order to give the Subclasses th...
Definition: shell.cxx:360
const OUString & GetName() const
Returns the name of the Shell object.
Definition: shell.cxx:119
void BroadcastContextForActivation(const bool bIsActivated)
Broadcast a sidebar context change.
Definition: shell.cxx:713
bool SetContextBroadcasterEnabled(const bool bIsEnabled)
Enabled or disable the context broadcaster.
Definition: shell.cxx:731
virtual bool IsConditionalFastCall(const SfxRequest &rReq)
This method determines whether we need to execute without checking the disabled state of the slot.
Definition: shell.cxx:404
virtual ~SfxShell() override
The connection to a possible corresponding SbxObject is dissolved.
Definition: shell.cxx:110
void SetVerbs(const css::uno::Sequence< css::embed::VerbDescriptor > &aVerbs)
Definition: shell.cxx:538
void SetContextName(const OUString &rsContextName)
Set the name of the sidebar context that is broadcast on calls to Activation().
Definition: shell.cxx:703
virtual bool HasUIFeature(SfxShellFeature nFeature) const
Definition: shell.cxx:657
SAL_DLLPRIVATE void DoActivate_Impl(SfxViewFrame *pFrame, bool bMDI)
This method controls the activation of SfxShell instance.
Definition: shell.cxx:292
SfxUndoManager * pUndoMgr
Definition: shell.hxx:133
static void HandleOpenXmlFilterSettings(SfxRequest &)
Definition: shell.cxx:279
SfxViewFrame * GetFrame() const
This method returns a pointer to the <SfxViewFrame> to which this SfxShell instance is associated or ...
Definition: shell.cxx:134
void SetDisableFlags(SfxDisableFlags nFlags)
Definition: shell.cxx:684
virtual std::optional< SfxItemSet > CreateItemSet(sal_uInt16 nId)
Definition: shell.cxx:694
SAL_DLLPRIVATE void Invalidate_Impl(SfxBindings &rBindings, sal_uInt16 nId)
Definition: shell.cxx:251
void VerbExec(SfxRequest &)
Definition: shell.cxx:602
const css::uno::Sequence< css::embed::VerbDescriptor > & GetVerbs() const
Definition: shell.cxx:597
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
With this method any objects of <SfxPoolItemu> subclasses can be accessed.
Definition: shell.cxx:144
SAL_DLLPRIVATE void DoDeactivate_Impl(SfxViewFrame const *pFrame, bool bMDI)
This method controls the deactivation of the SfxShell instance.
Definition: shell.cxx:329
SAL_DLLPRIVATE const SfxSlot * GetVerbSlot_Impl(sal_uInt16 nId) const
Definition: shell.cxx:635
virtual SfxInterface * GetInterface() const
With this virtual method, which is automatically overridden by each subclass with its own slots throu...
Definition: shell.cxx:198
virtual void Invalidate(sal_uInt16 nId=0)
With this method can the slots of the subclasses be invalidated through the slot Id or alternatively ...
Definition: shell.cxx:235
virtual void Deactivate(bool bMDI)
Virtual method that is called when disabling the SfxShell instance, to give the Subclasses the opport...
Definition: shell.cxx:377
void SetViewShell_Impl(SfxViewShell *pView)
Definition: shell.cxx:708
SfxDisableFlags GetDisableFlags() const
Definition: shell.cxx:689
virtual SfxObjectShell * GetObjectShell()
Definition: shell.cxx:649
std::unique_ptr< SfxShell_Impl > pImpl
Definition: shell.hxx:131
static SfxInterface * GetStaticInterface()
Definition: shell.hxx:176
SfxRepeatTarget * GetRepeatTarget() const
Returns a pointer to the <SfxRepeatTarget> instance that is used in SID_REPEAT as repeat target when ...
Definition: shell.cxx:224
const SfxPoolItem * ExecuteSlot(SfxRequest &rReq, const SfxInterface *pIF=nullptr)
This method allows you to forward a <SfxRequest> to the specified base <SfxShell>.
Definition: shell.cxx:438
virtual SfxUndoManager * GetUndoManager()
Each Subclass of SfxShell can have a <SfxUndoManager>.
Definition: shell.cxx:203
static void EmptyExecStub(SfxShell *pShell, SfxRequest &)
Definition: shell.cxx:87
SfxViewShell * GetViewShell() const
Returns the SfxViewShell in which they are located in the subshells.
Definition: shell.cxx:129
static void VerbState(SfxItemSet &)
Definition: shell.cxx:631
static void EmptyStateStub(SfxShell *pShell, SfxItemSet &)
Definition: shell.cxx:91
bool IsActive() const
Definition: shell.cxx:354
void UIFeatureChanged()
Definition: shell.cxx:668
SfxDispatcher * GetDispatcher() const
This method returns a pointer to the <SfxDispatcher>, when the SfxShell is currently <UI-active> or a...
Definition: shell.cxx:124
void SetName(const OUString &rName)
Sets the name of the Shell object.
Definition: shell.cxx:114
Definition: msg.hxx:184
sal_uInt16 GetSlotId() const
Definition: msg.hxx:253
const SfxSlot * pNextSlot
Definition: msg.hxx:198
SfxStateFunc GetStateFnc() const
Definition: msg.hxx:245
SfxExecFunc GetExecFnc() const
Definition: msg.hxx:244
sal_uInt16 GetWhich(const SfxItemPool &rPool) const
Definition: msg.cxx:39
void SetState(SfxItemState, const SfxPoolItem *, bool bMaybeDirty=false)
Definition: statcach.cxx:311
void SetCachedState(bool bAlways)
Definition: statcach.cxx:450
void SetMaxUndoActionCount(size_t nMaxUndoActionCount)
SfxDispatcher * GetDispatcher()
Definition: viewfrm.hxx:109
SfxFrame & GetFrame() const
Definition: viewfrm.cxx:2782
virtual SfxObjectShell * GetObjectShell() override
Definition: viewfrm.cxx:2218
bool IsVisible() const
Definition: viewfrm.cxx:2162
One SfxViewShell more or less represents one edit window for a document, there can be multiple ones f...
Definition: viewsh.hxx:165
SfxViewFrame & GetViewFrame() const
Definition: viewsh.hxx:290
virtual ErrCode DoVerb(sal_Int32 nVerb)
Definition: viewsh.cxx:1433
virtual SfxObjectShell * GetObjectShell() override
Definition: viewsh.cxx:2591
This class is a helper for broadcasting context changes that are tied to shells being activated or de...
static bool IsFuzzing()
int nCount
#define DBG_ASSERT(sCon, aError)
virtual SfxBindings & GetBindings() override
bool bReadOnly
sal_Int32 nIndex
void DeleteItemOnIdle(std::unique_ptr< SfxPoolItem > pItem)
Definition: itemdel.cxx:50
sal_Int64 n
#define SAL_INFO(area, stream)
int n1
#define SFX_STUB_PTR(aShellClass, aMethod)
Definition: msg.hxx:78
NONE
sal_Int16 nId
SfxItemState
static SFX_EXEC_STUB(SfxShell, VerbExec) static void SfxStubSfxShellVerbState(SfxShell *
static SfxItemSet & rSet
Definition: shell.cxx:534
static void DispatcherUpdate_Impl(void *, void *pArg)
Definition: shell.cxx:662
static void ShellCall_Impl(void *pObj, void *pArg)
Definition: shell.cxx:419
SfxDisableFlags
Definition: shell.hxx:102
SfxShellFeature
Definition: shell.hxx:74
void(* SfxExecFunc)(SfxShell *, SfxRequest &rReq)
Definition: shell.hxx:111
void(* SfxStateFunc)(SfxShell *, SfxItemSet &rSet)
Definition: shell.hxx:112
SfxViewShell * pViewSh
Definition: shell.cxx:61
OUString aObjectName
Definition: shell.cxx:57
::sfx2::sidebar::ContextChangeBroadcaster maContextChangeBroadcaster
Definition: shell.cxx:72
std::vector< std::unique_ptr< SfxSlot > > aSlotArr
Definition: shell.cxx:69
SfxViewFrame * pFrame
Definition: shell.cxx:63
SfxDisableFlags nDisableFlags
Definition: shell.cxx:66
css::uno::Sequence< css::embed::VerbDescriptor > aVerbList
Definition: shell.cxx:71
SfxShell_Impl()
Definition: shell.cxx:74
std::map< sal_uInt16, std::unique_ptr< SfxPoolItem > > m_Items
Definition: shell.cxx:60
virtual ~SfxShell_Impl() override
Definition: shell.cxx:83
SfxRepeatTarget * pRepeatTarget
Definition: shell.cxx:64
std::unique_ptr< svtools::AsynchronLink > pExecuter
Definition: shell.cxx:67
bool bActive
Definition: shell.cxx:65
std::unique_ptr< svtools::AsynchronLink > pUpdater
Definition: shell.cxx:68
bool bIsEnabled