update dev300-m58
[ooovba.git] / framework / inc / classes / addonmenu.hxx
blob37e5e05933d95e5f0588e27662653b28483bb98a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: addonmenu.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef __FRAMEWORK_CLASSES_ADDONMENU_HXX_
31 #define __FRAMEWORK_CLASSES_ADDONMENU_HXX_
33 //_________________________________________________________________________________________________________________
34 // interface includes
35 //_________________________________________________________________________________________________________________
37 #include <com/sun/star/frame/XFrame.hpp>
38 #include <com/sun/star/beans/PropertyValue.hpp>
39 #include <com/sun/star/uno/Sequence.hxx>
41 //_________________________________________________________________________________________________________________
42 // includes of other projects
43 //_________________________________________________________________________________________________________________
45 #include <vcl/menu.hxx>
47 #define ADDONMENU_ITEMID_START 2000
48 #define ADDONMENU_ITEMID_END 3000
50 namespace framework
53 class AddonMenu : public PopupMenu
55 public:
56 AddonMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame );
57 ~AddonMenu();
59 protected:
60 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
63 class AddonMenuManager;
64 class AddonPopupMenu : public AddonMenu
66 public:
67 ~AddonPopupMenu();
69 // Check if command URL string has the unique prefix to identify addon popup menus
70 static sal_Bool IsCommandURLPrefix( const rtl::OUString& aCmdURL );
72 void SetCommandURL( const rtl::OUString& aCmdURL ) { m_aCommandURL = aCmdURL; }
73 const rtl::OUString& GetCommandURL() const { return m_aCommandURL; }
75 protected:
76 void Initialize( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rAddonPopupMenuDefinition );
78 private:
79 AddonPopupMenu( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame );
81 rtl::OUString m_aCommandURL;
83 friend class AddonMenuManager;
86 class AddonMenuManager
88 public:
89 enum MenuType
91 ADDON_MENU,
92 ADDON_POPUPMENU
95 static sal_Bool HasAddonMenuElements();
96 static sal_Bool HasAddonHelpMenuElements();
98 static sal_Bool IsAddonMenuId( USHORT nId ) { return (( nId >= ADDONMENU_ITEMID_START ) && ( nId < ADDONMENU_ITEMID_END )); }
100 // Check if the context string matches the provided xModel context
101 static sal_Bool IsCorrectContext( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rModel, const rtl::OUString& aContext );
103 // Factory method to create different Add-On menu types
104 static PopupMenu* CreatePopupMenuType( MenuType eMenuType, const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame );
106 // Create the Add-Ons menu
107 static AddonMenu* CreateAddonMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame );
109 // Merge the Add-Ons help menu items into the given menu bar at a defined pos
110 static void MergeAddonHelpMenu( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
111 MenuBar* pMergeMenuBar );
113 // Merge the addon popup menus into the given menu bar at the provided pos.
114 static void MergeAddonPopupMenus( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
115 const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rModel,
116 USHORT nMergeAtPos,
117 MenuBar* pMergeMenuBar );
119 // Returns the next position to insert a menu item/sub menu
120 static USHORT GetNextPos( USHORT nPos );
122 // Build up the menu item and sub menu into the provided pCurrentMenu. The sub menus should be of type nSubMenuType.
123 static void BuildMenu( PopupMenu* pCurrentMenu,
124 MenuType nSubMenuType,
125 USHORT nInsPos,
126 USHORT& nUniqueMenuId,
127 com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > > aAddonMenuDefinition,
128 const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
129 const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rModel );
131 // Retrieve the menu entry property values from a sequence
132 static void GetMenuEntry( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rAddonMenuEntry,
133 ::rtl::OUString& rTitle,
134 ::rtl::OUString& rURL,
135 ::rtl::OUString& rTarget,
136 ::rtl::OUString& rImageId,
137 ::rtl::OUString& rContext,
138 com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > >& rAddonSubMenu );
141 } // namespace framework
143 #endif // #ifndef __FRAMEWORK_CLASSES_ADDONMENU_HXX_