1*f8e07b45SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f8e07b45SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f8e07b45SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f8e07b45SAndrew Rist * distributed with this work for additional information 6*f8e07b45SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f8e07b45SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f8e07b45SAndrew Rist * "License"); you may not use this file except in compliance 9*f8e07b45SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*f8e07b45SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*f8e07b45SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f8e07b45SAndrew Rist * software distributed under the License is distributed on an 15*f8e07b45SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f8e07b45SAndrew Rist * KIND, either express or implied. See the License for the 17*f8e07b45SAndrew Rist * specific language governing permissions and limitations 18*f8e07b45SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*f8e07b45SAndrew Rist *************************************************************/ 21*f8e07b45SAndrew Rist 22*f8e07b45SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef __FRAMEWORK_UIELEMENT_MENUBARMERGER_HXX_ 25cdf0e10cSrcweir #define __FRAMEWORK_UIELEMENT_MENUBARMERGER_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <rtl/ustring.hxx> 30cdf0e10cSrcweir #include <vcl/menu.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir namespace framework 33cdf0e10cSrcweir { 34cdf0e10cSrcweir 35cdf0e10cSrcweir struct AddonMenuItem; 36cdf0e10cSrcweir typedef ::std::vector< AddonMenuItem > AddonMenuContainer; 37cdf0e10cSrcweir 38cdf0e10cSrcweir struct AddonMenuItem 39cdf0e10cSrcweir { 40cdf0e10cSrcweir ::rtl::OUString aTitle; 41cdf0e10cSrcweir ::rtl::OUString aURL; 42cdf0e10cSrcweir ::rtl::OUString aTarget; 43cdf0e10cSrcweir ::rtl::OUString aImageId; 44cdf0e10cSrcweir ::rtl::OUString aContext; 45cdf0e10cSrcweir AddonMenuContainer aSubMenu; 46cdf0e10cSrcweir }; 47cdf0e10cSrcweir 48cdf0e10cSrcweir enum RPResultInfo 49cdf0e10cSrcweir { 50cdf0e10cSrcweir RP_OK, 51cdf0e10cSrcweir RP_POPUPMENU_NOT_FOUND, 52cdf0e10cSrcweir RP_MENUITEM_NOT_FOUND, 53cdf0e10cSrcweir RP_MENUITEM_INSTEAD_OF_POPUPMENU_FOUND 54cdf0e10cSrcweir }; 55cdf0e10cSrcweir 56cdf0e10cSrcweir struct ReferencePathInfo 57cdf0e10cSrcweir { 58cdf0e10cSrcweir Menu* pPopupMenu; 59cdf0e10cSrcweir sal_uInt16 nPos; 60cdf0e10cSrcweir sal_Int32 nLevel; 61cdf0e10cSrcweir RPResultInfo eResult; 62cdf0e10cSrcweir }; 63cdf0e10cSrcweir 64cdf0e10cSrcweir class MenuBarMerger 65cdf0e10cSrcweir { 66cdf0e10cSrcweir public: 67cdf0e10cSrcweir static bool IsCorrectContext( const ::rtl::OUString& aContext, const ::rtl::OUString& aModuleIdentifier ); 68cdf0e10cSrcweir 69cdf0e10cSrcweir static void RetrieveReferencePath( const ::rtl::OUString&, 70cdf0e10cSrcweir std::vector< ::rtl::OUString >& aReferencePath ); 71cdf0e10cSrcweir static ReferencePathInfo FindReferencePath( const std::vector< ::rtl::OUString >& aReferencePath, Menu* pMenu ); 72cdf0e10cSrcweir static sal_uInt16 FindMenuItem( const ::rtl::OUString& rCmd, 73cdf0e10cSrcweir Menu* pMenu ); 74cdf0e10cSrcweir static void GetMenuEntry( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rAddonMenuEntry, 75cdf0e10cSrcweir AddonMenuItem& aAddonMenu ); 76cdf0e10cSrcweir static void GetSubMenu( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& rSubMenuEntries, 77cdf0e10cSrcweir AddonMenuContainer& rSubMenu ); 78cdf0e10cSrcweir static bool ProcessMergeOperation( Menu* pMenu, 79cdf0e10cSrcweir sal_uInt16 nPos, 80cdf0e10cSrcweir sal_uInt16& rItemId, 81cdf0e10cSrcweir const ::rtl::OUString& rMergeCommand, 82cdf0e10cSrcweir const ::rtl::OUString& rMergeCommandParameter, 83cdf0e10cSrcweir const ::rtl::OUString& rModuleIdentifier, 84cdf0e10cSrcweir const AddonMenuContainer& rAddonMenuItems ); 85cdf0e10cSrcweir static bool ProcessFallbackOperation( const ReferencePathInfo& aRefPathInfo, 86cdf0e10cSrcweir sal_uInt16& rItemId, 87cdf0e10cSrcweir const ::rtl::OUString& rMergeCommand, 88cdf0e10cSrcweir const ::rtl::OUString& rMergeFallback, 89cdf0e10cSrcweir const ::std::vector< ::rtl::OUString >& rReferencePath, 90cdf0e10cSrcweir const ::rtl::OUString& rModuleIdentifier, 91cdf0e10cSrcweir const AddonMenuContainer& rAddonMenuItems ); 92cdf0e10cSrcweir static bool ProcessFallbackOperation(); 93cdf0e10cSrcweir static bool MergeMenuItems( Menu* pMenu, 94cdf0e10cSrcweir sal_uInt16 nPos, 95cdf0e10cSrcweir sal_uInt16 nModIndex, 96cdf0e10cSrcweir sal_uInt16& rItemId, 97cdf0e10cSrcweir const ::rtl::OUString& rModuleIdentifier, 98cdf0e10cSrcweir const AddonMenuContainer& rAddonMenuItems ); 99cdf0e10cSrcweir static bool ReplaceMenuItem( Menu* pMenu, 100cdf0e10cSrcweir sal_uInt16 nPos, 101cdf0e10cSrcweir sal_uInt16& rItemId, 102cdf0e10cSrcweir const ::rtl::OUString& rModuleIdentifier, 103cdf0e10cSrcweir const AddonMenuContainer& rAddonMenuItems ); 104cdf0e10cSrcweir static bool RemoveMenuItems( Menu* pMenu, 105cdf0e10cSrcweir sal_uInt16 nPos, 106cdf0e10cSrcweir const ::rtl::OUString& rMergeCommandParameter ); 107cdf0e10cSrcweir static bool CreateSubMenu( Menu* pSubMenu, 108cdf0e10cSrcweir sal_uInt16& nItemId, 109cdf0e10cSrcweir const ::rtl::OUString& rModuleIdentifier, 110cdf0e10cSrcweir const AddonMenuContainer& rAddonSubMenu ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir private: 113cdf0e10cSrcweir MenuBarMerger(); 114cdf0e10cSrcweir MenuBarMerger( const MenuBarMerger& ); 115cdf0e10cSrcweir MenuBarMerger& operator=( const MenuBarMerger& ); 116cdf0e10cSrcweir }; 117cdf0e10cSrcweir 118cdf0e10cSrcweir } // namespace framework 119cdf0e10cSrcweir 120cdf0e10cSrcweir #endif // __FRAMEWORK_UIELEMENT_MENUBARMERGER_HXX_ 121