merge the formfield patch from ooo-build
[ooovba.git] / framework / inc / uielement / menubarmerger.hxx
blob1435b3db81ba24c6e0b59e0a7f2a300fbd775c98
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: menubarmerger.hxx,v $
10 * $Revision: 1.3 $
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 ************************************************************************/
31 #ifndef __FRAMEWORK_UIELEMENT_MENUBARMERGER_HXX_
32 #define __FRAMEWORK_UIELEMENT_MENUBARMERGER_HXX_
34 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <rtl/ustring.hxx>
37 #include <vcl/menu.hxx>
39 namespace framework
42 struct AddonMenuItem;
43 typedef ::std::vector< AddonMenuItem > AddonMenuContainer;
45 struct AddonMenuItem
47 ::rtl::OUString aTitle;
48 ::rtl::OUString aURL;
49 ::rtl::OUString aTarget;
50 ::rtl::OUString aImageId;
51 ::rtl::OUString aContext;
52 AddonMenuContainer aSubMenu;
55 enum RPResultInfo
57 RP_OK,
58 RP_POPUPMENU_NOT_FOUND,
59 RP_MENUITEM_NOT_FOUND,
60 RP_MENUITEM_INSTEAD_OF_POPUPMENU_FOUND
63 struct ReferencePathInfo
65 Menu* pPopupMenu;
66 sal_uInt16 nPos;
67 sal_Int32 nLevel;
68 RPResultInfo eResult;
71 class MenuBarMerger
73 public:
74 static bool IsCorrectContext( const ::rtl::OUString& aContext, const ::rtl::OUString& aModuleIdentifier );
76 static void RetrieveReferencePath( const ::rtl::OUString&,
77 std::vector< ::rtl::OUString >& aReferencePath );
78 static ReferencePathInfo FindReferencePath( const std::vector< ::rtl::OUString >& aReferencePath, Menu* pMenu );
79 static sal_uInt16 FindMenuItem( const ::rtl::OUString& rCmd,
80 Menu* pMenu );
81 static void GetMenuEntry( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rAddonMenuEntry,
82 AddonMenuItem& aAddonMenu );
83 static void GetSubMenu( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& rSubMenuEntries,
84 AddonMenuContainer& rSubMenu );
85 static bool ProcessMergeOperation( Menu* pMenu,
86 sal_uInt16 nPos,
87 sal_uInt16& rItemId,
88 const ::rtl::OUString& rMergeCommand,
89 const ::rtl::OUString& rMergeCommandParameter,
90 const ::rtl::OUString& rModuleIdentifier,
91 const AddonMenuContainer& rAddonMenuItems );
92 static bool ProcessFallbackOperation( const ReferencePathInfo& aRefPathInfo,
93 sal_uInt16& rItemId,
94 const ::rtl::OUString& rMergeCommand,
95 const ::rtl::OUString& rMergeFallback,
96 const ::std::vector< ::rtl::OUString >& rReferencePath,
97 const ::rtl::OUString& rModuleIdentifier,
98 const AddonMenuContainer& rAddonMenuItems );
99 static bool ProcessFallbackOperation();
100 static bool MergeMenuItems( Menu* pMenu,
101 sal_uInt16 nPos,
102 sal_uInt16 nModIndex,
103 sal_uInt16& rItemId,
104 const ::rtl::OUString& rModuleIdentifier,
105 const AddonMenuContainer& rAddonMenuItems );
106 static bool ReplaceMenuItem( Menu* pMenu,
107 sal_uInt16 nPos,
108 sal_uInt16& rItemId,
109 const ::rtl::OUString& rModuleIdentifier,
110 const AddonMenuContainer& rAddonMenuItems );
111 static bool RemoveMenuItems( Menu* pMenu,
112 sal_uInt16 nPos,
113 const ::rtl::OUString& rMergeCommandParameter );
114 static bool CreateSubMenu( Menu* pSubMenu,
115 sal_uInt16& nItemId,
116 const ::rtl::OUString& rModuleIdentifier,
117 const AddonMenuContainer& rAddonSubMenu );
119 private:
120 MenuBarMerger();
121 MenuBarMerger( const MenuBarMerger& );
122 MenuBarMerger& operator=( const MenuBarMerger& );
125 } // namespace framework
127 #endif // __FRAMEWORK_UIELEMENT_MENUBARMERGER_HXX_