1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef __FRAMEWORK_UIELEMENT_MACROSMENUCONTROLLER_HXX_
25 #define __FRAMEWORK_UIELEMENT_MACROSMENUCONTROLLER_HXX_
26 
27 #include <macros/xserviceinfo.hxx>
28 #include <stdtypes.h>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/lang/XTypeProvider.hpp>
31 #include <com/sun/star/lang/XInitialization.hpp>
32 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 #include <com/sun/star/frame/XFrame.hpp>
34 #include <com/sun/star/frame/XDispatch.hpp>
35 #include <com/sun/star/frame/XDispatchProvider.hpp>
36 #include <com/sun/star/frame/XStatusListener.hpp>
37 #include <com/sun/star/container/XNameAccess.hpp>
38 #include <com/sun/star/frame/XPopupMenuController.hpp>
39 #include <svtools/popupmenucontrollerbase.hxx>
40 #include <toolkit/awt/vclxmenu.hxx>
41 #include <cppuhelper/weak.hxx>
42 #include <vcl/menu.hxx>
43 #include <rtl/ustring.hxx>
44 
45 namespace framework
46 {
47 	class MacrosMenuController :  public svt::PopupMenuControllerBase
48     {
49 		using svt::PopupMenuControllerBase::disposing;
50 
51         struct ExecuteInfo
52         {
53             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >     xDispatch;
54             ::com::sun::star::util::URL                                                aTargetURL;
55             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >  aArgs;
56          };
57          DECL_STATIC_LINK( MacrosMenuController, ExecuteHdl_Impl, ExecuteInfo* );
58         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
59         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xDispatchProvider;
60         ::rtl::OUString m_aModuleIdentifier;
61         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xUICommandLabels;
62 
63 		public:
64 		    MacrosMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
65 		    virtual ~MacrosMenuController();
66 
67             // XServiceInfo
68 		    DECLARE_XSERVICEINFO
69 
70 		    // XStatusListener
71 		    virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
72 
73 		    // XEventListener
74 		    virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
75 
76 		private:
77             virtual void impl_select(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& _xDispatch,const ::com::sun::star::util::URL& aURL);
78             void fillPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu );
79             String RetrieveLabelFromCommand( const String& aCmdURL );
80             void addScriptItems( PopupMenu* pPopupMenu, sal_uInt16 startItemId );
81     };
82 }
83 
84 #endif // __FRAMEWORK_UIELEMENT_MACROSMENUCONTROLLER_HXX_
85