20#include <config_feature_desktop.h>
29#include <boost/property_tree/json_parser.hpp>
31#include <com/sun/star/awt/PopupMenuDirection.hpp>
32#include <com/sun/star/beans/XPropertySet.hpp>
33#include <com/sun/star/frame/XDispatchRecorderSupplier.hpp>
34#include <com/sun/star/frame/XLayoutManager.hpp>
35#include <com/sun/star/frame/XPopupMenuController.hpp>
36#include <com/sun/star/uno/XComponentContext.hpp>
37#include <com/sun/star/ui/ContextMenuExecuteEvent.hpp>
39#include <LibreOfficeKit/LibreOfficeKitEnums.h>
43#include <rtl/strbuf.hxx>
57#include <sfx2/sfxsids.hrc>
85 SfxToDo_Impl(
bool bOpPush,
bool bOpDelete,
bool bOpUntil,
SfxShell& rCluster )
94struct SfxObjectBars_Impl
112 std::vector<std::unique_ptr<SfxRequest>>
147 return xImp->bFlushed;
198 return xImp->bLocked;
208 return !
xImp->pFrame;
225 css::uno::Reference< css::beans::XPropertySet > xSet(
227 css::uno::UNO_QUERY);
231 css::uno::Any aProp = xSet->getPropertyValue(
"DispatchRecorderSupplier");
232 css::uno::Reference< css::frame::XDispatchRecorderSupplier > xSupplier;
233 css::uno::Reference< css::frame::XDispatchRecorder > xRecorder;
236 xRecorder = xSupplier->getDispatchRecorder();
249 bool bThisDispatcherAlive =
true;
250 bool *pOldInCallAliveFlag =
xImp->pInCallAliveFlag;
251 xImp->pInCallAliveFlag = &bThisDispatcherAlive;
254 (*pFunc)(&rShell, rReq);
257 if ( bThisDispatcherAlive )
258 xImp->pInCallAliveFlag = pOldInCallAliveFlag;
261 if ( pOldInCallAliveFlag )
264 *pOldInCallAliveFlag =
false;
277 if ( bAutoUpdate && pBindings )
288 xImp->bFlushed =
true;
290 xImp->bFlushing =
false;
291 xImp->bUpdated =
false;
292 xImp->bLocked =
false;
293 xImp->bActive =
false;
295 xImp->bReadOnly =
false;
296 xImp->bQuiet =
false;
297 xImp->pInCallAliveFlag =
nullptr;
301 xImp->bInvalidateOnUnlock =
false;
303 for (SfxObjectBars_Impl & rObjBar :
xImp->aObjBars)
308 xImp->aIdle.SetPriority(TaskPriority::HIGH_IDLE );
315 xImp->pFrame =
nullptr;
324 xImp->pFrame = pViewFrame;
333 SAL_INFO(
"sfx.control",
"Delete Dispatcher " <<
reinterpret_cast<sal_Int64
>(
this));
338 xImp->xPoster->SetEventHdl( std::function<
void (std::unique_ptr<SfxRequest>)>() );
341 if (
xImp->pInCallAliveFlag )
342 *
xImp->pInCallAliveFlag =
false;
350 pBindings->DLEAVEREGISTRATIONS();
383 "pushing SfxShell without previous RegisterInterface()" );
393 "-SfxDispatcher(" <<
this << (bPush ?
")::Push(" :
")::Pop(")
396 << (bDelete ?
") with delete" :
")")
397 << (bUntil ?
" (up to)" :
""));
400 if(!
xImp->aToDoStack.empty() &&
xImp->aToDoStack.front().pCluster == &rShell)
403 if (
xImp->aToDoStack.front().bPush != bPush )
404 xImp->aToDoStack.pop_front();
407 DBG_ASSERT( bPush,
"SfxInterface pushed more than once" );
408 DBG_ASSERT( !bPush,
"SfxInterface popped more than once" );
414 xImp->aToDoStack.push_front( SfxToDo_Impl(bPush, bDelete, bUntil, rShell) );
417 SAL_INFO(
"sfx.control",
"Unflushed dispatcher!");
418 xImp->bFlushed =
false;
419 xImp->bUpdated =
false;
424 pBindings->DENTERREGISTRATIONS();
439 if(
xImp->aToDoStack.empty())
443 pBindings->DLEAVEREGISTRATIONS();
476 for(std::deque<SfxToDo_Impl>::reverse_iterator
i =
xImp->aToDoStack.rbegin();
i !=
xImp->aToDoStack.rend(); ++
i)
479 aStack.push_back(
i->pCluster);
485 DBG_ASSERT( !aStack.empty(),
"popping from empty stack" );
486 pPopped = aStack.back();
489 while(
i->bUntil && pPopped !=
i->pCluster);
490 DBG_ASSERT(pPopped ==
i->pCluster,
"popping unpushed SfxInterface");
494 bool bReturn = std::find(aStack.begin(), aStack.end(), &rShell) != aStack.end();
515 for (
size_t n = 0;
n <
xImp->aStack.size(); ++
n )
516 if ( *(
xImp->aStack.rbegin() +
n ) == &rShell )
531 sal_uInt16 nShellCount =
xImp->aStack.size();
532 if ( nIdx < nShellCount )
533 return *(
xImp->aStack.rbegin() + nIdx);
548 return &
xImp->pFrame->GetBindings();
578 SAL_INFO(
"sfx.control",
"Activate Dispatcher " <<
reinterpret_cast<sal_Int64
>(
this));
581 xImp->bActive =
true;
582 xImp->bUpdated =
false;
592 SAL_INFO(
"sfx.control",
"Non-MDI-Activate Dispatcher " <<
reinterpret_cast<sal_Int64
>(
this));
598 for (
int i =
int(
xImp->aStack.size()) - 1;
i >= 0; --
i )
599 (*(
xImp->aStack.rbegin() +
i ))->DoActivate_Impl(
xImp->pFrame, bMDI);
601 if ( bMDI &&
xImp->pFrame )
603 xImp->pFrame->GetFrame().GetWorkWindow_Impl()->HidePopups_Impl(
false, 1 );
606 if(!
xImp->aToDoStack.empty())
632 SAL_INFO(
"sfx.control",
"Deactivate Dispatcher " <<
this);
634 xImp->bActive =
false;
636 if (
xImp->pFrame && !(
xImp->pFrame->GetObjectShell()->IsInPlaceActive() ) )
641 for (
size_t n=0;
n<
xImp->aChildWins.size();)
645 xImp->aChildWins.erase(
xImp->aChildWins.begin()+
n);
653 SAL_INFO(
"sfx.control",
"Non-MDI-DeActivate Dispatcher " <<
this);
659 for (
size_t i = 0;
i <
xImp->aStack.size(); ++
i )
660 (*(
xImp->aStack.rbegin() +
i))->DoDeactivate_Impl(
xImp->pFrame, bMDI);
662 bool bHidePopups = bMDI &&
xImp->pFrame;
663 if ( pNew &&
xImp->pFrame )
665 css::uno::Reference< css::frame::XFrame > xOldFrame =
668 css::uno::Reference< css::frame::XFrame > xMyFrame =
671 if ( xOldFrame == xMyFrame )
677 xImp->pFrame->GetFrame().GetWorkWindow_Impl()->HidePopups_Impl(
true, 1 );
697 const SfxSlot** ppSlot,
bool bOwnShellsOnly,
bool bRealSlot)
710 if (
nullptr == (*ppSlot)->GetExecFnc() && bRealSlot )
711 *ppSlot = (*ppShell)->GetInterface()->GetRealSlot(*ppSlot);
713 return !bRealSlot || ((
nullptr != *ppSlot) && (
nullptr != (*ppSlot)->GetExecFnc()) );
731 DBG_ASSERT(
xImp->aToDoStack.empty(),
"unprepared InPlace _Execute" );
740 sal_uInt16 nShellCount =
xImp->aStack.size();
741 for ( sal_uInt16
n=0;
n<nShellCount;
n++ )
743 if ( &rShell == *(
xImp->aStack.rbegin() +
n) )
747 xImp->xPoster->Post(std::make_unique<SfxRequest>(rReq));
763 sal_uInt16 nWhich = rItem.
Which();
773 sal_uInt16 nTotCount =
xImp->aStack.size();
775 for ( sal_uInt16
i = 0;
i < nTotCount; ++
i )
796 const SfxSlot *pSlot =
nullptr;
813 Execute_( *pShell, *pSlot, aReq, nCall );
840 const SfxSlot *pSlot =
nullptr;
843 std::unique_ptr<SfxRequest> pReq;
844 if ( pArgs && *pArgs )
847 for (
const SfxPoolItem **pArg = pArgs; *pArg; ++pArg )
849 pReq.reset(
new SfxRequest( nSlot, eCall, aSet ));
853 pReq->SetModifier( nModi );
854 if( pInternalArgs && *pInternalArgs)
857 for (
const SfxPoolItem **pArg = pInternalArgs; *pArg; ++pArg )
859 pReq->SetInternalArgs_Impl( aSet );
861 Execute_( *pShell, *pSlot, *pReq, eCall );
888 const SfxSlot *pSlot =
nullptr;
899 Execute_( *pShell, *pSlot, aReq, eCall );
932 std::initializer_list<SfxPoolItem const*> args,
933 std::initializer_list<SfxPoolItem const*> internalargs)
939 const SfxSlot *pSlot =
nullptr;
952 if (internalargs.begin() != internalargs.end())
958 aInternalSet.
Put(*pArg);
963 Execute_( *pShell, *pSlot, aReq, eCall );
977 if ( pReq->IsCancelled() )
991 pReq->SetSynchronCall(
false );
992 Call_Impl( *pSh, *pSlot, *pReq, pReq->AllowsRecording() );
998 xImp->aReqArr.emplace_back(std::move(pReq));
1000 xImp->xPoster->Post(std::move(pReq));
1006#if HAVE_FEATURE_DESKTOP
1007 if ( !
xImp->pFrame )
1018 css::uno::Reference < css::beans::XPropertySet > xPropSet( rFrame.
GetFrameInterface(), css::uno::UNO_QUERY );
1019 if ( xPropSet.is() )
1021 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
1022 css::uno::Any aValue = xPropSet->getPropertyValue(
"LayoutManager");
1023 aValue >>= xLayoutManager;
1024 if ( xLayoutManager.is() )
1026 OUString aMenuBarURL(
"private:resource/menubar/menubar" );
1027 if ( !xLayoutManager->isElementVisible( aMenuBarURL ) )
1028 xLayoutManager->createElement( aMenuBarURL );
1040 if ( !
xImp->pFrame )
1043 bool bUpdate = bForce;
1051 bUpdate = !
xImp->bUpdated;
1052 xImp->bUpdated =
true;
1056 if ( !bUpdate ||
xImp->pFrame->GetFrame().IsClosing_Impl() )
1066 css::uno::Reference< css::frame::XFrame >
xFrame;
1070 pBindings->DENTERREGISTRATIONS();
1073 css::uno::Reference< css::beans::XPropertySet > xPropSet(
xFrame, css::uno::UNO_QUERY );
1074 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
1075 if ( xPropSet.is() )
1079 css::uno::Any aValue = xPropSet->getPropertyValue(
"LayoutManager");
1080 aValue >>= xLayoutManager;
1082 catch (
const css::uno::Exception&)
1087 if ( xLayoutManager.is() )
1088 xLayoutManager->lock();
1090 bool bIsIPActive =
xImp->pFrame &&
xImp->pFrame->GetObjectShell()->IsInPlaceActive();
1108 bool bIsActive =
false;
1110 if ( !bIsActive &&
this == pActDispat )
1113 Update_Impl_( bUIActive, !bIsIPActive, bIsIPActive, pWorkWin );
1114 if (bUIActive || bIsActive)
1118 pBindings->DLEAVEREGISTRATIONS();
1120 if ( xLayoutManager.is() )
1121 xLayoutManager->unlock();
1133 bool bIsActive =
false;
1135 if ( pActDispat && !bIsActive )
1137 if (
this == pActDispat )
1141 for (SfxObjectBars_Impl & rObjBar :
xImp->aObjBars)
1143 xImp->aChildWins.clear();
1147 if (
xImp->bQuiet ||
xImp->bNoUI || (
xImp->pFrame &&
xImp->pFrame->GetObjectShell()->IsPreview()) )
1153 sal_uInt16 nTotCount =
xImp->aStack.size();
1154 for ( sal_uInt16 nShell = nTotCount; nShell > 0; --nShell )
1183 bool bIsViewer = pItem && pItem->
GetValue();
1184 if ( bIsViewer != bViewerTbx )
1193 SfxObjectBars_Impl& rBar =
xImp->aObjBars[
nPos];
1195 rBar.nFlags = nFlags;
1198 if ( bUIActive || bIsActive )
1211 SAL_WARN_IF( !pSlot,
"sfx.control",
"Childwindow slot missing: " <<
nId );
1212 if ( bReadOnlyShell )
1239 if ( bUIActive || bIsActive )
1241 if ( bUIActive || bIsActive || !pWorkWin->
IsFloating(
static_cast<sal_uInt16
>(
nId & 0xFFFF ) ) )
1242 xImp->aChildWins.push_back(
nId );
1245 if ( bIsMDIApp || bIsIPOwner )
1255 SfxObjectBars_Impl& rFixed =
xImp->aFixedObjBars[
nPos];
1258 SfxObjectBars_Impl& rBar =
xImp->aObjBars[
nPos];
1265 if ( !pTaskWin || ( !bIsMDIApp && !bIsIPOwner ) )
1268 bool bIsTaskActive =
false;
1271 if ( pActDispatcher && !bIsTaskActive )
1273 if (
this == pActDispatcher )
1274 bIsTaskActive =
true;
1280 xImp->pFrame->GetFrame().GetWorkWindow_Impl()->SetStatusBar_Impl(eStatBarId);
1290 SAL_INFO(
"sfx.control",
"Flushing dispatcher!");
1294 xImp->bFlushing = !
xImp->bFlushing;
1295 if ( !
xImp->bFlushing )
1297 xImp->bFlushing =
true;
1304 std::deque<SfxToDo_Impl> aToDoCopy;
1305 bool bModify =
false;
1306 for(std::deque<SfxToDo_Impl>::reverse_iterator
i =
xImp->aToDoStack.rbegin();
i !=
xImp->aToDoStack.rend(); ++
i)
1314 "pushed SfxShell already on stack" );
1315 xImp->aStack.push_back(
i->pCluster);
1316 i->pCluster->SetDisableFlags(
xImp->nDisableFlags);
1319 aToDoCopy.push_front(*
i);
1324 bool bFound =
false;
1328 if (
auto it = std::find(
xImp->aStack.begin(),
xImp->aStack.end(),
i->pCluster);
1329 it !=
xImp->aStack.end())
1331 xImp->aStack.erase(it);
1336 aToDoCopy.push_front(SfxToDo_Impl(
false,
i->bDelete,
false, *
i->pCluster));
1343 xImp->aStack.pop_back();
1345 bFound = (pPopped ==
i->pCluster);
1348 aToDoCopy.push_front(SfxToDo_Impl(
false,
i->bDelete,
false, *pPopped));
1357 DBG_ASSERT( bFound,
"wrong SfxShell popped" );
1360 xImp->aToDoStack.clear();
1368 xImp->bFlushing =
false;
1369 xImp->bUpdated =
false;
1370 xImp->bFlushed =
true;
1371 SAL_INFO(
"sfx.control",
"Successfully flushed dispatcher!");
1377 xImp->aToDoCopyStack.push_back(aToDoCopy);
1378 std::deque<SfxToDo_Impl>& rToDoCopy =
xImp->aToDoCopyStack.back();
1380 for(std::deque<SfxToDo_Impl>::reverse_iterator
i = rToDoCopy.rbegin();
i != rToDoCopy.rend(); ++
i)
1387 i->pCluster->DoActivate_Impl(
xImp->pFrame,
true);
1389 i->pCluster->DoDeactivate_Impl(
xImp->pFrame,
true);
1392 aToDoCopy =
xImp->aToDoCopyStack.back();
1393 xImp->aToDoCopyStack.pop_back();
1395 for(std::deque<SfxToDo_Impl>::reverse_iterator
i = aToDoCopy.rbegin();
i != aToDoCopy.rend(); ++
i)
1397 if (
i->bDelete && !
i->bDeleted)
1399 if (!
xImp->aToDoCopyStack.empty())
1403 for (
auto & elem :
xImp->aToDoCopyStack)
1405 for (
auto & subelem : elem)
1407 if (subelem.pCluster ==
i->pCluster)
1408 subelem.bDeleted =
true;
1415 bool bAwakeBindings = !aToDoCopy.empty();
1416 if( bAwakeBindings )
1421 if (!
xImp->bFlushed)
1428 for (SfxObjectBars_Impl & rFixedObjBar :
xImp->aFixedObjBars)
1431 SAL_INFO(
"sfx.control",
"SfxDispatcher(" <<
this <<
")::Flush() done");
1470 for ( std::size_t
n = 1;
n < pSIDs.
size(); ++
n )
1471 DBG_ASSERT( pSIDs[
n] > pSIDs[
n-1],
"SetSlotFilter: SIDs not sorted" );
1474 xImp->nFilterEnabling = nEnable;
1475 xImp->pFilterSIDs = pSIDs;
1484 return static_cast<tools::Long>(*
static_cast<sal_uInt16
const *
>(pSmaller)) -
static_cast<tools::Long>(*
static_cast<sal_uInt16
const *
>(pBigger));
1500 if (
xImp->pFilterSIDs.empty() )
1505 bool bFound =
nullptr != bsearch( &nSID,
xImp->pFilterSIDs.data(),
xImp->pFilterSIDs.size(),
1542 xImp->bInvalidateOnUnlock =
true;
1548 sal_uInt16 nTotCount =
xImp->aStack.size();
1551 if (nSlot >= SID_VERB_START && nSlot <= SID_VERB_END)
1553 for ( sal_uInt16 nShell = 0;; ++nShell )
1556 if ( pSh ==
nullptr )
1558 if (
dynamic_cast< const SfxViewShell *
>( pSh ) !=
nullptr )
1590 sal_uInt16 nFirstShell = 0;
1591 for ( sal_uInt16
i = nFirstShell;
i < nTotCount; ++
i )
1611 bool bIsInPlace =
xImp->pFrame &&
xImp->pFrame->GetObjectShell()->IsInPlaceActive();
1615 bool bIsServerShell = !
xImp->pFrame || bIsInPlace;
1619 if ( !bIsServerShell )
1627 bool bIsContainerShell = !
xImp->pFrame || !bIsInPlace;
1629 if ( !( ( bIsContainerSlot && bIsContainerShell ) ||
1630 ( !bIsContainerSlot && bIsServerShell ) ) )
1663 xImp->bInvalidateOnUnlock =
true;
1670 "Dispatcher not flushed after retrieving slot servers!");
1671 if (!
xImp->bFlushed)
1686 (*pFunc)(pSh, rState);
1689 if ( rState.
Count() )
1703 "item-type unequal to IDL (=> no BASIC) with SID: "
1719 sal_uInt16 nShLevel = 0;
1722 if ( rDisp.
xImp->bQuiet )
1723 nShLevel = rDisp.
xImp->aStack.size();
1725 for ( pSh = rDisp.
GetShell(nShLevel); pSh; ++nShLevel, pSh = rDisp.
GetShell(nShLevel) )
1728 if ( !rResName.isEmpty() )
1738boost::property_tree::ptree fillPopupMenu(
Menu* pMenu)
1744 boost::property_tree::ptree aTree;
1746 bool bIsLastItemText =
false;
1750 boost::property_tree::ptree aItemTree;
1753 if (aItemType == MenuItemType::DONTKNOW)
1756 if (aItemType == MenuItemType::SEPARATOR)
1758 if (bIsLastItemText)
1759 aItemTree.put(
"type",
"separator");
1760 bIsLastItemText =
false;
1767 if (aCommandURL.isEmpty())
1774 const OUString aItemText = pMenu->
GetItemText(nItemId);
1777 if (!aItemText.isEmpty())
1778 aItemTree.put(
"text", aItemText.toUtf8().getStr());
1782 boost::property_tree::ptree aSubmenu = ::fillPopupMenu(pPopupSubmenu);
1783 if (aSubmenu.empty())
1786 aItemTree.put(
"type",
"menu");
1787 if (!aCommandURL.isEmpty())
1788 aItemTree.put(
"command", aCommandURL.toUtf8().getStr());
1789 aItemTree.push_back(std::make_pair(
"menu", aSubmenu));
1795 if (aCommandURL.isEmpty())
1798 aItemTree.put(
"type",
"command");
1799 aItemTree.put(
"command", aCommandURL.toUtf8().getStr());
1805 bool bHasChecks =
true;
1806 if (aItemBits & MenuItemBits::CHECKABLE)
1807 aItemTree.put(
"checktype",
"checkmark");
1808 else if (aItemBits & MenuItemBits::RADIOCHECK)
1809 aItemTree.put(
"checktype",
"radio");
1810 else if (aItemBits & MenuItemBits::AUTOCHECK)
1811 aItemTree.put(
"checktype",
"auto");
1819 if (!aItemTree.empty())
1821 aTree.push_back(std::make_pair(
"", aItemTree));
1822 if (aItemType != MenuItemType::SEPARATOR)
1823 bIsLastItemText =
true;
1835 return ::fillPopupMenu(pVCLMenu);
1840 css::uno::Sequence< css::uno::Any > aArgs{
1847 css::uno::Reference< css::frame::XPopupMenuController > xPopupController(
1848 xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
1849 "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext ), css::uno::UNO_QUERY );
1853 if ( !xPopupController.is() || !xPopupMenu.is() )
1856 vcl::Window* pWindow = pWin ? pWin :
xImp->pFrame->GetFrame().GetWorkWindow_Impl()->GetWindow();
1859 css::ui::ContextMenuExecuteEvent
aEvent;
1861 aEvent.ExecutePosition.X = aPos.
X();
1862 aEvent.ExecutePosition.Y = aPos.
Y();
1864 xPopupController->setPopupMenu( xPopupMenu );
1867 boost::property_tree::ptree aMenu =
fillPopupMenu(xPopupMenu);
1868 boost::property_tree::ptree aRoot;
1869 aRoot.add_child(
"menu", aMenu);
1871 std::stringstream aStream;
1872 boost::property_tree::write_json(aStream, aRoot,
true);
1874 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_MENU, OString(aStream.str()));
1878 OUString aMenuURL =
"private:resource/popupmenu/" + rResName;
1879 if (
GetFrame()->GetViewShell()->TryContextMenuInterception(xPopupMenu, aMenuURL,
aEvent))
1881 css::uno::Reference<css::awt::XWindowPeer> xParent(
aEvent.SourceWindow, css::uno::UNO_QUERY);
1882 xPopupMenu->execute(xParent, css::awt::Rectangle(aPos.
X(), aPos.
Y(), 1, 1), css::awt::PopupMenuDirection::EXECUTE_DOWN);
1886 css::uno::Reference< css::lang::XComponent > xComponent( xPopupController, css::uno::UNO_QUERY );
1887 if ( xComponent.is() )
1888 xComponent->dispose();
1898 if ( !bLock &&
xImp->bLocked &&
xImp->bInvalidateOnUnlock )
1902 xImp->bInvalidateOnUnlock =
false;
1904 else if ( pBindings )
1906 xImp->bLocked = bLock;
1909 for(
size_t i = 0;
i <
xImp->aReqArr.size(); ++
i)
1910 xImp->xPoster->Post(std::move(
xImp->aReqArr[
i]));
1911 xImp->aReqArr.clear();
1922 bool bWasHidden =
xImp->bNoUI;
1923 xImp->bNoUI = bHide;
1932 css::uno::Reference < css::beans::XPropertySet > xPropSet( rFrame.
GetFrameInterface(), css::uno::UNO_QUERY );
1933 if ( xPropSet.is() )
1935 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
1936 css::uno::Any aValue = xPropSet->getPropertyValue(
"LayoutManager");
1937 aValue >>= xLayoutManager;
1938 if ( xLayoutManager.is() )
1939 xLayoutManager->setVisible( !bHide );
1945 if ( bHide != bWasHidden )
1951 xImp->bReadOnly = bOn;
1956 return xImp->bReadOnly;
1973 const SfxSlot *pSlot =
nullptr;
1978 return SfxItemState::DISABLED;
1980 return SfxItemState::DEFAULT;
1983 return SfxItemState::DISABLED;
1989 const SfxSlot *pSlot =
nullptr;
1994 return SfxItemState::DISABLED;
1997 css::uno::Any aState;
2000 sal_uInt16 nSubId( 0 );
2002 sal_uInt16 nWhich = rPool.
GetWhich( nSID );
2003 if ( rPool.
GetMetric( nWhich ) == MapUnit::MapTwip )
2009 return SfxItemState::DEFAULT;
2013 return SfxItemState::DISABLED;
2018 sal_uInt16 nShellCount =
xImp->aStack.size();
2019 if ( nShell < nShellCount )
2021 SfxShell* pShell = *(
xImp->aStack.rbegin() + nShell );
2022 if(
dynamic_cast< const SfxModule *
>( pShell ) !=
nullptr ||
dynamic_cast< const SfxApplication *
>( pShell ) !=
nullptr ||
dynamic_cast< const SfxViewFrame *
>( pShell ) != nullptr )
2025 return xImp->bReadOnly;
2037 if (
xImp->aStack[
n] == &rShell )
2039 xImp->aStack.erase(
xImp->aStack.begin() +
n );
2048 xImp->bUpdated =
false;
2061 pFrame->GetBindings().InvalidateAll(bModify);
2066 if ( pDisp ==
this )
2075 return xImp->bUpdated;
2080 xImp->nDisableFlags = nFlags;
2081 for ( SfxShellStack_Impl::reverse_iterator it =
xImp->aStack.rbegin(); it !=
xImp->aStack.rend(); ++it )
2082 (*it)->SetDisableFlags( nFlags );
2087 return xImp->nDisableFlags;
2092 for ( sal_uInt16 nShell = 0;; ++nShell )
2095 if ( pSh ==
nullptr )
2097 if (
auto pModule =
dynamic_cast<SfxModule *
>( pSh ) )
SfxApplication * SfxGetpApp()
constexpr tools::Long Y() const
constexpr tools::Long X() const
SAL_DLLPRIVATE SfxDispatcher * GetDispatcher_Impl()
SAL_DLLPRIVATE SfxDispatcher * GetDispatcher_Impl()
SAL_DLLPRIVATE void StartUpdate_Impl(bool bComplete=false)
void Update(sal_uInt16 nId)
SfxDispatcher * GetDispatcher() const
void Invalidate(sal_uInt16 nId)
css::uno::Reference< css::frame::XFrame > GetActiveFrame() const
SAL_DLLPRIVATE SfxBindings * GetSubBindings_Impl() const
void SetActiveFrame(const css::uno::Reference< css::frame::XFrame > &rFrame)
void SetDispatcher(SfxDispatcher *pDisp)
void InvalidateAll(bool bWithMsg)
SfxChildAlignment GetAlignment() const
void FlushImpl()
Helper method to execute the outstanding push and pop commands.
bool FindServer_(sal_uInt16 nId, SfxSlotServer &rServer)
This helper method searches for the <Slot-Server> which currently serves the nSlot.
const SfxSlot * GetSlot(const OUString &rCommand)
std::unique_ptr< SfxDispatcher_Impl > xImp
SAL_DLLPRIVATE void DoActivate_Impl(bool bMDI)
This method controls the activation of a dispatcher.
SAL_DLLPRIVATE void Update_Impl(bool bForce=false)
void HideUI(bool bHide=true)
SAL_DLLPRIVATE bool CheckVirtualStack(const SfxShell &rShell)
With this method it can be tested whether the <SfxShell> rShell is on the stack, when it was flushed.
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
Method to execute a <SfxSlot>s over the Slot-Id.
bool IsFlushed() const
This method checks if the stack of the SfxDispatchers is flushed, or if push- or pop- commands are pe...
SAL_DLLPRIVATE void SetQuietMode_Impl(bool bOn)
With 'bOn' the Dispatcher is quasi dead and transfers everything to the Parent-Dispatcher.
SfxBindings * GetBindings() const
This method returns a pointer to the <SfxBinding> Instance on which the SfxDispatcher is currently bo...
void SetDisableFlags(SfxDisableFlags nFlags)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
Method to execute a <SfxSlot>s over the Slot-Id.
ToolbarId GetObjectBarId(sal_uInt16 nPos) const
SAL_DLLPRIVATE void Construct_Impl()
bool IsLocked() const
With this method it can be determined whether the SfxDispatcher is locked or unlocked.
void SetSlotFilter(SfxSlotFilterState nEnable=SfxSlotFilterState::DISABLED, o3tl::span< sal_uInt16 const > pSIDs=o3tl::span< sal_uInt16 const >())
With this method a filter set, the target slots can be enabled or disabled.
SAL_DLLPRIVATE SfxSlotFilterState IsSlotEnabledByFilter_Impl(sal_uInt16 nSID) const
Searches for 'nSID' in the Filter set by <SetSlotFilter()> and returns sal_True, if the SIDis allowed...
bool FillState_(const SfxSlotServer &rServer, SfxItemSet &rState, const SfxSlot *pRealSlot)
Helper method to obtain the status of the <Slot-Server>s rSvr.
void Pop(SfxShell &rShell, SfxDispatcherPopFlags nMode=SfxDispatcherPopFlags::NONE)
With this method, one or more <SfxShell> are popped from the SfxDispatcher.
SAL_DLLPRIVATE bool IsUpdated_Impl() const
SfxDisableFlags GetDisableFlags() const
sal_uInt16 GetShellLevel(const SfxShell &rShell)
Determines the position of a given SfxShell in the stack of the dispatcher.
bool IsAppDispatcher() const
With this method it can be determined if the SfxDispacher is the applications dispatcher.
SAL_DLLPRIVATE void DoDeactivate_Impl(bool bMDI, SfxViewFrame const *pNew)
This method controls the deactivation of a dispatcher.
SAL_DLLPRIVATE void InvalidateBindings_Impl(bool)
SAL_DLLPRIVATE void SetReadOnly_Impl(bool bOn)
SfxViewFrame * GetFrame() const
Returns a pointer to the <SfxViewFrame> instance, which belongs to this SfxDispatcher.
SAL_DLLPRIVATE void Call_Impl(SfxShell &rShell, const SfxSlot &rSlot, SfxRequest &rReq, bool bRecord)
Helper function to check whether a slot can be executed and check the execution itself.
void PostMsgHandler(std::unique_ptr< SfxRequest >)
Helper method to receive the asynchronously executed <SfxRequest>s.
~SfxDispatcher()
The destructor of the SfxDispatcher class should not be called when the SfxDispatcher instance is act...
SAL_DLLPRIVATE void SetMenu_Impl()
SAL_DLLPRIVATE void RemoveShell_Impl(SfxShell &rShell)
void ExecutePopup(const OUString &rResName, vcl::Window *pWin=nullptr, const Point *pPos=nullptr)
bool IsActive(const SfxShell &rShell)
This method checks whether a particular <SfxShell> instance is on the SfxDispatcher.
void Lock(bool bLock)
With this method the SfxDispatcher can be locked and released.
SAL_DLLPRIVATE void Update_Impl_(bool, bool, bool, SfxWorkWindow *)
static boost::property_tree::ptree fillPopupMenu(const rtl::Reference< VCLXPopupMenu > &rMenu)
SfxModule * GetModule() const
void Push(SfxShell &rShell)
With this method, a <SfxShell> pushed on to the SfxDispatcher.
SfxShell * GetShell(sal_uInt16 nIdx) const
Returns a pointer to the <SfxShell> which is at the position nIdx (from the top, last pushed is 0) on...
SAL_DLLPRIVATE bool GetReadOnly_Impl() const
SAL_DLLPRIVATE bool GetShellAndSlot_Impl(sal_uInt16 nSlot, SfxShell **ppShell, const SfxSlot **ppSlot, bool bOwnShellsOnly, bool bRealSlot)
This method searches in SfxDispatcher after <SfxShell> , from the Slot Id nSlot currently being handl...
void Execute_(SfxShell &rShell, const SfxSlot &rSlot, SfxRequest &rReq, SfxCallMode eCall)
This method performs a request for a cached <Slot-Server>.
SfxItemState QueryState(sal_uInt16 nSID, const SfxPoolItem *&rpState)
void Flush()
This method performs outstanding push- and pop- commands.
SAL_DLLPRIVATE bool IsReadOnlyShell_Impl(sal_uInt16 nShell) const
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
SAL_DLLPRIVATE bool IsMenuBarOn_Impl() const
bool IsObjectUIActive() const
StatusBarId GetStatusBarId() const
bool IsObjectBarVisible(sal_uInt16 nNo) const
const char * GetClassName() const
const SfxSlot * GetSlot(sal_uInt16 nSlotId) const
sal_uInt16 GetChildWindowCount() const
SfxShellFeature GetChildWindowFeature(sal_uInt16 nNo) const
ToolbarId GetObjectBarId(sal_uInt16 nNo) const
sal_uInt16 GetObjectBarCount() const
const OUString & GetPopupMenuName() const
SfxVisibilityFlags GetObjectBarFlags(sal_uInt16 nNo) const
sal_uInt16 GetObjectBarPos(sal_uInt16 nNo) const
SfxShellFeature GetObjectBarFeature(sal_uInt16 nNo) const
sal_uInt32 GetChildWindowId(sal_uInt16 nNo) const
const SfxPoolItem * GetCurItem() const
const SfxPoolItem * NextItem()
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
static bool IsSlot(sal_uInt16 nId)
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
SfxItemPool * GetPool() const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SfxItemSet & GetItemSet() const
SfxMedium * GetMedium() const
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
virtual bool IsVoidItem() const
const SfxPoolItem * GetReturnValue() const
SAL_DLLPRIVATE void Record_Impl(SfxShell &rSh, const SfxSlot &rSlot, const css::uno::Reference< css::frame::XDispatchRecorder > &xRecorder, SfxViewFrame *)
void SetModifier(sal_uInt16 nModi)
void SetInternalArgs_Impl(const SfxAllItemSet &rArgs)
void AllowRecording(bool)
The class SfxShell is the base class for all classes, which provide the functionality of the form <Sl...
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.
SAL_DLLPRIVATE bool CanExecuteSlot_Impl(const SfxSlot &rSlot)
This method determines by calling the status function whether 'rSlot' can be executed currently.
SfxItemPool & GetPool() const
Each Subclass of SfxShell must reference a pool.
virtual bool IsConditionalFastCall(const SfxRequest &rReq)
This method determines whether we need to execute without checking the disabled state of the slot.
virtual bool HasUIFeature(SfxShellFeature nFeature) const
void SetDisableFlags(SfxDisableFlags nFlags)
SAL_DLLPRIVATE void DoDeactivate_Impl(SfxViewFrame const *pFrame, bool bMDI)
This method controls the deactivation of the SfxShell instance.
SAL_DLLPRIVATE const SfxSlot * GetVerbSlot_Impl(sal_uInt16 nId) const
virtual SfxInterface * GetInterface() const
With this virtual method, which is automatically overridden by each subclass with its own slots throu...
SfxDisableFlags GetDisableFlags() const
SfxDispatcher * GetDispatcher() const
This method returns a pointer to the <SfxDispatcher>, when the SfxShell is currently <UI-active> or a...
static SfxSlotPool & GetSlotPool(SfxViewFrame *pFrame=nullptr)
const SfxSlot * GetSlot(sal_uInt16 nId) const
void SetSlot(const SfxSlot *pSlot)
void SetShellLevel(sal_uInt16 nLevel)
const SfxSlot * GetSlot() const
sal_uInt16 GetShellLevel() const
sal_uInt16 GetSlotId() const
const SfxType * GetType() const
SFX2_DLLPUBLIC OUString GetCommand() const
SfxStateFunc GetStateFnc() const
SfxDisableFlags nDisableFlags
SfxExecFunc GetExecFnc() const
bool IsMode(SfxSlotMode nMode) const
SfxBindings & GetBindings()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
SfxFrame & GetFrame() const
One SfxViewShell more or less represents one edit window for a document, there can be multiple ones f...
SfxInPlaceClient * GetUIActiveClient() const
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
void UpdateObjectBars_Impl()
void ResetObjectBars_Impl()
bool IsFloating(sal_uInt16 nId)
SfxBindings & GetBindings()
bool IsVisible_Impl() const
void ResetChildWindows_Impl()
void SetObjectBar_Impl(sal_uInt16 nPos, SfxVisibilityFlags nFlags, ToolbarId eId)
void SetChildWindowVisible_Impl(sal_uInt32, bool, SfxVisibilityFlags)
void ResetStatusBar_Impl()
SfxChildWindow * GetChildWindow_Impl(sal_uInt16)
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
constexpr size_type size() const noexcept
Point GetPointerPosPixel()
#define DBG_ASSERT(sCon, aError)
static int SfxCompareSIDs_Impl(const void *pSmaller, const void *pBigger)
static void MappedPut_Impl(SfxAllItemSet &rSet, const SfxPoolItem &rItem)
Helper function to put from rItem below the Which-ID in the pool of the Item Sets rSet.
IMPL_LINK_NOARG(SfxDispatcher, EventHdl_Impl, Timer *, void)
This handler is called after <SfxDispatcher::Invalidate()> or after changes on the stack (<SfxDispatc...
std::vector< SfxShell * > SfxShellStack_Impl
virtual SfxBindings & GetBindings() override
#define LINK(Instance, Class, Member)
#define SAL_INFO_IF(condition, area, stream)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_STREAM(stream)
#define SAL_INFO(area, stream)
SfxDispatcher * GetDispatcher()
Reference< XComponentContext > getProcessComponentContext()
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
#define SFX_OBJECTBAR_MAX
bool IsInvalidItem(const SfxPoolItem *pItem)
void(* SfxExecFunc)(SfxShell *, SfxRequest &rReq)
void(* SfxStateFunc)(SfxShell *, SfxItemSet &rSet)
SfxSlotFilterState nFilterEnabling
tools::SvRef< SfxHintPoster > xPoster
SfxDisableFlags nDisableFlags
SfxObjectBars_Impl aFixedObjBars[SFX_OBJECTBAR_MAX]
SfxObjectBars_Impl aObjBars[SFX_OBJECTBAR_MAX]
std::deque< SfxToDo_Impl > aToDoStack
SfxShellStack_Impl aStack
std::vector< std::unique_ptr< SfxRequest > > aReqArr
o3tl::span< sal_uInt16 const > pFilterSIDs
std::deque< std::deque< SfxToDo_Impl > > aToDoCopyStack
std::vector< sal_uInt32 > aChildWins
const std::type_info * Type() const
Reference< XFrame > xFrame