Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef __FRAMEWORK_CLASSES_MENUMANAGER_HXX_
30 : : #define __FRAMEWORK_CLASSES_MENUMANAGER_HXX_
31 : :
32 : : /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
33 : : with solaris headers ...
34 : : */
35 : : #include <vector>
36 : :
37 : : #include <com/sun/star/frame/XFrame.hpp>
38 : : #include <com/sun/star/frame/XDispatch.hpp>
39 : : #include <com/sun/star/frame/FeatureStateEvent.hpp>
40 : : #include <com/sun/star/beans/PropertyValue.hpp>
41 : : #include <com/sun/star/util/XURLTransformer.hpp>
42 : :
43 : : #include <rtl/ustring.hxx>
44 : : #include <vcl/menu.hxx>
45 : : #include <vcl/accel.hxx>
46 : : #include <cppuhelper/implbase1.hxx>
47 : : #include <threadhelp/threadhelpbase.hxx>
48 : : #include <macros/debug.hxx>
49 : :
50 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
51 : :
52 : : #define REFERENCE ::com::sun::star::uno::Reference
53 : : #define XFRAME ::com::sun::star::frame::XFrame
54 : : #define XDISPATCH ::com::sun::star::frame::XDispatch
55 : : #define XDISPATCHPROVIDER ::com::sun::star::frame::XDispatchProvider
56 : : #define XSTATUSLISTENER ::com::sun::star::frame::XStatusListener
57 : : #define XEVENTLISTENER ::com::sun::star::lang::XEventListener
58 : : #define FEATURSTATEEVENT ::com::sun::star::frame::FeatureStateEvent
59 : : #define RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException
60 : : #define EVENTOBJECT ::com::sun::star::lang::EventObject
61 : :
62 : : namespace framework
63 : : {
64 : :
65 : : class BmkMenu;
66 : : class AddonMenu;
67 : : class AddonPopupMenu;
68 : : class MenuManager : public ThreadHelpBase ,
69 : : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
70 : : {
71 : : public:
72 : : MenuManager(
73 : : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
74 : : REFERENCE< XFRAME >& rFrame,
75 : : Menu* pMenu,
76 : : sal_Bool bDelete,
77 : : sal_Bool bDeleteChildren );
78 : :
79 : : virtual ~MenuManager();
80 : :
81 : : // XStatusListener
82 : : virtual void SAL_CALL statusChanged( const FEATURSTATEEVENT& Event ) throw ( RUNTIMEEXCEPTION );
83 : :
84 : : // XEventListener
85 : : virtual void SAL_CALL disposing( const EVENTOBJECT& Source ) throw ( RUNTIMEEXCEPTION );
86 : :
87 : : DECL_LINK( Select, Menu * );
88 : :
89 : 0 : Menu* GetMenu() const { return m_pVCLMenu; }
90 : :
91 : : void RemoveListener();
92 : :
93 : : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getServiceFactory();
94 : :
95 : : static void UpdateSpecialWindowMenu( Menu* pMenu ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,IMutex& _rMutex);
96 : : static void FillMenuImages(
97 : : ::com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame,
98 : : Menu* _pMenu,
99 : : sal_Bool bShowMenuImages
100 : : );
101 : :
102 : : protected:
103 : : DECL_LINK(Highlight, void *);
104 : : DECL_LINK( Activate, Menu * );
105 : : DECL_LINK( Deactivate, Menu * );
106 : :
107 : : private:
108 : : void UpdateSpecialFileMenu( Menu* pMenu );
109 : : void UpdateSpecialWindowMenu( Menu* pMenu );
110 : : void ClearMenuDispatch(const EVENTOBJECT& Source = EVENTOBJECT(),bool _bRemoveOnly = true);
111 : : void SetHdl();
112 : : void AddMenu(PopupMenu* _pPopupMenu,const ::rtl::OUString& _sItemCommand,sal_uInt16 _nItemId,sal_Bool _bDelete,sal_Bool _bDeleteChildren);
113 : : sal_uInt16 FillItemCommand(::rtl::OUString& _rItemCommand,Menu* _pMenu,sal_uInt16 _nIndex) const;
114 : :
115 : :
116 : 0 : struct MenuItemHandler
117 : : {
118 : 0 : MenuItemHandler( sal_uInt16 aItemId, MenuManager* pManager, REFERENCE< XDISPATCH >& rDispatch ) :
119 : 0 : nItemId( aItemId ), pSubMenuManager( pManager ), xMenuItemDispatch( rDispatch ) {}
120 : :
121 : : sal_uInt16 nItemId;
122 : : ::rtl::OUString aTargetFrame;
123 : : ::rtl::OUString aMenuItemURL;
124 : : ::rtl::OUString aFilter;
125 : : ::rtl::OUString aPassword;
126 : : ::rtl::OUString aTitle;
127 : : MenuManager* pSubMenuManager;
128 : : REFERENCE< XDISPATCH > xMenuItemDispatch;
129 : : };
130 : :
131 : : void CreatePicklistArguments(
132 : : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgsList,
133 : : const MenuItemHandler* );
134 : :
135 : : MenuItemHandler* GetMenuItemHandler( sal_uInt16 nItemId );
136 : :
137 : : sal_Bool m_bInitialized;
138 : : sal_Bool m_bDeleteMenu;
139 : : sal_Bool m_bDeleteChildren;
140 : : sal_Bool m_bActive;
141 : : sal_Bool m_bIsBookmarkMenu;
142 : : sal_Bool m_bShowMenuImages;
143 : : ::rtl::OUString m_aMenuItemCommand;
144 : : Menu* m_pVCLMenu;
145 : : REFERENCE< XFRAME > m_xFrame;
146 : : ::std::vector< MenuItemHandler* > m_aMenuItemHandlerVector;
147 : :
148 : : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& mxServiceFactory;
149 : : ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
150 : : };
151 : :
152 : : } // namespace
153 : :
154 : : #endif
155 : :
156 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|