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_CLASSES_MENUMANAGER_HXX
21 : #define INCLUDED_FRAMEWORK_INC_CLASSES_MENUMANAGER_HXX
22 :
23 : #include <vector>
24 :
25 : #include <com/sun/star/frame/XFrame.hpp>
26 : #include <com/sun/star/frame/XDispatch.hpp>
27 : #include <com/sun/star/frame/FeatureStateEvent.hpp>
28 : #include <com/sun/star/beans/PropertyValue.hpp>
29 : #include <com/sun/star/util/XURLTransformer.hpp>
30 :
31 : #include <rtl/ustring.hxx>
32 : #include <vcl/menu.hxx>
33 : #include <vcl/accel.hxx>
34 : #include <cppuhelper/implbase1.hxx>
35 :
36 : namespace com { namespace sun { namespace star { namespace uno {
37 : class XComponentContext;
38 : } } } }
39 :
40 : namespace framework
41 : {
42 :
43 : class BmkMenu;
44 : class AddonMenu;
45 : class AddonPopupMenu;
46 : class MenuManager : public ::cppu::WeakImplHelper1< css::frame::XStatusListener >
47 : {
48 : public:
49 : MenuManager(
50 : const css::uno::Reference< css::uno::XComponentContext >& rxContext,
51 : css::uno::Reference< css::frame::XFrame >& rFrame,
52 : Menu* pMenu,
53 : bool bDelete,
54 : bool bDeleteChildren );
55 :
56 : virtual ~MenuManager();
57 :
58 : // XStatusListener
59 : virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
60 :
61 : // XEventListener
62 : virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
63 :
64 : DECL_LINK( Select, Menu * );
65 :
66 0 : Menu* GetMenu() const { return m_pVCLMenu; }
67 :
68 : void RemoveListener();
69 :
70 : static void UpdateSpecialWindowMenu( Menu* pMenu ,const css::uno::Reference< css::uno::XComponentContext >& xContext);
71 : static void FillMenuImages(
72 : css::uno::Reference< css::frame::XFrame >& xFrame,
73 : Menu* _pMenu,
74 : bool bShowMenuImages
75 : );
76 :
77 : protected:
78 : DECL_LINK_TYPED(Highlight, Menu *, bool);
79 : DECL_LINK_TYPED( Activate, Menu *, bool );
80 : DECL_LINK_TYPED( Deactivate, Menu *, bool );
81 :
82 : private:
83 : void UpdateSpecialFileMenu( Menu* pMenu );
84 : void UpdateSpecialWindowMenu( Menu* pMenu );
85 : void ClearMenuDispatch(const css::lang::EventObject& Source = css::lang::EventObject(),bool _bRemoveOnly = true);
86 : void SetHdl();
87 : void AddMenu(PopupMenu* _pPopupMenu,const OUString& _sItemCommand,sal_uInt16 _nItemId,bool _bDelete,bool _bDeleteChildren);
88 : sal_uInt16 FillItemCommand(OUString& _rItemCommand, Menu* _pMenu,sal_uInt16 _nIndex) const;
89 :
90 0 : struct MenuItemHandler
91 : {
92 0 : MenuItemHandler( sal_uInt16 aItemId, MenuManager* pManager, css::uno::Reference< css::frame::XDispatch >& rDispatch ) :
93 0 : nItemId( aItemId ), pSubMenuManager( pManager ), xMenuItemDispatch( rDispatch ) {}
94 :
95 : sal_uInt16 nItemId;
96 : OUString aTargetFrame;
97 : OUString aMenuItemURL;
98 : OUString aFilter;
99 : OUString aPassword;
100 : OUString aTitle;
101 : MenuManager* pSubMenuManager;
102 : css::uno::Reference< css::frame::XDispatch > xMenuItemDispatch;
103 : };
104 :
105 : void CreatePicklistArguments(
106 : css::uno::Sequence< css::beans::PropertyValue >& aArgsList,
107 : const MenuItemHandler* );
108 :
109 : MenuItemHandler* GetMenuItemHandler( sal_uInt16 nItemId );
110 :
111 : bool m_bInitialized;
112 : bool m_bDeleteMenu;
113 : bool m_bDeleteChildren;
114 : bool m_bActive;
115 : bool m_bIsBookmarkMenu;
116 : bool m_bShowMenuImages;
117 : OUString m_aMenuItemCommand;
118 : Menu* m_pVCLMenu;
119 : css::uno::Reference< css::frame::XFrame > m_xFrame;
120 : ::std::vector< MenuItemHandler* > m_aMenuItemHandlerVector;
121 :
122 : css::uno::Reference< css::uno::XComponentContext > m_xContext;
123 : css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer;
124 : };
125 :
126 : } // namespace
127 :
128 : #endif
129 :
130 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|