1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: menumanager.hxx,v $
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 ...
39 //_________________________________________________________________________________________________________________
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 //_________________________________________________________________________________________________________________
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>
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
76 class MenuManager
: public XSTATUSLISTENER
,
77 public ThreadHelpBase
,
78 public ::cppu::OWeakObject
83 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xServiceFactory
,
84 REFERENCE
< XFRAME
>& rFrame
,
87 sal_Bool bDeleteChildren
);
90 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xServiceFactory
,
91 REFERENCE
< XFRAME
>& rFrame
,
94 sal_Bool bDeleteChildren
);
97 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xServiceFactory
,
98 REFERENCE
< XFRAME
>& rFrame
,
99 AddonMenu
* pAddonMenu
,
101 sal_Bool bDeleteChildren
);
104 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xServiceFactory
,
105 REFERENCE
< XFRAME
>& rFrame
,
106 AddonPopupMenu
* pAddonMenu
,
108 sal_Bool bDeleteChildren
);
110 virtual ~MenuManager();
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
);
121 virtual void SAL_CALL
statusChanged( const FEATURSTATEEVENT
& Event
) throw ( RUNTIMEEXCEPTION
);
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();
133 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& getServiceFactory();
136 DECL_LINK( Highlight
, Menu
* );
137 DECL_LINK( Activate
, Menu
* );
138 DECL_LINK( Deactivate
, Menu
* );
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
) {}
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
;
170 sal_Bool m_bIsBookmarkMenu
;
171 sal_Bool m_bWasHiContrast
;
172 sal_Bool m_bShowMenuImages
;
173 ::rtl::OUString m_aMenuItemCommand
;
175 REFERENCE
< XFRAME
> m_xFrame
;
176 ::std::vector
< MenuItemHandler
* > m_aMenuItemHandlerVector
;
179 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& mxServiceFactory
;