Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARSMENUCONTROLLER_HXX
21 : #define INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARSMENUCONTROLLER_HXX
22 :
23 : #include <macros/xserviceinfo.hxx>
24 : #include <stdtypes.h>
25 :
26 : #include <com/sun/star/lang/XServiceInfo.hpp>
27 : #include <com/sun/star/lang/XTypeProvider.hpp>
28 : #include <com/sun/star/lang/XInitialization.hpp>
29 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 : #include <com/sun/star/frame/XFrame.hpp>
31 : #include <com/sun/star/frame/XDispatch.hpp>
32 : #include <com/sun/star/frame/XStatusListener.hpp>
33 : #include <com/sun/star/frame/XPopupMenuController.hpp>
34 : #include <com/sun/star/frame/XLayoutManager.hpp>
35 : #include <com/sun/star/frame/XModel.hpp>
36 : #include <com/sun/star/container/XNameAccess.hpp>
37 : #include <com/sun/star/ui/XUIConfigurationManager.hpp>
38 :
39 : #include <svtools/popupmenucontrollerbase.hxx>
40 : #include <toolkit/awt/vclxmenu.hxx>
41 : #include <cppuhelper/weak.hxx>
42 : #include <rtl/ustring.hxx>
43 : #include <unotools/intlwrapper.hxx>
44 :
45 : #include <vector>
46 :
47 : namespace framework
48 : {
49 : class ToolbarsMenuController : public svt::PopupMenuControllerBase
50 : {
51 : using svt::PopupMenuControllerBase::disposing;
52 :
53 : public:
54 : ToolbarsMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
55 : virtual ~ToolbarsMenuController();
56 :
57 : // XServiceInfo
58 : DECLARE_XSERVICEINFO
59 :
60 : // XPopupMenuController
61 : virtual void SAL_CALL setPopupMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu >& PopupMenu ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
62 :
63 : // XInitialization
64 : 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, std::exception) SAL_OVERRIDE;
65 :
66 : // XStatusListener
67 : virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
68 :
69 : // XMenuListener
70 : virtual void SAL_CALL itemSelected( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
71 : virtual void SAL_CALL itemActivated( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
72 :
73 : // XEventListener
74 : virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
75 :
76 0 : struct ExecuteInfo
77 : {
78 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch;
79 : ::com::sun::star::util::URL aTargetURL;
80 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs;
81 : };
82 :
83 : DECL_STATIC_LINK( ToolbarsMenuController, ExecuteHdl_Impl, ExecuteInfo* );
84 :
85 : private:
86 : void fillPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu );
87 : ::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 );
88 : OUString getUINameFromCommand( const OUString& rCommandURL );
89 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > getDispatchFromCommandURL( const OUString& rCommandURL );
90 : void addCommand( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu, const OUString& rCommandURL, const OUString& aLabel );
91 : bool isContextSensitiveToolbarNonVisible();
92 :
93 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
94 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xPersistentWindowState;
95 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xUICommandDescription;
96 : ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xModuleCfgMgr;
97 : ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xDocCfgMgr;
98 : OUString m_aModuleIdentifier;
99 : OUString m_aPropUIName;
100 : OUString m_aPropResourceURL;
101 : bool m_bModuleIdentified;
102 : bool m_bResetActive;
103 : std::vector< OUString > m_aCommandVector;
104 : IntlWrapper m_aIntlWrapper;
105 : };
106 : }
107 :
108 : #endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARSMENUCONTROLLER_HXX
109 :
110 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|