update dev300-m58
[ooovba.git] / framework / inc / classes / menumanager.hxx
blob50a7457f0faa7fc0ebb6ee361c9945804e0f2aea
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: menumanager.hxx,v $
10 * $Revision: 1.18 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_CLASSES_MENUMANAGER_HXX_
32 #define __FRAMEWORK_CLASSES_MENUMANAGER_HXX_
34 /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
35 with solaris headers ...
37 #include <vector>
39 //_________________________________________________________________________________________________________________
40 // interface includes
41 //_________________________________________________________________________________________________________________
42 #include <com/sun/star/frame/XFrame.hpp>
43 #include <com/sun/star/frame/XDispatch.hpp>
44 #include <com/sun/star/frame/FeatureStateEvent.hpp>
45 #include <com/sun/star/beans/PropertyValue.hpp>
46 #include <com/sun/star/util/XURLTransformer.hpp>
48 //_________________________________________________________________________________________________________________
49 // other includes
50 //_________________________________________________________________________________________________________________
51 #include <rtl/ustring.hxx>
52 #include <vcl/menu.hxx>
53 #include <vcl/accel.hxx>
54 #include <cppuhelper/implbase1.hxx>
55 #include <threadhelp/threadhelpbase.hxx>
56 #include <macros/debug.hxx>
58 // #110897#
59 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
61 #define REFERENCE ::com::sun::star::uno::Reference
62 #define XFRAME ::com::sun::star::frame::XFrame
63 #define XDISPATCH ::com::sun::star::frame::XDispatch
64 #define XDISPATCHPROVIDER ::com::sun::star::frame::XDispatchProvider
65 #define XSTATUSLISTENER ::com::sun::star::frame::XStatusListener
66 #define XEVENTLISTENER ::com::sun::star::lang::XEventListener
67 #define FEATURSTATEEVENT ::com::sun::star::frame::FeatureStateEvent
68 #define RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException
69 #define EVENTOBJECT ::com::sun::star::lang::EventObject
71 namespace framework
74 class BmkMenu;
75 class AddonMenu;
76 class AddonPopupMenu;
77 class MenuManager : public ThreadHelpBase ,
78 public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
80 public:
81 // #110897#
82 MenuManager(
83 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
84 REFERENCE< XFRAME >& rFrame,
85 Menu* pMenu,
86 sal_Bool bDelete,
87 sal_Bool bDeleteChildren );
89 MenuManager(
90 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
91 REFERENCE< XFRAME >& rFrame,
92 AddonMenu* pAddonMenu,
93 sal_Bool bDelete,
94 sal_Bool bDeleteChildren );
96 virtual ~MenuManager();
98 // XStatusListener
99 virtual void SAL_CALL statusChanged( const FEATURSTATEEVENT& Event ) throw ( RUNTIMEEXCEPTION );
101 // XEventListener
102 virtual void SAL_CALL disposing( const EVENTOBJECT& Source ) throw ( RUNTIMEEXCEPTION );
104 DECL_LINK( Select, Menu * );
106 Menu* GetMenu() const { return m_pVCLMenu; }
108 void RemoveListener();
110 // #110897#
111 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getServiceFactory();
113 static void UpdateSpecialWindowMenu( Menu* pMenu ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,IMutex& _rMutex);
114 static void FillMenuImages(::com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame,Menu* _pMenu,sal_Bool bIsHiContrast,sal_Bool bShowMenuImages);
116 protected:
117 DECL_LINK( Highlight, Menu * );
118 DECL_LINK( Activate, Menu * );
119 DECL_LINK( Deactivate, Menu * );
121 private:
122 void UpdateSpecialFileMenu( Menu* pMenu );
123 void UpdateSpecialWindowMenu( Menu* pMenu );
124 void ClearMenuDispatch(const EVENTOBJECT& Source = EVENTOBJECT(),bool _bRemoveOnly = true);
125 void SetHdl();
126 void AddMenu(PopupMenu* _pPopupMenu,const ::rtl::OUString& _sItemCommand,USHORT _nItemId,sal_Bool _bDelete,sal_Bool _bDeleteChildren);
127 USHORT FillItemCommand(::rtl::OUString& _rItemCommand,Menu* _pMenu,USHORT _nIndex) const;
130 struct MenuItemHandler
132 MenuItemHandler( USHORT aItemId, MenuManager* pManager, REFERENCE< XDISPATCH >& rDispatch ) :
133 nItemId( aItemId ), pSubMenuManager( pManager ), xMenuItemDispatch( rDispatch ) {}
135 USHORT nItemId;
136 ::rtl::OUString aTargetFrame;
137 ::rtl::OUString aMenuItemURL;
138 ::rtl::OUString aFilter;
139 ::rtl::OUString aPassword;
140 ::rtl::OUString aTitle;
141 MenuManager* pSubMenuManager;
142 REFERENCE< XDISPATCH > xMenuItemDispatch;
145 void CreatePicklistArguments(
146 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgsList,
147 const MenuItemHandler* );
149 MenuItemHandler* GetMenuItemHandler( USHORT nItemId );
151 sal_Bool m_bInitialized;
152 sal_Bool m_bDeleteMenu;
153 sal_Bool m_bDeleteChildren;
154 sal_Bool m_bActive;
155 sal_Bool m_bIsBookmarkMenu;
156 sal_Bool m_bWasHiContrast;
157 sal_Bool m_bShowMenuImages;
158 ::rtl::OUString m_aMenuItemCommand;
159 Menu* m_pVCLMenu;
160 REFERENCE< XFRAME > m_xFrame;
161 ::std::vector< MenuItemHandler* > m_aMenuItemHandlerVector;
163 // #110897#
164 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& mxServiceFactory;
165 ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
168 } // namespace
170 #endif