Update git submodules
[LibreOffice.git] / framework / inc / uielement / toolbarmerger.hxx
blobb84ca2005e3927fcb2243bc07104019f4f948760
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <sal/config.h>
24 #include <string_view>
26 #include <uielement/commandinfo.hxx>
28 #include <com/sun/star/beans/PropertyValue.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
31 #include <cppuhelper/weak.hxx>
32 #include <rtl/ustring.hxx>
33 #include <vcl/toolbox.hxx>
35 namespace framework
38 struct AddonsParams
40 OUString aControlType;
41 sal_uInt16 nWidth;
44 struct AddonToolbarItem
46 OUString aCommandURL;
47 OUString aLabel;
48 OUString aTarget;
49 OUString aContext;
50 OUString aControlType;
51 sal_uInt16 nWidth;
54 typedef ::std::vector< AddonToolbarItem > AddonToolbarItemContainer;
56 struct ReferenceToolbarPathInfo
58 ToolBox::ImplToolItems::size_type nPos;
59 bool bResult;
62 class ToolBarMerger
64 public:
65 static bool IsCorrectContext( std::u16string_view aContext, std::u16string_view aModuleIdentifier );
67 static void ConvertSeqSeqToVector( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rSequence,
68 AddonToolbarItemContainer& rContainer );
70 static void ConvertSequenceToValues( const css::uno::Sequence< css::beans::PropertyValue >& rSequence,
71 OUString& rCommandURL,
72 OUString& rLabel,
73 OUString& rTarget,
74 OUString& rContext,
75 OUString& rControlType,
76 sal_uInt16& rWidth );
78 static ReferenceToolbarPathInfo FindReferencePoint( const ToolBox* pToolbar, sal_uInt16 nFirstItem,
79 std::u16string_view rReferencePoint );
81 static bool ProcessMergeOperation( ToolBox* pToolbar,
82 ToolBox::ImplToolItems::size_type nPos,
83 ToolBoxItemId& rItemId,
84 CommandToInfoMap& rCommandMap,
85 std::u16string_view rModuleIdentifier,
86 std::u16string_view rMergeCommand,
87 std::u16string_view rMergeCommandParameter,
88 const AddonToolbarItemContainer& rItems );
90 static bool ProcessMergeFallback( ToolBox* pToolbar,
91 ToolBoxItemId& rItemId,
92 CommandToInfoMap& rCommandMap,
93 std::u16string_view rModuleIdentifier,
94 std::u16string_view rMergeCommand,
95 std::u16string_view rMergeFallback,
96 const AddonToolbarItemContainer& rItems );
98 static void MergeItems( ToolBox* pToolbar,
99 ToolBox::ImplToolItems::size_type nPos,
100 sal_uInt16 nModIndex,
101 ToolBoxItemId& rItemId,
102 CommandToInfoMap& rCommandMap,
103 std::u16string_view rModuleIdentifier,
104 const AddonToolbarItemContainer& rAddonToolbarItems );
106 static void ReplaceItem( ToolBox* pToolbar,
107 ToolBox::ImplToolItems::size_type nPos,
108 ToolBoxItemId& rItemId,
109 CommandToInfoMap& rCommandMap,
110 std::u16string_view rModuleIdentifier,
111 const AddonToolbarItemContainer& rAddonToolbarItems );
113 static void RemoveItems( ToolBox* pToolbar,
114 ToolBox::ImplToolItems::size_type nPos,
115 std::u16string_view rMergeCommandParameter );
117 static rtl::Reference<::cppu::OWeakObject> CreateController(
118 const css::uno::Reference< css::uno::XComponentContext > & rxContext,
119 const css::uno::Reference< css::frame::XFrame > & xFrame,
120 ToolBox* pToolbar,
121 const OUString& rCommandURL,
122 ToolBoxItemId nId,
123 sal_uInt16 nWidth,
124 std::u16string_view rControlType );
126 static void CreateToolbarItem( ToolBox* pToolbox,
127 ToolBox::ImplToolItems::size_type nPos,
128 ToolBoxItemId nItemId,
129 const AddonToolbarItem& rAddonToolbarItem );
131 private:
132 ToolBarMerger( const ToolBarMerger& ) = delete;
133 ToolBarMerger& operator=( const ToolBarMerger& ) = delete;
136 } // namespace framework
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */