update dev300-m57
[ooovba.git] / framework / inc / classes / menumanager.hxx
bloba379d70eacaa43d66eab3fa91036b78a1e86d7b3
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>
47 //_________________________________________________________________________________________________________________
48 // other includes
49 //_________________________________________________________________________________________________________________
50 #include <rtl/ustring.hxx>
51 #include <vcl/menu.hxx>
52 #include <vcl/accel.hxx>
53 #include <cppuhelper/weak.hxx>
54 #include <threadhelp/threadhelpbase.hxx>
55 #include <macros/debug.hxx>
57 // #110897#
58 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
60 #define REFERENCE ::com::sun::star::uno::Reference
61 #define XFRAME ::com::sun::star::frame::XFrame
62 #define XDISPATCH ::com::sun::star::frame::XDispatch
63 #define XDISPATCHPROVIDER ::com::sun::star::frame::XDispatchProvider
64 #define XSTATUSLISTENER ::com::sun::star::frame::XStatusListener
65 #define XEVENTLISTENER ::com::sun::star::lang::XEventListener
66 #define FEATURSTATEEVENT ::com::sun::star::frame::FeatureStateEvent
67 #define RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException
68 #define EVENTOBJECT ::com::sun::star::lang::EventObject
70 namespace framework
73 class BmkMenu;
74 class AddonMenu;
75 class AddonPopupMenu;
76 class MenuManager : public XSTATUSLISTENER ,
77 public ThreadHelpBase ,
78 public ::cppu::OWeakObject
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 BmkMenu* pBmkMenu,
93 sal_Bool bDelete,
94 sal_Bool bDeleteChildren );
96 MenuManager(
97 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
98 REFERENCE< XFRAME >& rFrame,
99 AddonMenu* pAddonMenu,
100 sal_Bool bDelete,
101 sal_Bool bDeleteChildren );
103 MenuManager(
104 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
105 REFERENCE< XFRAME >& rFrame,
106 AddonPopupMenu* pAddonMenu,
107 sal_Bool bDelete,
108 sal_Bool bDeleteChildren );
110 virtual ~MenuManager();
112 // XInterface
113 virtual void SAL_CALL acquire() throw()
114 { OWeakObject::acquire(); }
115 virtual void SAL_CALL release() throw()
116 { OWeakObject::release(); }
117 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
118 const ::com::sun::star::uno::Type & rType ) throw( RUNTIMEEXCEPTION );
120 // XStatusListener
121 virtual void SAL_CALL statusChanged( const FEATURSTATEEVENT& Event ) throw ( RUNTIMEEXCEPTION );
123 // XEventListener
124 virtual void SAL_CALL disposing( const EVENTOBJECT& Source ) throw ( RUNTIMEEXCEPTION );
126 DECL_LINK( Select, Menu * );
128 Menu* GetMenu() const { return m_pVCLMenu; }
130 void RemoveListener();
132 // #110897#
133 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getServiceFactory();
135 protected:
136 DECL_LINK( Highlight, Menu * );
137 DECL_LINK( Activate, Menu * );
138 DECL_LINK( Deactivate, Menu * );
140 private:
141 void UpdateSpecialFileMenu( Menu* pMenu );
142 void UpdateSpecialWindowMenu( Menu* pMenu );
145 struct MenuItemHandler
147 MenuItemHandler( USHORT aItemId, MenuManager* pManager, REFERENCE< XDISPATCH >& rDispatch ) :
148 nItemId( aItemId ), pSubMenuManager( pManager ), xMenuItemDispatch( rDispatch ) {}
150 USHORT nItemId;
151 ::rtl::OUString aTargetFrame;
152 ::rtl::OUString aMenuItemURL;
153 ::rtl::OUString aFilter;
154 ::rtl::OUString aPassword;
155 ::rtl::OUString aTitle;
156 MenuManager* pSubMenuManager;
157 REFERENCE< XDISPATCH > xMenuItemDispatch;
160 void CreatePicklistArguments(
161 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgsList,
162 const MenuItemHandler* );
164 MenuItemHandler* GetMenuItemHandler( USHORT nItemId );
166 sal_Bool m_bInitialized;
167 sal_Bool m_bDeleteMenu;
168 sal_Bool m_bDeleteChildren;
169 sal_Bool m_bActive;
170 sal_Bool m_bIsBookmarkMenu;
171 sal_Bool m_bWasHiContrast;
172 sal_Bool m_bShowMenuImages;
173 ::rtl::OUString m_aMenuItemCommand;
174 Menu* m_pVCLMenu;
175 REFERENCE< XFRAME > m_xFrame;
176 ::std::vector< MenuItemHandler* > m_aMenuItemHandlerVector;
178 // #110897#
179 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& mxServiceFactory;
182 } // namespace
184 #endif