22#include <com/sun/star/embed/VerbAttributes.hpp>
23#include <com/sun/star/embed/VerbDescriptor.hpp>
29#include <osl/mutex.hxx>
41class ObjectMenuController :
public svt::PopupMenuControllerBase
43 using svt::PopupMenuControllerBase::disposing;
46 explicit ObjectMenuController(
const css::uno::Reference< css::uno::XComponentContext >& xContext );
51 return "com.sun.star.comp.framework.ObjectMenuController";
61 return {
"com.sun.star.frame.PopupMenuController"};
65 virtual void SAL_CALL statusChanged(
const css::frame::FeatureStateEvent& Event )
override;
68 virtual void SAL_CALL disposing(
const css::lang::EventObject& Source )
override;
71 void fillPopupMenu(
const css::uno::Sequence< css::embed::VerbDescriptor >& rVerbCommandSeq, css::uno::Reference< css::awt::XPopupMenu >
const & rPopupMenu );
74ObjectMenuController::ObjectMenuController(
const css::uno::Reference< css::uno::XComponentContext >& xContext ) :
75 svt::PopupMenuControllerBase( xContext )
82 const css::embed::VerbDescriptor* pVerbCommandArray = rVerbCommandSeq.getConstArray();
86 resetPopupMenu( rPopupMenu );
88 static constexpr OUStringLiteral aVerbCommand( u
".uno:ObjectMenue?VerbID:short=" );
89 for ( sal_Int32 i = 0;
i < rVerbCommandSeq.getLength();
i++ )
91 const css::embed::VerbDescriptor& rVerb = pVerbCommandArray[
i];
92 if ( rVerb.VerbAttributes & css::embed::VerbAttributes::MS_VERBATTR_ONCONTAINERMENU )
94 m_xPopupMenu->insertItem( i+1, rVerb.VerbName, 0, i );
95 OUString
aCommand = aVerbCommand + OUString::number( rVerb.VerbID );
96 m_xPopupMenu->setCommand( i+1,
aCommand );
102void SAL_CALL ObjectMenuController::disposing(
const EventObject& )
110 if ( m_xPopupMenu.is() )
112 m_xPopupMenu.clear();
116void SAL_CALL ObjectMenuController::statusChanged(
const FeatureStateEvent& Event )
119 if ( Event.State >>= aVerbCommandSeq )
122 if ( m_xPopupMenu.is() )
123 fillPopupMenu( aVerbCommandSeq, m_xPopupMenu );
129extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
131 css::uno::XComponentContext *context,
132 css::uno::Sequence<css::uno::Any>
const &)
134 return cppu::acquire(
new ObjectMenuController(context));
css::uno::Reference< css::lang::XComponent > m_xFrame
css::uno::Reference< css::frame::XDispatch > m_xDispatch
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)