Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef __FRAMEWORK_CLASSES_ADDONMENU_HXX_
29 : : #define __FRAMEWORK_CLASSES_ADDONMENU_HXX_
30 : :
31 : : #include <com/sun/star/frame/XFrame.hpp>
32 : : #include <com/sun/star/beans/PropertyValue.hpp>
33 : : #include <com/sun/star/uno/Sequence.hxx>
34 : :
35 : : #include <vcl/menu.hxx>
36 : : #include <framework/fwedllapi.h>
37 : :
38 : : #define ADDONMENU_ITEMID_START 2000
39 : : #define ADDONMENU_ITEMID_END 3000
40 : :
41 : : namespace framework
42 : : {
43 : :
44 : : class FWE_DLLPUBLIC AddonMenu : public PopupMenu
45 : : {
46 : : public:
47 : : AddonMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame );
48 : : ~AddonMenu();
49 : :
50 : : protected:
51 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
52 : : };
53 : :
54 : : class AddonMenuManager;
55 : :
56 : : class FWE_DLLPUBLIC AddonPopupMenu : public AddonMenu
57 : : {
58 : : public:
59 : : ~AddonPopupMenu();
60 : :
61 : : // Check if command URL string has the unique prefix to identify addon popup menus
62 : : static sal_Bool IsCommandURLPrefix( const rtl::OUString& aCmdURL );
63 : :
64 : : void SetCommandURL( const rtl::OUString& aCmdURL ) { m_aCommandURL = aCmdURL; }
65 : : const rtl::OUString& GetCommandURL() const { return m_aCommandURL; }
66 : :
67 : : protected:
68 : : void Initialize( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rAddonPopupMenuDefinition );
69 : :
70 : : private:
71 : : AddonPopupMenu( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame );
72 : :
73 : : rtl::OUString m_aCommandURL;
74 : :
75 : : friend class AddonMenuManager;
76 : : };
77 : :
78 : : class FWE_DLLPUBLIC AddonMenuManager
79 : : {
80 : : public:
81 : : enum MenuType
82 : : {
83 : : ADDON_MENU,
84 : : ADDON_POPUPMENU
85 : : };
86 : :
87 : : static sal_Bool HasAddonMenuElements();
88 : :
89 [ # # ][ # # ]: 0 : static sal_Bool IsAddonMenuId( sal_uInt16 nId ) { return (( nId >= ADDONMENU_ITEMID_START ) && ( nId < ADDONMENU_ITEMID_END )); }
90 : :
91 : : // Check if the context string matches the provided xModel context
92 : : static sal_Bool IsCorrectContext( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rModel, const rtl::OUString& aContext );
93 : :
94 : : // Factory method to create different Add-On menu types
95 : : static PopupMenu* CreatePopupMenuType( MenuType eMenuType, const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame );
96 : :
97 : : // Create the Add-Ons menu
98 : : static AddonMenu* CreateAddonMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame );
99 : :
100 : : // Merge the Add-Ons help menu items into the given menu bar at a defined pos
101 : : static void MergeAddonHelpMenu( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
102 : : MenuBar* pMergeMenuBar );
103 : :
104 : : // Merge the addon popup menus into the given menu bar at the provided pos.
105 : : static void MergeAddonPopupMenus( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
106 : : const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rModel,
107 : : sal_uInt16 nMergeAtPos,
108 : : MenuBar* pMergeMenuBar );
109 : :
110 : : // Returns the next position to insert a menu item/sub menu
111 : : static sal_uInt16 GetNextPos( sal_uInt16 nPos );
112 : :
113 : : // Build up the menu item and sub menu into the provided pCurrentMenu. The sub menus should be of type nSubMenuType.
114 : : static void BuildMenu( PopupMenu* pCurrentMenu,
115 : : MenuType nSubMenuType,
116 : : sal_uInt16 nInsPos,
117 : : sal_uInt16& nUniqueMenuId,
118 : : com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > > aAddonMenuDefinition,
119 : : const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
120 : : const com::sun::star::uno::Reference< com::sun::star::frame::XModel >& rModel );
121 : :
122 : : // Retrieve the menu entry property values from a sequence
123 : : static void GetMenuEntry( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rAddonMenuEntry,
124 : : ::rtl::OUString& rTitle,
125 : : ::rtl::OUString& rURL,
126 : : ::rtl::OUString& rTarget,
127 : : ::rtl::OUString& rImageId,
128 : : ::rtl::OUString& rContext,
129 : : com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > >& rAddonSubMenu );
130 : : };
131 : :
132 : : } // namespace framework
133 : :
134 : : #endif // #ifndef __FRAMEWORK_CLASSES_ADDONMENU_HXX_
135 : :
136 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|