23#include <com/sun/star/awt/MenuItemStyle.hpp>
24#include <com/sun/star/ui/UIElementType.hpp>
25#include <com/sun/star/frame/XModuleManager.hpp>
26#include <com/sun/star/frame/ModuleManager.hpp>
30#include <officecfg/Office/Common.hxx>
33#include <rtl/ustrbuf.hxx>
58 return "com.sun.star.comp.framework.ToolbarModeMenuController";
73 svt::PopupMenuControllerBase( xContext ),
84 if ( officecfg::Office::Common::Misc::DisableUICustomization::get() )
88 resetPopupMenu( rPopupMenu );
90 const Reference<XComponentContext> xContext (::comphelper::getProcessComponentContext() );
91 const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( xContext );
94 OUStringBuffer aPath(
"org.openoffice.Office.UI.ToolbarMode/Applications/");
98 aPath.append(
"Writer");
101 aPath.append(
"Calc");
104 aPath.append(
"Impress");
107 aPath.append(
"Draw");
110 aPath.append(
"Formula");
113 aPath.append(
"Base");
118 aPath.append(
"/Modes");
122 aPath.makeStringAndClear(),
127 const Sequence<OUString> aModeNodeNames (aModesNode.
getNodeNames());
128 const sal_Int32
nCount(aModeNodeNames.getLength());
131 for ( sal_Int32 nReadIndex = 0; nReadIndex <
nCount; ++nReadIndex )
144 if ( isExperimental && !officecfg::Office::Common::Misc::ExperimentalMode::get() )
149 m_xPopupMenu->insertItem( nReadIndex+1,
aLabel, css::awt::MenuItemStyle::RADIOCHECK, nPosition );
150 rPopupMenu->setCommand( nReadIndex+1, aCommandArg );
152 rPopupMenu->insertSeparator(nCountToolbar);
158 Reference< css::awt::XMenuListener > xHolder(
this);
164 if ( m_xPopupMenu.is() )
165 m_xPopupMenu->removeMenuListener( Reference< css::awt::XMenuListener >(
this) );
166 m_xPopupMenu.clear();
172 OUString aFeatureURL( Event.FeatureURL.Complete );
176 Reference< css::awt::XPopupMenu > xPopupMenu( m_xPopupMenu );
179 if ( !xPopupMenu.is() )
184 bool bSetCheckmark =
false;
185 bool bCheckmark =
false;
186 for (sal_Int16
i = 0,
nCount = xPopupMenu->getItemCount();
i <
nCount; ++
i)
188 sal_Int16
nId = xPopupMenu->getItemId(
i);
192 OUString aCmd = xPopupMenu->getCommand(
nId);
193 if ( aCmd == aFeatureURL )
196 xPopupMenu->enableItem(
nId, Event.IsEnabled);
199 if ( Event.State >>= bCheckmark )
200 bSetCheckmark =
true;
203 xPopupMenu->checkItem(
nId, bCheckmark);
208 if ( Event.State >>= aItemText )
209 xPopupMenu->setItemText(
nId, aItemText);
224 const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create(
m_xContext );
227 OUStringBuffer aPath(
"org.openoffice.Office.UI.ToolbarMode/Applications/");
231 aPath.append(
"Writer");
234 aPath.append(
"Calc");
237 aPath.append(
"Impress");
240 aPath.append(
"Draw");
243 aPath.append(
"Formula");
246 aPath.append(
"Base");
254 aPath.makeStringAndClear(),
261 for (
int i = 0;
i < m_xPopupMenu->getItemCount(); ++
i )
263 sal_Int16 nItemId(m_xPopupMenu->getItemId(
i));
264 m_xPopupMenu->checkItem(nItemId, aMode == m_xPopupMenu->getCommand(nItemId));
273 throwIfDisposed(aLock);
275 if (
m_xFrame.is() && !m_xPopupMenu.is() )
280 m_xPopupMenu =
dynamic_cast<VCLXPopupMenu*
>(xPopupMenu.get());
281 assert(
bool(xPopupMenu) ==
bool(m_xPopupMenu) &&
"we only support VCLXPopupMenu");
282 m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >(
this) );
289extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
291 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const& )
constexpr OUStringLiteral sServiceName
css::uno::Reference< css::lang::XComponent > m_xFrame
css::uno::Reference< css::frame::XDispatch > m_xDispatch
css::uno::Sequence< OUString > getNodeNames() const noexcept
css::uno::Any getNodeValue(const OUString &_rPath) const noexcept
OConfigurationNode openNode(const OUString &_rPath) const noexcept
static Application GetApplicationEnum(const OUString &rsApplicationName)
css::uno::Reference< css::uno::XComponentContext > m_xContext
bool getBOOL(const Any &_rAny)
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
sal_Int32 getINT32(const Any &_rAny)
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
OUString getString(const Any &_rAny)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr OUStringLiteral SERVICENAME_POPUPMENUCONTROLLER