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_TOOLBARMERGER_HXX_
21 : : #define __FRAMEWORK_UIELEMENT_TOOLBARMERGER_HXX_
22 : :
23 : : #include <uielement/comboboxtoolbarcontroller.hxx>
24 : : #include <uielement/imagebuttontoolbarcontroller.hxx>
25 : : #include <uielement/togglebuttontoolbarcontroller.hxx>
26 : : #include <uielement/buttontoolbarcontroller.hxx>
27 : : #include <uielement/spinfieldtoolbarcontroller.hxx>
28 : : #include <uielement/edittoolbarcontroller.hxx>
29 : : #include <uielement/dropdownboxtoolbarcontroller.hxx>
30 : : #include <uielement/commandinfo.hxx>
31 : :
32 : : #include <com/sun/star/beans/PropertyValue.hpp>
33 : :
34 : : #include <svtools/toolboxcontroller.hxx>
35 : :
36 : : #include <rtl/ustring.hxx>
37 : : #include <vcl/toolbox.hxx>
38 : :
39 : : namespace framework
40 : : {
41 : :
42 : 0 : struct AddonsParams
43 : : {
44 : : ::rtl::OUString aImageId;
45 : : ::rtl::OUString aTarget;
46 : : ::rtl::OUString aControlType;
47 : : };
48 : :
49 : 0 : struct AddonToolbarItem
50 : : {
51 : : ::rtl::OUString aCommandURL;
52 : : ::rtl::OUString aLabel;
53 : : ::rtl::OUString aImageIdentifier;
54 : : ::rtl::OUString aTarget;
55 : : ::rtl::OUString aContext;
56 : : ::rtl::OUString aControlType;
57 : : sal_uInt16 nWidth;
58 : : };
59 : :
60 : : typedef ::std::vector< AddonToolbarItem > AddonToolbarItemContainer;
61 : :
62 : : struct ReferenceToolbarPathInfo
63 : : {
64 : : ToolBox* pToolbar;
65 : : sal_uInt16 nPos;
66 : : bool bResult;
67 : : };
68 : :
69 : : class ToolBarMerger
70 : : {
71 : : public:
72 : : static bool IsCorrectContext( const ::rtl::OUString& aContext, const ::rtl::OUString& aModuleIdentifier );
73 : :
74 : : static bool ConvertSeqSeqToVector( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > rSequence,
75 : : AddonToolbarItemContainer& rContainer );
76 : :
77 : : static void ConvertSequenceToValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > rSequence,
78 : : ::rtl::OUString& rCommandURL,
79 : : ::rtl::OUString& rLabel,
80 : : ::rtl::OUString& rImageIdentifier,
81 : : ::rtl::OUString& rTarget,
82 : : ::rtl::OUString& rContext,
83 : : ::rtl::OUString& rControlType,
84 : : sal_uInt16& rWidth );
85 : :
86 : : static ReferenceToolbarPathInfo FindReferencePoint( ToolBox* pToolbar,
87 : : const ::rtl::OUString& rReferencePoint );
88 : :
89 : : static bool ProcessMergeOperation( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
90 : : ToolBox* pToolbar,
91 : : sal_uInt16 nPos,
92 : : sal_uInt16& rItemId,
93 : : CommandToInfoMap& rCommandMap,
94 : : const ::rtl::OUString& rModuleIdentifier,
95 : : const ::rtl::OUString& rMergeCommand,
96 : : const ::rtl::OUString& rMergeCommandParameter,
97 : : const AddonToolbarItemContainer& rItems );
98 : :
99 : : static bool ProcessMergeFallback( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
100 : : ToolBox* pToolbar,
101 : : sal_uInt16 nPos,
102 : : sal_uInt16& rItemId,
103 : : CommandToInfoMap& rCommandMap,
104 : : const ::rtl::OUString& rModuleIdentifier,
105 : : const ::rtl::OUString& rMergeCommand,
106 : : const ::rtl::OUString& rMergeFallback,
107 : : const AddonToolbarItemContainer& rItems );
108 : :
109 : : static bool MergeItems( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
110 : : ToolBox* pToolbar,
111 : : sal_uInt16 nPos,
112 : : sal_uInt16 nModIndex,
113 : : sal_uInt16& rItemId,
114 : : CommandToInfoMap& rCommandMap,
115 : : const ::rtl::OUString& rModuleIdentifier,
116 : : const AddonToolbarItemContainer& rAddonToolbarItems );
117 : :
118 : : static bool ReplaceItem( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
119 : : ToolBox* pToolbar,
120 : : sal_uInt16 nPos,
121 : : sal_uInt16& rItemId,
122 : : CommandToInfoMap& rCommandMap,
123 : : const ::rtl::OUString& rModuleIdentifier,
124 : : const AddonToolbarItemContainer& rAddonToolbarItems );
125 : :
126 : : static bool RemoveItems( ToolBox* pToolbar,
127 : : sal_uInt16 nPos,
128 : : const ::rtl::OUString& rMergeCommandParameter );
129 : :
130 : : static ::cppu::OWeakObject* CreateController(
131 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMGR,
132 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame,
133 : : ToolBox* pToolbar,
134 : : const ::rtl::OUString& rCommandURL,
135 : : sal_uInt16 nId,
136 : : sal_uInt16 nWidth,
137 : : const ::rtl::OUString& rControlType );
138 : :
139 : : static void CreateToolbarItem( ToolBox* pToolbox,
140 : : CommandToInfoMap& rCommandMap,
141 : : sal_uInt16 nPos,
142 : : sal_uInt16 nItemId,
143 : : const AddonToolbarItem& rAddonToolbarItem );
144 : :
145 : : private:
146 : : ToolBarMerger();
147 : : ToolBarMerger( const ToolBarMerger& );
148 : : ToolBarMerger& operator=( const ToolBarMerger& );
149 : : };
150 : :
151 : : } // namespace framework
152 : :
153 : : #endif // __FRAMEWORK_UIELEMENT_TOOLBARMERGER_HXX_
154 : :
155 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|