1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: addonmenu.hxx,v $
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 //_________________________________________________________________________________________________________________
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
53 class AddonMenu
: public PopupMenu
56 AddonMenu( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
);
60 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> m_xFrame
;
63 class AddonMenuManager
;
64 class AddonPopupMenu
: public PopupMenu
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
; }
76 void Initialize( const com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>& rAddonPopupMenuDefinition
);
79 AddonPopupMenu( const com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& rFrame
);
81 rtl::OUString m_aCommandURL
;
82 ::com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
> m_xFrame
;
84 friend class AddonMenuManager
;
87 class AddonMenuManager
96 static sal_Bool
HasAddonMenuElements();
97 static sal_Bool
HasAddonHelpMenuElements();
99 static sal_Bool
IsAddonMenuId( USHORT nId
) { return (( nId
>= ADDONMENU_ITEMID_START
) && ( nId
< ADDONMENU_ITEMID_END
)); }
101 // Check if the context string matches the provided xModel context
102 static sal_Bool
IsCorrectContext( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& rModel
, const rtl::OUString
& aContext
);
104 // Factory method to create different Add-On menu types
105 static PopupMenu
* CreatePopupMenuType( MenuType eMenuType
, const com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& rFrame
);
107 // Create the Add-Ons menu
108 static AddonMenu
* CreateAddonMenu( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
);
110 // Merge the Add-Ons help menu items into the given menu bar at a defined pos
111 static void MergeAddonHelpMenu( const com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& rFrame
,
112 MenuBar
* pMergeMenuBar
);
114 // Merge the addon popup menus into the given menu bar at the provided pos.
115 static void MergeAddonPopupMenus( const com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& rFrame
,
116 const com::sun::star::uno::Reference
< com::sun::star::frame::XModel
>& rModel
,
118 MenuBar
* pMergeMenuBar
);
120 // Returns the next position to insert a menu item/sub menu
121 static USHORT
GetNextPos( USHORT nPos
);
123 // Build up the menu item and sub menu into the provided pCurrentMenu. The sub menus should be of type nSubMenuType.
124 static void BuildMenu( PopupMenu
* pCurrentMenu
,
125 MenuType nSubMenuType
,
127 USHORT
& nUniqueMenuId
,
128 com::sun::star::uno::Sequence
< com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
> > aAddonMenuDefinition
,
129 const com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& rFrame
,
130 const com::sun::star::uno::Reference
< com::sun::star::frame::XModel
>& rModel
);
132 // Retrieve the menu entry property values from a sequence
133 static void GetMenuEntry( const com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>& rAddonMenuEntry
,
134 ::rtl::OUString
& rTitle
,
135 ::rtl::OUString
& rURL
,
136 ::rtl::OUString
& rTarget
,
137 ::rtl::OUString
& rImageId
,
138 ::rtl::OUString
& rContext
,
139 com::sun::star::uno::Sequence
< com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
> >& rAddonSubMenu
);
142 } // namespace framework
144 #endif // #ifndef __FRAMEWORK_CLASSES_ADDONMENU_HXX_