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>
46 #include <com/sun/star/util/XURLTransformer.hpp>
48 //_________________________________________________________________________________________________________________
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>
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
77 class MenuManager
: public ThreadHelpBase
,
78 public ::cppu::WeakImplHelper1
< ::com::sun::star::frame::XStatusListener
>
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
,
92 AddonMenu
* pAddonMenu
,
94 sal_Bool bDeleteChildren
);
96 virtual ~MenuManager();
99 virtual void SAL_CALL
statusChanged( const FEATURSTATEEVENT
& Event
) throw ( RUNTIMEEXCEPTION
);
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();
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
);
117 DECL_LINK( Highlight
, Menu
* );
118 DECL_LINK( Activate
, Menu
* );
119 DECL_LINK( Deactivate
, Menu
* );
122 void UpdateSpecialFileMenu( Menu
* pMenu
);
123 void UpdateSpecialWindowMenu( Menu
* pMenu
);
124 void ClearMenuDispatch(const EVENTOBJECT
& Source
= EVENTOBJECT(),bool _bRemoveOnly
= true);
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
) {}
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
;
155 sal_Bool m_bIsBookmarkMenu
;
156 sal_Bool m_bWasHiContrast
;
157 sal_Bool m_bShowMenuImages
;
158 ::rtl::OUString m_aMenuItemCommand
;
160 REFERENCE
< XFRAME
> m_xFrame
;
161 ::std::vector
< MenuItemHandler
* > m_aMenuItemHandlerVector
;
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
;