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_TOOLBARSMENUCONTROLLER_HXX_
25 #define __FRAMEWORK_UIELEMENT_TOOLBARSMENUCONTROLLER_HXX_
26 
27 //_________________________________________________________________________________________________________________
28 //	my own includes
29 //_________________________________________________________________________________________________________________
30 
31 #include <macros/xserviceinfo.hxx>
32 #include <stdtypes.h>
33 
34 //_________________________________________________________________________________________________________________
35 //	interface includes
36 //_________________________________________________________________________________________________________________
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/lang/XTypeProvider.hpp>
39 #include <com/sun/star/lang/XInitialization.hpp>
40 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <com/sun/star/frame/XFrame.hpp>
42 #include <com/sun/star/frame/XDispatch.hpp>
43 #include <com/sun/star/frame/XStatusListener.hpp>
44 #include <com/sun/star/frame/XPopupMenuController.hpp>
45 #include <com/sun/star/frame/XLayoutManager.hpp>
46 #include <com/sun/star/frame/XModel.hpp>
47 #include <com/sun/star/container/XNameAccess.hpp>
48 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
49 
50 //_________________________________________________________________________________________________________________
51 //	includes of other projects
52 //_________________________________________________________________________________________________________________
53 #include <svtools/popupmenucontrollerbase.hxx>
54 #include <toolkit/awt/vclxmenu.hxx>
55 #include <cppuhelper/weak.hxx>
56 #include <rtl/ustring.hxx>
57 #include <unotools/intlwrapper.hxx>
58 
59 #include <vector>
60 
61 namespace framework
62 {
63 	class ToolbarsMenuController :  public svt::PopupMenuControllerBase
64     {
65 		using svt::PopupMenuControllerBase::disposing;
66 
67 		public:
68 		    ToolbarsMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
69 		    virtual ~ToolbarsMenuController();
70 
71             // XServiceInfo
72 		    DECLARE_XSERVICEINFO
73 
74             // XPopupMenuController
75             virtual void SAL_CALL setPopupMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu >& PopupMenu ) throw (::com::sun::star::uno::RuntimeException);
76 
77             // XInitialization
78             virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
79 
80 		    // XStatusListener
81 		    virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
82 
83             // XMenuListener
84             virtual void SAL_CALL select( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException);
85             virtual void SAL_CALL activate( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException);
86 
87 		    // XEventListener
88 		    virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
89 
90             struct ExecuteInfo
91             {
92                 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >     xDispatch;
93                 ::com::sun::star::util::URL                                                aTargetURL;
94                 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >  aArgs;
95             };
96 
97             DECL_STATIC_LINK( ToolbarsMenuController, ExecuteHdl_Impl, ExecuteInfo* );
98 
99         private:
100             void fillPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu );
101             ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > > getLayoutManagerToolbars( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& rLayoutManager );
102             rtl::OUString getUINameFromCommand( const rtl::OUString& rCommandURL );
103             ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > getDispatchFromCommandURL( const rtl::OUString& rCommandURL );
104             void addCommand( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu, const rtl::OUString& rCommandURL, const rtl::OUString& aLabel );
105             sal_Bool isContextSensitiveToolbarNonVisible();
106 
107             ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >                m_xPersistentWindowState;
108             ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >                m_xUICommandDescription;
109             ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager >   m_xModuleCfgMgr;
110             ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager >   m_xDocCfgMgr;
111             rtl::OUString                                                                               m_aModuleIdentifier;
112             rtl::OUString                                                                               m_aPropUIName;
113             rtl::OUString                                                                               m_aPropResourceURL;
114             sal_Bool                                                                                    m_bModuleIdentified;
115             sal_Bool                                                                                    m_bResetActive;
116             std::vector< rtl::OUString >                                                                m_aCommandVector;
117             IntlWrapper                                                                                 m_aIntlWrapper;
118     };
119 }
120 
121 #endif // __FRAMEWORK_UIELEMENT_TOOLBARSMENUCONTROLLER_HXX_
122