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 : /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
24 : with solaris headers ...
25 : */
26 : #include <vector>
27 :
28 : #include <com/sun/star/frame/XFrame.hpp>
29 : #include <com/sun/star/frame/XDispatch.hpp>
30 : #include <com/sun/star/frame/FeatureStateEvent.hpp>
31 : #include <com/sun/star/beans/PropertyValue.hpp>
32 : #include <com/sun/star/util/XURLTransformer.hpp>
33 :
34 : #include <rtl/ustring.hxx>
35 : #include <vcl/menu.hxx>
36 : #include <vcl/accel.hxx>
37 : #include <cppuhelper/implbase1.hxx>
38 : #include <threadhelp/threadhelpbase.hxx>
39 : #include <macros/debug.hxx>
40 :
41 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42 :
43 : #define REFERENCE ::com::sun::star::uno::Reference
44 : #define XFRAME ::com::sun::star::frame::XFrame
45 : #define XDISPATCH ::com::sun::star::frame::XDispatch
46 : #define XDISPATCHPROVIDER ::com::sun::star::frame::XDispatchProvider
47 : #define XSTATUSLISTENER ::com::sun::star::frame::XStatusListener
48 : #define XEVENTLISTENER ::com::sun::star::lang::XEventListener
49 : #define FEATURSTATEEVENT ::com::sun::star::frame::FeatureStateEvent
50 : #define RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException
51 : #define EVENTOBJECT ::com::sun::star::lang::EventObject
52 :
53 : namespace framework
54 : {
55 :
56 : class BmkMenu;
57 : class AddonMenu;
58 : class AddonPopupMenu;
59 : class MenuManager : public ThreadHelpBase ,
60 : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
61 : {
62 : public:
63 : MenuManager(
64 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
65 : REFERENCE< XFRAME >& rFrame,
66 : Menu* pMenu,
67 : sal_Bool bDelete,
68 : sal_Bool bDeleteChildren );
69 :
70 : virtual ~MenuManager();
71 :
72 : // XStatusListener
73 : virtual void SAL_CALL statusChanged( const FEATURSTATEEVENT& Event ) throw ( RUNTIMEEXCEPTION );
74 :
75 : // XEventListener
76 : virtual void SAL_CALL disposing( const EVENTOBJECT& Source ) throw ( RUNTIMEEXCEPTION );
77 :
78 : DECL_LINK( Select, Menu * );
79 :
80 0 : Menu* GetMenu() const { return m_pVCLMenu; }
81 :
82 : void RemoveListener();
83 :
84 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getServiceFactory();
85 :
86 : static void UpdateSpecialWindowMenu( Menu* pMenu ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,IMutex& _rMutex);
87 : static void FillMenuImages(
88 : ::com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame,
89 : Menu* _pMenu,
90 : sal_Bool bShowMenuImages
91 : );
92 :
93 : protected:
94 : DECL_LINK(Highlight, void *);
95 : DECL_LINK( Activate, Menu * );
96 : DECL_LINK( Deactivate, Menu * );
97 :
98 : private:
99 : void UpdateSpecialFileMenu( Menu* pMenu );
100 : void UpdateSpecialWindowMenu( Menu* pMenu );
101 : void ClearMenuDispatch(const EVENTOBJECT& Source = EVENTOBJECT(),bool _bRemoveOnly = true);
102 : void SetHdl();
103 : void AddMenu(PopupMenu* _pPopupMenu,const ::rtl::OUString& _sItemCommand,sal_uInt16 _nItemId,sal_Bool _bDelete,sal_Bool _bDeleteChildren);
104 : sal_uInt16 FillItemCommand(::rtl::OUString& _rItemCommand, Menu* _pMenu,sal_uInt16 _nIndex) const;
105 :
106 :
107 0 : struct MenuItemHandler
108 : {
109 0 : MenuItemHandler( sal_uInt16 aItemId, MenuManager* pManager, REFERENCE< XDISPATCH >& rDispatch ) :
110 0 : nItemId( aItemId ), pSubMenuManager( pManager ), xMenuItemDispatch( rDispatch ) {}
111 :
112 : sal_uInt16 nItemId;
113 : ::rtl::OUString aTargetFrame;
114 : ::rtl::OUString aMenuItemURL;
115 : ::rtl::OUString aFilter;
116 : ::rtl::OUString aPassword;
117 : ::rtl::OUString aTitle;
118 : MenuManager* pSubMenuManager;
119 : REFERENCE< XDISPATCH > xMenuItemDispatch;
120 : };
121 :
122 : void CreatePicklistArguments(
123 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgsList,
124 : const MenuItemHandler* );
125 :
126 : MenuItemHandler* GetMenuItemHandler( sal_uInt16 nItemId );
127 :
128 : sal_Bool m_bInitialized;
129 : sal_Bool m_bDeleteMenu;
130 : sal_Bool m_bDeleteChildren;
131 : sal_Bool m_bActive;
132 : sal_Bool m_bIsBookmarkMenu;
133 : sal_Bool m_bShowMenuImages;
134 : ::rtl::OUString m_aMenuItemCommand;
135 : Menu* m_pVCLMenu;
136 : REFERENCE< XFRAME > m_xFrame;
137 : ::std::vector< MenuItemHandler* > m_aMenuItemHandlerVector;
138 :
139 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& mxServiceFactory;
140 : ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
141 : };
142 :
143 : } // namespace
144 :
145 : #endif
146 :
147 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|