25#include <com/sun/star/awt/MenuItemType.hpp>
26#include <com/sun/star/beans/PropertyValue.hpp>
27#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
28#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
29#include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
30#include <com/sun/star/frame/ModuleManager.hpp>
31#include <com/sun/star/frame/XFrame.hpp>
32#include <com/sun/star/util/XURLTransformer.hpp>
43#include <osl/mutex.hxx>
63 return "com.sun.star.comp.framework.NewMenuController";
81 for ( sal_uInt16
i = 0;
i < nItemCount;
i++ )
83 sal_uInt16 nItemId = pPopupMenu->
GetItemId(
i );
90 void* nAttributePtr = pPopupMenu->
GetUserValue( nItemId );
95 INetURLObject aURLObj( aImageId.isEmpty() ? aCmd : aImageId );
111 sal_uInt16
nCount(m_xPopupMenu->getItemCount());
119 for ( sal_uInt16
i = 0;
i <
nCount;
i++ )
121 if (m_xPopupMenu->getItemType(
i) != css::awt::MenuItemType_SEPARATOR)
123 nId = m_xPopupMenu->getItemId(
i);
127 m_xPopupMenu->setAcceleratorKeyEvent(
nId, rKeyCode);
148 if ( !xDocAccelCfg.is() )
158 if ( xSupplier.is() )
161 if ( xDocUICfgMgr.is() )
163 xDocAccelCfg = xDocUICfgMgr->getShortCutManager();
171 if ( !xModuleAccelCfg.is() )
174 theModuleUIConfigurationManagerSupplier::get(
m_xContext );
176 if ( xUICfgMgr.is() )
178 xModuleAccelCfg = xUICfgMgr->getShortCutManager();
183 if ( !xGlobalAccelCfg.is() )
185 xGlobalAccelCfg = GlobalAcceleratorConfiguration::create(
m_xContext );
191 sal_uInt16 nItemCount(m_xPopupMenu->getItemCount());
192 std::vector< vcl::KeyCode > aMenuShortCuts;
193 std::vector< OUString > aCmds;
194 std::vector< sal_uInt16 > aIds;
195 for ( sal_uInt16
i = 0;
i < nItemCount;
i++ )
197 if (m_xPopupMenu->getItemType(
i) != css::awt::MenuItemType_SEPARATOR)
199 sal_uInt16
nId(m_xPopupMenu->getItemId(
i));
200 aIds.push_back(
nId );
201 aMenuShortCuts.push_back( aEmptyKeyCode );
202 aCmds.push_back(m_xPopupMenu->getCommand(
nId));
206 sal_uInt32 nSeqCount( aIds.size() );
212 auto aSeqRange = asNonConstRange(
aSeq);
217 aSeqRange[nSeqCount-1] = m_aCommandURL;
218 aMenuShortCuts.push_back( aEmptyKeyCode );
221 const sal_uInt32
nCount = aCmds.size();
222 for ( sal_uInt32
i = 0;
i <
nCount;
i++ )
223 aSeqRange[
i] = aCmds[
i];
232 const sal_uInt32 nCount2 = aIds.size();
233 for ( sal_uInt32
i = 0;
i < nCount2;
i++ )
240 if ( aMenuShortCuts[nSeqCount-1] != aEmptyKeyCode )
248 std::vector< vcl::KeyCode >& aMenuShortCuts )
250 if ( !rAccelCfg.is() )
255 css::awt::KeyEvent aKeyEvent;
256 Sequence< Any > aSeqKeyCode = rAccelCfg->getPreferredKeyEventsForCommandList( rCommands );
257 for ( sal_Int32
i = 0;
i < aSeqKeyCode.getLength();
i++ )
259 if ( aSeqKeyCode[
i] >>= aKeyEvent )
263 catch (
const IllegalArgumentException& )
269 svt::PopupMenuControllerBase( xContext ),
270 m_bShowImages( true ),
272 m_bModuleIdentified( false ),
273 m_bAcceleratorCfg( false ),
274 m_aTargetFrame(
"_default" ),
291 resetPopupMenu( rPopupMenu );
295 if ( !pVCLPopupMenu )
303 if(xMenuItemDispatch ==
nullptr)
306 const std::vector< SvtDynMenuEntry > aDynamicMenuEntries =
309 sal_uInt16 nItemId = 1;
311 for (
const auto& aDynamicMenuEntry : aDynamicMenuEntries )
313 if ( aDynamicMenuEntry.sTitle.isEmpty() && aDynamicMenuEntry.sURL.isEmpty() )
316 if ( aDynamicMenuEntry.sURL ==
"private:separator" )
317 rPopupMenu->insertSeparator(-1);
320 rPopupMenu->insertItem(nItemId, aDynamicMenuEntry.sTitle, 0, -1);
321 rPopupMenu->setCommand(nItemId, aDynamicMenuEntry.sURL);
344 if ( m_xPopupMenu.is() )
346 m_xPopupMenu.clear();
363 xPopupMenu = m_xPopupMenu;
367 if ( !xPopupMenu.is() )
380 void* nAttributePtr = pPopupMenu->
getUserValue(rEvent.MenuId);
387 OUString(
"private:user" )) };
395 if ( !(
m_xFrame.is() && m_xPopupMenu.is()) )
418 if ( m_xPopupMenu.is() )
440 bool bInitialized( m_bInitialized );
444 svt::PopupMenuControllerBase::initializeImpl( rGuard,
aArguments );
446 if ( m_bInitialized )
459extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
461 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
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
OUString DetermineIconTheme() const
bool GetUseImagesInMenus() const
static vcl::KeyCode st_AWTKey2VCLKey(const css::awt::KeyEvent &aKey)
static css::awt::KeyEvent st_VCLKey2AWTKey(const vcl::KeyCode &aKey)
css::uno::Reference< css::uno::XComponentContext > m_xContext
Sequence< PropertyValue > aArguments
Sequence< sal_Int8 > aSeq
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)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr OUStringLiteral SERVICENAME_POPUPMENUCONTROLLER
Image GetImageForCommand(const OUString &rsCommandName, const Reference< frame::XFrame > &rxFrame, vcl::ImageType eImageType)
Reference< XController > xController
Reference< XFrame > xFrame
Reference< XModel > xModel