24#include <com/sun/star/uno/Reference.hxx>
25#include <com/sun/star/uno/Sequence.hxx>
26#include <com/sun/star/beans/PropertyValue.hpp>
40 return AddonsOptions().HasAddonsMenu();
46 AddonsOptions aOptions;
49 const Sequence< Sequence< PropertyValue > >& rAddonMenuEntries = aOptions.GetAddonsMenu();
50 if ( rAddonMenuEntries.hasElements() )
58 if ( pAddonMenu->GetItemCount() == 0 )
97 if (
nId != USHRT_MAX )
107 AddonsOptions aOptions;
113 const Sequence< Sequence< PropertyValue > >& rAddonHelpMenuEntries = aOptions.GetAddonsHelpMenu();
115 if ( nInsPos < nItemCount && pHelpMenu->GetItemType( nInsPos ) != MenuItemType::SEPARATOR )
116 nInsSepAfterPos = nInsPos;
125 nInsSepAfterPos += ( pHelpMenu->
GetItemCount() - nItemCount );
126 if ( pHelpMenu->
GetItemType( nInsSepAfterPos ) != MenuItemType::SEPARATOR )
134void AddonMenuManager::MergeAddonPopupMenus(
const Reference< XFrame >& rFrame,
135 sal_uInt16 nMergeAtPos,
138 if ( !pMergeMenuBar )
141 AddonsOptions aAddonsOptions;
142 sal_uInt16 nInsertPos = nMergeAtPos;
148 Sequence< Sequence< PropertyValue > > aAddonSubMenu;
153 const Sequence< Sequence< PropertyValue > >& rAddonMenuEntries = aAddonsOptions.GetAddonsMenuBarPart();
154 for (
const Sequence< PropertyValue >& rEntry : rAddonMenuEntries )
162 if ( !aTitle.isEmpty() &&
164 aAddonSubMenu.hasElements() &&
167 sal_uInt16
nId = nUniqueMenuId++;
170 AddonMenuManager::BuildMenu( pAddonPopupMenu,
MENU_APPEND, nUniqueMenuId, aAddonSubMenu, rFrame, aModuleIdentifier );
172 if ( pAddonPopupMenu->GetItemCount() > 0 )
174 pMergeMenuBar->
InsertItem(
nId, aTitle, MenuItemBits::NONE, {}, nInsertPos++);
187void AddonMenuManager::BuildMenu(
PopupMenu* pCurrentMenu,
189 sal_uInt16& nUniqueMenuId,
190 const Sequence< Sequence< PropertyValue > >& aAddonMenuDefinition,
191 const Reference< XFrame >& rFrame,
192 const OUString& rModuleIdentifier )
194 Sequence< Sequence< PropertyValue > > aAddonSubMenu;
195 bool bInsertSeparator =
false;
198 sal_uInt32
nCount = aAddonMenuDefinition.getLength();
207 GetMenuEntry( aAddonMenuDefinition[
i], aTitle,
aURL, aTarget, aContext, aAddonSubMenu );
209 if ( !
IsCorrectContext( rModuleIdentifier, aContext ) || ( aTitle.isEmpty() &&
aURL.isEmpty() ))
212 if (
aURL ==
"private:separator" )
213 bInsertSeparator =
true;
217 if ( aAddonSubMenu.hasElements() )
220 AddonMenuManager::BuildMenu( pSubMenu,
MENU_APPEND, nUniqueMenuId, aAddonSubMenu, rFrame, rModuleIdentifier );
223 if ( pSubMenu->GetItemCount() == 0 )
235 bInsertSeparator =
false;
237 nInsPos = AddonMenuManager::GetNextPos( nInsPos );
240 sal_uInt16
nId = nUniqueMenuId++;
241 pCurrentMenu->
InsertItem(
nId, aTitle, MenuItemBits::NONE, {}, nInsPos);
242 nInsPos = AddonMenuManager::GetNextPos( nInsPos );
246 void* nAttributePtr = MenuAttributes::CreateAttribute(aTarget, OUString());
247 pCurrentMenu->
SetUserValue(
nId, nAttributePtr, MenuAttributes::ReleaseAttribute);
262 Sequence< Sequence< PropertyValue > >& rAddonSubMenu )
265 rAddonSubMenu = Sequence< Sequence< PropertyValue > >();
267 for (
const PropertyValue& rEntry : rAddonMenuEntry )
269 OUString aMenuEntryPropName = rEntry.Name;
271 rEntry.Value >>= rURL;
273 rEntry.Value >>= rTitle;
277 rEntry.Value >>= rAddonSubMenu;
279 rEntry.Value >>= rContext;
286 if ( rContext.empty() )
289 if ( !rModuleIdentifier.empty() )
291 return rContext.find( rModuleIdentifier ) != std::u16string_view::npos;
constexpr OUStringLiteral ADDONSMENUITEM_STRING_TARGET
constexpr OUStringLiteral ADDONSMENUITEM_STRING_URL
constexpr OUStringLiteral ADDONSMENUITEM_STRING_SUBMENU
constexpr OUStringLiteral ADDONSMENUITEM_STRING_CONTEXT
constexpr OUStringLiteral ADDONSMENUITEM_STRING_TITLE
static VclPtr< reference_type > Create(Arg &&... arg)
static sal_uInt16 FindMenuId(Menu const *pMenu, std::u16string_view aCommand)
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)