Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef __FRAMEWORK_UIELEMENT_MENUBARMERGER_HXX_
21 : : #define __FRAMEWORK_UIELEMENT_MENUBARMERGER_HXX_
22 : :
23 : : #include <com/sun/star/beans/PropertyValue.hpp>
24 : :
25 : : #include <rtl/ustring.hxx>
26 : : #include <vcl/menu.hxx>
27 : :
28 : : namespace framework
29 : : {
30 : :
31 : : struct AddonMenuItem;
32 : : typedef ::std::vector< AddonMenuItem > AddonMenuContainer;
33 : :
34 [ + - ][ + - ]: 208 : struct AddonMenuItem
35 : : {
36 : : ::rtl::OUString aTitle;
37 : : ::rtl::OUString aURL;
38 : : ::rtl::OUString aTarget;
39 : : ::rtl::OUString aImageId;
40 : : ::rtl::OUString aContext;
41 : : AddonMenuContainer aSubMenu;
42 : : };
43 : :
44 : : enum RPResultInfo
45 : : {
46 : : RP_OK,
47 : : RP_POPUPMENU_NOT_FOUND,
48 : : RP_MENUITEM_NOT_FOUND,
49 : : RP_MENUITEM_INSTEAD_OF_POPUPMENU_FOUND
50 : : };
51 : :
52 : : struct ReferencePathInfo
53 : : {
54 : : Menu* pPopupMenu;
55 : : sal_uInt16 nPos;
56 : : sal_Int32 nLevel;
57 : : RPResultInfo eResult;
58 : : };
59 : :
60 : : class MenuBarMerger
61 : : {
62 : : public:
63 : : static bool IsCorrectContext( const ::rtl::OUString& aContext, const ::rtl::OUString& aModuleIdentifier );
64 : :
65 : : static void RetrieveReferencePath( const ::rtl::OUString&,
66 : : std::vector< ::rtl::OUString >& aReferencePath );
67 : : static ReferencePathInfo FindReferencePath( const std::vector< ::rtl::OUString >& aReferencePath, Menu* pMenu );
68 : : static sal_uInt16 FindMenuItem( const ::rtl::OUString& rCmd,
69 : : Menu* pMenu );
70 : : static void GetMenuEntry( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rAddonMenuEntry,
71 : : AddonMenuItem& aAddonMenu );
72 : : static void GetSubMenu( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& rSubMenuEntries,
73 : : AddonMenuContainer& rSubMenu );
74 : : static bool ProcessMergeOperation( Menu* pMenu,
75 : : sal_uInt16 nPos,
76 : : sal_uInt16& rItemId,
77 : : const ::rtl::OUString& rMergeCommand,
78 : : const ::rtl::OUString& rMergeCommandParameter,
79 : : const ::rtl::OUString& rModuleIdentifier,
80 : : const AddonMenuContainer& rAddonMenuItems );
81 : : static bool ProcessFallbackOperation( const ReferencePathInfo& aRefPathInfo,
82 : : sal_uInt16& rItemId,
83 : : const ::rtl::OUString& rMergeCommand,
84 : : const ::rtl::OUString& rMergeFallback,
85 : : const ::std::vector< ::rtl::OUString >& rReferencePath,
86 : : const ::rtl::OUString& rModuleIdentifier,
87 : : const AddonMenuContainer& rAddonMenuItems );
88 : : static bool ProcessFallbackOperation();
89 : : static bool MergeMenuItems( Menu* pMenu,
90 : : sal_uInt16 nPos,
91 : : sal_uInt16 nModIndex,
92 : : sal_uInt16& rItemId,
93 : : const ::rtl::OUString& rModuleIdentifier,
94 : : const AddonMenuContainer& rAddonMenuItems );
95 : : static bool ReplaceMenuItem( Menu* pMenu,
96 : : sal_uInt16 nPos,
97 : : sal_uInt16& rItemId,
98 : : const ::rtl::OUString& rModuleIdentifier,
99 : : const AddonMenuContainer& rAddonMenuItems );
100 : : static bool RemoveMenuItems( Menu* pMenu,
101 : : sal_uInt16 nPos,
102 : : const ::rtl::OUString& rMergeCommandParameter );
103 : : static bool CreateSubMenu( Menu* pSubMenu,
104 : : sal_uInt16& nItemId,
105 : : const ::rtl::OUString& rModuleIdentifier,
106 : : const AddonMenuContainer& rAddonSubMenu );
107 : :
108 : : private:
109 : : MenuBarMerger();
110 : : MenuBarMerger( const MenuBarMerger& );
111 : : MenuBarMerger& operator=( const MenuBarMerger& );
112 : : };
113 : :
114 : : } // namespace framework
115 : :
116 : : #endif // __FRAMEWORK_UIELEMENT_MENUBARMERGER_HXX_
117 : :
118 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|