xref: /aoo41x/main/sfx2/source/menu/virtmenu.cxx (revision d119d52d)
1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d119d52dSAndrew Rist  * distributed with this work for additional information
6*d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d119d52dSAndrew Rist  *
11*d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist  *
13*d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*d119d52dSAndrew Rist  * specific language governing permissions and limitations
18*d119d52dSAndrew Rist  * under the License.
19*d119d52dSAndrew Rist  *
20*d119d52dSAndrew Rist  *************************************************************/
21*d119d52dSAndrew Rist 
22*d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <sot/factory.hxx>
28cdf0e10cSrcweir #include <svtools/menuoptions.hxx>
29cdf0e10cSrcweir #include <svtools/imagemgr.hxx>
30cdf0e10cSrcweir #include <svl/imageitm.hxx>
31cdf0e10cSrcweir #include <com/sun/star/container/XEnumeration.hpp>
32cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
33cdf0e10cSrcweir #include <com/sun/star/frame/XFramesSupplier.hpp>
34cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
35cdf0e10cSrcweir #include <toolkit/unohlp.hxx>
36cdf0e10cSrcweir #include <tools/urlobj.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include "virtmenu.hxx"
39cdf0e10cSrcweir #include <sfx2/msgpool.hxx>
40cdf0e10cSrcweir #include "statcach.hxx"
41cdf0e10cSrcweir #include <sfx2/msg.hxx>
42cdf0e10cSrcweir #include "idpool.hxx"
43cdf0e10cSrcweir #include <sfx2/mnuitem.hxx>
44cdf0e10cSrcweir #include <sfx2/mnumgr.hxx>
45cdf0e10cSrcweir #include <sfx2/bindings.hxx>
46cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
47cdf0e10cSrcweir #include <sfx2/app.hxx>
48cdf0e10cSrcweir #include "sfxtypes.hxx"
49cdf0e10cSrcweir #include "arrdecl.hxx"
50cdf0e10cSrcweir #include <sfx2/sfx.hrc>
51cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
52cdf0e10cSrcweir #include "sfxpicklist.hxx"
53cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
54cdf0e10cSrcweir #include "menu.hrc"
55cdf0e10cSrcweir #include "sfx2/imagemgr.hxx"
56cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
57cdf0e10cSrcweir #include <sfx2/objsh.hxx>
58cdf0e10cSrcweir #include <framework/addonsoptions.hxx>
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #ifndef __FRAMEWORK_CLASSES_ADDONMENUS_HXX_
61cdf0e10cSrcweir #include <framework/addonmenu.hxx>
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir #include <framework/menuconfiguration.hxx>
64cdf0e10cSrcweir 
65cdf0e10cSrcweir using namespace ::com::sun::star::container;
66cdf0e10cSrcweir using namespace ::com::sun::star::frame;
67cdf0e10cSrcweir using namespace ::com::sun::star::uno;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir //=========================================================================
70cdf0e10cSrcweir 
71cdf0e10cSrcweir DBG_NAME(SfxVirtualMenu)
72cdf0e10cSrcweir 
73cdf0e10cSrcweir //=========================================================================
74cdf0e10cSrcweir 
75cdf0e10cSrcweir typedef SfxMenuControl* SfxMenuControlPtr;
76cdf0e10cSrcweir SV_IMPL_PTRARR(SfxMenuCtrlArr_Impl, SfxMenuControlPtr);
77cdf0e10cSrcweir 
78cdf0e10cSrcweir class SfxMenuImageControl_Impl : public SfxControllerItem
79cdf0e10cSrcweir {
80cdf0e10cSrcweir     SfxVirtualMenu*     pMenu;
81cdf0e10cSrcweir     long                lRotation;
82cdf0e10cSrcweir     sal_Bool                bIsMirrored;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir protected:
85cdf0e10cSrcweir     virtual void        StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
86cdf0e10cSrcweir public:
SfxMenuImageControl_Impl(sal_uInt16 nSlotId,SfxBindings & rBindings,SfxVirtualMenu * pVMenu)87cdf0e10cSrcweir                         SfxMenuImageControl_Impl( sal_uInt16 nSlotId, SfxBindings& rBindings, SfxVirtualMenu* pVMenu )
88cdf0e10cSrcweir                             : SfxControllerItem( nSlotId, rBindings )
89cdf0e10cSrcweir                             , pMenu( pVMenu )
90cdf0e10cSrcweir                             , lRotation( 0 )
91cdf0e10cSrcweir                             , bIsMirrored( sal_False )
92cdf0e10cSrcweir                         {}
93cdf0e10cSrcweir     void                Update();
94cdf0e10cSrcweir };
95cdf0e10cSrcweir 
StateChanged(sal_uInt16,SfxItemState,const SfxPoolItem * pState)96cdf0e10cSrcweir void SfxMenuImageControl_Impl::StateChanged( sal_uInt16 /*nSID*/, SfxItemState /*eState*/, const SfxPoolItem* pState )
97cdf0e10cSrcweir {
98cdf0e10cSrcweir     const SfxImageItem* pItem = PTR_CAST( SfxImageItem, pState );
99cdf0e10cSrcweir     if ( pItem )
100cdf0e10cSrcweir     {
101cdf0e10cSrcweir         lRotation = pItem->GetRotation();
102cdf0e10cSrcweir         bIsMirrored = pItem->IsMirrored();
103cdf0e10cSrcweir         Update();
104cdf0e10cSrcweir     }
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
Update()107cdf0e10cSrcweir void SfxMenuImageControl_Impl::Update()
108cdf0e10cSrcweir {
109cdf0e10cSrcweir     SfxViewFrame* pViewFrame = GetBindings().GetDispatcher_Impl()->GetFrame();
110cdf0e10cSrcweir     SfxModule* pModule = pViewFrame->GetObjectShell()->GetModule();
111cdf0e10cSrcweir     SfxSlotPool* pPool = pModule->GetSlotPool();
112cdf0e10cSrcweir     Menu* pSVMenu = pMenu->GetSVMenu();
113cdf0e10cSrcweir     for (sal_uInt16 nPos = 0; nPos<pSVMenu->GetItemCount(); nPos++)
114cdf0e10cSrcweir     {
115cdf0e10cSrcweir         sal_uInt16 nslotId = pSVMenu->GetItemId( nPos );
116cdf0e10cSrcweir         const SfxSlot* pSlot = pPool->GetSlot( nslotId );
117cdf0e10cSrcweir         if ( pSlot && pSlot->IsMode( SFX_SLOT_IMAGEROTATION ) )
118cdf0e10cSrcweir         {
119cdf0e10cSrcweir             pSVMenu->SetItemImageMirrorMode( nslotId, sal_False );
120cdf0e10cSrcweir             pSVMenu->SetItemImageAngle( nslotId, lRotation );
121cdf0e10cSrcweir         }
122cdf0e10cSrcweir 
123cdf0e10cSrcweir         if ( pSlot && pSlot->IsMode( SFX_SLOT_IMAGEREFLECTION ) )
124cdf0e10cSrcweir             pSVMenu->SetItemImageMirrorMode( nslotId, bIsMirrored );
125cdf0e10cSrcweir     }
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
128cdf0e10cSrcweir //=========================================================================
129cdf0e10cSrcweir 
RetrieveAddOnImage(Reference<com::sun::star::frame::XFrame> & rFrame,const rtl::OUString & aImageId,const rtl::OUString & aURL,sal_Bool bBigImage,sal_Bool bHiContrast)130cdf0e10cSrcweir static Image RetrieveAddOnImage( Reference< com::sun::star::frame::XFrame >& rFrame,
131cdf0e10cSrcweir 								 const rtl::OUString& aImageId,
132cdf0e10cSrcweir 								 const rtl::OUString& aURL,
133cdf0e10cSrcweir 								 sal_Bool bBigImage,
134cdf0e10cSrcweir 								 sal_Bool bHiContrast )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir 	Image aImage;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 	if ( aImageId.getLength() > 0 )
139cdf0e10cSrcweir 	{
140cdf0e10cSrcweir 		aImage = GetImage( rFrame, aImageId, bBigImage, bHiContrast );
141cdf0e10cSrcweir 		if ( !!aImage )
142cdf0e10cSrcweir 			return aImage;
143cdf0e10cSrcweir 	}
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	aImage = GetImage( rFrame, aURL, bBigImage, bHiContrast );
146cdf0e10cSrcweir 	if ( !aImage )
147cdf0e10cSrcweir 		aImage = framework::AddonsOptions().GetImageFromURL( aURL, bBigImage, bHiContrast );
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	return aImage;
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
152cdf0e10cSrcweir //=========================================================================
153cdf0e10cSrcweir 
154cdf0e10cSrcweir /*	Diese Hilfsfunktion pr"uft, ob eine Slot-Id im aktuellen Applikations-
155cdf0e10cSrcweir 	Status sichtbar ist oder nicht. Dabei bezieht sich der Applikations-Status
156cdf0e10cSrcweir 	darauf, ob die Applikation OLE-Server ist oder nicht.
157cdf0e10cSrcweir */
158cdf0e10cSrcweir 
IsItemHidden_Impl(sal_uInt16 nItemId,int bOleServer,int bMac)159cdf0e10cSrcweir sal_Bool IsItemHidden_Impl( sal_uInt16 nItemId, int bOleServer, int bMac )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir 	return ( bMac &&
162cdf0e10cSrcweir              ( nItemId == SID_MINIMIZED ) ) ||
163cdf0e10cSrcweir 		   (  bOleServer &&
164cdf0e10cSrcweir 			 ( nItemId == SID_QUITAPP || nItemId == SID_SAVEDOC ||
165cdf0e10cSrcweir 			   nItemId == SID_OPENDOC || nItemId == SID_SAVEASDOC ||
166cdf0e10cSrcweir 			   nItemId == SID_NEWDOC ) ) ||
167cdf0e10cSrcweir 		   ( !bOleServer &&
168cdf0e10cSrcweir 			 ( nItemId == SID_EXITANDRETURN || nItemId == SID_UPDATEDOC ) );
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir //====================================================================
172cdf0e10cSrcweir 
Construct_Impl()173cdf0e10cSrcweir void SfxVirtualMenu::Construct_Impl()
174cdf0e10cSrcweir {
175cdf0e10cSrcweir 	pSVMenu->SetHighlightHdl( LINK(this, SfxVirtualMenu, Highlight) );
176cdf0e10cSrcweir 	pSVMenu->SetActivateHdl( LINK(this, SfxVirtualMenu, Activate) );
177cdf0e10cSrcweir 	pSVMenu->SetDeactivateHdl( LINK(this, SfxVirtualMenu, Deactivate) );
178cdf0e10cSrcweir 	pSVMenu->SetSelectHdl( LINK(this, SfxVirtualMenu, Select) );
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	// #107258# accelerator keys are needed for accessibility
181cdf0e10cSrcweir     //if ( bOLE )
182cdf0e10cSrcweir     //    InvalidateKeyCodes();
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 	if ( !pResMgr && pParent )
185cdf0e10cSrcweir 		pResMgr = pParent->pResMgr;
186cdf0e10cSrcweir }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir //--------------------------------------------------------------------
189cdf0e10cSrcweir 
SfxVirtualMenu(sal_uInt16 nOwnId,SfxVirtualMenu * pOwnParent,Menu & rMenu,sal_Bool bWithHelp,SfxBindings & rBindings,sal_Bool bOLEServer,sal_Bool bRes,sal_Bool bIsAddonMenu)190cdf0e10cSrcweir SfxVirtualMenu::SfxVirtualMenu( sal_uInt16 nOwnId,
191cdf0e10cSrcweir 				SfxVirtualMenu* pOwnParent, Menu& rMenu, sal_Bool bWithHelp,
192cdf0e10cSrcweir 				SfxBindings &rBindings, sal_Bool bOLEServer, sal_Bool bRes, sal_Bool bIsAddonMenu ):
193cdf0e10cSrcweir 	pItems(0),
194cdf0e10cSrcweir        pImageControl(0),
195cdf0e10cSrcweir 	pBindings(&rBindings),
196cdf0e10cSrcweir 	pResMgr(0),
197cdf0e10cSrcweir 	pAutoDeactivate(0),
198cdf0e10cSrcweir 	nLocks(0),
199cdf0e10cSrcweir 	bHelpInitialized( bWithHelp ),
200cdf0e10cSrcweir 	bWasHighContrast( sal_False ),
201cdf0e10cSrcweir 	bIsAddonPopupMenu( bIsAddonMenu )
202cdf0e10cSrcweir {
203cdf0e10cSrcweir 	DBG_MEMTEST();
204cdf0e10cSrcweir 	DBG_CTOR(SfxVirtualMenu, 0);
205cdf0e10cSrcweir 	pSVMenu = &rMenu;
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	bResCtor = bRes;
208cdf0e10cSrcweir 	bOLE = bOLEServer;
209cdf0e10cSrcweir 	nId = nOwnId;
210cdf0e10cSrcweir 	pParent = pOwnParent;
211cdf0e10cSrcweir 	nVisibleItems = 0;
212cdf0e10cSrcweir 	pAppCtrl = 0;
213cdf0e10cSrcweir     pWindowMenu = NULL;
214cdf0e10cSrcweir     pPickMenu = NULL;
215cdf0e10cSrcweir     pAddonsMenu = NULL;
216cdf0e10cSrcweir 	bIsActive = sal_False;
217cdf0e10cSrcweir 	bControllersUnBound = sal_False;
218cdf0e10cSrcweir 	CreateFromSVMenu();
219cdf0e10cSrcweir 	Construct_Impl();
220cdf0e10cSrcweir 	bHelpInitialized = sal_False;
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir //--------------------------------------------------------------------
224cdf0e10cSrcweir 
225cdf0e10cSrcweir // creates a virtual menu from a StarView MenuBar or PopupMenu
226cdf0e10cSrcweir 
SfxVirtualMenu(Menu * pStarViewMenu,sal_Bool bWithHelp,SfxBindings & rBindings,sal_Bool bOLEServer,sal_Bool bRes,sal_Bool bIsAddonMenu)227cdf0e10cSrcweir SfxVirtualMenu::SfxVirtualMenu( Menu *pStarViewMenu, sal_Bool bWithHelp,
228cdf0e10cSrcweir 					SfxBindings &rBindings, sal_Bool bOLEServer, sal_Bool bRes, sal_Bool bIsAddonMenu ):
229cdf0e10cSrcweir 	pItems(0),
230cdf0e10cSrcweir        pImageControl(0),
231cdf0e10cSrcweir 	pBindings(&rBindings),
232cdf0e10cSrcweir 	pResMgr(0),
233cdf0e10cSrcweir 	pAutoDeactivate(0),
234cdf0e10cSrcweir 	nLocks(0),
235cdf0e10cSrcweir 	bHelpInitialized( bWithHelp ),
236cdf0e10cSrcweir 	bWasHighContrast( sal_False ),
237cdf0e10cSrcweir 	bIsAddonPopupMenu( bIsAddonMenu )
238cdf0e10cSrcweir {
239cdf0e10cSrcweir 	DBG_MEMTEST();
240cdf0e10cSrcweir 	DBG_CTOR(SfxVirtualMenu, 0);
241cdf0e10cSrcweir 
242cdf0e10cSrcweir     pSVMenu = pStarViewMenu;
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 	bResCtor = bRes;
245cdf0e10cSrcweir 	bOLE = bOLEServer;
246cdf0e10cSrcweir 	nId = 0;
247cdf0e10cSrcweir 	pParent = 0;
248cdf0e10cSrcweir 	pAppCtrl = 0;
249cdf0e10cSrcweir 	nVisibleItems = 0;
250cdf0e10cSrcweir     pWindowMenu = NULL;
251cdf0e10cSrcweir     pPickMenu = NULL;
252cdf0e10cSrcweir     pAddonsMenu = NULL;
253cdf0e10cSrcweir 	bIsActive = sal_False;
254cdf0e10cSrcweir 	bControllersUnBound = sal_False;
255cdf0e10cSrcweir 	CreateFromSVMenu();
256cdf0e10cSrcweir 	Construct_Impl();
257cdf0e10cSrcweir 	bHelpInitialized = sal_False;
258cdf0e10cSrcweir }
259cdf0e10cSrcweir 
260cdf0e10cSrcweir //--------------------------------------------------------------------
261cdf0e10cSrcweir 
262cdf0e10cSrcweir /*  Der Destruktor der Klasse SfxVirtualMenu gib die gebundenen Items frei
263cdf0e10cSrcweir 	und klinkt das zugeh"orige StarView-PopupMenu aus seinem Parent aus.
264cdf0e10cSrcweir 	Falls es sich um das Pickmenu oder das MDI-Menu handelt, wird es
265cdf0e10cSrcweir 	dort abgemeldet.
266cdf0e10cSrcweir */
267cdf0e10cSrcweir 
~SfxVirtualMenu()268cdf0e10cSrcweir SfxVirtualMenu::~SfxVirtualMenu()
269cdf0e10cSrcweir {
270cdf0e10cSrcweir 	DBG_MEMTEST();
271cdf0e10cSrcweir 	DBG_DTOR(SfxVirtualMenu, 0);
272cdf0e10cSrcweir 
273cdf0e10cSrcweir     DELETEZ( pImageControl );
274cdf0e10cSrcweir     SvtMenuOptions().RemoveListenerLink( LINK( this, SfxVirtualMenu, SettingsChanged ) );
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	if ( bIsActive )
277cdf0e10cSrcweir 	{
278cdf0e10cSrcweir 		pBindings->LEAVEREGISTRATIONS(); --nLocks; bIsActive = sal_False;
279cdf0e10cSrcweir 	}
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 	// QAP-Hack
282cdf0e10cSrcweir 	if ( pAutoDeactivate )
283cdf0e10cSrcweir 	{
284cdf0e10cSrcweir 		if ( pAutoDeactivate->IsActive() )
285cdf0e10cSrcweir 			Deactivate(0);
286cdf0e10cSrcweir 		DELETEX(pAutoDeactivate);
287cdf0e10cSrcweir 	}
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 	if (pItems)
290cdf0e10cSrcweir 	{
291cdf0e10cSrcweir 		delete [] pItems;
292cdf0e10cSrcweir 	}
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 	delete pAppCtrl;
295cdf0e10cSrcweir 	pBindings = 0;
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 	// Alle Menues, die von SV erzeugt wurden, werden auch dort wieder
298cdf0e10cSrcweir 	// gel"oscht (also die beim Laden aus der Resource erzeugten).
299cdf0e10cSrcweir 	// Das Top-Level-Menu wird nie von SV gel"oscht, da die Allocierung
300cdf0e10cSrcweir 	// im SFX erfolgt
301cdf0e10cSrcweir 	if ( !bResCtor || !pParent)
302cdf0e10cSrcweir 	{
303cdf0e10cSrcweir         if ( pParent )
304cdf0e10cSrcweir         {
305cdf0e10cSrcweir             if( pParent->pSVMenu->GetItemPos( nId ) != MENU_ITEM_NOTFOUND )
306cdf0e10cSrcweir                 pParent->pSVMenu->SetPopupMenu( nId, 0 );
307cdf0e10cSrcweir             if ( pParent->pPickMenu == pSVMenu )
308cdf0e10cSrcweir                 pParent->pPickMenu = 0;
309cdf0e10cSrcweir             if ( pParent->pWindowMenu == pSVMenu)
310cdf0e10cSrcweir                 pParent->pWindowMenu = 0;
311cdf0e10cSrcweir             if ( pParent->pAddonsMenu == pSVMenu )
312cdf0e10cSrcweir 				pParent->pAddonsMenu = 0;
313cdf0e10cSrcweir         }
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 		delete pSVMenu;
316cdf0e10cSrcweir 	}
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 	DBG_OUTF( ("SfxVirtualMenu %lx destroyed", this) );
319cdf0e10cSrcweir 	DBG_ASSERT( !nLocks, "destroying active menu" );
320cdf0e10cSrcweir }
321cdf0e10cSrcweir //--------------------------------------------------------------------
322cdf0e10cSrcweir 
IsHiContrastMode() const323cdf0e10cSrcweir sal_Bool SfxVirtualMenu::IsHiContrastMode() const
324cdf0e10cSrcweir {
325cdf0e10cSrcweir 	const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
326cdf0e10cSrcweir     return rSettings.GetHighContrastMode();
327cdf0e10cSrcweir }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir //--------------------------------------------------------------------
330cdf0e10cSrcweir // internal: creates the virtual menu from the pSVMenu
331cdf0e10cSrcweir 
CreateFromSVMenu()332cdf0e10cSrcweir void SfxVirtualMenu::CreateFromSVMenu()
333cdf0e10cSrcweir {
334cdf0e10cSrcweir 	DBG_MEMTEST();
335cdf0e10cSrcweir 	DBG_CHKTHIS(SfxVirtualMenu, 0);
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 	// Merge Addon popup menus into the SV Menu
338cdf0e10cSrcweir     SfxViewFrame* pViewFrame = pBindings->GetDispatcher()->GetFrame();
339cdf0e10cSrcweir     SfxSlotPool* pSlotPool = pViewFrame->GetObjectShell()->GetModule()->GetSlotPool();
340cdf0e10cSrcweir 	Reference< com::sun::star::frame::XFrame > xFrame( pViewFrame->GetFrame().GetFrameInterface() );
341cdf0e10cSrcweir 
342cdf0e10cSrcweir 	if ( pSVMenu->IsMenuBar() )
343cdf0e10cSrcweir 	{
344cdf0e10cSrcweir 		sal_uInt16 nPos = pSVMenu->GetItemPos( SID_MDIWINDOWLIST );
345cdf0e10cSrcweir 		if ( nPos != MENU_ITEM_NOTFOUND && xFrame.is() )
346cdf0e10cSrcweir 		{
347cdf0e10cSrcweir 			// Retrieve addon popup menus and add them to our menu bar
348cdf0e10cSrcweir 			Reference< com::sun::star::frame::XModel >		xModel;
349cdf0e10cSrcweir 			Reference< com::sun::star::frame::XController >	xController( xFrame->getController(), UNO_QUERY );
350cdf0e10cSrcweir 			if ( xController.is() )
351cdf0e10cSrcweir 				xModel = Reference< com::sun::star::frame::XModel >( xController->getModel(), UNO_QUERY );
352cdf0e10cSrcweir 			framework::AddonMenuManager::MergeAddonPopupMenus( xFrame, xModel, nPos, (MenuBar *)pSVMenu );
353cdf0e10cSrcweir 		}
354cdf0e10cSrcweir 
355cdf0e10cSrcweir         // Merge the Add-Ons help menu items into the Office help menu
356cdf0e10cSrcweir 		if ( xFrame.is() )
357cdf0e10cSrcweir 		    framework::AddonMenuManager::MergeAddonHelpMenu( xFrame, (MenuBar *)pSVMenu );
358cdf0e10cSrcweir 
359cdf0e10cSrcweir         // Set addon menu pointer here to avoid problems. When accessibility is enabled, the whole menu
360cdf0e10cSrcweir         // is created immediately!
361cdf0e10cSrcweir 		pAddonsMenu = pSVMenu->GetPopupMenu( SID_ADDONLIST );
362cdf0e10cSrcweir 	}
363cdf0e10cSrcweir 	else if ( pParent )
364cdf0e10cSrcweir 	{
365cdf0e10cSrcweir 		if ( pSVMenu == pParent->pAddonsMenu &&
366cdf0e10cSrcweir 			 framework::AddonsOptions().HasAddonsMenu() &&
367cdf0e10cSrcweir 			 !pSVMenu->GetPopupMenu( SID_ADDONS ) )
368cdf0e10cSrcweir 		{
369cdf0e10cSrcweir 			// Create menu item at the end of the tools popup menu for the addons popup menu
370cdf0e10cSrcweir 			InsertAddOnsMenuItem( pSVMenu );
371cdf0e10cSrcweir 		}
372cdf0e10cSrcweir 	}
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 	// get and store the number of items
375cdf0e10cSrcweir 	nCount = pSVMenu->GetItemCount();
376cdf0e10cSrcweir 
377cdf0e10cSrcweir 	// Achtung: nur zu diesem Zeitpunkt ist garantiert, da\s nCount und
378cdf0e10cSrcweir 	// der ItemCount des SV-Menues "ubereinstimmen; sp"ater kann das SvMenue
379cdf0e10cSrcweir 	// auch mehr Eintr"age haben (Pickliste!)
380cdf0e10cSrcweir 	if (nCount)
381cdf0e10cSrcweir 		pItems = new SfxMenuControl[nCount];
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 	// remember some values
384cdf0e10cSrcweir 	SFX_APP();
385cdf0e10cSrcweir 	const int bOleServer = sal_False;
386cdf0e10cSrcweir 	const int bMac = sal_False;
387cdf0e10cSrcweir     SvtMenuOptions aOptions;
388cdf0e10cSrcweir     aOptions.AddListenerLink( LINK( this, SfxVirtualMenu, SettingsChanged ) );
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 	// iterate through the items
391cdf0e10cSrcweir 	pBindings->ENTERREGISTRATIONS(); ++nLocks;
392cdf0e10cSrcweir     pImageControl = new SfxMenuImageControl_Impl( SID_IMAGE_ORIENTATION, *pBindings, this );
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 	// Update high contrast state
395cdf0e10cSrcweir 	bWasHighContrast = IsHiContrastMode();
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 	sal_uInt16 nSVPos = 0;
398cdf0e10cSrcweir 	for ( sal_uInt16 nPos=0; nPos<nCount; ++nPos, ++nSVPos )
399cdf0e10cSrcweir 	{
400cdf0e10cSrcweir 		sal_uInt16 nSlotId = pSVMenu->GetItemId(nSVPos);
401cdf0e10cSrcweir 		PopupMenu* pPopup = pSVMenu->GetPopupMenu(nSlotId);
402cdf0e10cSrcweir 		if( pPopup && nSlotId >= SID_OBJECTMENU0 && nSlotId <= SID_OBJECTMENU_LAST )
403cdf0e10cSrcweir 		{
404cdf0e10cSrcweir 			// artefact in XML menuconfig: every entry in root menu must have a popup!
405cdf0e10cSrcweir 			pSVMenu->SetPopupMenu( nSlotId, NULL );
406cdf0e10cSrcweir 			DELETEZ( pPopup );
407cdf0e10cSrcweir 		}
408cdf0e10cSrcweir 
409cdf0e10cSrcweir 		const String sItemText = pSVMenu->GetItemText(nSlotId);
410cdf0e10cSrcweir         const String sHelpText = pSVMenu->GetHelpText(nSlotId);
411cdf0e10cSrcweir 
412cdf0e10cSrcweir         if ( pPopup )
413cdf0e10cSrcweir 		{
414cdf0e10cSrcweir 
415cdf0e10cSrcweir             SfxMenuControl *pMnuCtrl =
416cdf0e10cSrcweir 				SfxMenuControl::CreateControl(nSlotId, *pPopup, *pBindings);
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 			if ( pMnuCtrl )
419cdf0e10cSrcweir 			{
420cdf0e10cSrcweir 				// Das Popup war offensichtlich kein "echtes"; solche werden
421cdf0e10cSrcweir 				// niemals aus der Resource geladen und m"ussen daher explizit
422cdf0e10cSrcweir 				// gel"oscht werden
423cdf0e10cSrcweir 				if ( pSVMenu->GetPopupMenu( nSlotId ) == pPopup )
424cdf0e10cSrcweir 					pSVMenu->SetPopupMenu( nSlotId, NULL );
425cdf0e10cSrcweir 				delete pPopup;
426cdf0e10cSrcweir 				pPopup = 0;
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 				SfxMenuCtrlArr_Impl &rCtrlArr = GetAppCtrl_Impl();
429cdf0e10cSrcweir 				rCtrlArr.C40_INSERT( SfxMenuControl, pMnuCtrl, rCtrlArr.Count() );
430cdf0e10cSrcweir 				(pItems+nPos)->Bind( 0, nSlotId, sItemText, sHelpText, *pBindings);
431cdf0e10cSrcweir 				pMnuCtrl->Bind( this, nSlotId, sItemText, sHelpText, *pBindings);
432cdf0e10cSrcweir 
433cdf0e10cSrcweir                 if (  Application::GetSettings().GetStyleSettings().GetUseImagesInMenus() )
434cdf0e10cSrcweir                 {
435cdf0e10cSrcweir                     rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
436cdf0e10cSrcweir                     aSlotURL += rtl::OUString::valueOf( sal_Int32( nSlotId ));
437cdf0e10cSrcweir                     Image aImage = GetImage( xFrame, aSlotURL, sal_False, bWasHighContrast );
438cdf0e10cSrcweir                     pSVMenu->SetItemImage( nSlotId, aImage );
439cdf0e10cSrcweir                 }
440cdf0e10cSrcweir 			}
441cdf0e10cSrcweir 			else
442cdf0e10cSrcweir 			{
443cdf0e10cSrcweir                 const SfxSlot* pSlot = pSlotPool->GetSlot( nSlotId );
444cdf0e10cSrcweir                 if ( pSlot )
445cdf0e10cSrcweir                 {
446cdf0e10cSrcweir                     rtl::OString aCmd(".uno:");
447cdf0e10cSrcweir                     aCmd += pSlot->GetUnoName();
448cdf0e10cSrcweir     				pSVMenu->SetHelpId( nSlotId, pSlot->GetUnoName() );
449cdf0e10cSrcweir                 }
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 				pMnuCtrl = pItems+nPos;
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 				// normalerweise jetzt erst im Activate-Handler
454cdf0e10cSrcweir 				if ( bOLE )
455cdf0e10cSrcweir 				{
456cdf0e10cSrcweir 					pMnuCtrl->Bind( this, nSlotId,
457cdf0e10cSrcweir 						*new SfxVirtualMenu(nSlotId, this, *pPopup, bHelpInitialized, *pBindings, bOLE, bResCtor),
458cdf0e10cSrcweir 						sItemText, sHelpText,
459cdf0e10cSrcweir 						*pBindings );
460cdf0e10cSrcweir 				}
461cdf0e10cSrcweir 			}
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 			++nVisibleItems;
464cdf0e10cSrcweir 		}
465cdf0e10cSrcweir 		else
466cdf0e10cSrcweir 		{
467cdf0e10cSrcweir 			switch ( pSVMenu->GetItemType(nSVPos) )
468cdf0e10cSrcweir 			{
469cdf0e10cSrcweir 				case MENUITEM_STRING:
470cdf0e10cSrcweir 				case MENUITEM_STRINGIMAGE:
471cdf0e10cSrcweir 				{
472cdf0e10cSrcweir                     SfxMenuControl *pMnuCtrl=0;
473cdf0e10cSrcweir 					String aCmd( pSVMenu->GetItemCommand( nSlotId ) );
474cdf0e10cSrcweir                     if ( aCmd.Len() && (( nSlotId < SID_SFX_START ) || ( nSlotId > SHRT_MAX )) )
475cdf0e10cSrcweir 					{
476cdf0e10cSrcweir                         // try to create control via comand name
477cdf0e10cSrcweir                         pMnuCtrl = SfxMenuControl::CreateControl( aCmd, nSlotId, *pSVMenu, sItemText, sHelpText, *pBindings, this );
478cdf0e10cSrcweir 						if ( pMnuCtrl )
479cdf0e10cSrcweir 						{
480cdf0e10cSrcweir 							SfxMenuCtrlArr_Impl &rCtrlArr = GetAppCtrl_Impl();
481cdf0e10cSrcweir                             rCtrlArr.C40_INSERT( SfxMenuControl, pMnuCtrl, rCtrlArr.Count());
482cdf0e10cSrcweir                             (pItems+nPos)->Bind( 0, nSlotId, sItemText, sHelpText, *pBindings);
483cdf0e10cSrcweir 						}
484cdf0e10cSrcweir 					}
485cdf0e10cSrcweir 
486cdf0e10cSrcweir                     if ( !pMnuCtrl )
487cdf0e10cSrcweir 					{
488cdf0e10cSrcweir                         // try to create control via Id
489cdf0e10cSrcweir                         pMnuCtrl = SfxMenuControl::CreateControl(nSlotId, *pSVMenu, *pBindings);
490cdf0e10cSrcweir 						if ( pMnuCtrl )
491cdf0e10cSrcweir 						{
492cdf0e10cSrcweir 							SfxMenuCtrlArr_Impl &rCtrlArr = GetAppCtrl_Impl();
493cdf0e10cSrcweir                             rCtrlArr.C40_INSERT( SfxMenuControl, pMnuCtrl, rCtrlArr.Count());
494cdf0e10cSrcweir                             (pItems+nPos)->Bind( 0, nSlotId, sItemText, sHelpText, *pBindings);
495cdf0e10cSrcweir 						}
496cdf0e10cSrcweir 						else
497cdf0e10cSrcweir                             // take default control
498cdf0e10cSrcweir 							pMnuCtrl = (pItems+nPos);
499cdf0e10cSrcweir 
500cdf0e10cSrcweir                         pMnuCtrl->Bind( this, nSlotId, sItemText, sHelpText, *pBindings);
501cdf0e10cSrcweir 					}
502cdf0e10cSrcweir 
503cdf0e10cSrcweir                     if ( Application::GetSettings().GetStyleSettings().GetUseImagesInMenus() )
504cdf0e10cSrcweir                     {
505cdf0e10cSrcweir 						Image aImage;
506cdf0e10cSrcweir 						if ( bIsAddonPopupMenu || framework::AddonMenuManager::IsAddonMenuId( nSlotId ))
507cdf0e10cSrcweir 						{
508cdf0e10cSrcweir 							rtl::OUString aImageId;
509cdf0e10cSrcweir 
510cdf0e10cSrcweir 							::framework::MenuConfiguration::Attributes* pMenuAttributes =
511cdf0e10cSrcweir 								(::framework::MenuConfiguration::Attributes*)pSVMenu->GetUserValue( nSlotId );
512cdf0e10cSrcweir 
513cdf0e10cSrcweir 							if ( pMenuAttributes )
514cdf0e10cSrcweir 								aImageId = pMenuAttributes->aImageId; // Retrieve image id from menu attributes
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 							aImage = RetrieveAddOnImage( xFrame, aImageId, aCmd, sal_False, bWasHighContrast );
517cdf0e10cSrcweir 						}
518cdf0e10cSrcweir 						else
519cdf0e10cSrcweir                         {
520cdf0e10cSrcweir                             rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
521cdf0e10cSrcweir                             aSlotURL += rtl::OUString::valueOf( sal_Int32( nSlotId ));
522cdf0e10cSrcweir                             aImage = GetImage( xFrame, aSlotURL, sal_False, bWasHighContrast );
523cdf0e10cSrcweir                         }
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 						if ( !!aImage )
526cdf0e10cSrcweir 							pSVMenu->SetItemImage( nSlotId, aImage );
527cdf0e10cSrcweir                     }
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 					if ( !IsItemHidden_Impl(nSlotId, bOleServer, bMac) )
530cdf0e10cSrcweir 						++nVisibleItems;
531cdf0e10cSrcweir 					else
532cdf0e10cSrcweir 						pSVMenu->RemoveItem( nSVPos-- );
533cdf0e10cSrcweir 					break;
534cdf0e10cSrcweir 				}
535cdf0e10cSrcweir 
536cdf0e10cSrcweir 				case MENUITEM_IMAGE:
537cdf0e10cSrcweir 					//! not implemented
538cdf0e10cSrcweir 					break;
539cdf0e10cSrcweir 
540cdf0e10cSrcweir 				case MENUITEM_SEPARATOR:
541cdf0e10cSrcweir 					//! not implemented
542cdf0e10cSrcweir 					break;
543cdf0e10cSrcweir 				default:
544cdf0e10cSrcweir 					break; // DONTKNOW and STRINGIMAGE not handled.
545cdf0e10cSrcweir 			}
546cdf0e10cSrcweir 		}
547cdf0e10cSrcweir 	}
548cdf0e10cSrcweir 	pBindings->LEAVEREGISTRATIONS(); --nLocks;
549cdf0e10cSrcweir }
550cdf0e10cSrcweir 
551cdf0e10cSrcweir //--------------------------------------------------------------------
552cdf0e10cSrcweir 
553cdf0e10cSrcweir // called on activation of the SV-Menu
554cdf0e10cSrcweir 
IMPL_LINK(SfxVirtualMenu,Highlight,Menu *,pMenu)555cdf0e10cSrcweir IMPL_LINK( SfxVirtualMenu, Highlight, Menu *, pMenu )
556cdf0e10cSrcweir {
557cdf0e10cSrcweir 	DBG_MEMTEST();
558cdf0e10cSrcweir 	DBG_CHKTHIS(SfxVirtualMenu, 0);
559cdf0e10cSrcweir 
560cdf0e10cSrcweir 	// eigenes StarView-Menu
561cdf0e10cSrcweir 	if ( pMenu == pSVMenu )
562cdf0e10cSrcweir 	{
563cdf0e10cSrcweir 		// AutoDeactivate ist jetzt nicht mehr n"otig
564cdf0e10cSrcweir 		//sal_uInt16 nSlotId = pMenu->GetCurItemId();
565cdf0e10cSrcweir 		if ( pAutoDeactivate )
566cdf0e10cSrcweir 			pAutoDeactivate->Stop();
567cdf0e10cSrcweir 	}
568cdf0e10cSrcweir 
569cdf0e10cSrcweir 	return sal_True;
570cdf0e10cSrcweir }
571cdf0e10cSrcweir 
IMPL_LINK(SfxVirtualMenu,SettingsChanged,void *,EMPTYARG)572cdf0e10cSrcweir IMPL_LINK( SfxVirtualMenu, SettingsChanged, void*, EMPTYARG )
573cdf0e10cSrcweir {
574cdf0e10cSrcweir     sal_uInt16 nItemCount = pSVMenu->GetItemCount();
575cdf0e10cSrcweir     SfxViewFrame *pViewFrame = pBindings->GetDispatcher()->GetFrame();
576cdf0e10cSrcweir     sal_Bool bIcons = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus();
577cdf0e10cSrcweir 	sal_Bool bIsHiContrastMode = IsHiContrastMode();
578cdf0e10cSrcweir 	Reference<com::sun::star::frame::XFrame> xFrame( pViewFrame->GetFrame().GetFrameInterface() );
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 	if ( !bIsAddonPopupMenu )
581cdf0e10cSrcweir 	{
582cdf0e10cSrcweir 		for ( sal_uInt16 nSVPos=0; nSVPos<nItemCount; ++nSVPos )
583cdf0e10cSrcweir 		{
584cdf0e10cSrcweir 			sal_uInt16          nSlotId = pSVMenu->GetItemId( nSVPos );
585cdf0e10cSrcweir 			MenuItemType    nType   = pSVMenu->GetItemType( nSVPos );
586cdf0e10cSrcweir 			if ( nType == MENUITEM_STRING && bIcons )
587cdf0e10cSrcweir 			{
588cdf0e10cSrcweir 				if ( framework::AddonMenuManager::IsAddonMenuId( nSlotId ))
589cdf0e10cSrcweir 				{
590cdf0e10cSrcweir                     // Special code for Add-On menu items. They can appear inside the help menu.
591cdf0e10cSrcweir 					rtl::OUString aCmd( pSVMenu->GetItemCommand( nSlotId ) );
592cdf0e10cSrcweir 					rtl::OUString aImageId;
593cdf0e10cSrcweir 
594cdf0e10cSrcweir 					::framework::MenuConfiguration::Attributes* pMenuAttributes =
595cdf0e10cSrcweir 						(::framework::MenuConfiguration::Attributes*)pSVMenu->GetUserValue( nSlotId );
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 					if ( pMenuAttributes )
598cdf0e10cSrcweir 						aImageId = pMenuAttributes->aImageId; // Retrieve image id from menu attributes
599cdf0e10cSrcweir 
600cdf0e10cSrcweir 					pSVMenu->SetItemImage( nSlotId, RetrieveAddOnImage( xFrame, aImageId, aCmd, sal_False, bIsHiContrastMode ));
601cdf0e10cSrcweir 				}
602cdf0e10cSrcweir 				else
603cdf0e10cSrcweir                 {
604cdf0e10cSrcweir                     rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
605cdf0e10cSrcweir                     aSlotURL += rtl::OUString::valueOf( sal_Int32( nSlotId ));
606cdf0e10cSrcweir 				    pSVMenu->SetItemImage( nSlotId, GetImage( xFrame, aSlotURL, sal_False, bWasHighContrast ));
607cdf0e10cSrcweir                 }
608cdf0e10cSrcweir 			}
609cdf0e10cSrcweir 			else if( nType == MENUITEM_STRINGIMAGE && !bIcons )
610cdf0e10cSrcweir 			{
611cdf0e10cSrcweir 				pSVMenu->SetItemImage( nSlotId, Image() );
612cdf0e10cSrcweir 			}
613cdf0e10cSrcweir 		}
614cdf0e10cSrcweir 	}
615cdf0e10cSrcweir 	else
616cdf0e10cSrcweir 	{
617cdf0e10cSrcweir 		// Remove/update images from Add-Ons top-level popup menus when settings have changed
618cdf0e10cSrcweir 		if ( !bIcons )
619cdf0e10cSrcweir 			RemoveMenuImages( pSVMenu );
620cdf0e10cSrcweir 		else
621cdf0e10cSrcweir 			UpdateImages( pSVMenu );
622cdf0e10cSrcweir 	}
623cdf0e10cSrcweir 
624cdf0e10cSrcweir 	// Special code to remove menu images from runtime popup menus when settings have changed
625cdf0e10cSrcweir 	if ( pParent && pSVMenu == pParent->pAddonsMenu )
626cdf0e10cSrcweir 	{
627cdf0e10cSrcweir 		if ( !bIcons )
628cdf0e10cSrcweir 			RemoveMenuImages( pParent->pAddonsMenu->GetPopupMenu( SID_ADDONS ));
629cdf0e10cSrcweir 		else
630cdf0e10cSrcweir 			UpdateImages( pParent->pAddonsMenu->GetPopupMenu( SID_ADDONS ));
631cdf0e10cSrcweir 	}
632cdf0e10cSrcweir 
633cdf0e10cSrcweir     if ( pImageControl )
634cdf0e10cSrcweir         pImageControl->Update();
635cdf0e10cSrcweir 
636cdf0e10cSrcweir     return 0;
637cdf0e10cSrcweir }
638cdf0e10cSrcweir 
639cdf0e10cSrcweir //--------------------------------------------------------------------
640cdf0e10cSrcweir 
UpdateImages()641cdf0e10cSrcweir void SfxVirtualMenu::UpdateImages()
642cdf0e10cSrcweir {
643cdf0e10cSrcweir     sal_Bool bIcons = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus();
644cdf0e10cSrcweir 
645cdf0e10cSrcweir 	if ( bIcons )
646cdf0e10cSrcweir 	{
647cdf0e10cSrcweir 		sal_Bool			bIsHiContrastMode   = IsHiContrastMode();
648cdf0e10cSrcweir 		sal_uInt16			nItemCount          = pSVMenu->GetItemCount();
649cdf0e10cSrcweir 		SfxViewFrame *	pViewFrame          = pBindings->GetDispatcher()->GetFrame();
650cdf0e10cSrcweir 		Reference<com::sun::star::frame::XFrame> xFrame( pViewFrame->GetFrame().GetFrameInterface() );
651cdf0e10cSrcweir 
652cdf0e10cSrcweir 		for ( sal_uInt16 nSVPos=0; nSVPos < nItemCount; ++nSVPos )
653cdf0e10cSrcweir 		{
654cdf0e10cSrcweir 			sal_uInt16 nSlotId = pSVMenu->GetItemId( nSVPos );
655cdf0e10cSrcweir 			if ( pSVMenu->GetItemType( nSVPos ) == MENUITEM_STRINGIMAGE )
656cdf0e10cSrcweir 			{
657cdf0e10cSrcweir                 if ( framework::AddonMenuManager::IsAddonMenuId( nSlotId ))
658cdf0e10cSrcweir                 {
659cdf0e10cSrcweir                     // Special code for Add-On menu items. They can appear inside the help menu.
660cdf0e10cSrcweir 					rtl::OUString aCmd( pSVMenu->GetItemCommand( nSlotId ) );
661cdf0e10cSrcweir 					rtl::OUString aImageId;
662cdf0e10cSrcweir 
663cdf0e10cSrcweir 					::framework::MenuConfiguration::Attributes* pMenuAttributes =
664cdf0e10cSrcweir 						(::framework::MenuConfiguration::Attributes*)pSVMenu->GetUserValue( nSlotId );
665cdf0e10cSrcweir 
666cdf0e10cSrcweir 					if ( pMenuAttributes )
667cdf0e10cSrcweir 						aImageId = pMenuAttributes->aImageId; // Retrieve image id from menu attributes
668cdf0e10cSrcweir 
669cdf0e10cSrcweir 					pSVMenu->SetItemImage( nSlotId, RetrieveAddOnImage( xFrame, aImageId, aCmd, sal_False, bIsHiContrastMode ));
670cdf0e10cSrcweir                 }
671cdf0e10cSrcweir                 else
672cdf0e10cSrcweir                 {
673cdf0e10cSrcweir                     rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
674cdf0e10cSrcweir                     aSlotURL += rtl::OUString::valueOf( sal_Int32( nSlotId ));
675cdf0e10cSrcweir 				    pSVMenu->SetItemImage( nSlotId, GetImage( xFrame, aSlotURL, sal_False, bWasHighContrast ));
676cdf0e10cSrcweir                 }
677cdf0e10cSrcweir 			}
678cdf0e10cSrcweir 		}
679cdf0e10cSrcweir 
680cdf0e10cSrcweir         if ( pImageControl )
681cdf0e10cSrcweir             pImageControl->Update();
682cdf0e10cSrcweir 	}
683cdf0e10cSrcweir }
684cdf0e10cSrcweir 
685cdf0e10cSrcweir //--------------------------------------------------------------------
686cdf0e10cSrcweir 
UpdateImages(Menu * pMenu)687cdf0e10cSrcweir void SfxVirtualMenu::UpdateImages( Menu* pMenu )
688cdf0e10cSrcweir {
689cdf0e10cSrcweir 	if ( !pMenu )
690cdf0e10cSrcweir 		return;
691cdf0e10cSrcweir 
692cdf0e10cSrcweir 	framework::AddonsOptions	aAddonOptions;
693cdf0e10cSrcweir 
694cdf0e10cSrcweir     sal_Bool bIcons = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus();
695cdf0e10cSrcweir 	if ( bIcons )
696cdf0e10cSrcweir 	{
697cdf0e10cSrcweir 		sal_Bool			bIsHiContrastMode	= IsHiContrastMode();
698cdf0e10cSrcweir 		sal_uInt16			nItemCount			= pMenu->GetItemCount();
699cdf0e10cSrcweir 		Reference<com::sun::star::frame::XFrame> aXFrame( pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame().GetFrameInterface() );
700cdf0e10cSrcweir 
701cdf0e10cSrcweir 		for ( sal_uInt16 nPos=0; nPos < nItemCount; ++nPos )
702cdf0e10cSrcweir 		{
703cdf0e10cSrcweir 			sal_uInt16 nSlotId = pMenu->GetItemId( nPos );
704cdf0e10cSrcweir 			PopupMenu* pPopup = pMenu->GetPopupMenu( nSlotId );
705cdf0e10cSrcweir 			if ( pMenu->GetItemType( nPos ) != MENUITEM_SEPARATOR )
706cdf0e10cSrcweir 			{
707cdf0e10cSrcweir 				rtl::OUString aImageId;
708cdf0e10cSrcweir 
709cdf0e10cSrcweir 				::framework::MenuConfiguration::Attributes* pMenuAttributes =
710cdf0e10cSrcweir 					(::framework::MenuConfiguration::Attributes*)pMenu->GetUserValue( nSlotId );
711cdf0e10cSrcweir 
712cdf0e10cSrcweir 				if ( pMenuAttributes )
713cdf0e10cSrcweir 					aImageId = pMenuAttributes->aImageId; // Retrieve image id from menu attributes
714cdf0e10cSrcweir 
715cdf0e10cSrcweir 				pMenu->SetItemImage( nSlotId, RetrieveAddOnImage( aXFrame, aImageId, pMenu->GetItemCommand( nSlotId ), sal_False, bIsHiContrastMode ));
716cdf0e10cSrcweir 			}
717cdf0e10cSrcweir 
718cdf0e10cSrcweir 			if ( pPopup )
719cdf0e10cSrcweir 				UpdateImages( pPopup );
720cdf0e10cSrcweir 		}
721cdf0e10cSrcweir 
722cdf0e10cSrcweir         if ( pImageControl )
723cdf0e10cSrcweir             pImageControl->Update();
724cdf0e10cSrcweir 	}
725cdf0e10cSrcweir }
726cdf0e10cSrcweir 
727cdf0e10cSrcweir //--------------------------------------------------------------------
728cdf0e10cSrcweir 
RemoveMenuImages(Menu * pMenu)729cdf0e10cSrcweir void SfxVirtualMenu::RemoveMenuImages( Menu* pMenu )
730cdf0e10cSrcweir {
731cdf0e10cSrcweir 	if ( !pMenu )
732cdf0e10cSrcweir 		return;
733cdf0e10cSrcweir 
734cdf0e10cSrcweir 	sal_uInt16 nItemCount = pMenu->GetItemCount();
735cdf0e10cSrcweir 	for ( sal_uInt16 nPos=0; nPos < nItemCount; ++nPos )
736cdf0e10cSrcweir 	{
737cdf0e10cSrcweir 		sal_uInt16 nSlotId = pMenu->GetItemId( nPos );
738cdf0e10cSrcweir 		PopupMenu* pPopup = pMenu->GetPopupMenu( nSlotId );
739cdf0e10cSrcweir 		if ( pMenu->GetItemType( nPos ) == MENUITEM_STRINGIMAGE )
740cdf0e10cSrcweir 			pMenu->SetItemImage( nSlotId, Image() );
741cdf0e10cSrcweir 		if ( pPopup )
742cdf0e10cSrcweir 			RemoveMenuImages( pPopup );
743cdf0e10cSrcweir 	}
744cdf0e10cSrcweir }
745cdf0e10cSrcweir 
746cdf0e10cSrcweir //--------------------------------------------------------------------
747cdf0e10cSrcweir 
Bind_Impl(Menu * pMenu)748cdf0e10cSrcweir bool SfxVirtualMenu::Bind_Impl( Menu *pMenu )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir 	// Selber suchen, da SV mit 'sal_uInt16 nSID = pSVMenu->GetCurItemId();' immer
751cdf0e10cSrcweir 	// 0 liefert. Das ist so, weil die Event-Weiterleitung lt. TH nichts mit
752cdf0e10cSrcweir 	// CurItem des Parent-Menus zu tun hat.
753cdf0e10cSrcweir 	sal_uInt32 nAddonsPopupPrefixLen = ADDONSPOPUPMENU_URL_PREFIX.getLength();
754cdf0e10cSrcweir 
755cdf0e10cSrcweir 	for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos )
756cdf0e10cSrcweir 	{
757cdf0e10cSrcweir 		// angesprochenes Sub-Menu gefunden?
758cdf0e10cSrcweir 		bool bFound = false;
759cdf0e10cSrcweir 		sal_uInt16 nSID = pSVMenu->GetItemId(nPos);
760cdf0e10cSrcweir 		SfxMenuControl &rCtrl = pItems[nPos];
761cdf0e10cSrcweir 		bFound = pSVMenu->GetPopupMenu(nSID) == pMenu;
762cdf0e10cSrcweir 		SfxVirtualMenu *pSubMenu = rCtrl.GetPopupMenu();
763cdf0e10cSrcweir 
764cdf0e10cSrcweir 		if ( bFound )
765cdf0e10cSrcweir 		{
766cdf0e10cSrcweir 			// Nur ein gebundener Menu-Controller hat schon seine Id!
767cdf0e10cSrcweir 			if ( !rCtrl.GetId() )
768cdf0e10cSrcweir 			{
769cdf0e10cSrcweir 				bIsAddonPopupMenu = sal_False;
770cdf0e10cSrcweir 				DBG_ASSERT( !pSubMenu, "Popup schon vorhanden!");
771cdf0e10cSrcweir 
772cdf0e10cSrcweir 				// Check if the popup is an Add-On popup menu
773cdf0e10cSrcweir 				// Either the popup menu has a special ID  or a special command URL prefix!
774cdf0e10cSrcweir 				rtl::OUString aCommand = pSVMenu->GetItemCommand( nSID );
775cdf0e10cSrcweir 				if ( ( nSID == SID_ADDONS ) ||
776cdf0e10cSrcweir 					 ( nSID == SID_ADDONHELP ) ||
777cdf0e10cSrcweir 					 (( (sal_uInt32)aCommand.getLength() > nAddonsPopupPrefixLen ) &&
778cdf0e10cSrcweir 					  ( aCommand.indexOf( ADDONSPOPUPMENU_URL_PREFIX ) == 0 )) )
779cdf0e10cSrcweir 					bIsAddonPopupMenu = sal_True;
780cdf0e10cSrcweir 
781cdf0e10cSrcweir 				// VirtualMenu f"ur Sub-Menu erzeugen
782cdf0e10cSrcweir 				sal_Bool bRes = bResCtor;
783cdf0e10cSrcweir 				pSubMenu = new SfxVirtualMenu( nSID, this,
784cdf0e10cSrcweir 						*pMenu, sal_False, *pBindings, bOLE, bRes, bIsAddonPopupMenu );
785cdf0e10cSrcweir 
786cdf0e10cSrcweir 				DBG_OUTF( ("Neues VirtualMenu %lx erzeugt", pSubMenu) );
787cdf0e10cSrcweir 
788cdf0e10cSrcweir 				rCtrl.Bind( this, nSID, *pSubMenu,
789cdf0e10cSrcweir 					pSVMenu->GetItemText(nSID), pSVMenu->GetHelpText(nSID),
790cdf0e10cSrcweir 					*pBindings );
791cdf0e10cSrcweir 
792cdf0e10cSrcweir 				// Activate weiterleiten
793cdf0e10cSrcweir 				pSubMenu->Bind_Impl( pMenu );
794cdf0e10cSrcweir 				pSubMenu->Activate( pMenu );
795cdf0e10cSrcweir 			}
796cdf0e10cSrcweir 		}
797cdf0e10cSrcweir 
798cdf0e10cSrcweir 		// rekursiv weitersuchen (SV Activate nur am Menu selbst und Top-Menu)
799cdf0e10cSrcweir 		if ( !bFound && pSubMenu )
800cdf0e10cSrcweir 			bFound = pSubMenu->Bind_Impl( pMenu );
801cdf0e10cSrcweir 
802cdf0e10cSrcweir 		// gefunden, dann abbrechen
803cdf0e10cSrcweir 		if ( bFound )
804cdf0e10cSrcweir 			return true;
805cdf0e10cSrcweir 	}
806cdf0e10cSrcweir 
807cdf0e10cSrcweir 	// nicht in diesem Untermenu gefunden
808cdf0e10cSrcweir 	return false;
809cdf0e10cSrcweir }
810cdf0e10cSrcweir 
BindControllers()811cdf0e10cSrcweir void SfxVirtualMenu::BindControllers()
812cdf0e10cSrcweir {
813cdf0e10cSrcweir 	pBindings->ENTERREGISTRATIONS();
814cdf0e10cSrcweir 
815cdf0e10cSrcweir 	sal_uInt16 nPos;
816cdf0e10cSrcweir 	for ( nPos = 0; nPos < nCount; ++nPos )
817cdf0e10cSrcweir 	{
818cdf0e10cSrcweir 		SfxMenuControl& rCtrl = pItems[nPos];
819cdf0e10cSrcweir 		if ( rCtrl.IsBindable_Impl() && !rCtrl.GetPopupMenu() )
820cdf0e10cSrcweir 			rCtrl.ReBind();
821cdf0e10cSrcweir 	}
822cdf0e10cSrcweir 
823cdf0e10cSrcweir 	SfxMenuCtrlArr_Impl& rCtrlArr = GetAppCtrl_Impl();
824cdf0e10cSrcweir 	for ( nPos=0; nPos<rCtrlArr.Count(); nPos++ )
825cdf0e10cSrcweir 	{
826cdf0e10cSrcweir 		SfxMenuControl* pCtrl = rCtrlArr[nPos];
827cdf0e10cSrcweir 		sal_uInt16 nSlotId = pCtrl->GetId();
828cdf0e10cSrcweir         if ( !pSVMenu->GetItemCommand(nSlotId).Len() )
829cdf0e10cSrcweir 			pCtrl->ReBind();
830cdf0e10cSrcweir 	}
831cdf0e10cSrcweir 
832cdf0e10cSrcweir 	pBindings->LEAVEREGISTRATIONS();
833cdf0e10cSrcweir 	bControllersUnBound = sal_False;
834cdf0e10cSrcweir }
835cdf0e10cSrcweir 
UnbindControllers()836cdf0e10cSrcweir void SfxVirtualMenu::UnbindControllers()
837cdf0e10cSrcweir {
838cdf0e10cSrcweir 	pBindings->ENTERREGISTRATIONS();
839cdf0e10cSrcweir 
840cdf0e10cSrcweir 	sal_uInt16 nPos;
841cdf0e10cSrcweir 	for ( nPos = 0; nPos < nCount; ++nPos )
842cdf0e10cSrcweir 	{
843cdf0e10cSrcweir 		SfxMenuControl &rCtrl = pItems[nPos];
844cdf0e10cSrcweir 		if ( rCtrl.IsBound() )
845cdf0e10cSrcweir 			rCtrl.UnBind();
846cdf0e10cSrcweir 	}
847cdf0e10cSrcweir 
848cdf0e10cSrcweir 	SfxMenuCtrlArr_Impl& rCtrlArr = GetAppCtrl_Impl();
849cdf0e10cSrcweir 	for ( nPos=0; nPos<rCtrlArr.Count(); nPos++ )
850cdf0e10cSrcweir 	{
851cdf0e10cSrcweir 		SfxMenuControl* pCtrl = rCtrlArr[nPos];
852cdf0e10cSrcweir 		if ( pCtrl->IsBound() )
853cdf0e10cSrcweir 			// UnoController sind nicht gebunden!
854cdf0e10cSrcweir 			pCtrl->UnBind();
855cdf0e10cSrcweir 	}
856cdf0e10cSrcweir 
857cdf0e10cSrcweir 	pBindings->LEAVEREGISTRATIONS();
858cdf0e10cSrcweir 	bControllersUnBound = sal_True;
859cdf0e10cSrcweir }
860cdf0e10cSrcweir 
861cdf0e10cSrcweir 
862cdf0e10cSrcweir //--------------------------------------------------------------------
InsertAddOnsMenuItem(Menu * pMenu)863cdf0e10cSrcweir void SfxVirtualMenu::InsertAddOnsMenuItem( Menu* pMenu )
864cdf0e10cSrcweir {
865cdf0e10cSrcweir 	// Create special popup menu that is filled with the 3rd party components popup menu items
866cdf0e10cSrcweir 	Reference<com::sun::star::lang::XMultiServiceFactory> aXMultiServiceFactory(::comphelper::getProcessServiceFactory());
867cdf0e10cSrcweir 	::framework::MenuConfiguration aConf( aXMultiServiceFactory );
868cdf0e10cSrcweir 	Reference<com::sun::star::frame::XFrame> xFrame( pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame().GetFrameInterface() );
869cdf0e10cSrcweir 
870cdf0e10cSrcweir 	PopupMenu* pAddonMenu = NULL;
871cdf0e10cSrcweir 	try
872cdf0e10cSrcweir 	{
873cdf0e10cSrcweir 		pAddonMenu = framework::AddonMenuManager::CreateAddonMenu( xFrame );
874cdf0e10cSrcweir 	}
875cdf0e10cSrcweir 	catch ( ::com::sun::star::lang::WrappedTargetException )
876cdf0e10cSrcweir 	{
877cdf0e10cSrcweir 	}
878cdf0e10cSrcweir 
879cdf0e10cSrcweir 	// Create menu item at the end of the tools popup menu for the addons popup menu
880cdf0e10cSrcweir 	if ( pAddonMenu && pAddonMenu->GetItemCount() > 0 )
881cdf0e10cSrcweir 	{
882cdf0e10cSrcweir 	    sal_uInt16 nItemCount = pMenu->GetItemCount();
883cdf0e10cSrcweir 	    String aAddonsTitle( SfxResId( STR_MENU_ADDONS ));
884cdf0e10cSrcweir 	    if ( nItemCount > 0 && pMenu->GetItemType( nItemCount-1 ) != MENUITEM_SEPARATOR )
885cdf0e10cSrcweir 		    pMenu->InsertSeparator();
886cdf0e10cSrcweir 	    pMenu->InsertItem( SID_ADDONS, aAddonsTitle );
887cdf0e10cSrcweir         pMenu->SetPopupMenu( SID_ADDONS, pAddonMenu );
888cdf0e10cSrcweir 
889cdf0e10cSrcweir 	    if ( Application::GetSettings().GetStyleSettings().GetUseImagesInMenus() )
890cdf0e10cSrcweir 	    {
891cdf0e10cSrcweir                rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
892cdf0e10cSrcweir                aSlotURL += rtl::OUString::valueOf( sal_Int32( SID_ADDONS ));
893cdf0e10cSrcweir 		 pMenu->SetItemImage( SID_ADDONS, GetImage( xFrame, aSlotURL, sal_False, bWasHighContrast ));
894cdf0e10cSrcweir 	    }
895cdf0e10cSrcweir     }
896cdf0e10cSrcweir 	else
897cdf0e10cSrcweir 	    delete pAddonMenu;
898cdf0e10cSrcweir }
899cdf0e10cSrcweir 
900cdf0e10cSrcweir //--------------------------------------------------------------------
901cdf0e10cSrcweir 
902cdf0e10cSrcweir // called on activation of the SV-Menu
903cdf0e10cSrcweir 
IMPL_LINK(SfxVirtualMenu,Activate,Menu *,pMenu)904cdf0e10cSrcweir IMPL_LINK( SfxVirtualMenu, Activate, Menu *, pMenu )
905cdf0e10cSrcweir {
906cdf0e10cSrcweir 	DBG_MEMTEST();
907cdf0e10cSrcweir 	DBG_CHKTHIS(SfxVirtualMenu, 0);
908cdf0e10cSrcweir 	DBG_OUTF( ("SfxVirtualMenu %lx activated %lx, own %lx", this, pMenu, pSVMenu));
909cdf0e10cSrcweir 
910cdf0e10cSrcweir 	// MI: wozu war der noch gut?
911cdf0e10cSrcweir 	// MBA: scheint ein alter QAP-Hack gewesen zu sein ( in rev.1.41 eingecheckt ! )
912cdf0e10cSrcweir //	if ( Application::IsInModalMode() )
913cdf0e10cSrcweir //		return TRUE; // abw"urgen
914cdf0e10cSrcweir 
915cdf0e10cSrcweir 	if ( pMenu )
916cdf0e10cSrcweir 	{
917cdf0e10cSrcweir 		sal_Bool bDontHide = SvtMenuOptions().IsEntryHidingEnabled();
918cdf0e10cSrcweir 		sal_uInt16 nFlag = pMenu->GetMenuFlags();
919cdf0e10cSrcweir 		if ( bDontHide )
920cdf0e10cSrcweir 			nFlag &= ~MENU_FLAG_HIDEDISABLEDENTRIES;
921cdf0e10cSrcweir 		else
922cdf0e10cSrcweir 			nFlag |= MENU_FLAG_HIDEDISABLEDENTRIES;
923cdf0e10cSrcweir 		pMenu->SetMenuFlags( nFlag );
924cdf0e10cSrcweir 	}
925cdf0e10cSrcweir 
926cdf0e10cSrcweir 	// eigenes StarView-Menu
927cdf0e10cSrcweir 	if ( pMenu == pSVMenu )
928cdf0e10cSrcweir 	{
929cdf0e10cSrcweir 		// doppelt-Activate verhindern
930cdf0e10cSrcweir 		if ( bIsActive )
931cdf0e10cSrcweir 			return sal_True;
932cdf0e10cSrcweir 
933cdf0e10cSrcweir 		// ggf. Pick-Menu erzeugen
934cdf0e10cSrcweir         if ( pParent && pSVMenu == pParent->pPickMenu )
935cdf0e10cSrcweir         {
936cdf0e10cSrcweir 			SfxPickList::Get()->CreateMenuEntries( pParent->pPickMenu );
937cdf0e10cSrcweir         }
938cdf0e10cSrcweir         else
939cdf0e10cSrcweir             pPickMenu = pSVMenu->GetPopupMenu(SID_PICKLIST);
940cdf0e10cSrcweir 
941cdf0e10cSrcweir         if ( pParent && pSVMenu == pParent->pWindowMenu )
942cdf0e10cSrcweir         {
943cdf0e10cSrcweir 			// update window list
944cdf0e10cSrcweir 			::std::vector< ::rtl::OUString > aNewWindowListVector;
945cdf0e10cSrcweir 			Reference< XDesktop > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
946cdf0e10cSrcweir 											DEFINE_CONST_OUSTRING( "com.sun.star.frame.Desktop" ) ), UNO_QUERY );
947cdf0e10cSrcweir 
948cdf0e10cSrcweir 			sal_uInt16	nActiveItemId = 0;
949cdf0e10cSrcweir 			sal_uInt16	nItemId = START_ITEMID_WINDOWLIST;
950cdf0e10cSrcweir 
951cdf0e10cSrcweir 			if ( xDesktop.is() )
952cdf0e10cSrcweir 			{
953cdf0e10cSrcweir                 Reference< XFramesSupplier > xTasksSupplier( xDesktop, UNO_QUERY );
954cdf0e10cSrcweir 				Reference< XFrame > xCurrentFrame = xDesktop->getCurrentFrame();
955cdf0e10cSrcweir                 Reference< XIndexAccess > xList ( xTasksSupplier->getFrames(), UNO_QUERY );
956cdf0e10cSrcweir                 sal_Int32 nFrameCount = xList->getCount();
957cdf0e10cSrcweir                 for( sal_Int32 i=0; i<nFrameCount; ++i )
958cdf0e10cSrcweir 				{
959cdf0e10cSrcweir                     Reference< XFrame > xFrame;
960cdf0e10cSrcweir                     Any aVal = xList->getByIndex(i);
961cdf0e10cSrcweir 					if (!(aVal>>=xFrame) || !xFrame.is() )
962cdf0e10cSrcweir 						continue;
963cdf0e10cSrcweir 
964cdf0e10cSrcweir 					if ( xFrame == xCurrentFrame )
965cdf0e10cSrcweir 						nActiveItemId = nItemId;
966cdf0e10cSrcweir 
967cdf0e10cSrcweir 					Window* pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
968cdf0e10cSrcweir 					if ( pWin && pWin->IsVisible() )
969cdf0e10cSrcweir 					{
970cdf0e10cSrcweir 						aNewWindowListVector.push_back( pWin->GetText() );
971cdf0e10cSrcweir 						++nItemId;
972cdf0e10cSrcweir 					}
973cdf0e10cSrcweir 				}
974cdf0e10cSrcweir 			}
975cdf0e10cSrcweir 
976cdf0e10cSrcweir 			int	nItemCount		 = pMenu->GetItemCount();
977cdf0e10cSrcweir 
978cdf0e10cSrcweir 			if ( nItemCount > 0 )
979cdf0e10cSrcweir 			{
980cdf0e10cSrcweir 				// remove all old window list entries from menu
981cdf0e10cSrcweir 				sal_uInt16 nPos = pMenu->GetItemPos( START_ITEMID_WINDOWLIST );
982cdf0e10cSrcweir             	for ( sal_uInt16 n = nPos; n < pMenu->GetItemCount(); )
983cdf0e10cSrcweir                 	pMenu->RemoveItem( n );
984cdf0e10cSrcweir 
985cdf0e10cSrcweir 				if ( pMenu->GetItemType( pMenu->GetItemCount()-1 ) == MENUITEM_SEPARATOR )
986cdf0e10cSrcweir                 	pMenu->RemoveItem( pMenu->GetItemCount()-1 );
987cdf0e10cSrcweir 			}
988cdf0e10cSrcweir 
989cdf0e10cSrcweir 			if ( aNewWindowListVector.size() > 0 )
990cdf0e10cSrcweir 			{
991cdf0e10cSrcweir 				// append new window list entries to menu
992cdf0e10cSrcweir 				pMenu->InsertSeparator();
993cdf0e10cSrcweir 				nItemId = START_ITEMID_WINDOWLIST;
994cdf0e10cSrcweir 				for ( sal_uInt32 i = 0; i < aNewWindowListVector.size(); i++ )
995cdf0e10cSrcweir 				{
996cdf0e10cSrcweir 					pMenu->InsertItem( nItemId, aNewWindowListVector.at( i ), MIB_RADIOCHECK );
997cdf0e10cSrcweir 					if ( nItemId == nActiveItemId )
998cdf0e10cSrcweir 						pMenu->CheckItem( nItemId );
999cdf0e10cSrcweir 					++nItemId;
1000cdf0e10cSrcweir 				}
1001cdf0e10cSrcweir 			}
1002cdf0e10cSrcweir         }
1003cdf0e10cSrcweir         else
1004cdf0e10cSrcweir             pWindowMenu = pSVMenu->GetPopupMenu(SID_MDIWINDOWLIST);
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir         if ( !pParent && pSVMenu->IsMenuBar() && !pAddonsMenu )
1007cdf0e10cSrcweir         {
1008cdf0e10cSrcweir 			// Store Add-Ons parents of our runtime menu items
1009cdf0e10cSrcweir 			pAddonsMenu	= pSVMenu->GetPopupMenu( SID_ADDONLIST );
1010cdf0e10cSrcweir 		}
1011cdf0e10cSrcweir 
1012cdf0e10cSrcweir 		// f"ur konstistenten Status sorgen
1013cdf0e10cSrcweir 		if ( bControllersUnBound )
1014cdf0e10cSrcweir 			BindControllers();
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir         //InvalidateKeyCodes();
1017cdf0e10cSrcweir 		pBindings->GetDispatcher_Impl()->Flush();
1018cdf0e10cSrcweir 		for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos )
1019cdf0e10cSrcweir 		{
1020cdf0e10cSrcweir 			sal_uInt16 nSlotId = (pItems+nPos)->GetId();
1021cdf0e10cSrcweir             if ( nSlotId && nSlotId > END_ITEMID_WINDOWLIST )
1022cdf0e10cSrcweir 				pBindings->Update(nSlotId);
1023cdf0e10cSrcweir 		}
1024cdf0e10cSrcweir 
1025cdf0e10cSrcweir         pBindings->Update( SID_IMAGE_ORIENTATION );
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir 		// HelpText on-demand
1028cdf0e10cSrcweir 		if ( !bHelpInitialized )
1029cdf0e10cSrcweir 		{
1030cdf0e10cSrcweir             // TODO/CLEANUP: do we need help texts in context menus?
1031cdf0e10cSrcweir             // old way with SlotInfo doesn't work anymore
1032cdf0e10cSrcweir 		}
1033cdf0e10cSrcweir 
1034cdf0e10cSrcweir 		// bis zum Deactivate die Statusupdates unterdr"ucken
1035cdf0e10cSrcweir 		pBindings->ENTERREGISTRATIONS(); ++nLocks; bIsActive = sal_True;
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir 		if ( pAutoDeactivate ) // QAP-Hack
1038cdf0e10cSrcweir 			pAutoDeactivate->Start();
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir 		if ( IsHiContrastMode() != bWasHighContrast )
1041cdf0e10cSrcweir 		{
1042cdf0e10cSrcweir 			// Refresh images as our background color changed and remember it!!
1043cdf0e10cSrcweir 			bWasHighContrast = IsHiContrastMode();
1044cdf0e10cSrcweir 			if ( bIsAddonPopupMenu )
1045cdf0e10cSrcweir 				UpdateImages( pSVMenu );
1046cdf0e10cSrcweir 			else
1047cdf0e10cSrcweir 				UpdateImages();
1048cdf0e10cSrcweir 		}
1049cdf0e10cSrcweir 
1050cdf0e10cSrcweir 		// erledigt
1051cdf0e10cSrcweir 		return sal_True;
1052cdf0e10cSrcweir 	}
1053cdf0e10cSrcweir 	else
1054cdf0e10cSrcweir 	{
1055cdf0e10cSrcweir 		// VirtualMenu fuer SubMenu finden und ggf. an VirtualMenu binden
1056cdf0e10cSrcweir 		bool bRet = Bind_Impl( pMenu );
1057cdf0e10cSrcweir #ifdef DBG_UTIL
1058cdf0e10cSrcweir 		if ( !bRet)
1059cdf0e10cSrcweir 			DBG_WARNING( "W1: Virtual menu konnte nicht erzeugt werden!" );
1060cdf0e10cSrcweir #endif
1061cdf0e10cSrcweir 		return bRet;
1062cdf0e10cSrcweir 	}
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir //--------------------------------------------------------------------
1066cdf0e10cSrcweir 
IMPL_LINK(SfxVirtualMenu,Deactivate,Menu *,pMenu)1067cdf0e10cSrcweir IMPL_LINK( SfxVirtualMenu, Deactivate, Menu *, pMenu )
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir 	DBG_MEMTEST();
1070cdf0e10cSrcweir 	DBG_OUTF( ("SfxVirtualMenu %lx deactivated %lx, own %lx", this, pMenu, pSVMenu) );
1071cdf0e10cSrcweir 	if ( bIsActive && ( 0 == pMenu || pMenu == pSVMenu ) )
1072cdf0e10cSrcweir 	{
1073cdf0e10cSrcweir 		if ( pAutoDeactivate )
1074cdf0e10cSrcweir 			pAutoDeactivate->Stop();
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir 		// Bis auf die Menubar k"onnen alle Controller unbinded werden, wenn
1077cdf0e10cSrcweir 		// das Menue deaktiviert ( = zugeklappt ) wird
1078cdf0e10cSrcweir 		if ( pParent )
1079cdf0e10cSrcweir 			UnbindControllers();
1080cdf0e10cSrcweir 		pBindings->LEAVEREGISTRATIONS(); --nLocks; bIsActive = sal_False;
1081cdf0e10cSrcweir 	}
1082cdf0e10cSrcweir 	return sal_True;
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir //--------------------------------------------------------------------
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir // called on activation of the SV-Menu
1087cdf0e10cSrcweir 
IMPL_LINK(SfxVirtualMenu,Select,Menu *,pMenu)1088cdf0e10cSrcweir IMPL_LINK( SfxVirtualMenu, Select, Menu *, pMenu )
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir 	sal_uInt16 nSlotId = (sal_uInt16) pMenu->GetCurItemId();
1091cdf0e10cSrcweir 	DBG_OUTF( ("SfxVirtualMenu %lx selected %u from %lx", this, nSlotId, pMenu) );
1092cdf0e10cSrcweir /*
1093cdf0e10cSrcweir 	if ( pSVMenu->GetItemCommand( nSlotId ).Len() )
1094cdf0e10cSrcweir 	{
1095cdf0e10cSrcweir 		SfxMenuCtrlArr_Impl& rCtrlArr = GetAppCtrl_Impl();
1096cdf0e10cSrcweir 		for ( sal_uInt16 nPos=0; nPos<rCtrlArr.Count(); nPos++ )
1097cdf0e10cSrcweir 		{
1098cdf0e10cSrcweir 			SfxMenuControl* pCtrl = rCtrlArr[nPos];
1099cdf0e10cSrcweir 			if ( pCtrl->GetId() == nSlotId )
1100cdf0e10cSrcweir 			{
1101cdf0e10cSrcweir 				SfxUnoMenuControl *pUnoCtrl = (SfxUnoMenuControl*) pCtrl;
1102cdf0e10cSrcweir 				pUnoCtrl->Select();
1103cdf0e10cSrcweir 				return sal_True;
1104cdf0e10cSrcweir 			}
1105cdf0e10cSrcweir 		}
1106cdf0e10cSrcweir 	}
1107cdf0e10cSrcweir */
1108cdf0e10cSrcweir     if ( nSlotId >= START_ITEMID_WINDOWLIST && nSlotId <= END_ITEMID_WINDOWLIST )
1109cdf0e10cSrcweir 	{
1110cdf0e10cSrcweir 		// window list menu item selected
1111cdf0e10cSrcweir         Reference< XFramesSupplier > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
1112cdf0e10cSrcweir 										DEFINE_CONST_OUSTRING( "com.sun.star.frame.Desktop" ) ), UNO_QUERY );
1113cdf0e10cSrcweir 		if ( xDesktop.is() )
1114cdf0e10cSrcweir 		{
1115cdf0e10cSrcweir 			sal_uInt16 nTaskId = START_ITEMID_WINDOWLIST;
1116cdf0e10cSrcweir             Reference< XIndexAccess > xList( xDesktop->getFrames(), UNO_QUERY );
1117cdf0e10cSrcweir             sal_Int32 nFrameCount = xList->getCount();
1118cdf0e10cSrcweir             for ( sal_Int32 i=0; i<nFrameCount; ++i )
1119cdf0e10cSrcweir 			{
1120cdf0e10cSrcweir                 Any aItem = xList->getByIndex(i);
1121cdf0e10cSrcweir                 Reference< XFrame > xFrame;
1122cdf0e10cSrcweir 				if (( aItem >>= xFrame ) && xFrame.is() && nTaskId == nSlotId )
1123cdf0e10cSrcweir 				{
1124cdf0e10cSrcweir                     Window* pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
1125cdf0e10cSrcweir 					pWin->GrabFocus();
1126cdf0e10cSrcweir                     pWin->ToTop( TOTOP_RESTOREWHENMIN );
1127cdf0e10cSrcweir 					break;
1128cdf0e10cSrcweir 				}
1129cdf0e10cSrcweir 
1130cdf0e10cSrcweir 				nTaskId++;
1131cdf0e10cSrcweir 			}
1132cdf0e10cSrcweir 		}
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir 		return sal_True;
1135cdf0e10cSrcweir 	}
1136cdf0e10cSrcweir     else if ( nSlotId >= START_ITEMID_PICKLIST && nSlotId <= END_ITEMID_PICKLIST )
1137cdf0e10cSrcweir     {
1138cdf0e10cSrcweir         SfxPickList::Get()->ExecuteMenuEntry( nSlotId );
1139cdf0e10cSrcweir         return sal_True;
1140cdf0e10cSrcweir     }
1141cdf0e10cSrcweir 
1142cdf0e10cSrcweir 	if ( pMenu->GetItemCommand( nSlotId ).Len() )
1143cdf0e10cSrcweir 		pBindings->ExecuteCommand_Impl( pMenu->GetItemCommand( nSlotId ) );
1144cdf0e10cSrcweir 	else
1145cdf0e10cSrcweir 		pBindings->Execute( nSlotId );
1146cdf0e10cSrcweir 
1147cdf0e10cSrcweir 	return sal_True;
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir //--------------------------------------------------------------------
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir // returns the associated StarView-menu
1153cdf0e10cSrcweir 
GetSVMenu() const1154cdf0e10cSrcweir Menu* SfxVirtualMenu::GetSVMenu() const
1155cdf0e10cSrcweir {
1156cdf0e10cSrcweir 	DBG_MEMTEST();
1157cdf0e10cSrcweir 	DBG_CHKTHIS(SfxVirtualMenu, 0);
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir 	return pSVMenu;
1160cdf0e10cSrcweir }
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir //--------------------------------------------------------------------
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir // return the position of the specified item
1165cdf0e10cSrcweir 
GetItemPos(sal_uInt16 nItemId) const1166cdf0e10cSrcweir sal_uInt16 SfxVirtualMenu::GetItemPos( sal_uInt16 nItemId ) const
1167cdf0e10cSrcweir {
1168cdf0e10cSrcweir 	DBG_MEMTEST();
1169cdf0e10cSrcweir 	DBG_CHKTHIS(SfxVirtualMenu, 0);
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir 	for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos )
1172cdf0e10cSrcweir 		if ( (pItems+nPos)->GetId() == nItemId )
1173cdf0e10cSrcweir 			return nPos;
1174cdf0e10cSrcweir 	return MENU_ITEM_NOTFOUND;
1175cdf0e10cSrcweir }
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir //--------------------------------------------------------------------
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir // returns the popup-menu assigned to the item or 0 if none
1180cdf0e10cSrcweir 
GetPopupMenu(sal_uInt16 nItemId) const1181cdf0e10cSrcweir SfxVirtualMenu* SfxVirtualMenu::GetPopupMenu( sal_uInt16 nItemId ) const
1182cdf0e10cSrcweir {
1183cdf0e10cSrcweir 	DBG_MEMTEST();
1184cdf0e10cSrcweir 	DBG_CHKTHIS(SfxVirtualMenu, 0);
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos(nItemId);
1187cdf0e10cSrcweir 	if ( nPos != MENU_ITEM_NOTFOUND )
1188cdf0e10cSrcweir 		return (pItems+nPos)->GetPopupMenu();
1189cdf0e10cSrcweir 	return 0;
1190cdf0e10cSrcweir }
1191cdf0e10cSrcweir //--------------------------------------------------------------------
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir // returns the text of the item as currently shown in the menu
1194cdf0e10cSrcweir 
GetItemText(sal_uInt16 nSlotId) const1195cdf0e10cSrcweir String SfxVirtualMenu::GetItemText( sal_uInt16 nSlotId ) const
1196cdf0e10cSrcweir {
1197cdf0e10cSrcweir 	DBG_MEMTEST();
1198cdf0e10cSrcweir 	DBG_CHKTHIS(SfxVirtualMenu, 0);
1199cdf0e10cSrcweir 
1200cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos(nSlotId);
1201cdf0e10cSrcweir 	if ( nPos != MENU_ITEM_NOTFOUND )
1202cdf0e10cSrcweir 		return (pItems+nPos)->GetTitle();
1203cdf0e10cSrcweir 	return String();
1204cdf0e10cSrcweir }
1205cdf0e10cSrcweir //--------------------------------------------------------------------
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir // returns the text of the item as currently shown in the menu
1208cdf0e10cSrcweir 
GetItemHelpText(sal_uInt16 nSlotId) const1209cdf0e10cSrcweir String SfxVirtualMenu::GetItemHelpText( sal_uInt16 nSlotId ) const
1210cdf0e10cSrcweir {
1211cdf0e10cSrcweir 	DBG_MEMTEST();
1212cdf0e10cSrcweir 	DBG_CHKTHIS(SfxVirtualMenu, 0);
1213cdf0e10cSrcweir 
1214cdf0e10cSrcweir 	sal_uInt16 nPos = GetItemPos(nSlotId);
1215cdf0e10cSrcweir 	if ( nPos != MENU_ITEM_NOTFOUND )
1216cdf0e10cSrcweir 		return (pItems+nPos)->GetHelpText();
1217cdf0e10cSrcweir 	return String();
1218cdf0e10cSrcweir }
1219cdf0e10cSrcweir 
1220cdf0e10cSrcweir //--------------------------------------------------------------------
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir // set the checkmark of the specified item
1223cdf0e10cSrcweir 
CheckItem(sal_uInt16 nItemId,sal_Bool bCheck)1224cdf0e10cSrcweir void SfxVirtualMenu::CheckItem( sal_uInt16 nItemId, sal_Bool bCheck )
1225cdf0e10cSrcweir {
1226cdf0e10cSrcweir 	DBG_MEMTEST();
1227cdf0e10cSrcweir 	DBG_CHKTHIS(SfxVirtualMenu, 0);
1228cdf0e10cSrcweir 	DBG_ASSERT( this != 0, "");
1229cdf0e10cSrcweir 	DBG_ASSERT( pSVMenu != 0, "" );
1230cdf0e10cSrcweir 	if (pSVMenu->GetItemPos( nItemId ) != MENU_ITEM_NOTFOUND )
1231cdf0e10cSrcweir 		pSVMenu->CheckItem( nItemId, bCheck );
1232cdf0e10cSrcweir }
1233cdf0e10cSrcweir //--------------------------------------------------------------------
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir // set the enabled-state of the specified item
1236cdf0e10cSrcweir 
EnableItem(sal_uInt16 nItemId,sal_Bool bEnable)1237cdf0e10cSrcweir void SfxVirtualMenu::EnableItem( sal_uInt16 nItemId, sal_Bool bEnable )
1238cdf0e10cSrcweir {
1239cdf0e10cSrcweir 	DBG_MEMTEST();
1240cdf0e10cSrcweir 	DBG_CHKTHIS(SfxVirtualMenu, 0);
1241cdf0e10cSrcweir 	DBG_ASSERT( this != 0, "");
1242cdf0e10cSrcweir 	DBG_ASSERT( pSVMenu != 0, "" );
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir 	if (pSVMenu->GetItemPos( nItemId ) != MENU_ITEM_NOTFOUND )
1245cdf0e10cSrcweir 		pSVMenu->EnableItem( nItemId, bEnable );
1246cdf0e10cSrcweir }
1247cdf0e10cSrcweir //--------------------------------------------------------------------
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir // set the text of the specified item
1250cdf0e10cSrcweir 
SetItemText(sal_uInt16 nItemId,const String & rText)1251cdf0e10cSrcweir void SfxVirtualMenu::SetItemText( sal_uInt16 nItemId, const String& rText )
1252cdf0e10cSrcweir {
1253cdf0e10cSrcweir 	DBG_MEMTEST();
1254cdf0e10cSrcweir 	DBG_CHKTHIS(SfxVirtualMenu, 0);
1255cdf0e10cSrcweir 	DBG_ASSERT( this != 0, "");
1256cdf0e10cSrcweir 	DBG_ASSERT( pSVMenu != 0, "" );
1257cdf0e10cSrcweir 	if (pSVMenu->GetItemPos( nItemId ) != MENU_ITEM_NOTFOUND )
1258cdf0e10cSrcweir 		pSVMenu->SetItemText( nItemId, rText );
1259cdf0e10cSrcweir }
1260cdf0e10cSrcweir 
1261cdf0e10cSrcweir //--------------------------------------------------------------------
1262cdf0e10cSrcweir 
1263cdf0e10cSrcweir //
1264cdf0e10cSrcweir 
SetPopupMenu(sal_uInt16 nItemId,PopupMenu * pMenu)1265cdf0e10cSrcweir void SfxVirtualMenu::SetPopupMenu( sal_uInt16 nItemId, PopupMenu *pMenu )
1266cdf0e10cSrcweir {
1267cdf0e10cSrcweir 	DBG_MEMTEST();
1268cdf0e10cSrcweir 	DBG_CHKTHIS(SfxVirtualMenu, 0);
1269cdf0e10cSrcweir 
1270cdf0e10cSrcweir 	if (pSVMenu->GetItemPos( nItemId ) != MENU_ITEM_NOTFOUND )
1271cdf0e10cSrcweir 		GetSVMenu()->SetPopupMenu( nItemId, pMenu );
1272cdf0e10cSrcweir 	for ( sal_uInt16 n = 0; n < nCount; ++n )
1273cdf0e10cSrcweir 	{
1274cdf0e10cSrcweir 		SfxVirtualMenu *pSubMenu = (pItems+n)->GetPopupMenu();
1275cdf0e10cSrcweir 		if ( pSubMenu )
1276cdf0e10cSrcweir 			pSubMenu->SetPopupMenu( nItemId, pMenu );
1277cdf0e10cSrcweir 	}
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir 
1280cdf0e10cSrcweir //--------------------------------------------------------------------
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir // Erzwingt die Initialisierung, die sonst nur im Activate kommt
1283cdf0e10cSrcweir 
InitPopup(sal_uInt16 nPos,sal_Bool)1284cdf0e10cSrcweir void SfxVirtualMenu::InitPopup( sal_uInt16 nPos, sal_Bool /*bOLE*/ )
1285cdf0e10cSrcweir {
1286cdf0e10cSrcweir 	DBG_MEMTEST();
1287cdf0e10cSrcweir 	DBG_CHKTHIS(SfxVirtualMenu, 0);
1288cdf0e10cSrcweir 
1289cdf0e10cSrcweir 	sal_uInt16 nSID = pSVMenu->GetItemId(nPos);
1290cdf0e10cSrcweir 	PopupMenu *pMenu = pSVMenu->GetPopupMenu( nSID );
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir 	DBG_ASSERT( pMenu, "Hier gibt es kein Popup!");
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir 	SfxMenuControl &rCtrl = pItems[nPos];
1295cdf0e10cSrcweir 	if ( !rCtrl.GetId() )
1296cdf0e10cSrcweir 	{
1297cdf0e10cSrcweir 		// VirtualMenu f"ur Sub-Menu erzeugen
1298cdf0e10cSrcweir 		sal_Bool bRes = bResCtor;
1299cdf0e10cSrcweir 		SfxVirtualMenu *pSubMenu =
1300cdf0e10cSrcweir 			new SfxVirtualMenu(nSID, this, *pMenu, sal_False, *pBindings, bOLE, bRes);
1301cdf0e10cSrcweir 
1302cdf0e10cSrcweir 		DBG_OUTF( ("Neues VirtualMenu %lx erzeugt", pSubMenu) );
1303cdf0e10cSrcweir 
1304cdf0e10cSrcweir 		rCtrl.Bind( this, nSID, *pSubMenu,
1305cdf0e10cSrcweir 			pSVMenu->GetItemText(nSID), pSVMenu->GetHelpText(nSID),
1306cdf0e10cSrcweir 			*pBindings );
1307cdf0e10cSrcweir 	}
1308cdf0e10cSrcweir }
1309cdf0e10cSrcweir 
InitializeHelp()1310cdf0e10cSrcweir void SfxVirtualMenu::InitializeHelp()
1311cdf0e10cSrcweir {
1312cdf0e10cSrcweir 	for ( sal_uInt16 nPos = 0; nPos<pSVMenu->GetItemCount(); ++nPos )
1313cdf0e10cSrcweir 	{
1314cdf0e10cSrcweir 		sal_uInt16 nSlotId = pSVMenu->GetItemId(nPos);
1315cdf0e10cSrcweir         // TODO/CLEANUP: this code does nothing!
1316cdf0e10cSrcweir //        if ( !bHelpInitialized )
1317cdf0e10cSrcweir //            pSVMenu->SetHelpText( nId, rSlotPool.GetSlotHelpText_Impl( nId ) );
1318cdf0e10cSrcweir 		SfxMenuControl &rCtrl = pItems[nPos];
1319cdf0e10cSrcweir 		if ( nSlotId && !rCtrl.GetId() )
1320cdf0e10cSrcweir 		{
1321cdf0e10cSrcweir 			InitPopup( nPos, sal_True );
1322cdf0e10cSrcweir 		}
1323cdf0e10cSrcweir 
1324cdf0e10cSrcweir 		SfxVirtualMenu *pSubMenu = rCtrl.GetPopupMenu();
1325cdf0e10cSrcweir 		if ( pSubMenu )
1326cdf0e10cSrcweir 			pSubMenu->InitializeHelp();
1327cdf0e10cSrcweir 	}
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir 	bHelpInitialized = sal_True;
1330cdf0e10cSrcweir }
1331cdf0e10cSrcweir 
1332cdf0e10cSrcweir typedef sal_uIntPtr (__LOADONCALLAPI *HelpIdFunc) ( const String& );
1333cdf0e10cSrcweir 
SetHelpIds(ResMgr * pRes)1334cdf0e10cSrcweir void SfxVirtualMenu::SetHelpIds( ResMgr *pRes )
1335cdf0e10cSrcweir {
1336cdf0e10cSrcweir 	pResMgr = pRes;
1337cdf0e10cSrcweir }
1338cdf0e10cSrcweir 
1339