1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_framework.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <uielement/toolbarmerger.hxx>
32*cdf0e10cSrcweir #include <uielement/generictoolbarcontroller.hxx>
33*cdf0e10cSrcweir #include <framework/imageproducer.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <svtools/miscopt.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir namespace framework
38*cdf0e10cSrcweir {
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir static const char MERGE_TOOLBAR_URL[]              = "URL";
41*cdf0e10cSrcweir static const sal_uInt32 MERGE_TOOLBAR_URL_LEN      = 3;
42*cdf0e10cSrcweir static const char MERGE_TOOLBAR_TITLE[]            = "Title";
43*cdf0e10cSrcweir static const sal_uInt32 MERGE_TOOLBAR_TITLE_LEN    = 5;
44*cdf0e10cSrcweir static const char MERGE_TOOLBAR_IMAGEID[]          = "ImageIdentifier";
45*cdf0e10cSrcweir static const sal_uInt32 MERGE_TOOLBAR_IMAGEID_LEN  = 15;
46*cdf0e10cSrcweir static const char MERGE_TOOLBAR_CONTEXT[]          = "Context";
47*cdf0e10cSrcweir static const sal_uInt32 MERGE_TOOLBAR_CONTEXT_LEN  = 7;
48*cdf0e10cSrcweir static const char MERGE_TOOLBAR_TARGET[]           = "Target";
49*cdf0e10cSrcweir static const sal_uInt32 MERGE_TOOLBAR_TARGET_LEN   = 6;
50*cdf0e10cSrcweir static const char MERGE_TOOLBAR_CONTROLTYPE[]      = "ControlType";
51*cdf0e10cSrcweir static const char MERGE_TOOLBAR_CONTROLTYPE_LEN    = 11;
52*cdf0e10cSrcweir static const char MERGE_TOOLBAR_WIDTH[]            = "Width";
53*cdf0e10cSrcweir static const char MERGE_TOOLBAR_WIDTH_LEN          = 5;
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir static const char MERGECOMMAND_ADDAFTER[]          = "AddAfter";
56*cdf0e10cSrcweir static const sal_uInt32 MERGECOMMAND_ADDAFTER_LEN  = 8;
57*cdf0e10cSrcweir static const char MERGECOMMAND_ADDBEFORE[]         = "AddBefore";
58*cdf0e10cSrcweir static const sal_uInt32 MERGECOMMAND_ADDBEFORE_LEN = 9;
59*cdf0e10cSrcweir static const char MERGECOMMAND_REPLACE[]           = "Replace";
60*cdf0e10cSrcweir static const sal_uInt32 MERGECOMMAND_REPLACE_LEN   = 7;
61*cdf0e10cSrcweir static const char MERGECOMMAND_REMOVE[]            = "Remove";
62*cdf0e10cSrcweir static const sal_uInt32 MERGECOMMAND_REMOVE_LEN    = 6;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir static const char MERGEFALLBACK_ADDLAST[]          = "AddLast";
65*cdf0e10cSrcweir static const char MERGEFALLBACK_ADDLAST_LEN        = 7;
66*cdf0e10cSrcweir static const char MERGEFALLBACK_ADDFIRST[]         = "AddFirst";
67*cdf0e10cSrcweir static const char MERGEFALLBACK_ADDFIRST_LEN       = 8;
68*cdf0e10cSrcweir static const char MERGEFALLBACK_IGNORE[]           = "Ignore";
69*cdf0e10cSrcweir static const char MERGEFALLBACK_IGNORE_LEN         = 6;
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir static const char TOOLBARCONTROLLER_BUTTON[]              = "Button";
72*cdf0e10cSrcweir static const sal_uInt32 TOOLBARCONTROLLER_BUTTON_LEN      = 6;
73*cdf0e10cSrcweir static const char TOOLBARCONTROLLER_COMBOBOX[]            = "Combobox";
74*cdf0e10cSrcweir static const sal_uInt32 TOOLBARCONTROLLER_COMBOBOX_LEN    = 8;
75*cdf0e10cSrcweir static const char TOOLBARCONTROLLER_EDIT[]                = "Editfield";
76*cdf0e10cSrcweir static const sal_uInt32 TOOLBARCONTROLLER_EDIT_LEN        = 9;
77*cdf0e10cSrcweir static const char TOOLBARCONTROLLER_SPINFIELD[]           = "Spinfield";
78*cdf0e10cSrcweir static const sal_uInt32 TOOLBARCONTROLLER_SPINFIELD_LEN   = 9;
79*cdf0e10cSrcweir static const char TOOLBARCONTROLLER_IMGBUTTON[]           = "ImageButton";
80*cdf0e10cSrcweir static const sal_uInt32 TOOLBARCONTROLLER_IMGBUTTON_LEN   = 11;
81*cdf0e10cSrcweir static const char TOOLBARCONTROLLER_DROPDOWNBOX[]         = "Dropdownbox";
82*cdf0e10cSrcweir static const sal_uInt32 TOOLBARCONTROLLER_DROPDOWNBOX_LEN = 11;
83*cdf0e10cSrcweir static const char TOOLBARCONTROLLER_DROPDOWNBTN[]         = "DropdownButton";
84*cdf0e10cSrcweir static const sal_uInt32 TOOLBARCONTROLLER_DROPDOWNBTN_LEN = 14;
85*cdf0e10cSrcweir static const char TOOLBARCONTROLLER_TOGGLEDDBTN[]         = "ToggleDropdownButton";
86*cdf0e10cSrcweir static const sal_uInt32 TOOLBARCONTROLLER_TOGGLEDDBTN_LEN = 20;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir static const char   TOOLBOXITEM_SEPARATOR_STR[]   = "private:separator";
89*cdf0e10cSrcweir static const sal_uInt16 TOOLBOXITEM_SEPARATOR_STR_LEN = sizeof( TOOLBOXITEM_SEPARATOR_STR )-1;
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir using namespace ::com::sun::star;
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir /**
94*cdf0e10cSrcweir  Check whether a module identifier is part of a context
95*cdf0e10cSrcweir  defined by a colon separated list of module identifier.
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir  @param
98*cdf0e10cSrcweir      rContext
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir      Describes a context string list where all contexts
101*cdf0e10cSrcweir      are delimited by a colon. For more information about
102*cdf0e10cSrcweir      the module identifier used as context strings see the
103*cdf0e10cSrcweir      IDL description of com::sun::star::frame::XModuleManager
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir  @param
106*cdf0e10cSrcweir      rModuleIdentifier
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir      A string describing a module identifier. See IDL
109*cdf0e10cSrcweir      description of com::sun::star::frame::XModuleManager.
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir  @result
112*cdf0e10cSrcweir      The result is true if the rContext is an empty string
113*cdf0e10cSrcweir      or rModuleIdentifier is part of the context string.
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir */
116*cdf0e10cSrcweir bool ToolBarMerger::IsCorrectContext(
117*cdf0e10cSrcweir     const ::rtl::OUString& rContext,
118*cdf0e10cSrcweir     const ::rtl::OUString& rModuleIdentifier )
119*cdf0e10cSrcweir {
120*cdf0e10cSrcweir     return (( rContext.getLength() == 0 ) || ( rContext.indexOf( rModuleIdentifier ) >= 0 ));
121*cdf0e10cSrcweir }
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir /**
124*cdf0e10cSrcweir  Converts a sequence, sequence of property values to
125*cdf0e10cSrcweir  a vector of structs.
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir  @param
128*cdf0e10cSrcweir      rSequence
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir      Provides a sequence, sequence of property values.
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir  @param
133*cdf0e10cSrcweir      rContainer
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir      A vector of AddonToolbarItems which will hold the
136*cdf0e10cSrcweir      conversion from the rSequence argument.
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir  @result
139*cdf0e10cSrcweir      The result is true if the sequence, sequence of property
140*cdf0e10cSrcweir      values could be converted to a vector of structs.
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir */
143*cdf0e10cSrcweir bool ToolBarMerger::ConvertSeqSeqToVector(
144*cdf0e10cSrcweir     const uno::Sequence< uno::Sequence< beans::PropertyValue > > rSequence,
145*cdf0e10cSrcweir     AddonToolbarItemContainer& rContainer )
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir     sal_Int32 nLen( rSequence.getLength() );
148*cdf0e10cSrcweir     for ( sal_Int32 i = 0; i < nLen; i++ )
149*cdf0e10cSrcweir     {
150*cdf0e10cSrcweir         AddonToolbarItem aAddonToolbarItem;
151*cdf0e10cSrcweir         ConvertSequenceToValues( rSequence[i],
152*cdf0e10cSrcweir                                  aAddonToolbarItem.aCommandURL,
153*cdf0e10cSrcweir                                  aAddonToolbarItem.aLabel,
154*cdf0e10cSrcweir                                  aAddonToolbarItem.aImageIdentifier,
155*cdf0e10cSrcweir                                  aAddonToolbarItem.aTarget,
156*cdf0e10cSrcweir                                  aAddonToolbarItem.aContext,
157*cdf0e10cSrcweir                                  aAddonToolbarItem.aControlType,
158*cdf0e10cSrcweir                                  aAddonToolbarItem.nWidth );
159*cdf0e10cSrcweir         rContainer.push_back( aAddonToolbarItem );
160*cdf0e10cSrcweir     }
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir     return true;
163*cdf0e10cSrcweir }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir /**
166*cdf0e10cSrcweir  Converts a sequence of property values to single
167*cdf0e10cSrcweir  values.
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir  @param
170*cdf0e10cSrcweir      rSequence
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir      Provides a sequence of property values.
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir  @param
175*cdf0e10cSrcweir      rCommandURL
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir      Contains the value of the property with
178*cdf0e10cSrcweir      Name="CommandURL".
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir  @param
181*cdf0e10cSrcweir      rLabel
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir      Contains the value of the property with
184*cdf0e10cSrcweir      Name="Title"
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir  @param
187*cdf0e10cSrcweir      rImageIdentifier
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir      Contains the value of the property with
190*cdf0e10cSrcweir      Name="ImageIdentifier"
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir  @param
193*cdf0e10cSrcweir      rTarget
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir      Contains the value of the property with
196*cdf0e10cSrcweir      Name="Target"
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir  @param
199*cdf0e10cSrcweir      rContext
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir      Contains the value of the property with
202*cdf0e10cSrcweir      Name="Context"
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir  @param
205*cdf0e10cSrcweir      rControlType
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir      Contains the value of the property with
208*cdf0e10cSrcweir      Name="ControlType"
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir  @result
211*cdf0e10cSrcweir      All possible mapping between sequence of property
212*cdf0e10cSrcweir      values and the single values are done.
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir */
215*cdf0e10cSrcweir void ToolBarMerger::ConvertSequenceToValues(
216*cdf0e10cSrcweir     const uno::Sequence< beans::PropertyValue > rSequence,
217*cdf0e10cSrcweir     ::rtl::OUString& rCommandURL,
218*cdf0e10cSrcweir     ::rtl::OUString& rLabel,
219*cdf0e10cSrcweir     ::rtl::OUString& rImageIdentifier,
220*cdf0e10cSrcweir     ::rtl::OUString& rTarget,
221*cdf0e10cSrcweir     ::rtl::OUString& rContext,
222*cdf0e10cSrcweir     ::rtl::OUString& rControlType,
223*cdf0e10cSrcweir     sal_uInt16&      rWidth )
224*cdf0e10cSrcweir {
225*cdf0e10cSrcweir     for ( sal_Int32 i = 0; i < rSequence.getLength(); i++ )
226*cdf0e10cSrcweir     {
227*cdf0e10cSrcweir         if ( rSequence[i].Name.equalsAsciiL( MERGE_TOOLBAR_URL, MERGE_TOOLBAR_URL_LEN ))
228*cdf0e10cSrcweir             rSequence[i].Value >>= rCommandURL;
229*cdf0e10cSrcweir         else if ( rSequence[i].Name.equalsAsciiL( MERGE_TOOLBAR_TITLE, MERGE_TOOLBAR_TITLE_LEN ))
230*cdf0e10cSrcweir             rSequence[i].Value >>= rLabel;
231*cdf0e10cSrcweir         else if ( rSequence[i].Name.equalsAsciiL( MERGE_TOOLBAR_IMAGEID, MERGE_TOOLBAR_IMAGEID_LEN ))
232*cdf0e10cSrcweir             rSequence[i].Value >>= rImageIdentifier;
233*cdf0e10cSrcweir         else if ( rSequence[i].Name.equalsAsciiL( MERGE_TOOLBAR_CONTEXT, MERGE_TOOLBAR_CONTEXT_LEN ))
234*cdf0e10cSrcweir             rSequence[i].Value >>= rContext;
235*cdf0e10cSrcweir         else if ( rSequence[i].Name.equalsAsciiL( MERGE_TOOLBAR_TARGET, MERGE_TOOLBAR_TARGET_LEN ))
236*cdf0e10cSrcweir             rSequence[i].Value >>= rTarget;
237*cdf0e10cSrcweir         else if ( rSequence[i].Name.equalsAsciiL( MERGE_TOOLBAR_CONTROLTYPE, MERGE_TOOLBAR_CONTROLTYPE_LEN ))
238*cdf0e10cSrcweir             rSequence[i].Value >>= rControlType;
239*cdf0e10cSrcweir         else if ( rSequence[i].Name.equalsAsciiL( MERGE_TOOLBAR_WIDTH, MERGE_TOOLBAR_WIDTH_LEN ))
240*cdf0e10cSrcweir         {
241*cdf0e10cSrcweir             sal_Int32 aValue = 0;
242*cdf0e10cSrcweir             rSequence[i].Value >>= aValue;
243*cdf0e10cSrcweir             rWidth = sal_uInt16( aValue );
244*cdf0e10cSrcweir         }
245*cdf0e10cSrcweir     }
246*cdf0e10cSrcweir }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir /**
249*cdf0e10cSrcweir  Tries to find the reference point provided and delivers
250*cdf0e10cSrcweir  position and result of the search process.
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir  @param
253*cdf0e10cSrcweir      pToolbar
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir      Must be a valid pointer to a toolbar with items which
256*cdf0e10cSrcweir      should be searched.
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir  @param
259*cdf0e10cSrcweir      rReferencePoint
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir      A command URL which should be the reference point for
262*cdf0e10cSrcweir      the coming merge operation.
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir  @result
265*cdf0e10cSrcweir      Provides information about the search result, the
266*cdf0e10cSrcweir      position of the reference point and the toolbar used.
267*cdf0e10cSrcweir */
268*cdf0e10cSrcweir ReferenceToolbarPathInfo ToolBarMerger::FindReferencePoint(
269*cdf0e10cSrcweir     ToolBox*               pToolbar,
270*cdf0e10cSrcweir     const ::rtl::OUString& rReferencePoint )
271*cdf0e10cSrcweir {
272*cdf0e10cSrcweir     ReferenceToolbarPathInfo aResult;
273*cdf0e10cSrcweir     aResult.bResult  = false;
274*cdf0e10cSrcweir     aResult.pToolbar = pToolbar;
275*cdf0e10cSrcweir     aResult.nPos     = TOOLBOX_ITEM_NOTFOUND;
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir     const sal_uInt16 nSize( pToolbar->GetItemCount() );
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < nSize; i++ )
280*cdf0e10cSrcweir     {
281*cdf0e10cSrcweir         const sal_uInt16 nItemId = pToolbar->GetItemId( i );
282*cdf0e10cSrcweir         if ( nItemId > 0 )
283*cdf0e10cSrcweir         {
284*cdf0e10cSrcweir             const ::rtl::OUString rCmd = pToolbar->GetItemCommand( nItemId );
285*cdf0e10cSrcweir             if ( rCmd == rReferencePoint )
286*cdf0e10cSrcweir             {
287*cdf0e10cSrcweir                 aResult.bResult = true;
288*cdf0e10cSrcweir                 aResult.nPos    = i;
289*cdf0e10cSrcweir                 return aResult;
290*cdf0e10cSrcweir             }
291*cdf0e10cSrcweir         }
292*cdf0e10cSrcweir     }
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir     return aResult;
295*cdf0e10cSrcweir }
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir /**
298*cdf0e10cSrcweir  Processes a merge operation.
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir  @param
301*cdf0e10cSrcweir      xFrame
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir      Must be a valid reference to a frame.
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir  @param
306*cdf0e10cSrcweir      pToolbar
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir      A valid pointer to the toolbar where the merge
309*cdf0e10cSrcweir      operation is applied to.
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir  @param
312*cdf0e10cSrcweir      nPos
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir      The reference position of the toolbar item for
315*cdf0e10cSrcweir      the merge operation. Value must be between
316*cdf0e10cSrcweir      0 and number of toolbar items - 1.
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir  @param
319*cdf0e10cSrcweir      rItemId
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir      A unique item ID.
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir  @param
324*cdf0e10cSrcweir      rModuleIdentifier
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir      The current application module context.
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir  @param
329*cdf0e10cSrcweir      rMergeCommand
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir      A merge command.
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir  @param
334*cdf0e10cSrcweir      rMergeCommandParameter.
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir      An optional argument for the merge command.
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir  @param
339*cdf0e10cSrcweir      rItems
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir      Toolbar items which are associated to the merge
342*cdf0e10cSrcweir      command.
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir  @result
345*cdf0e10cSrcweir      Returns true for a successful operation otherwise
346*cdf0e10cSrcweir      false.
347*cdf0e10cSrcweir */
348*cdf0e10cSrcweir bool ToolBarMerger::ProcessMergeOperation(
349*cdf0e10cSrcweir     const uno::Reference< frame::XFrame >& xFrame,
350*cdf0e10cSrcweir     ToolBox*                               pToolbar,
351*cdf0e10cSrcweir     sal_uInt16                             nPos,
352*cdf0e10cSrcweir     sal_uInt16&                            rItemId,
353*cdf0e10cSrcweir     CommandToInfoMap&                      rCommandMap,
354*cdf0e10cSrcweir     const ::rtl::OUString&                 rModuleIdentifier,
355*cdf0e10cSrcweir     const ::rtl::OUString&                 rMergeCommand,
356*cdf0e10cSrcweir     const ::rtl::OUString&                 rMergeCommandParameter,
357*cdf0e10cSrcweir     const AddonToolbarItemContainer&       rItems )
358*cdf0e10cSrcweir {
359*cdf0e10cSrcweir     if ( rMergeCommand.equalsAsciiL( MERGECOMMAND_ADDAFTER, MERGECOMMAND_ADDAFTER_LEN ))
360*cdf0e10cSrcweir         return MergeItems( xFrame, pToolbar, nPos, 1, rItemId, rCommandMap, rModuleIdentifier, rItems );
361*cdf0e10cSrcweir     else if ( rMergeCommand.equalsAsciiL( MERGECOMMAND_ADDBEFORE, MERGECOMMAND_ADDBEFORE_LEN ))
362*cdf0e10cSrcweir         return MergeItems( xFrame, pToolbar, nPos, 0, rItemId, rCommandMap, rModuleIdentifier, rItems );
363*cdf0e10cSrcweir     else if ( rMergeCommand.equalsAsciiL( MERGECOMMAND_REPLACE, MERGECOMMAND_REPLACE_LEN ))
364*cdf0e10cSrcweir         return ReplaceItem( xFrame, pToolbar, nPos, rItemId, rCommandMap, rModuleIdentifier, rItems );
365*cdf0e10cSrcweir     else if ( rMergeCommand.equalsAsciiL( MERGECOMMAND_REMOVE, MERGECOMMAND_REMOVE_LEN ))
366*cdf0e10cSrcweir         return RemoveItems( pToolbar, nPos, rMergeCommandParameter );
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir     return false;
369*cdf0e10cSrcweir }
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir /**
372*cdf0e10cSrcweir  Processes a merge fallback operation.
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir  @param
375*cdf0e10cSrcweir      xFrame
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir      Must be a valid reference to a frame.
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir  @param
380*cdf0e10cSrcweir      pToolbar
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir      A valid pointer to the toolbar where the merge
383*cdf0e10cSrcweir      fall back operation is applied to.
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir  @param
386*cdf0e10cSrcweir      nPos
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir      The reference position of the toolbar item for
389*cdf0e10cSrcweir      the merge operation. Value must be between
390*cdf0e10cSrcweir      0 and number of toolbar items - 1.
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir  @param
393*cdf0e10cSrcweir      rItemId
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir      A unique item ID.
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir  @param
398*cdf0e10cSrcweir      rModuleIdentifier
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir      The current application module context.
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir  @param
403*cdf0e10cSrcweir      rMergeCommand
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir      A merge command.
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir  @param
408*cdf0e10cSrcweir      rItems
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir      Toolbar items which are associated to the merge
411*cdf0e10cSrcweir      command.
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir  @result
414*cdf0e10cSrcweir      Returns true for a successful operation otherwise
415*cdf0e10cSrcweir      false.
416*cdf0e10cSrcweir */
417*cdf0e10cSrcweir bool ToolBarMerger::ProcessMergeFallback(
418*cdf0e10cSrcweir     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
419*cdf0e10cSrcweir     ToolBox*                         pToolbar,
420*cdf0e10cSrcweir     sal_uInt16                       /*nPos*/,
421*cdf0e10cSrcweir     sal_uInt16&                      rItemId,
422*cdf0e10cSrcweir     CommandToInfoMap&                rCommandMap,
423*cdf0e10cSrcweir     const ::rtl::OUString&           rModuleIdentifier,
424*cdf0e10cSrcweir     const ::rtl::OUString&           rMergeCommand,
425*cdf0e10cSrcweir     const ::rtl::OUString&           rMergeFallback,
426*cdf0e10cSrcweir     const AddonToolbarItemContainer& rItems )
427*cdf0e10cSrcweir {
428*cdf0e10cSrcweir     if (( rMergeFallback.equalsAsciiL( MERGEFALLBACK_IGNORE, MERGEFALLBACK_IGNORE_LEN )) ||
429*cdf0e10cSrcweir         ( rMergeCommand.equalsAsciiL(  MERGECOMMAND_REPLACE, MERGECOMMAND_REPLACE_LEN )) ||
430*cdf0e10cSrcweir         ( rMergeCommand.equalsAsciiL(  MERGECOMMAND_REMOVE, MERGECOMMAND_REMOVE_LEN   )) )
431*cdf0e10cSrcweir     {
432*cdf0e10cSrcweir         return true;
433*cdf0e10cSrcweir     }
434*cdf0e10cSrcweir     else if (( rMergeCommand.equalsAsciiL( MERGECOMMAND_ADDBEFORE, MERGECOMMAND_ADDBEFORE_LEN )) ||
435*cdf0e10cSrcweir              ( rMergeCommand.equalsAsciiL( MERGECOMMAND_ADDAFTER, MERGECOMMAND_ADDAFTER_LEN   )) )
436*cdf0e10cSrcweir     {
437*cdf0e10cSrcweir         if ( rMergeFallback.equalsAsciiL( MERGEFALLBACK_ADDFIRST, MERGEFALLBACK_ADDFIRST_LEN ))
438*cdf0e10cSrcweir             return MergeItems( xFrame, pToolbar, 0, 0, rItemId, rCommandMap, rModuleIdentifier, rItems );
439*cdf0e10cSrcweir         else if ( rMergeFallback.equalsAsciiL( MERGEFALLBACK_ADDLAST, MERGEFALLBACK_ADDLAST_LEN ))
440*cdf0e10cSrcweir             return MergeItems( xFrame, pToolbar, TOOLBOX_APPEND, 0, rItemId, rCommandMap, rModuleIdentifier, rItems );
441*cdf0e10cSrcweir     }
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir     return false;
444*cdf0e10cSrcweir }
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir /**
447*cdf0e10cSrcweir  Merges (adds) toolbar items into an existing toolbar.
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir  @param
450*cdf0e10cSrcweir      xFrame
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir      Must be a valid reference to a frame.
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir  @param
455*cdf0e10cSrcweir      pToolbar
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir      A valid pointer to the toolbar where the merge
458*cdf0e10cSrcweir      fall back operation is applied to.
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir  @param
461*cdf0e10cSrcweir      nPos
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir      The reference position of the toolbar item for
464*cdf0e10cSrcweir      the merge operation. Value must be between
465*cdf0e10cSrcweir      0 and number of toolbar items - 1.
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir  @param
468*cdf0e10cSrcweir      rItemId
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir      A unique item ID.
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir  @param
473*cdf0e10cSrcweir      rModuleIdentifier
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir      The current application module context.
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir  @param
478*cdf0e10cSrcweir      rItems
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir      Toolbar items which are associated to the merge
481*cdf0e10cSrcweir      command.
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir  @result
484*cdf0e10cSrcweir      Returns true for a successful operation otherwise
485*cdf0e10cSrcweir      false.
486*cdf0e10cSrcweir */
487*cdf0e10cSrcweir bool ToolBarMerger::MergeItems(
488*cdf0e10cSrcweir     const uno::Reference< frame::XFrame >& rFrame,
489*cdf0e10cSrcweir     ToolBox*                               pToolbar,
490*cdf0e10cSrcweir     sal_uInt16                             nPos,
491*cdf0e10cSrcweir     sal_uInt16                             nModIndex,
492*cdf0e10cSrcweir     sal_uInt16&                            rItemId,
493*cdf0e10cSrcweir     CommandToInfoMap&                      rCommandMap,
494*cdf0e10cSrcweir     const ::rtl::OUString&                 rModuleIdentifier,
495*cdf0e10cSrcweir     const AddonToolbarItemContainer&       rAddonToolbarItems )
496*cdf0e10cSrcweir {
497*cdf0e10cSrcweir     const sal_Int32 nSize( rAddonToolbarItems.size() );
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir     uno::Reference< frame::XFrame > xFrame( rFrame );
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir     sal_uInt16 nIndex( 0 );
502*cdf0e10cSrcweir     for ( sal_Int32 i = 0; i < nSize; i++ )
503*cdf0e10cSrcweir     {
504*cdf0e10cSrcweir         const AddonToolbarItem& rItem = rAddonToolbarItems[i];
505*cdf0e10cSrcweir         if ( IsCorrectContext( rItem.aContext, rModuleIdentifier ))
506*cdf0e10cSrcweir         {
507*cdf0e10cSrcweir             sal_Int32 nInsPos = nPos+nModIndex+i;
508*cdf0e10cSrcweir             if ( nInsPos > sal_Int32( pToolbar->GetItemCount() ))
509*cdf0e10cSrcweir                 nInsPos = TOOLBOX_APPEND;
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir             if ( rItem.aCommandURL.equalsAsciiL( TOOLBOXITEM_SEPARATOR_STR, TOOLBOXITEM_SEPARATOR_STR_LEN ))
512*cdf0e10cSrcweir                 pToolbar->InsertSeparator( sal_uInt16( nInsPos ));
513*cdf0e10cSrcweir             else
514*cdf0e10cSrcweir             {
515*cdf0e10cSrcweir                 CommandToInfoMap::iterator pIter = rCommandMap.find( rItem.aCommandURL );
516*cdf0e10cSrcweir                 if ( pIter == rCommandMap.end())
517*cdf0e10cSrcweir                 {
518*cdf0e10cSrcweir                     CommandInfo aCmdInfo;
519*cdf0e10cSrcweir                     aCmdInfo.nId = rItemId;
520*cdf0e10cSrcweir                     rCommandMap.insert( CommandToInfoMap::value_type( rItem.aCommandURL, aCmdInfo ));
521*cdf0e10cSrcweir                 }
522*cdf0e10cSrcweir                 else
523*cdf0e10cSrcweir                 {
524*cdf0e10cSrcweir                     pIter->second.aIds.push_back( rItemId );
525*cdf0e10cSrcweir                 }
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir                 ToolBarMerger::CreateToolbarItem( pToolbar, rCommandMap, sal_uInt16( nInsPos ), rItemId, rItem );
528*cdf0e10cSrcweir             }
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir             ++nIndex;
531*cdf0e10cSrcweir             ++rItemId;
532*cdf0e10cSrcweir         }
533*cdf0e10cSrcweir     }
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir     return true;
536*cdf0e10cSrcweir }
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir /**
539*cdf0e10cSrcweir  Replaces a toolbar item with new items for an
540*cdf0e10cSrcweir  existing toolbar.
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir  @param
543*cdf0e10cSrcweir      xFrame
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir      Must be a valid reference to a frame.
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir  @param
548*cdf0e10cSrcweir      pToolbar
549*cdf0e10cSrcweir 
550*cdf0e10cSrcweir      A valid pointer to the toolbar where the merge
551*cdf0e10cSrcweir      fall back operation is applied to.
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir  @param
554*cdf0e10cSrcweir      nPos
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir      The reference position of the toolbar item for
557*cdf0e10cSrcweir      the merge operation. Value must be between
558*cdf0e10cSrcweir      0 and number of toolbar items - 1.
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir  @param
561*cdf0e10cSrcweir      rItemId
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir      A unique item ID.
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir  @param
566*cdf0e10cSrcweir      rModuleIdentifier
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir      The current application module context.
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir  @param
571*cdf0e10cSrcweir      rItems
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir      Toolbar items which are associated to the merge
574*cdf0e10cSrcweir      command.
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir  @result
577*cdf0e10cSrcweir      Returns true for a successful operation otherwise
578*cdf0e10cSrcweir      false.
579*cdf0e10cSrcweir */
580*cdf0e10cSrcweir bool ToolBarMerger::ReplaceItem(
581*cdf0e10cSrcweir     const uno::Reference< frame::XFrame >& xFrame,
582*cdf0e10cSrcweir     ToolBox*                               pToolbar,
583*cdf0e10cSrcweir     sal_uInt16                             nPos,
584*cdf0e10cSrcweir     sal_uInt16&                            rItemId,
585*cdf0e10cSrcweir     CommandToInfoMap&                      rCommandMap,
586*cdf0e10cSrcweir     const ::rtl::OUString&                 rModuleIdentifier,
587*cdf0e10cSrcweir     const AddonToolbarItemContainer&       rAddonToolbarItems )
588*cdf0e10cSrcweir {
589*cdf0e10cSrcweir     pToolbar->RemoveItem( nPos );
590*cdf0e10cSrcweir     return MergeItems( xFrame, pToolbar, nPos, 0, rItemId, rCommandMap, rModuleIdentifier, rAddonToolbarItems );
591*cdf0e10cSrcweir }
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir /**
594*cdf0e10cSrcweir  Removes toolbar items from an existing toolbar.
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir  @param
597*cdf0e10cSrcweir      pToolbar
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir      A valid pointer to the toolbar where the merge
600*cdf0e10cSrcweir      fall back operation is applied to.
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir  @param
603*cdf0e10cSrcweir      nPos
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir      The reference position of the toolbar item for
606*cdf0e10cSrcweir      the merge operation. Value must be between
607*cdf0e10cSrcweir      0 and number of toolbar items - 1.
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir  @param
610*cdf0e10cSrcweir      rMergeCommandParameter.
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir      An optional argument for the merge command.
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir  @result
615*cdf0e10cSrcweir      Returns true for a successful operation otherwise
616*cdf0e10cSrcweir      false.
617*cdf0e10cSrcweir */
618*cdf0e10cSrcweir bool ToolBarMerger::RemoveItems(
619*cdf0e10cSrcweir     ToolBox*                  pToolbar,
620*cdf0e10cSrcweir     sal_uInt16                nPos,
621*cdf0e10cSrcweir     const ::rtl::OUString&    rMergeCommandParameter )
622*cdf0e10cSrcweir {
623*cdf0e10cSrcweir     sal_Int32 nCount = rMergeCommandParameter.toInt32();
624*cdf0e10cSrcweir     if ( nCount > 0 )
625*cdf0e10cSrcweir     {
626*cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < nCount; i++ )
627*cdf0e10cSrcweir         {
628*cdf0e10cSrcweir             if ( nPos < pToolbar->GetItemCount() )
629*cdf0e10cSrcweir                 pToolbar->RemoveItem( nPos );
630*cdf0e10cSrcweir         }
631*cdf0e10cSrcweir     }
632*cdf0e10cSrcweir     return true;
633*cdf0e10cSrcweir }
634*cdf0e10cSrcweir 
635*cdf0e10cSrcweir /**
636*cdf0e10cSrcweir  Removes toolbar items from an existing toolbar.
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir  @param
639*cdf0e10cSrcweir      pToolbar
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir      A valid pointer to the toolbar where the merge
642*cdf0e10cSrcweir      fall back operation is applied to.
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir  @param
645*cdf0e10cSrcweir      nPos
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir      The reference position of the toolbar item for
648*cdf0e10cSrcweir      the merge operation. Value must be between
649*cdf0e10cSrcweir      0 and number of toolbar items - 1.
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir  @param
652*cdf0e10cSrcweir      rMergeCommandParameter.
653*cdf0e10cSrcweir 
654*cdf0e10cSrcweir      An optional argument for the merge command.
655*cdf0e10cSrcweir 
656*cdf0e10cSrcweir  @result
657*cdf0e10cSrcweir      Returns true for a successful operation otherwise
658*cdf0e10cSrcweir      false.
659*cdf0e10cSrcweir */
660*cdf0e10cSrcweir ::cppu::OWeakObject* ToolBarMerger::CreateController(
661*cdf0e10cSrcweir     uno::Reference< lang::XMultiServiceFactory > xSMGR,
662*cdf0e10cSrcweir     uno::Reference< frame::XFrame > xFrame,
663*cdf0e10cSrcweir     ToolBox*               pToolbar,
664*cdf0e10cSrcweir     const ::rtl::OUString& rCommandURL,
665*cdf0e10cSrcweir     sal_uInt16             nId,
666*cdf0e10cSrcweir     sal_uInt16             nWidth,
667*cdf0e10cSrcweir     const ::rtl::OUString& rControlType )
668*cdf0e10cSrcweir {
669*cdf0e10cSrcweir     ::cppu::OWeakObject* pResult( 0 );
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir     if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_BUTTON, TOOLBARCONTROLLER_BUTTON_LEN ))
672*cdf0e10cSrcweir         pResult = new ButtonToolbarController( xSMGR, pToolbar, rCommandURL );
673*cdf0e10cSrcweir     else if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_COMBOBOX, TOOLBARCONTROLLER_COMBOBOX_LEN ))
674*cdf0e10cSrcweir         pResult = new ComboboxToolbarController( xSMGR, xFrame, pToolbar, nId, nWidth, rCommandURL );
675*cdf0e10cSrcweir     else if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_EDIT, TOOLBARCONTROLLER_EDIT_LEN ))
676*cdf0e10cSrcweir         pResult = new EditToolbarController( xSMGR, xFrame, pToolbar, nId, nWidth, rCommandURL );
677*cdf0e10cSrcweir     else if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_SPINFIELD, TOOLBARCONTROLLER_SPINFIELD_LEN ))
678*cdf0e10cSrcweir         pResult = new SpinfieldToolbarController( xSMGR, xFrame, pToolbar, nId, nWidth, rCommandURL );
679*cdf0e10cSrcweir     else if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_IMGBUTTON, TOOLBARCONTROLLER_IMGBUTTON_LEN ))
680*cdf0e10cSrcweir         pResult = new ImageButtonToolbarController( xSMGR, xFrame, pToolbar, nId, rCommandURL );
681*cdf0e10cSrcweir     else if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_DROPDOWNBOX, TOOLBARCONTROLLER_DROPDOWNBOX_LEN ))
682*cdf0e10cSrcweir         pResult = new DropdownToolbarController( xSMGR, xFrame, pToolbar, nId, nWidth, rCommandURL );
683*cdf0e10cSrcweir     else if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_DROPDOWNBTN, TOOLBARCONTROLLER_DROPDOWNBTN_LEN ))
684*cdf0e10cSrcweir         pResult = new ToggleButtonToolbarController( xSMGR, xFrame, pToolbar, nId,
685*cdf0e10cSrcweir                                                      ToggleButtonToolbarController::STYLE_DROPDOWNBUTTON, rCommandURL );
686*cdf0e10cSrcweir     else if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_TOGGLEDDBTN, TOOLBARCONTROLLER_TOGGLEDDBTN_LEN ))
687*cdf0e10cSrcweir         pResult = new ToggleButtonToolbarController( xSMGR, xFrame, pToolbar, nId,
688*cdf0e10cSrcweir                                                      ToggleButtonToolbarController::STYLE_TOGGLE_DROPDOWNBUTTON, rCommandURL );
689*cdf0e10cSrcweir     else
690*cdf0e10cSrcweir         pResult = new GenericToolbarController( xSMGR, xFrame, pToolbar, nId, rCommandURL );
691*cdf0e10cSrcweir 
692*cdf0e10cSrcweir     return pResult;
693*cdf0e10cSrcweir }
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir void ToolBarMerger::CreateToolbarItem( ToolBox* pToolbar, CommandToInfoMap& rCommandMap, sal_uInt16 nPos, sal_uInt16 nItemId, const AddonToolbarItem& rItem )
696*cdf0e10cSrcweir {
697*cdf0e10cSrcweir     pToolbar->InsertItem( nItemId, rItem.aLabel, 0, nPos );
698*cdf0e10cSrcweir     pToolbar->SetItemCommand( nItemId, rItem.aCommandURL );
699*cdf0e10cSrcweir     pToolbar->SetQuickHelpText( nItemId, rItem.aLabel );
700*cdf0e10cSrcweir     pToolbar->SetItemText( nItemId, rItem.aLabel );
701*cdf0e10cSrcweir     pToolbar->EnableItem( nItemId, sal_True );
702*cdf0e10cSrcweir     pToolbar->SetItemState( nItemId, STATE_NOCHECK );
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir     CommandToInfoMap::iterator pIter = rCommandMap.find( rItem.aCommandURL );
705*cdf0e10cSrcweir     if ( pIter != rCommandMap.end() )
706*cdf0e10cSrcweir         pIter->second.nWidth = rItem.nWidth;
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir     // Use the user data to store add-on specific data with the toolbar item
709*cdf0e10cSrcweir     AddonsParams* pAddonParams = new AddonsParams;
710*cdf0e10cSrcweir     pAddonParams->aImageId     = rItem.aImageIdentifier;
711*cdf0e10cSrcweir     pAddonParams->aTarget      = rItem.aTarget;
712*cdf0e10cSrcweir     pAddonParams->aControlType = rItem.aControlType;
713*cdf0e10cSrcweir     pToolbar->SetItemData( nItemId, pAddonParams );
714*cdf0e10cSrcweir }
715*cdf0e10cSrcweir 
716*cdf0e10cSrcweir } // namespace framework
717