addonmenu.cxx (6d739b60) addonmenu.cxx (707fc0d4)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 47 unchanged lines hidden (view full) ---

56using namespace ::com::sun::star::uno;
57using namespace ::com::sun::star::lang;
58using namespace ::com::sun::star::frame;
59using namespace ::com::sun::star::beans;
60
61// Please look at sfx2/inc/sfxsids.hrc the values are defined there. Due to build dependencies
62// we cannot include the header file.
63const sal_uInt16 SID_HELPMENU = (SID_SFX_START + 410);
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 47 unchanged lines hidden (view full) ---

56using namespace ::com::sun::star::uno;
57using namespace ::com::sun::star::lang;
58using namespace ::com::sun::star::frame;
59using namespace ::com::sun::star::beans;
60
61// Please look at sfx2/inc/sfxsids.hrc the values are defined there. Due to build dependencies
62// we cannot include the header file.
63const sal_uInt16 SID_HELPMENU = (SID_SFX_START + 410);
64const sal_uInt16 SID_ONLINE_REGISTRATION = (SID_SFX_START + 1537);
64const sal_uInt16 SID_HELP_SUPPORTPAGE = (SID_SFX_START + 1683);
65
66namespace framework
67{
68
69AddonMenu::AddonMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ) :
70 m_xFrame( rFrame )
71{
72}

--- 130 unchanged lines hidden (view full) ---

203 {
204 sal_uInt16 nId = FindMenuId( pMergeMenuBar, String::CreateFromAscii( ".uno:HelpMenu" ));
205 if ( nId != USHRT_MAX )
206 pHelpMenu = pMergeMenuBar->GetPopupMenu( nId );
207 }
208
209 if ( pHelpMenu )
210 {
65
66namespace framework
67{
68
69AddonMenu::AddonMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ) :
70 m_xFrame( rFrame )
71{
72}

--- 130 unchanged lines hidden (view full) ---

203 {
204 sal_uInt16 nId = FindMenuId( pMergeMenuBar, String::CreateFromAscii( ".uno:HelpMenu" ));
205 if ( nId != USHRT_MAX )
206 pHelpMenu = pMergeMenuBar->GetPopupMenu( nId );
207 }
208
209 if ( pHelpMenu )
210 {
211 static const char REFERENCECOMMAND_AFTER[] = ".uno:OnlineRegistrationDlg";
211 static const char REFERENCECOMMAND_AFTER[] = ".uno:HelpSupport";
212 static const char REFERENCECOMMAND_BEFORE[] = ".uno:About";
213
214 // Add-Ons help menu items should be inserted after the "registration" menu item
215 bool bAddAfter = true;
216 sal_uInt16 nItemCount = pHelpMenu->GetItemCount();
212 static const char REFERENCECOMMAND_BEFORE[] = ".uno:About";
213
214 // Add-Ons help menu items should be inserted after the "registration" menu item
215 bool bAddAfter = true;
216 sal_uInt16 nItemCount = pHelpMenu->GetItemCount();
217 sal_uInt16 nRegPos = pHelpMenu->GetItemPos( SID_ONLINE_REGISTRATION );
218 sal_uInt16 nInsPos = nRegPos;
217 sal_uInt16 nSupPos = pHelpMenu->GetItemPos( SID_HELP_SUPPORTPAGE );
218 sal_uInt16 nInsPos = nSupPos;
219 sal_uInt16 nInsSepAfterPos = MENU_APPEND;
220 sal_uInt16 nUniqueMenuId = ADDONMENU_ITEMID_START;
221 AddonsOptions aOptions;
222
219 sal_uInt16 nInsSepAfterPos = MENU_APPEND;
220 sal_uInt16 nUniqueMenuId = ADDONMENU_ITEMID_START;
221 AddonsOptions aOptions;
222
223 if ( nRegPos == USHRT_MAX )
223 if ( nSupPos == USHRT_MAX )
224 {
225 // try to detect the online registration dialog menu item with the command URL
226 sal_uInt16 nId = FindMenuId( pHelpMenu, String::CreateFromAscii( REFERENCECOMMAND_AFTER ));
224 {
225 // try to detect the online registration dialog menu item with the command URL
226 sal_uInt16 nId = FindMenuId( pHelpMenu, String::CreateFromAscii( REFERENCECOMMAND_AFTER ));
227 nRegPos = pHelpMenu->GetItemPos( nId );
228 nInsPos = nRegPos;
227 nSupPos = pHelpMenu->GetItemPos( nId );
228 nInsPos = nSupPos;
229 }
230
229 }
230
231 if ( nRegPos == USHRT_MAX )
231 if ( nSupPos == USHRT_MAX )
232 {
233 // second try:
234 // try to detect the about menu item with the command URL
235 sal_uInt16 nId = FindMenuId( pHelpMenu, String::CreateFromAscii( REFERENCECOMMAND_BEFORE ));
232 {
233 // second try:
234 // try to detect the about menu item with the command URL
235 sal_uInt16 nId = FindMenuId( pHelpMenu, String::CreateFromAscii( REFERENCECOMMAND_BEFORE ));
236 nRegPos = pHelpMenu->GetItemPos( nId );
237 nInsPos = nRegPos;
236 nSupPos = pHelpMenu->GetItemPos( nId );
237 nInsPos = nSupPos;
238 bAddAfter = false;
239 }
240
241 Sequence< Sequence< PropertyValue > > aAddonSubMenu;
242 const Sequence< Sequence< PropertyValue > >& rAddonHelpMenuEntries = aOptions.GetAddonsHelpMenu();
243
244 nInsPos = bAddAfter ? AddonMenuManager::GetNextPos( nInsPos ) : nInsPos;
245 if ( nInsPos < nItemCount && pHelpMenu->GetItemType( nInsPos ) != MENUITEM_SEPARATOR )

--- 5 unchanged lines hidden (view full) ---

251 if ( pHelpMenu->GetItemCount() > nItemCount )
252 {
253 if ( nInsSepAfterPos < MENU_APPEND )
254 {
255 nInsSepAfterPos += ( pHelpMenu->GetItemCount() - nItemCount );
256 if ( pHelpMenu->GetItemType( nInsSepAfterPos ) != MENUITEM_SEPARATOR )
257 pHelpMenu->InsertSeparator( nInsSepAfterPos );
258 }
238 bAddAfter = false;
239 }
240
241 Sequence< Sequence< PropertyValue > > aAddonSubMenu;
242 const Sequence< Sequence< PropertyValue > >& rAddonHelpMenuEntries = aOptions.GetAddonsHelpMenu();
243
244 nInsPos = bAddAfter ? AddonMenuManager::GetNextPos( nInsPos ) : nInsPos;
245 if ( nInsPos < nItemCount && pHelpMenu->GetItemType( nInsPos ) != MENUITEM_SEPARATOR )

--- 5 unchanged lines hidden (view full) ---

251 if ( pHelpMenu->GetItemCount() > nItemCount )
252 {
253 if ( nInsSepAfterPos < MENU_APPEND )
254 {
255 nInsSepAfterPos += ( pHelpMenu->GetItemCount() - nItemCount );
256 if ( pHelpMenu->GetItemType( nInsSepAfterPos ) != MENUITEM_SEPARATOR )
257 pHelpMenu->InsertSeparator( nInsSepAfterPos );
258 }
259 if ( nRegPos < MENU_APPEND )
260 pHelpMenu->InsertSeparator( nRegPos+1 );
259 if ( nSupPos < MENU_APPEND )
260 pHelpMenu->InsertSeparator( nSupPos+1 );
261 else
262 pHelpMenu->InsertSeparator( nItemCount );
263 }
264 }
265 }
266}
267
268// Merge the addon popup menus into the given menu bar at the provided pos.

--- 184 unchanged lines hidden ---
261 else
262 pHelpMenu->InsertSeparator( nItemCount );
263 }
264 }
265 }
266}
267
268// Merge the addon popup menus into the given menu bar at the provided pos.

--- 184 unchanged lines hidden ---