1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef __FRAMEWORK_UIELEMENT_MENUBARMERGER_HXX_ 29 #define __FRAMEWORK_UIELEMENT_MENUBARMERGER_HXX_ 30 31 #include <com/sun/star/beans/PropertyValue.hpp> 32 33 #include <rtl/ustring.hxx> 34 #include <vcl/menu.hxx> 35 36 namespace framework 37 { 38 39 struct AddonMenuItem; 40 typedef ::std::vector< AddonMenuItem > AddonMenuContainer; 41 42 struct AddonMenuItem 43 { 44 ::rtl::OUString aTitle; 45 ::rtl::OUString aURL; 46 ::rtl::OUString aTarget; 47 ::rtl::OUString aImageId; 48 ::rtl::OUString aContext; 49 AddonMenuContainer aSubMenu; 50 }; 51 52 enum RPResultInfo 53 { 54 RP_OK, 55 RP_POPUPMENU_NOT_FOUND, 56 RP_MENUITEM_NOT_FOUND, 57 RP_MENUITEM_INSTEAD_OF_POPUPMENU_FOUND 58 }; 59 60 struct ReferencePathInfo 61 { 62 Menu* pPopupMenu; 63 sal_uInt16 nPos; 64 sal_Int32 nLevel; 65 RPResultInfo eResult; 66 }; 67 68 class MenuBarMerger 69 { 70 public: 71 static bool IsCorrectContext( const ::rtl::OUString& aContext, const ::rtl::OUString& aModuleIdentifier ); 72 73 static void RetrieveReferencePath( const ::rtl::OUString&, 74 std::vector< ::rtl::OUString >& aReferencePath ); 75 static ReferencePathInfo FindReferencePath( const std::vector< ::rtl::OUString >& aReferencePath, Menu* pMenu ); 76 static sal_uInt16 FindMenuItem( const ::rtl::OUString& rCmd, 77 Menu* pMenu ); 78 static void GetMenuEntry( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rAddonMenuEntry, 79 AddonMenuItem& aAddonMenu ); 80 static void GetSubMenu( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& rSubMenuEntries, 81 AddonMenuContainer& rSubMenu ); 82 static bool ProcessMergeOperation( Menu* pMenu, 83 sal_uInt16 nPos, 84 sal_uInt16& rItemId, 85 const ::rtl::OUString& rMergeCommand, 86 const ::rtl::OUString& rMergeCommandParameter, 87 const ::rtl::OUString& rModuleIdentifier, 88 const AddonMenuContainer& rAddonMenuItems ); 89 static bool ProcessFallbackOperation( const ReferencePathInfo& aRefPathInfo, 90 sal_uInt16& rItemId, 91 const ::rtl::OUString& rMergeCommand, 92 const ::rtl::OUString& rMergeFallback, 93 const ::std::vector< ::rtl::OUString >& rReferencePath, 94 const ::rtl::OUString& rModuleIdentifier, 95 const AddonMenuContainer& rAddonMenuItems ); 96 static bool ProcessFallbackOperation(); 97 static bool MergeMenuItems( Menu* pMenu, 98 sal_uInt16 nPos, 99 sal_uInt16 nModIndex, 100 sal_uInt16& rItemId, 101 const ::rtl::OUString& rModuleIdentifier, 102 const AddonMenuContainer& rAddonMenuItems ); 103 static bool ReplaceMenuItem( Menu* pMenu, 104 sal_uInt16 nPos, 105 sal_uInt16& rItemId, 106 const ::rtl::OUString& rModuleIdentifier, 107 const AddonMenuContainer& rAddonMenuItems ); 108 static bool RemoveMenuItems( Menu* pMenu, 109 sal_uInt16 nPos, 110 const ::rtl::OUString& rMergeCommandParameter ); 111 static bool CreateSubMenu( Menu* pSubMenu, 112 sal_uInt16& nItemId, 113 const ::rtl::OUString& rModuleIdentifier, 114 const AddonMenuContainer& rAddonSubMenu ); 115 116 private: 117 MenuBarMerger(); 118 MenuBarMerger( const MenuBarMerger& ); 119 MenuBarMerger& operator=( const MenuBarMerger& ); 120 }; 121 122 } // namespace framework 123 124 #endif // __FRAMEWORK_UIELEMENT_MENUBARMERGER_HXX_ 125