build fix
[LibreOffice.git] / include / framework / addonmenu.hxx
blobc11eea13b177c587891b72571776dd60c67f6292
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_FRAMEWORK_ADDONMENU_HXX
20 #define INCLUDED_FRAMEWORK_ADDONMENU_HXX
22 #include <com/sun/star/frame/XFrame.hpp>
23 #include <com/sun/star/beans/PropertyValue.hpp>
24 #include <com/sun/star/uno/Sequence.hxx>
25 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 #include <vcl/menu.hxx>
29 #include <framework/fwedllapi.h>
31 #define ADDONMENU_ITEMID_START 2000
32 #define ADDONMENU_ITEMID_END 3000
34 namespace framework
37 class FWE_DLLPUBLIC AddonMenu : public PopupMenu
39 public:
40 AddonMenu();
41 virtual ~AddonMenu() override;
44 class AddonMenuManager;
46 class FWE_DLLPUBLIC AddonPopupMenu : public AddonMenu
48 public:
49 virtual ~AddonPopupMenu() override;
51 // Check if command URL string has the unique prefix to identify addon popup menus
52 static bool IsCommandURLPrefix( const OUString& aCmdURL );
54 void SetCommandURL( const OUString& aCmdURL ) { m_aCommandURL = aCmdURL; }
56 private:
57 AddonPopupMenu();
59 OUString m_aCommandURL;
61 friend class AddonMenuManager;
62 friend class ::VclPtr<AddonPopupMenu>;
65 class FWE_DLLPUBLIC AddonMenuManager
67 public:
68 enum MenuType
70 ADDON_MENU,
71 ADDON_POPUPMENU
74 static bool HasAddonMenuElements();
76 static bool IsAddonMenuId( sal_uInt16 nId ) { return (( nId >= ADDONMENU_ITEMID_START ) && ( nId < ADDONMENU_ITEMID_END )); }
78 // Check if the context string matches the provided xModel context
79 static bool IsCorrectContext(const OUString& rModuleIdentifier, const OUString& rContext);
81 // Factory method to create different Add-On menu types
82 static VclPtr<PopupMenu> CreatePopupMenuType( MenuType eMenuType );
84 // Create the Add-Ons menu
85 static VclPtr<AddonMenu> CreateAddonMenu( const css::uno::Reference< css::frame::XFrame >& rFrame,
86 const css::uno::Reference< css::uno::XComponentContext >& rContext );
88 // Merge the Add-Ons help menu items into the given menu bar at a defined pos
89 static void MergeAddonHelpMenu( const css::uno::Reference< css::frame::XFrame >& rFrame,
90 MenuBar* pMergeMenuBar,
91 const css::uno::Reference< css::uno::XComponentContext >& rContext );
93 // Merge the addon popup menus into the given menu bar at the provided pos.
94 static void MergeAddonPopupMenus( const css::uno::Reference< css::frame::XFrame >& rFrame,
95 sal_uInt16 nMergeAtPos,
96 MenuBar* pMergeMenuBar,
97 const css::uno::Reference< css::uno::XComponentContext >& rContext );
99 // Returns the next position to insert a menu item/sub menu
100 static sal_uInt16 GetNextPos( sal_uInt16 nPos );
102 // Build up the menu item and sub menu into the provided pCurrentMenu. The sub menus should be of type nSubMenuType.
103 static void BuildMenu( PopupMenu* pCurrentMenu,
104 MenuType nSubMenuType,
105 sal_uInt16 nInsPos,
106 sal_uInt16& nUniqueMenuId,
107 const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& aAddonMenuDefinition,
108 const css::uno::Reference< css::frame::XFrame >& rFrame,
109 const ::rtl::OUString& rModuleIdentifier );
111 // Retrieve the menu entry property values from a sequence
112 static void GetMenuEntry( const css::uno::Sequence< css::beans::PropertyValue >& rAddonMenuEntry,
113 OUString& rTitle,
114 OUString& rURL,
115 OUString& rTarget,
116 OUString& rImageId,
117 OUString& rContext,
118 css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rAddonSubMenu );
121 } // namespace framework
123 #endif // INCLUDED_FRAMEWORK_ADDONMENU_HXX
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */