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