xref: /aoo41x/main/sfx2/inc/sfx2/mnuitem.hxx (revision 595fd105)
1353d8f4dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3353d8f4dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4353d8f4dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5353d8f4dSAndrew Rist  * distributed with this work for additional information
6353d8f4dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7353d8f4dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8353d8f4dSAndrew Rist  * "License"); you may not use this file except in compliance
9353d8f4dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10353d8f4dSAndrew Rist  *
11353d8f4dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12353d8f4dSAndrew Rist  *
13353d8f4dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14353d8f4dSAndrew Rist  * software distributed under the License is distributed on an
15353d8f4dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16353d8f4dSAndrew Rist  * KIND, either express or implied.  See the License for the
17353d8f4dSAndrew Rist  * specific language governing permissions and limitations
18353d8f4dSAndrew Rist  * under the License.
19353d8f4dSAndrew Rist  *
20353d8f4dSAndrew Rist  *************************************************************/
21353d8f4dSAndrew Rist 
22353d8f4dSAndrew Rist 
23cdf0e10cSrcweir #ifndef _SFXMNUITEM_HXX
24cdf0e10cSrcweir #define _SFXMNUITEM_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "sal/config.h"
27cdf0e10cSrcweir #include "sfx2/dllapi.h"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir class SfxVirtualMenu;
30cdf0e10cSrcweir class SfxBindings;
31cdf0e10cSrcweir class SfxModule;
32cdf0e10cSrcweir class Menu;
33cdf0e10cSrcweir class PopupMenu;
34cdf0e10cSrcweir class SfxUnoMenuControl;
35cdf0e10cSrcweir class SfxUnoControllerItem;
36cdf0e10cSrcweir struct SfxMenuCtrlFactory;
37cdf0e10cSrcweir #include <tools/string.hxx>
38cdf0e10cSrcweir #include <sfx2/ctrlitem.hxx>
39cdf0e10cSrcweir 
40*595fd105SAriel Constenla-Haile #include <com/sun/star/frame/XDispatch.hpp>
41*595fd105SAriel Constenla-Haile #include <com/sun/star/util/URL.hpp>
42*595fd105SAriel Constenla-Haile 
43cdf0e10cSrcweir class SFX2_DLLPUBLIC SfxMenuControl: public SfxControllerItem
44cdf0e10cSrcweir {
45cdf0e10cSrcweir //friend SvStream& operator<<( SvStream& rStream, const SfxMenuControl& rItem );
46cdf0e10cSrcweir //friend SvStream& operator>>( SvStream& rStream, SfxMenuControl& rItem );
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 	String					aTitle;
49cdf0e10cSrcweir 	String					aHelpText;
50cdf0e10cSrcweir 	SfxVirtualMenu* 		pOwnMenu;
51cdf0e10cSrcweir 	SfxVirtualMenu* 		pSubMenu;
52cdf0e10cSrcweir 	sal_Bool					b_ShowStrings;
53cdf0e10cSrcweir 	sal_Bool					b_UnusedDummy;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir public:
56cdf0e10cSrcweir 							SfxMenuControl();
57cdf0e10cSrcweir 							SfxMenuControl( sal_Bool bShowStrings );
58cdf0e10cSrcweir 							SfxMenuControl( sal_uInt16, SfxBindings&);
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 	static SfxMenuControl* 	CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings );
61cdf0e10cSrcweir 	static void 			RegisterControl( sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL );
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 							~SfxMenuControl();
64cdf0e10cSrcweir 
65cdf0e10cSrcweir         using SfxControllerItem::Bind;
66cdf0e10cSrcweir 	void					Bind( SfxVirtualMenu* pOwnMenu, sal_uInt16 nId,
67cdf0e10cSrcweir 								  const String& rTitle, const String &rHelpText,
68cdf0e10cSrcweir 								  SfxBindings & );
69cdf0e10cSrcweir 	void					Bind( SfxVirtualMenu* pOwnMenu, sal_uInt16 nId,
70cdf0e10cSrcweir 								  SfxVirtualMenu& rSubMenu,
71cdf0e10cSrcweir 								  const String& rTitle, const String &rHelpText,
72cdf0e10cSrcweir 								  SfxBindings & );
73cdf0e10cSrcweir 
74cdf0e10cSrcweir //	SvStream &				Load(SvStream &, SfxBindings*);
75cdf0e10cSrcweir //	SvStream &				Store(SvStream &);
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	String					GetTitle() const;
78cdf0e10cSrcweir 	SfxVirtualMenu* 		GetPopupMenu() const;
79cdf0e10cSrcweir 	virtual PopupMenu*		GetPopup() const;
80cdf0e10cSrcweir 	void					SetOwnMenu( SfxVirtualMenu* pMenu );
81cdf0e10cSrcweir 	void 					RemovePopup();
82cdf0e10cSrcweir 
GetHelpText() const83cdf0e10cSrcweir 	const String&			GetHelpText() const { return aHelpText; }
SetHelpText(const String & rStr)84cdf0e10cSrcweir 	void					SetHelpText(const String &rStr) { aHelpText  = rStr; }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	virtual void			StateChanged( sal_uInt16 nSID, SfxItemState eState,
87cdf0e10cSrcweir 										  const SfxPoolItem* pState );
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	static SfxMenuControl*	  CreateControl( sal_uInt16 nId, Menu &, SfxBindings & );
90cdf0e10cSrcweir 	static SfxUnoMenuControl* CreateControl( const String&, sal_uInt16, Menu&, SfxBindings&, SfxVirtualMenu* );
91cdf0e10cSrcweir 	static SfxUnoMenuControl* CreateControl( const String&, sal_uInt16, Menu&, const String& sItemText, const String& sHelpText, SfxBindings&, SfxVirtualMenu* );
92cdf0e10cSrcweir     static sal_Bool             IsSpecialControl( sal_uInt16 nId, SfxModule* );
93cdf0e10cSrcweir     static void             RegisterMenuControl(SfxModule*, SfxMenuCtrlFactory*);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir };
96cdf0e10cSrcweir 
97cdf0e10cSrcweir class SfxUnoMenuControl : public SfxMenuControl
98cdf0e10cSrcweir {
99cdf0e10cSrcweir 	SfxUnoControllerItem*	pUnoCtrl;
100cdf0e10cSrcweir public:
101cdf0e10cSrcweir 							SfxUnoMenuControl( const String&, sal_uInt16 nId, Menu&,
102cdf0e10cSrcweir 												SfxBindings&, SfxVirtualMenu* );
103cdf0e10cSrcweir 							SfxUnoMenuControl( const String&, sal_uInt16 nId, Menu&,
104cdf0e10cSrcweir 											   const String&, const String&,
105cdf0e10cSrcweir                                                 SfxBindings&, SfxVirtualMenu* );
106cdf0e10cSrcweir 							~SfxUnoMenuControl();
107cdf0e10cSrcweir 	void					Select();
108cdf0e10cSrcweir };
109cdf0e10cSrcweir 
110cdf0e10cSrcweir //--------------------------------------------------------------------
111cdf0e10cSrcweir 
112cdf0e10cSrcweir typedef SfxMenuControl* (*SfxMenuControlCtor)( sal_uInt16 nId, Menu &, SfxBindings & );
113cdf0e10cSrcweir 
114cdf0e10cSrcweir struct SfxMenuCtrlFactory
115cdf0e10cSrcweir {
116cdf0e10cSrcweir 	SfxMenuControlCtor	pCtor;
117cdf0e10cSrcweir 	TypeId				nTypeId;
118cdf0e10cSrcweir 	sal_uInt16				nSlotId;
119cdf0e10cSrcweir 
SfxMenuCtrlFactorySfxMenuCtrlFactory120cdf0e10cSrcweir 	SfxMenuCtrlFactory( SfxMenuControlCtor pTheCtor,
121cdf0e10cSrcweir 			TypeId nTheTypeId, sal_uInt16 nTheSlotId ):
122cdf0e10cSrcweir 		pCtor(pTheCtor),
123cdf0e10cSrcweir 		nTypeId(nTheTypeId),
124cdf0e10cSrcweir 		nSlotId(nTheSlotId)
125cdf0e10cSrcweir 	{}
126cdf0e10cSrcweir };
127cdf0e10cSrcweir 
128cdf0e10cSrcweir //
129cdf0e10cSrcweir 
GetTitle() const130cdf0e10cSrcweir inline String SfxMenuControl::GetTitle() const
131cdf0e10cSrcweir {
132cdf0e10cSrcweir 	return aTitle;
133cdf0e10cSrcweir }
134cdf0e10cSrcweir //--------------------------------------------------------------------
135cdf0e10cSrcweir 
136cdf0e10cSrcweir //
137cdf0e10cSrcweir 
GetPopupMenu() const138cdf0e10cSrcweir inline SfxVirtualMenu* SfxMenuControl::GetPopupMenu() const
139cdf0e10cSrcweir {
140cdf0e10cSrcweir 	return pSubMenu;
141cdf0e10cSrcweir }
142cdf0e10cSrcweir //--------------------------------------------------------------------
143cdf0e10cSrcweir 
144cdf0e10cSrcweir #define SFX_DECL_MENU_CONTROL() \
145cdf0e10cSrcweir 		static SfxMenuControl* CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings ); \
146cdf0e10cSrcweir 		static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL)
147cdf0e10cSrcweir 
148cdf0e10cSrcweir #define SFX_IMPL_MENU_CONTROL(Class, nItemClass) \
149cdf0e10cSrcweir 		SfxMenuControl* __EXPORT Class::CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings ) \
150cdf0e10cSrcweir 			   { return new Class(nId, rMenu, rBindings); } \
151cdf0e10cSrcweir 		void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \
152cdf0e10cSrcweir                { SfxMenuControl::RegisterMenuControl( pMod, new SfxMenuCtrlFactory( \
153cdf0e10cSrcweir 					Class::CreateImpl, TYPE(nItemClass), nSlotId ) ); }
154cdf0e10cSrcweir 
155cdf0e10cSrcweir //#if 0 // _SOLAR__PRIVATE
156cdf0e10cSrcweir 
157cdf0e10cSrcweir class SfxAppMenuControl_Impl : public SfxMenuControl
158cdf0e10cSrcweir {
159cdf0e10cSrcweir     PopupMenu*	pMenu;
160cdf0e10cSrcweir     sal_uIntPtr       m_nSymbolsStyle;
161cdf0e10cSrcweir     sal_Bool        m_bWasHiContrastMode;
162cdf0e10cSrcweir 	sal_Bool		m_bShowMenuImages;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir protected:
165cdf0e10cSrcweir 	DECL_LINK( Activate, Menu * ); // Needed to support high contrast images
166cdf0e10cSrcweir 
167cdf0e10cSrcweir public:
168cdf0e10cSrcweir 	SFX_DECL_MENU_CONTROL();
169cdf0e10cSrcweir     SfxAppMenuControl_Impl( sal_uInt16 nPos, Menu& rMenu, SfxBindings& rBindings );
170cdf0e10cSrcweir 	~SfxAppMenuControl_Impl();
171*595fd105SAriel Constenla-Haile 
172*595fd105SAriel Constenla-Haile     struct ExecuteInfo
173*595fd105SAriel Constenla-Haile     {
174*595fd105SAriel Constenla-Haile         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >     xDispatch;
175*595fd105SAriel Constenla-Haile         ::com::sun::star::util::URL                                                aTargetURL;
176*595fd105SAriel Constenla-Haile         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >  aArgs;
177*595fd105SAriel Constenla-Haile     };
178*595fd105SAriel Constenla-Haile 
179*595fd105SAriel Constenla-Haile     DECL_STATIC_LINK( SfxAppMenuControl_Impl, ExecuteHdl_Impl, ExecuteInfo* );
180cdf0e10cSrcweir };
181cdf0e10cSrcweir 
182cdf0e10cSrcweir //#endif
183cdf0e10cSrcweir 
184cdf0e10cSrcweir #endif
185