LibreOffice Module framework (master) 1
toolbarmerger.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <sal/config.h>
23
24#include <string_view>
25
27
28#include <com/sun/star/beans/PropertyValue.hpp>
29#include <com/sun/star/uno/XComponentContext.hpp>
30
31#include <cppuhelper/weak.hxx>
32#include <rtl/ustring.hxx>
33#include <vcl/toolbox.hxx>
34
35namespace framework
36{
37
39{
40 OUString aControlType;
41 sal_uInt16 nWidth;
42};
43
45{
46 OUString aCommandURL;
47 OUString aLabel;
48 OUString aTarget;
49 OUString aContext;
50 OUString aControlType;
51 sal_uInt16 nWidth;
52};
53
54typedef ::std::vector< AddonToolbarItem > AddonToolbarItemContainer;
55
57{
58 ToolBox::ImplToolItems::size_type nPos;
59 bool bResult;
60};
61
63{
64 public:
65 static bool IsCorrectContext( std::u16string_view aContext, std::u16string_view aModuleIdentifier );
66
67 static void ConvertSeqSeqToVector( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rSequence,
68 AddonToolbarItemContainer& rContainer );
69
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 );
77
78 static ReferenceToolbarPathInfo FindReferencePoint( const ToolBox* pToolbar, sal_uInt16 nFirstItem,
79 std::u16string_view rReferencePoint );
80
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 );
89
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 );
97
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 );
105
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 );
112
113 static void RemoveItems( ToolBox* pToolbar,
114 ToolBox::ImplToolItems::size_type nPos,
115 std::u16string_view rMergeCommandParameter );
116
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,
123 sal_uInt16 nWidth,
124 std::u16string_view rControlType );
125
126 static void CreateToolbarItem( ToolBox* pToolbox,
127 ToolBox::ImplToolItems::size_type nPos,
128 ToolBoxItemId nItemId,
129 const AddonToolbarItem& rAddonToolbarItem );
130
131 private:
132 ToolBarMerger( const ToolBarMerger& ) = delete;
134};
135
136} // namespace framework
137
138/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void CreateToolbarItem(ToolBox *pToolbox, ToolBox::ImplToolItems::size_type nPos, ToolBoxItemId nItemId, const AddonToolbarItem &rAddonToolbarItem)
static rtl::Reference<::cppu::OWeakObject > CreateController(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XFrame > &xFrame, ToolBox *pToolbar, const OUString &rCommandURL, ToolBoxItemId nId, sal_uInt16 nWidth, std::u16string_view rControlType)
Removes toolbar items from an existing toolbar.
static void MergeItems(ToolBox *pToolbar, ToolBox::ImplToolItems::size_type nPos, sal_uInt16 nModIndex, ToolBoxItemId &rItemId, CommandToInfoMap &rCommandMap, std::u16string_view rModuleIdentifier, const AddonToolbarItemContainer &rAddonToolbarItems)
Merges (adds) toolbar items into an existing toolbar.
static bool ProcessMergeOperation(ToolBox *pToolbar, ToolBox::ImplToolItems::size_type nPos, ToolBoxItemId &rItemId, CommandToInfoMap &rCommandMap, std::u16string_view rModuleIdentifier, std::u16string_view rMergeCommand, std::u16string_view rMergeCommandParameter, const AddonToolbarItemContainer &rItems)
Processes a merge operation.
static void ReplaceItem(ToolBox *pToolbar, ToolBox::ImplToolItems::size_type nPos, ToolBoxItemId &rItemId, CommandToInfoMap &rCommandMap, std::u16string_view rModuleIdentifier, const AddonToolbarItemContainer &rAddonToolbarItems)
Replaces a toolbar item with new items for an existing toolbar.
static void ConvertSeqSeqToVector(const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > &rSequence, AddonToolbarItemContainer &rContainer)
Converts a sequence, sequence of property values to a vector of structs.
ToolBarMerger(const ToolBarMerger &)=delete
ToolBarMerger & operator=(const ToolBarMerger &)=delete
static void RemoveItems(ToolBox *pToolbar, ToolBox::ImplToolItems::size_type nPos, std::u16string_view rMergeCommandParameter)
Removes toolbar items from an existing toolbar.
static void ConvertSequenceToValues(const css::uno::Sequence< css::beans::PropertyValue > &rSequence, OUString &rCommandURL, OUString &rLabel, OUString &rTarget, OUString &rContext, OUString &rControlType, sal_uInt16 &rWidth)
Converts a sequence of property values to single values.
static bool ProcessMergeFallback(ToolBox *pToolbar, ToolBoxItemId &rItemId, CommandToInfoMap &rCommandMap, std::u16string_view rModuleIdentifier, std::u16string_view rMergeCommand, std::u16string_view rMergeFallback, const AddonToolbarItemContainer &rItems)
Processes a merge fallback operation.
static ReferenceToolbarPathInfo FindReferencePoint(const ToolBox *pToolbar, sal_uInt16 nFirstItem, std::u16string_view rReferencePoint)
Tries to find the reference point provided and delivers position and result of the search process.
static bool IsCorrectContext(std::u16string_view aContext, std::u16string_view aModuleIdentifier)
Check whether a module identifier is part of a context defined by a colon separated list of module id...
FilterGroup & rTarget
sal_uInt16 nPos
::std::vector< AddonToolbarItem > AddonToolbarItemContainer
std::unordered_map< OUString, CommandInfo > CommandToInfoMap
Definition: commandinfo.hxx:41
sal_Int16 nId
ToolBox::ImplToolItems::size_type nPos
Reference< XFrame > xFrame