Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <framework/addonsoptions.hxx>
30 : : #include <unotools/configmgr.hxx>
31 : : #include <unotools/configitem.hxx>
32 : : #include <unotools/ucbstreamhelper.hxx>
33 : : #include <tools/stream.hxx>
34 : : #include <com/sun/star/uno/Any.hxx>
35 : : #include <com/sun/star/uno/Sequence.hxx>
36 : : #include "com/sun/star/util/XMacroExpander.hpp"
37 : : #include "com/sun/star/uno/XComponentContext.hpp"
38 : : #include "com/sun/star/beans/XPropertySet.hpp"
39 : : #include <rtl/ustrbuf.hxx>
40 : : #include <rtl/uri.hxx>
41 : : #include <comphelper/processfactory.hxx>
42 : : #include <vcl/graph.hxx>
43 : : #include <svtools/filter.hxx>
44 : :
45 : : #include <boost/unordered_map.hpp>
46 : : #include <algorithm>
47 : : #include <vector>
48 : :
49 : : //_________________________________________________________________________________________________________________
50 : : // namespaces
51 : : //_________________________________________________________________________________________________________________
52 : :
53 : : using namespace ::std ;
54 : : using namespace ::utl ;
55 : : using namespace ::osl ;
56 : : using namespace ::com::sun::star::uno ;
57 : : using namespace ::com::sun::star::beans ;
58 : : using namespace ::com::sun::star::lang ;
59 : :
60 : : #define ROOTNODE_ADDONMENU ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Addons" ))
61 : : #define PATHDELIMITER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/" ))
62 : : #define SEPARATOR_URL_STR "private:separator"
63 : : #define SEPARATOR_URL_LEN 17
64 : : #define SEPARATOR_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SEPARATOR_URL_STR ))
65 : :
66 : : #define PROPERTYNAME_URL ADDONSMENUITEM_PROPERTYNAME_URL
67 : : #define PROPERTYNAME_TITLE ADDONSMENUITEM_PROPERTYNAME_TITLE
68 : : #define PROPERTYNAME_TARGET ADDONSMENUITEM_PROPERTYNAME_TARGET
69 : : #define PROPERTYNAME_IMAGEIDENTIFIER ADDONSMENUITEM_PROPERTYNAME_IMAGEIDENTIFIER
70 : : #define PROPERTYNAME_CONTEXT ADDONSMENUITEM_PROPERTYNAME_CONTEXT
71 : : #define PROPERTYNAME_SUBMENU ADDONSMENUITEM_PROPERTYNAME_SUBMENU
72 : : #define PROPERTYNAME_CONTROLTYPE ADDONSMENUITEM_PROPERTYNAME_CONTROLTYPE
73 : : #define PROPERTYNAME_WIDTH ADDONSMENUITEM_PROPERTYNAME_WIDTH
74 : :
75 : : #define PROPERTYNAME_IMAGESMALL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageSmall" ))
76 : : #define PROPERTYNAME_IMAGEBIG ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageBig" ))
77 : : #define PROPERTYNAME_IMAGESMALLHC ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageSmallHC" ))
78 : : #define PROPERTYNAME_IMAGEBIGHC ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageBigHC" ))
79 : : #define PROPERTYNAME_IMAGESMALL_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageSmallURL" ))
80 : : #define PROPERTYNAME_IMAGEBIG_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageBigURL" ))
81 : : #define PROPERTYNAME_IMAGESMALLHC_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageSmallHCURL" ))
82 : : #define PROPERTYNAME_IMAGEBIGHC_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageBigHCURL" ))
83 : :
84 : : #define IMAGES_NODENAME ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UserDefinedImages" ))
85 : : #define PRIVATE_IMAGE_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:image/" ))
86 : :
87 : : #define PROPERTYNAME_MERGEMENU_MERGEPOINT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergePoint" ))
88 : : #define PROPERTYNAME_MERGEMENU_MERGECOMMAND ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeCommand" ))
89 : : #define PROPERTYNAME_MERGEMENU_MERGECOMMANDPARAMETER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeCommandParameter" ))
90 : : #define PROPERTYNAME_MERGEMENU_MERGEFALLBACK ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeFallback" ))
91 : : #define PROPERTYNAME_MERGEMENU_MERGECONTEXT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeContext" ))
92 : : #define PROPERTYNAME_MERGEMENU_MENUITEMS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MenuItems" ))
93 : :
94 : : #define PROPERTYNAME_MERGETOOLBAR_TOOLBAR ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeToolBar" ))
95 : : #define PROPERTYNAME_MERGETOOLBAR_MERGEPOINT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergePoint" ))
96 : : #define PROPERTYNAME_MERGETOOLBAR_MERGECOMMAND ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeCommand" ))
97 : : #define PROPERTYNAME_MERGETOOLBAR_MERGECOMMANDPARAMETER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeCommandParameter" ))
98 : : #define PROPERTYNAME_MERGETOOLBAR_MERGEFALLBACK ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeFallback" ))
99 : : #define PROPERTYNAME_MERGETOOLBAR_MERGECONTEXT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeContext" ))
100 : : #define PROPERTYNAME_MERGETOOLBAR_TOOLBARITEMS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ToolBarItems" ))
101 : :
102 : : // The following order is mandatory. Please add properties at the end!
103 : : #define INDEX_URL 0
104 : : #define INDEX_TITLE 1
105 : : #define INDEX_IMAGEIDENTIFIER 2
106 : : #define INDEX_TARGET 3
107 : : #define INDEX_CONTEXT 4
108 : : #define INDEX_SUBMENU 5
109 : : #define INDEX_CONTROLTYPE 6
110 : : #define INDEX_WIDTH 7
111 : : #define PROPERTYCOUNT_INDEX 8
112 : :
113 : : // The following order is mandatory. Please add properties at the end!
114 : : #define PROPERTYCOUNT_MENUITEM 6
115 : : #define OFFSET_MENUITEM_URL 0
116 : : #define OFFSET_MENUITEM_TITLE 1
117 : : #define OFFSET_MENUITEM_IMAGEIDENTIFIER 2
118 : : #define OFFSET_MENUITEM_TARGET 3
119 : : #define OFFSET_MENUITEM_CONTEXT 4
120 : : #define OFFSET_MENUITEM_SUBMENU 5
121 : :
122 : : // The following order is mandatory. Please add properties at the end!
123 : : #define PROPERTYCOUNT_POPUPMENU 4
124 : : #define OFFSET_POPUPMENU_TITLE 0
125 : : #define OFFSET_POPUPMENU_CONTEXT 1
126 : : #define OFFSET_POPUPMENU_SUBMENU 2
127 : : #define OFFSET_POPUPMENU_URL 3 // Used for property set
128 : :
129 : : // The following order is mandatory. Please add properties at the end!
130 : : #define PROPERTYCOUNT_TOOLBARITEM 7
131 : : #define OFFSET_TOOLBARITEM_URL 0
132 : : #define OFFSET_TOOLBARITEM_TITLE 1
133 : : #define OFFSET_TOOLBARITEM_IMAGEIDENTIFIER 2
134 : : #define OFFSET_TOOLBARITEM_TARGET 3
135 : : #define OFFSET_TOOLBARITEM_CONTEXT 4
136 : : #define OFFSET_TOOLBARITEM_CONTROLTYPE 5
137 : : #define OFFSET_TOOLBARITEM_WIDTH 6
138 : :
139 : : // The following order is mandatory. Please add properties at the end!
140 : : #define PROPERTYCOUNT_IMAGES 8
141 : : #define PROPERTYCOUNT_EMBEDDED_IMAGES 4
142 : : #define OFFSET_IMAGES_SMALL 0
143 : : #define OFFSET_IMAGES_BIG 1
144 : : #define OFFSET_IMAGES_SMALLHC 2
145 : : #define OFFSET_IMAGES_BIGHC 3
146 : : #define OFFSET_IMAGES_SMALL_URL 4
147 : : #define OFFSET_IMAGES_BIG_URL 5
148 : : #define OFFSET_IMAGES_SMALLHC_URL 6
149 : : #define OFFSET_IMAGES_BIGHC_URL 7
150 : :
151 : : #define PROPERTYCOUNT_MERGE_MENUBAR 6
152 : : #define OFFSET_MERGEMENU_MERGEPOINT 0
153 : : #define OFFSET_MERGEMENU_MERGECOMMAND 1
154 : : #define OFFSET_MERGEMENU_MERGECOMMANDPARAMETER 2
155 : : #define OFFSET_MERGEMENU_MERGEFALLBACK 3
156 : : #define OFFSET_MERGEMENU_MERGECONTEXT 4
157 : : #define OFFSET_MERGEMENU_MENUITEMS 5
158 : :
159 : : #define PROPERTYCOUNT_MERGE_TOOLBAR 7
160 : : #define OFFSET_MERGETOOLBAR_TOOLBAR 0
161 : : #define OFFSET_MERGETOOLBAR_MERGEPOINT 1
162 : : #define OFFSET_MERGETOOLBAR_MERGECOMMAND 2
163 : : #define OFFSET_MERGETOOLBAR_MERGECOMMANDPARAMETER 3
164 : : #define OFFSET_MERGETOOLBAR_MERGEFALLBACK 4
165 : : #define OFFSET_MERGETOOLBAR_MERGECONTEXT 5
166 : : #define OFFSET_MERGETOOLBAR_TOOLBARITEMS 6
167 : :
168 : : #define EXPAND_PROTOCOL "vnd.sun.star.expand:"
169 : :
170 : 245 : const Size aImageSizeSmall( 16, 16 );
171 : 245 : const Size aImageSizeBig( 26, 26 );
172 : :
173 : : //_________________________________________________________________________________________________________________
174 : : // private declarations!
175 : : //_________________________________________________________________________________________________________________
176 : :
177 : : /*-****************************************************************************************************************
178 : : @descr struct to hold information about one menu entry.
179 : : ****************************************************************************************************************-*/
180 : :
181 : : namespace framework
182 : : {
183 : :
184 : : class AddonsOptions_Impl : public ConfigItem
185 : : {
186 : : //-------------------------------------------------------------------------------------------------------------
187 : : // public methods
188 : : //-------------------------------------------------------------------------------------------------------------
189 : :
190 : : public:
191 : : //---------------------------------------------------------------------------------------------------------
192 : : // constructor / destructor
193 : : //---------------------------------------------------------------------------------------------------------
194 : :
195 : : AddonsOptions_Impl();
196 : : ~AddonsOptions_Impl();
197 : :
198 : : //---------------------------------------------------------------------------------------------------------
199 : : // overloaded methods of baseclass
200 : : //---------------------------------------------------------------------------------------------------------
201 : :
202 : : /*-****************************************************************************************************//**
203 : : @short called for notify of configmanager
204 : : @descr These method is called from the ConfigManager before application ends or from the
205 : : PropertyChangeListener if the sub tree broadcasts changes. You must update your
206 : : internal values.
207 : :
208 : : @seealso baseclass ConfigItem
209 : :
210 : : @param "lPropertyNames" is the list of properties which should be updated.
211 : : @return -
212 : :
213 : : @onerror -
214 : : *//*-*****************************************************************************************************/
215 : :
216 : : virtual void Notify( const Sequence< ::rtl::OUString >& lPropertyNames );
217 : :
218 : : /*-****************************************************************************************************//**
219 : : @short write changes to configuration
220 : : @descr These method writes the changed values into the sub tree
221 : : and should always called in our destructor to guarantee consistency of config data.
222 : :
223 : : @seealso baseclass ConfigItem
224 : :
225 : : @param -
226 : : @return -
227 : :
228 : : @onerror -
229 : : *//*-*****************************************************************************************************/
230 : :
231 : : virtual void Commit();
232 : :
233 : : //---------------------------------------------------------------------------------------------------------
234 : : // public interface
235 : : //---------------------------------------------------------------------------------------------------------
236 : :
237 : : /*-****************************************************************************************************//**
238 : : @short base implementation of public interface for "SvtDynamicMenuOptions"!
239 : : @descr These class is used as static member of "SvtDynamicMenuOptions" ...
240 : : => The code exist only for one time and isn't duplicated for every instance!
241 : :
242 : : @seealso -
243 : :
244 : : @param -
245 : : @return -
246 : :
247 : : @onerror -
248 : : *//*-*****************************************************************************************************/
249 : :
250 : : sal_Bool HasAddonsMenu () const ;
251 : : sal_Int32 GetAddonsToolBarCount() const ;
252 : : const Sequence< Sequence< PropertyValue > >& GetAddonsMenu () const ;
253 : : const Sequence< Sequence< PropertyValue > >& GetAddonsMenuBarPart () const ;
254 : : const Sequence< Sequence< PropertyValue > >& GetAddonsToolBarPart ( sal_uInt32 nIndex ) const ;
255 : : const ::rtl::OUString GetAddonsToolbarResourceName( sal_uInt32 nIndex ) const;
256 : : const Sequence< Sequence< PropertyValue > >& GetAddonsHelpMenu () const ;
257 : : Image GetImageFromURL( const rtl::OUString& aURL, sal_Bool bBig, sal_Bool bNoScale ) const;
258 : : const MergeMenuInstructionContainer& GetMergeMenuInstructions() const;
259 : : bool GetMergeToolbarInstructions( const ::rtl::OUString& rToolbarName, MergeToolbarInstructionContainer& rToolbarInstructions ) const;
260 : :
261 : : void ReadConfigurationData();
262 : :
263 : : //-------------------------------------------------------------------------------------------------------------
264 : : // private methods
265 : : //-------------------------------------------------------------------------------------------------------------
266 : :
267 : : private:
268 : : struct OUStringHashCode
269 : : {
270 : 2233 : size_t operator()( const ::rtl::OUString& sString ) const
271 : : {
272 : 2233 : return sString.hashCode();
273 : : }
274 : : };
275 : :
276 [ + - ][ + - ]: 5340 : struct ImageEntry
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
277 : : {
278 : : Image aImageSmall;
279 : : Image aImageBig;
280 : :
281 : : Image aImageSmallNoScale;
282 : : Image aImageBigNoScale;
283 : : };
284 : :
285 : : typedef boost::unordered_map< ::rtl::OUString, ImageEntry, OUStringHashCode, ::std::equal_to< ::rtl::OUString > > ImageManager;
286 : : typedef boost::unordered_map< ::rtl::OUString, sal_uInt32, OUStringHashCode, ::std::equal_to< ::rtl::OUString > > StringToIndexMap;
287 : : typedef std::vector< Sequence< Sequence< PropertyValue > > > AddonToolBars;
288 : : typedef ::boost::unordered_map< ::rtl::OUString, MergeToolbarInstructionContainer, OUStringHashCode, ::std::equal_to< ::rtl::OUString > > ToolbarMergingInstructions;
289 : :
290 : : enum ImageSize
291 : : {
292 : : IMGSIZE_SMALL,
293 : : IMGSIZE_BIG
294 : : };
295 : :
296 : : /*-****************************************************************************************************//**
297 : : @short return list of key names of our configuration management which represent oue module tree
298 : : @descr These methods return the current list of key names! We need it to get needed values from our
299 : : configuration management!
300 : :
301 : : @seealso -
302 : :
303 : : @param "nCount" , returns count of menu entries for "new"
304 : : @return A list of configuration key names is returned.
305 : :
306 : : @onerror -
307 : : *//*-*****************************************************************************************************/
308 : :
309 : : sal_Bool ReadAddonMenuSet( Sequence< Sequence< PropertyValue > >& aAddonMenuSeq );
310 : : sal_Bool ReadOfficeMenuBarSet( Sequence< Sequence< PropertyValue > >& aAddonOfficeMenuBarSeq );
311 : : sal_Bool ReadOfficeToolBarSet( AddonToolBars& rAddonOfficeToolBars, std::vector< rtl::OUString >& rAddonOfficeToolBarResNames );
312 : : sal_Bool ReadToolBarItemSet( const rtl::OUString rToolBarItemSetNodeName, Sequence< Sequence< PropertyValue > >& aAddonOfficeToolBarSeq );
313 : : sal_Bool ReadOfficeHelpSet( Sequence< Sequence< PropertyValue > >& aAddonOfficeHelpMenuSeq );
314 : : sal_Bool ReadImages( ImageManager& aImageManager );
315 : : sal_Bool ReadMenuMergeInstructions( MergeMenuInstructionContainer& rContainer );
316 : : sal_Bool ReadToolbarMergeInstructions( ToolbarMergingInstructions& rToolbarMergeMap );
317 : :
318 : : sal_Bool ReadMergeMenuData( const ::rtl::OUString& aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeMenu );
319 : : sal_Bool ReadMergeToolbarData( const ::rtl::OUString& aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeToolbarItems );
320 : : sal_Bool ReadMenuItem( const ::rtl::OUString& aMenuItemNodeName, Sequence< PropertyValue >& aMenuItem, sal_Bool bIgnoreSubMenu = sal_False );
321 : : sal_Bool ReadPopupMenu( const ::rtl::OUString& aPopupMenuNodeName, Sequence< PropertyValue >& aPopupMenu );
322 : : sal_Bool AppendPopupMenu( Sequence< PropertyValue >& aTargetPopupMenu, const Sequence< PropertyValue >& rSourcePopupMenu );
323 : : sal_Bool ReadToolBarItem( const ::rtl::OUString& aToolBarItemNodeName, Sequence< PropertyValue >& aToolBarItem );
324 : : sal_Bool ReadImagesItem( const ::rtl::OUString& aImagesItemNodeName, Sequence< PropertyValue >& aImagesItem );
325 : : ImageEntry* ReadImageData( const ::rtl::OUString& aImagesNodeName );
326 : : void ReadAndAssociateImages( const ::rtl::OUString& aURL, const ::rtl::OUString& aImageId );
327 : : void ReadImageFromURL( ImageSize nImageSize, const ::rtl::OUString& aURL, Image& aImage, Image& aNoScaleImage );
328 : : sal_Bool HasAssociatedImages( const ::rtl::OUString& aURL );
329 : : void SubstituteVariables( ::rtl::OUString& aURL );
330 : :
331 : : sal_Bool ReadSubMenuEntries( const Sequence< ::rtl::OUString >& aSubMenuNodeNames, Sequence< Sequence< PropertyValue > >& rSubMenu );
332 : : void InsertToolBarSeparator( Sequence< Sequence< PropertyValue > >& rAddonOfficeToolBarSeq );
333 : : ::rtl::OUString GeneratePrefixURL();
334 : :
335 : : Sequence< ::rtl::OUString > GetPropertyNamesMenuItem( const ::rtl::OUString& aPropertyRootNode ) const;
336 : : Sequence< ::rtl::OUString > GetPropertyNamesPopupMenu( const ::rtl::OUString& aPropertyRootNode ) const;
337 : : Sequence< ::rtl::OUString > GetPropertyNamesToolBarItem( const ::rtl::OUString& aPropertyRootNode ) const;
338 : : Sequence< ::rtl::OUString > GetPropertyNamesImages( const ::rtl::OUString& aPropertyRootNode ) const;
339 : : sal_Bool CreateImageFromSequence( Image& rImage, sal_Bool bBig, Sequence< sal_Int8 >& rBitmapDataSeq ) const;
340 : :
341 : : //-------------------------------------------------------------------------------------------------------------
342 : : // private member
343 : : //-------------------------------------------------------------------------------------------------------------
344 : :
345 : : private:
346 : : ImageEntry* ReadOptionalImageData( const ::rtl::OUString& aMenuNodeName );
347 : :
348 : : sal_Int32 m_nRootAddonPopupMenuId;
349 : : ::rtl::OUString m_aPropNames[PROPERTYCOUNT_INDEX];
350 : : ::rtl::OUString m_aPropImagesNames[PROPERTYCOUNT_IMAGES];
351 : : ::rtl::OUString m_aPropMergeMenuNames[PROPERTYCOUNT_MERGE_MENUBAR];
352 : : ::rtl::OUString m_aPropMergeToolbarNames[PROPERTYCOUNT_MERGE_TOOLBAR];
353 : : ::rtl::OUString m_aEmpty;
354 : : ::rtl::OUString m_aPathDelimiter;
355 : : ::rtl::OUString m_aSeparator;
356 : : ::rtl::OUString m_aRootAddonPopupMenuURLPrexfix;
357 : : ::rtl::OUString m_aPrivateImageURL;
358 : : Sequence< Sequence< PropertyValue > > m_aCachedMenuProperties;
359 : : Sequence< Sequence< PropertyValue > > m_aCachedMenuBarPartProperties;
360 : : AddonToolBars m_aCachedToolBarPartProperties;
361 : : std::vector< rtl::OUString > m_aCachedToolBarPartResourceNames;
362 : : Sequence< Sequence< PropertyValue > > m_aCachedHelpMenuProperties;
363 : : Reference< com::sun::star::util::XMacroExpander > m_xMacroExpander;
364 : : ImageManager m_aImageManager;
365 : : Sequence< Sequence< PropertyValue > > m_aEmptyAddonToolBar;
366 : : MergeMenuInstructionContainer m_aCachedMergeMenuInsContainer;
367 : : ToolbarMergingInstructions m_aCachedToolbarMergingInstructions;
368 : : };
369 : :
370 : : //*****************************************************************************************************************
371 : : // constructor
372 : : //*****************************************************************************************************************
373 : 1284 : AddonsOptions_Impl::AddonsOptions_Impl()
374 : : // Init baseclasses first
375 : : : ConfigItem( ROOTNODE_ADDONMENU ),
376 : : m_nRootAddonPopupMenuId( 0 ),
377 : : m_aPathDelimiter( PATHDELIMITER ),
378 : : m_aSeparator( SEPARATOR_URL ),
379 : : m_aRootAddonPopupMenuURLPrexfix( ADDONSPOPUPMENU_URL_PREFIX ),
380 [ + - ][ + + ]: 38520 : m_aPrivateImageURL( PRIVATE_IMAGE_URL )
[ + + ][ + + ]
[ + + ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
381 : : {
382 : : // initialize array with fixed property names
383 [ + - ]: 1284 : m_aPropNames[ INDEX_URL ] = PROPERTYNAME_URL;
384 [ + - ]: 1284 : m_aPropNames[ INDEX_TITLE ] = PROPERTYNAME_TITLE;
385 [ + - ]: 1284 : m_aPropNames[ INDEX_TARGET ] = PROPERTYNAME_TARGET;
386 [ + - ]: 1284 : m_aPropNames[ INDEX_IMAGEIDENTIFIER ] = PROPERTYNAME_IMAGEIDENTIFIER;
387 [ + - ]: 1284 : m_aPropNames[ INDEX_CONTEXT ] = PROPERTYNAME_CONTEXT;
388 [ + - ]: 1284 : m_aPropNames[ INDEX_SUBMENU ] = PROPERTYNAME_SUBMENU; // Submenu set!
389 [ + - ]: 1284 : m_aPropNames[ INDEX_CONTROLTYPE ] = PROPERTYNAME_CONTROLTYPE;
390 [ + - ]: 1284 : m_aPropNames[ INDEX_WIDTH ] = PROPERTYNAME_WIDTH;
391 : :
392 : : // initialize array with fixed images property names
393 [ + - ]: 1284 : m_aPropImagesNames[ OFFSET_IMAGES_SMALL ] = PROPERTYNAME_IMAGESMALL;
394 [ + - ]: 1284 : m_aPropImagesNames[ OFFSET_IMAGES_BIG ] = PROPERTYNAME_IMAGEBIG;
395 [ + - ]: 1284 : m_aPropImagesNames[ OFFSET_IMAGES_SMALLHC ] = PROPERTYNAME_IMAGESMALLHC;
396 [ + - ]: 1284 : m_aPropImagesNames[ OFFSET_IMAGES_BIGHC ] = PROPERTYNAME_IMAGEBIGHC;
397 [ + - ]: 1284 : m_aPropImagesNames[ OFFSET_IMAGES_SMALL_URL ] = PROPERTYNAME_IMAGESMALL_URL;
398 [ + - ]: 1284 : m_aPropImagesNames[ OFFSET_IMAGES_BIG_URL ] = PROPERTYNAME_IMAGEBIG_URL;
399 [ + - ]: 1284 : m_aPropImagesNames[ OFFSET_IMAGES_SMALLHC_URL ] = PROPERTYNAME_IMAGESMALLHC_URL;
400 [ + - ]: 1284 : m_aPropImagesNames[ OFFSET_IMAGES_BIGHC_URL ] = PROPERTYNAME_IMAGEBIGHC_URL;
401 : :
402 : : // initialize array with fixed merge menu property names
403 [ + - ]: 1284 : m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGEPOINT ] = PROPERTYNAME_MERGEMENU_MERGEPOINT;
404 [ + - ]: 1284 : m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECOMMAND ] = PROPERTYNAME_MERGEMENU_MERGECOMMAND;
405 [ + - ]: 1284 : m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECOMMANDPARAMETER ] = PROPERTYNAME_MERGEMENU_MERGECOMMANDPARAMETER;
406 [ + - ]: 1284 : m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGEFALLBACK ] = PROPERTYNAME_MERGEMENU_MERGEFALLBACK;
407 [ + - ]: 1284 : m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECONTEXT ] = PROPERTYNAME_MERGEMENU_MERGECONTEXT;
408 [ + - ]: 1284 : m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MENUITEMS ] = PROPERTYNAME_MERGEMENU_MENUITEMS;
409 : :
410 [ + - ]: 1284 : m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBAR ] = PROPERTYNAME_MERGETOOLBAR_TOOLBAR;
411 [ + - ]: 1284 : m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGEPOINT ] = PROPERTYNAME_MERGETOOLBAR_MERGEPOINT;
412 [ + - ]: 1284 : m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECOMMAND ] = PROPERTYNAME_MERGETOOLBAR_MERGECOMMAND;
413 [ + - ]: 1284 : m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECOMMANDPARAMETER ] = PROPERTYNAME_MERGETOOLBAR_MERGECOMMANDPARAMETER;
414 [ + - ]: 1284 : m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGEFALLBACK ] = PROPERTYNAME_MERGETOOLBAR_MERGEFALLBACK;
415 [ + - ]: 1284 : m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECONTEXT ] = PROPERTYNAME_MERGETOOLBAR_MERGECONTEXT;
416 [ + - ]: 1284 : m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBARITEMS ] = PROPERTYNAME_MERGETOOLBAR_TOOLBARITEMS;
417 : :
418 : 1284 : Reference< XComponentContext > xContext;
419 [ + - ][ + - ]: 1284 : Reference< com::sun::star::beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
420 [ + - ][ + - ]: 1284 : xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xContext;
[ + - ][ + - ]
421 [ + - ]: 1284 : if ( xContext.is() )
422 : : {
423 [ + - ]: 1284 : m_xMacroExpander = Reference< com::sun::star::util::XMacroExpander >( xContext->getValueByName(
424 : 1284 : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.util.theMacroExpander"))),
425 [ + - ][ + - ]: 1284 : UNO_QUERY );
[ + - ][ + - ]
426 : : }
427 : :
428 [ + - ]: 1284 : ReadConfigurationData();
429 : :
430 : : // Enable notification mechanism of ouer baseclass.
431 : : // We need it to get information about changes outside these class on ouer used configuration keys!
432 [ + - ]: 1284 : Sequence< rtl::OUString > aNotifySeq( 1 );
433 [ + - ][ + - ]: 1284 : aNotifySeq[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AddonUI" ));
434 [ + - ][ + - ]: 1284 : EnableNotification( aNotifySeq );
435 [ # # # # : 1284 : }
# # # # #
# # # # #
# # ]
436 : :
437 : : //*****************************************************************************************************************
438 : : // destructor
439 : : //*****************************************************************************************************************
440 [ + - ][ + - ]: 39494 : AddonsOptions_Impl::~AddonsOptions_Impl()
[ + - ][ + - ]
[ + - ][ + - ]
441 : : {
442 : : // We must save our current values .. if user forget it!
443 [ + - ][ - + ]: 1274 : if( IsModified() == sal_True )
444 : : {
445 : 0 : Commit();
446 : : }
447 [ + - ][ + + ]: 40768 : }
[ + - ][ + + ]
[ + - ][ + + ]
[ + - ]
[ + + - + ]
[ # # # #
# # # # #
# # # # #
# # ]
448 : :
449 : 1284 : void AddonsOptions_Impl::ReadConfigurationData()
450 : : {
451 : : // reset members to be read again from configuration
452 [ + - ]: 1284 : m_aCachedMenuProperties = Sequence< Sequence< PropertyValue > >();
453 [ + - ]: 1284 : m_aCachedMenuBarPartProperties = Sequence< Sequence< PropertyValue > >();
454 : 1284 : m_aCachedToolBarPartProperties = AddonToolBars();
455 [ + - ]: 1284 : m_aCachedHelpMenuProperties = Sequence< Sequence< PropertyValue > >();
456 : 1284 : m_aCachedToolBarPartResourceNames.clear();
457 [ + - ][ + - ]: 1284 : m_aImageManager = ImageManager();
[ + - ]
458 : :
459 : 1284 : ReadAddonMenuSet( m_aCachedMenuProperties );
460 : 1284 : ReadOfficeMenuBarSet( m_aCachedMenuBarPartProperties );
461 : 1284 : ReadOfficeToolBarSet( m_aCachedToolBarPartProperties, m_aCachedToolBarPartResourceNames );
462 : 1284 : ReadOfficeHelpSet( m_aCachedHelpMenuProperties );
463 : 1284 : ReadImages( m_aImageManager );
464 : :
465 : 1284 : m_aCachedMergeMenuInsContainer.clear();
466 : 1284 : m_aCachedToolbarMergingInstructions.clear();
467 : :
468 : 1284 : ReadMenuMergeInstructions( m_aCachedMergeMenuInsContainer );
469 : 1284 : ReadToolbarMergeInstructions( m_aCachedToolbarMergingInstructions );
470 : 1284 : }
471 : :
472 : : //*****************************************************************************************************************
473 : : // public method
474 : : //*****************************************************************************************************************
475 : 0 : void AddonsOptions_Impl::Notify( const Sequence< ::rtl::OUString >& /*lPropertyNames*/ )
476 : : {
477 [ # # ]: 0 : Application::PostUserEvent( STATIC_LINK( 0, AddonsOptions, Notify ) );
478 : 0 : }
479 : :
480 : : //*****************************************************************************************************************
481 : : // public method
482 : : //*****************************************************************************************************************
483 : 0 : void AddonsOptions_Impl::Commit()
484 : : {
485 : : OSL_FAIL( "AddonsOptions_Impl::Commit()\nNot implemented yet!\n" );
486 : 0 : }
487 : :
488 : : //*****************************************************************************************************************
489 : : // public method
490 : : //*****************************************************************************************************************
491 : 1159 : sal_Bool AddonsOptions_Impl::HasAddonsMenu() const
492 : : {
493 : 1159 : return ( m_aCachedMenuProperties.getLength() > 0 );
494 : : }
495 : :
496 : : //*****************************************************************************************************************
497 : : // public method
498 : : //*****************************************************************************************************************
499 : 3518 : sal_Int32 AddonsOptions_Impl::GetAddonsToolBarCount() const
500 : : {
501 : 3518 : return m_aCachedToolBarPartProperties.size();
502 : : }
503 : :
504 : : //*****************************************************************************************************************
505 : : // public method
506 : : //*****************************************************************************************************************
507 : 0 : const Sequence< Sequence< PropertyValue > >& AddonsOptions_Impl::GetAddonsMenu() const
508 : : {
509 : 0 : return m_aCachedMenuProperties;
510 : : }
511 : :
512 : : //*****************************************************************************************************************
513 : : // public method
514 : : //*****************************************************************************************************************
515 : 1159 : const Sequence< Sequence< PropertyValue > >& AddonsOptions_Impl::GetAddonsMenuBarPart() const
516 : : {
517 : 1159 : return m_aCachedMenuBarPartProperties;
518 : : }
519 : :
520 : : //*****************************************************************************************************************
521 : : // public method
522 : : //*****************************************************************************************************************
523 : 0 : const Sequence< Sequence< PropertyValue > >& AddonsOptions_Impl::GetAddonsToolBarPart( sal_uInt32 nIndex ) const
524 : : {
525 [ # # ]: 0 : if ( /*nIndex >= 0 &&*/ nIndex < m_aCachedToolBarPartProperties.size() )
526 : 0 : return m_aCachedToolBarPartProperties[nIndex];
527 : : else
528 : 0 : return m_aEmptyAddonToolBar;
529 : : }
530 : :
531 : : //*****************************************************************************************************************
532 : : // public method
533 : : //*****************************************************************************************************************
534 : 0 : const ::rtl::OUString AddonsOptions_Impl::GetAddonsToolbarResourceName( sal_uInt32 nIndex ) const
535 : : {
536 [ # # ]: 0 : if ( nIndex < m_aCachedToolBarPartResourceNames.size() )
537 : 0 : return m_aCachedToolBarPartResourceNames[nIndex];
538 : : else
539 : 0 : return rtl::OUString();
540 : : }
541 : :
542 : : //*****************************************************************************************************************
543 : : // public method
544 : : //*****************************************************************************************************************
545 : 1159 : const Sequence< Sequence< PropertyValue > >& AddonsOptions_Impl::GetAddonsHelpMenu () const
546 : : {
547 : 1159 : return m_aCachedHelpMenuProperties;
548 : : }
549 : :
550 : : //*****************************************************************************************************************
551 : : // public method
552 : : //*****************************************************************************************************************
553 : 1159 : const MergeMenuInstructionContainer& AddonsOptions_Impl::GetMergeMenuInstructions() const
554 : : {
555 : 1159 : return m_aCachedMergeMenuInsContainer;
556 : : }
557 : :
558 : : //*****************************************************************************************************************
559 : : // public method
560 : : //*****************************************************************************************************************
561 : 2548 : bool AddonsOptions_Impl::GetMergeToolbarInstructions(
562 : : const ::rtl::OUString& rToolbarName,
563 : : MergeToolbarInstructionContainer& rToolbarInstructions ) const
564 : : {
565 [ + - ]: 2548 : ToolbarMergingInstructions::const_iterator pIter = m_aCachedToolbarMergingInstructions.find( rToolbarName );
566 [ + - ][ - + ]: 2548 : if ( pIter != m_aCachedToolbarMergingInstructions.end() )
567 : : {
568 [ # # ][ # # ]: 0 : rToolbarInstructions = pIter->second;
569 : 0 : return true;
570 : : }
571 : : else
572 : 2548 : return false;
573 : : }
574 : :
575 : : //*****************************************************************************************************************
576 : : // public method
577 : : //*****************************************************************************************************************
578 : 1343 : Image AddonsOptions_Impl::GetImageFromURL( const rtl::OUString& aURL, sal_Bool bBig, sal_Bool bNoScale ) const
579 : : {
580 [ + - ]: 1343 : Image aImage;
581 : :
582 [ + - ]: 1343 : ImageManager::const_iterator pIter = m_aImageManager.find( aURL );
583 [ + - ][ - + ]: 1343 : if ( pIter != m_aImageManager.end() )
584 : : {
585 [ # # ]: 0 : if ( bNoScale )
586 [ # # ][ # # ]: 0 : aImage = ( bBig ? pIter->second.aImageBigNoScale : pIter->second.aImageSmallNoScale );
[ # # ][ # # ]
587 [ # # ]: 0 : if ( !aImage )
588 [ # # ][ # # ]: 1343 : aImage = ( bBig ? pIter->second.aImageBig : pIter->second.aImageSmall );
[ # # ][ # # ]
589 : : }
590 : :
591 : 1343 : return aImage;
592 : : }
593 : :
594 : : //*****************************************************************************************************************
595 : : // private method
596 : : //*****************************************************************************************************************
597 : 1284 : sal_Bool AddonsOptions_Impl::ReadAddonMenuSet( Sequence< Sequence< PropertyValue > >& rAddonMenuSeq )
598 : : {
599 : : // Read the AddonMenu set and fill property sequences
600 [ + - ]: 1284 : ::rtl::OUString aAddonMenuNodeName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/AddonMenu" ));
601 [ + - ]: 1284 : Sequence< ::rtl::OUString > aAddonMenuNodeSeq = GetNodeNames( aAddonMenuNodeName );
602 : 1284 : ::rtl::OUString aAddonMenuItemNode( aAddonMenuNodeName + m_aPathDelimiter );
603 : :
604 : 1284 : sal_uInt32 nCount = aAddonMenuNodeSeq.getLength();
605 : 1284 : sal_uInt32 nIndex = 0;
606 [ + - ]: 1284 : Sequence< PropertyValue > aMenuItem( PROPERTYCOUNT_MENUITEM );
607 : :
608 : : // Init the property value sequence
609 [ + - ]: 1284 : aMenuItem[ OFFSET_MENUITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
610 [ + - ]: 1284 : aMenuItem[ OFFSET_MENUITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
611 [ + - ]: 1284 : aMenuItem[ OFFSET_MENUITEM_TARGET ].Name = m_aPropNames[ INDEX_TARGET ];
612 [ + - ]: 1284 : aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Name = m_aPropNames[ INDEX_IMAGEIDENTIFIER];
613 [ + - ]: 1284 : aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
614 [ + - ]: 1284 : aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Name = m_aPropNames[ INDEX_SUBMENU ]; // Submenu set!
615 : :
616 [ - + ]: 1284 : for ( sal_uInt32 n = 0; n < nCount; n++ )
617 : : {
618 [ # # ]: 0 : ::rtl::OUString aRootMenuItemNode( aAddonMenuItemNode + aAddonMenuNodeSeq[n] );
619 : :
620 : : // Read the MenuItem
621 [ # # ][ # # ]: 0 : if ( ReadMenuItem( aRootMenuItemNode, aMenuItem ) )
622 : : {
623 : : // Successfully read a menu item, append to our list
624 : 0 : sal_uInt32 nMenuItemCount = rAddonMenuSeq.getLength() + 1;
625 [ # # ]: 0 : rAddonMenuSeq.realloc( nMenuItemCount );
626 [ # # ][ # # ]: 0 : rAddonMenuSeq[nIndex++] = aMenuItem;
627 : : }
628 : 0 : }
629 : :
630 [ + - ][ + - ]: 1284 : return ( rAddonMenuSeq.getLength() > 0 );
631 : : }
632 : :
633 : : //*****************************************************************************************************************
634 : : // private method
635 : : //*****************************************************************************************************************
636 : 1284 : sal_Bool AddonsOptions_Impl::ReadOfficeHelpSet( Sequence< Sequence< PropertyValue > >& rAddonOfficeHelpMenuSeq )
637 : : {
638 : : // Read the AddonMenu set and fill property sequences
639 [ + - ]: 1284 : ::rtl::OUString aAddonHelpMenuNodeName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/OfficeHelp" ));
640 [ + - ]: 1284 : Sequence< ::rtl::OUString > aAddonHelpMenuNodeSeq = GetNodeNames( aAddonHelpMenuNodeName );
641 : 1284 : ::rtl::OUString aAddonHelpMenuItemNode( aAddonHelpMenuNodeName + m_aPathDelimiter );
642 : :
643 : 1284 : sal_uInt32 nCount = aAddonHelpMenuNodeSeq.getLength();
644 : 1284 : sal_uInt32 nIndex = 0;
645 [ + - ]: 1284 : Sequence< PropertyValue > aMenuItem( PROPERTYCOUNT_MENUITEM );
646 : :
647 : : // Init the property value sequence
648 [ + - ]: 1284 : aMenuItem[ OFFSET_MENUITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
649 [ + - ]: 1284 : aMenuItem[ OFFSET_MENUITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
650 [ + - ]: 1284 : aMenuItem[ OFFSET_MENUITEM_TARGET ].Name = m_aPropNames[ INDEX_TARGET ];
651 [ + - ]: 1284 : aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Name = m_aPropNames[ INDEX_IMAGEIDENTIFIER];
652 [ + - ]: 1284 : aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
653 [ + - ]: 1284 : aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Name = m_aPropNames[ INDEX_SUBMENU ]; // Submenu set!
654 : :
655 [ - + ]: 1284 : for ( sal_uInt32 n = 0; n < nCount; n++ )
656 : : {
657 [ # # ]: 0 : ::rtl::OUString aRootMenuItemNode( aAddonHelpMenuItemNode + aAddonHelpMenuNodeSeq[n] );
658 : :
659 : : // Read the MenuItem
660 [ # # ][ # # ]: 0 : if ( ReadMenuItem( aRootMenuItemNode, aMenuItem, sal_True ) )
661 : : {
662 : : // Successfully read a menu item, append to our list
663 : 0 : sal_uInt32 nMenuItemCount = rAddonOfficeHelpMenuSeq.getLength() + 1;
664 [ # # ]: 0 : rAddonOfficeHelpMenuSeq.realloc( nMenuItemCount );
665 [ # # ][ # # ]: 0 : rAddonOfficeHelpMenuSeq[nIndex++] = aMenuItem;
666 : : }
667 : 0 : }
668 : :
669 [ + - ][ + - ]: 1284 : return ( rAddonOfficeHelpMenuSeq.getLength() > 0 );
670 : : }
671 : :
672 : : //*****************************************************************************************************************
673 : : // private method
674 : : //*****************************************************************************************************************
675 : 1284 : sal_Bool AddonsOptions_Impl::ReadOfficeMenuBarSet( Sequence< Sequence< PropertyValue > >& rAddonOfficeMenuBarSeq )
676 : : {
677 : : // Read the OfficeMenuBar set and fill property sequences
678 [ + - ]: 1284 : ::rtl::OUString aAddonMenuBarNodeName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/OfficeMenuBar" ));
679 [ + - ]: 1284 : Sequence< ::rtl::OUString > aAddonMenuBarNodeSeq = GetNodeNames( aAddonMenuBarNodeName );
680 : 1284 : ::rtl::OUString aAddonMenuBarNode( aAddonMenuBarNodeName + m_aPathDelimiter );
681 : :
682 : 1284 : sal_uInt32 nCount = aAddonMenuBarNodeSeq.getLength();
683 : 1284 : sal_uInt32 nIndex = 0;
684 [ + - ]: 1284 : Sequence< PropertyValue > aPopupMenu( PROPERTYCOUNT_POPUPMENU );
685 : :
686 : : // Init the property value sequence
687 [ + - ]: 1284 : aPopupMenu[ OFFSET_POPUPMENU_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
688 [ + - ]: 1284 : aPopupMenu[ OFFSET_POPUPMENU_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT];
689 [ + - ]: 1284 : aPopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Name = m_aPropNames[ INDEX_SUBMENU];
690 [ + - ]: 1284 : aPopupMenu[ OFFSET_POPUPMENU_URL ].Name = m_aPropNames[ INDEX_URL ];
691 : :
692 [ + - ]: 1284 : StringToIndexMap aTitleToIndexMap;
693 : :
694 [ - + ]: 1284 : for ( sal_uInt32 n = 0; n < nCount; n++ )
695 : : {
696 [ # # ]: 0 : ::rtl::OUString aPopupMenuNode( aAddonMenuBarNode + aAddonMenuBarNodeSeq[n] );
697 : :
698 : : // Read the MenuItem
699 [ # # ][ # # ]: 0 : if ( ReadPopupMenu( aPopupMenuNode, aPopupMenu ) )
700 : : {
701 : : // Successfully read a popup menu, append to our list
702 : 0 : ::rtl::OUString aPopupTitle;
703 [ # # ][ # # ]: 0 : if ( aPopupMenu[OFFSET_POPUPMENU_TITLE].Value >>= aPopupTitle )
704 : : {
705 [ # # ]: 0 : StringToIndexMap::const_iterator pIter = aTitleToIndexMap.find( aPopupTitle );
706 [ # # ][ # # ]: 0 : if ( pIter != aTitleToIndexMap.end() )
707 : : {
708 : : // title already there => concat both popup menus
709 [ # # ][ # # ]: 0 : Sequence< PropertyValue >& rOldPopupMenu = rAddonOfficeMenuBarSeq[pIter->second];
710 [ # # ]: 0 : AppendPopupMenu( rOldPopupMenu, aPopupMenu );
711 : : }
712 : : else
713 : : {
714 : : // not found
715 : 0 : sal_uInt32 nMenuItemCount = rAddonOfficeMenuBarSeq.getLength() + 1;
716 [ # # ]: 0 : rAddonOfficeMenuBarSeq.realloc( nMenuItemCount );
717 [ # # ][ # # ]: 0 : rAddonOfficeMenuBarSeq[nIndex] = aPopupMenu;
718 [ # # ]: 0 : aTitleToIndexMap.insert( StringToIndexMap::value_type( aPopupTitle, nIndex ));
719 : 0 : ++nIndex;
720 : : }
721 : 0 : }
722 : : }
723 : 0 : }
724 : :
725 [ + - ][ + - ]: 1284 : return ( rAddonOfficeMenuBarSeq.getLength() > 0 );
[ + - ]
726 : : }
727 : :
728 : : //*****************************************************************************************************************
729 : : // private method
730 : : //*****************************************************************************************************************
731 : 1284 : sal_Bool AddonsOptions_Impl::ReadOfficeToolBarSet( AddonToolBars& rAddonOfficeToolBars, std::vector< rtl::OUString >& rAddonOfficeToolBarResNames )
732 : : {
733 : : // Read the OfficeToolBar set and fill property sequences
734 [ + - ]: 1284 : ::rtl::OUString aAddonToolBarNodeName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/OfficeToolBar" ));
735 [ + - ]: 1284 : Sequence< ::rtl::OUString > aAddonToolBarNodeSeq = GetNodeNames( aAddonToolBarNodeName );
736 : 1284 : ::rtl::OUString aAddonToolBarNode( aAddonToolBarNodeName + m_aPathDelimiter );
737 : :
738 : 1284 : sal_uInt32 nCount = aAddonToolBarNodeSeq.getLength();
739 : :
740 [ - + ]: 1284 : for ( sal_uInt32 n = 0; n < nCount; n++ )
741 : : {
742 [ # # ]: 0 : ::rtl::OUString aToolBarItemNode( aAddonToolBarNode + aAddonToolBarNodeSeq[n] );
743 [ # # ][ # # ]: 0 : rAddonOfficeToolBarResNames.push_back( aAddonToolBarNodeSeq[n] );
744 [ # # ]: 0 : rAddonOfficeToolBars.push_back( m_aEmptyAddonToolBar );
745 [ # # ]: 0 : ReadToolBarItemSet( aToolBarItemNode, rAddonOfficeToolBars[n] );
746 : 0 : }
747 : :
748 [ + - ]: 1284 : return ( !rAddonOfficeToolBars.empty() );
749 : : }
750 : :
751 : :
752 : : //*****************************************************************************************************************
753 : : // private method
754 : : //*****************************************************************************************************************
755 : 0 : sal_Bool AddonsOptions_Impl::ReadToolBarItemSet( const rtl::OUString rToolBarItemSetNodeName, Sequence< Sequence< PropertyValue > >& rAddonOfficeToolBarSeq )
756 : : {
757 : 0 : sal_Bool bInsertSeparator = sal_False;
758 : 0 : sal_uInt32 nToolBarItemCount = rAddonOfficeToolBarSeq.getLength();
759 : 0 : ::rtl::OUString aAddonToolBarItemSetNode( rToolBarItemSetNodeName + m_aPathDelimiter );
760 [ # # ]: 0 : Sequence< ::rtl::OUString > aAddonToolBarItemSetNodeSeq = GetNodeNames( rToolBarItemSetNodeName );
761 [ # # ]: 0 : Sequence< PropertyValue > aToolBarItem( PROPERTYCOUNT_TOOLBARITEM );
762 : :
763 : : // Init the property value sequence
764 [ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
765 [ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
766 [ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Name = m_aPropNames[ INDEX_IMAGEIDENTIFIER];
767 [ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Name = m_aPropNames[ INDEX_TARGET ];
768 [ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
769 [ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_CONTROLTYPE ].Name = m_aPropNames[ INDEX_CONTROLTYPE ];
770 [ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_WIDTH ].Name = m_aPropNames[ INDEX_WIDTH ];
771 : :
772 : 0 : sal_uInt32 nCount = aAddonToolBarItemSetNodeSeq.getLength();
773 [ # # ]: 0 : for ( sal_uInt32 n = 0; n < nCount; n++ )
774 : : {
775 [ # # ]: 0 : ::rtl::OUString aToolBarItemNode( aAddonToolBarItemSetNode + aAddonToolBarItemSetNodeSeq[n] );
776 : :
777 : : // Read the ToolBarItem
778 [ # # ][ # # ]: 0 : if ( ReadToolBarItem( aToolBarItemNode, aToolBarItem ) )
779 : : {
780 [ # # ]: 0 : if ( bInsertSeparator )
781 : : {
782 : 0 : bInsertSeparator = sal_False;
783 [ # # ]: 0 : InsertToolBarSeparator( rAddonOfficeToolBarSeq );
784 : : }
785 : :
786 : : // Successfully read a toolbar item, append to our list
787 : 0 : sal_uInt32 nAddonCount = rAddonOfficeToolBarSeq.getLength();
788 [ # # ]: 0 : rAddonOfficeToolBarSeq.realloc( nAddonCount+1 );
789 [ # # ][ # # ]: 0 : rAddonOfficeToolBarSeq[nAddonCount] = aToolBarItem;
790 : : }
791 : 0 : }
792 : :
793 [ # # ][ # # ]: 0 : return ( (sal_uInt32)rAddonOfficeToolBarSeq.getLength() > nToolBarItemCount );
794 : : }
795 : :
796 : : //*****************************************************************************************************************
797 : : // private method
798 : : //*****************************************************************************************************************
799 : 0 : void AddonsOptions_Impl::InsertToolBarSeparator( Sequence< Sequence< PropertyValue > >& rAddonOfficeToolBarSeq )
800 : : {
801 [ # # ]: 0 : Sequence< PropertyValue > aToolBarItem( PROPERTYCOUNT_TOOLBARITEM );
802 : :
803 [ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
804 [ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
805 [ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Name = m_aPropNames[ INDEX_IMAGEIDENTIFIER];
806 [ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Name = m_aPropNames[ INDEX_TARGET ];
807 [ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
808 : :
809 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_URL ].Value <<= SEPARATOR_URL;
[ # # ]
810 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Value <<= m_aEmpty;
811 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Value <<= m_aEmpty;
812 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Value <<= m_aEmpty;
813 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Value <<= m_aEmpty;
814 : :
815 : 0 : sal_uInt32 nToolBarItemCount = rAddonOfficeToolBarSeq.getLength();
816 [ # # ]: 0 : rAddonOfficeToolBarSeq.realloc( nToolBarItemCount+1 );
817 [ # # ][ # # ]: 0 : rAddonOfficeToolBarSeq[nToolBarItemCount] = aToolBarItem;
[ # # ]
818 : 0 : }
819 : :
820 : : //*****************************************************************************************************************
821 : : // private method
822 : : //*****************************************************************************************************************
823 : 1284 : sal_Bool AddonsOptions_Impl::ReadImages( ImageManager& aImageManager )
824 : : {
825 : : // Read the user-defined Images set and fill image manager
826 [ + - ]: 1284 : ::rtl::OUString aAddonImagesNodeName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/Images" ));
827 [ + - ]: 1284 : Sequence< ::rtl::OUString > aAddonImagesNodeSeq = GetNodeNames( aAddonImagesNodeName );
828 : 1284 : ::rtl::OUString aAddonImagesNode( aAddonImagesNodeName + m_aPathDelimiter );
829 : :
830 : 1284 : sal_uInt32 nCount = aAddonImagesNodeSeq.getLength();
831 : :
832 : : // Init the property value sequence
833 [ + - ]: 1284 : Sequence< ::rtl::OUString > aAddonImageItemNodePropNames( 1 );
834 : 1284 : ::rtl::OUString aURL;
835 : :
836 [ + + ]: 2174 : for ( sal_uInt32 n = 0; n < nCount; n++ )
837 : : {
838 [ + - ]: 890 : ::rtl::OUString aImagesItemNode( aAddonImagesNode + aAddonImagesNodeSeq[n] );
839 : :
840 : : // Create sequence for data access
841 [ + - ]: 890 : ::rtl::OUStringBuffer aBuffer( aImagesItemNode );
842 [ + - ]: 890 : aBuffer.append( m_aPathDelimiter );
843 [ + - ]: 890 : aBuffer.append( m_aPropNames[ OFFSET_MENUITEM_URL ] );
844 [ + - ][ + - ]: 890 : aAddonImageItemNodePropNames[0] = aBuffer.makeStringAndClear();
845 : :
846 [ + - ]: 890 : Sequence< Any > aAddonImageItemNodeValues = GetProperties( aAddonImageItemNodePropNames );
847 : :
848 : : // An user-defined image entry must have an URL. As "ImageIdentifier" has a higher priority
849 : : // we also check if we already have an images association.
850 [ + - ]: 2670 : if (( aAddonImageItemNodeValues[0] >>= aURL ) &&
[ + - + - ]
[ + - ][ + - ]
851 : 890 : !aURL.isEmpty() &&
852 [ + - ]: 890 : !HasAssociatedImages( aURL ))
853 : : {
854 [ + - ]: 890 : ::rtl::OUStringBuffer aBuf( aImagesItemNode );
855 [ + - ]: 890 : aBuf.append( m_aPathDelimiter );
856 [ + - ][ + - ]: 890 : aBuf.append( IMAGES_NODENAME );
857 [ + - ]: 890 : aBuf.append( m_aPathDelimiter );
858 [ + - ]: 890 : ::rtl::OUString aImagesUserDefinedItemNode = aBuf.makeStringAndClear();
859 : :
860 : : // Read a user-defined images data
861 [ + - ]: 890 : ImageEntry* pImageEntry = ReadImageData( aImagesUserDefinedItemNode );
862 [ + - ]: 890 : if ( pImageEntry )
863 : : {
864 : : // Successfully read a user-defined images item, put it into our image manager
865 [ + - ][ + - ]: 890 : aImageManager.insert( ImageManager::value_type( aURL, *pImageEntry ));
[ + - ]
866 [ + - ][ + - ]: 890 : delete pImageEntry; // We have the ownership of the pointer
867 : 890 : }
868 : : }
869 [ + - ]: 890 : }
870 : :
871 [ + - ][ + - ]: 1284 : return sal_True;
872 : : }
873 : :
874 : : //*****************************************************************************************************************
875 : : // private method
876 : : //*****************************************************************************************************************
877 : :
878 : 0 : ::rtl::OUString AddonsOptions_Impl::GeneratePrefixURL()
879 : : {
880 : : // Create an unique prefixed Add-On popup menu URL so it can be identified later as a runtime popup menu.
881 : : // They use a different image manager, so they must be identified by the sfx2/framework code.
882 : 0 : ::rtl::OUString aPopupMenuURL;
883 : 0 : ::rtl::OUStringBuffer aBuf( m_aRootAddonPopupMenuURLPrexfix.getLength() + 3 );
884 [ # # ]: 0 : aBuf.append( m_aRootAddonPopupMenuURLPrexfix );
885 [ # # ]: 0 : aBuf.append( ::rtl::OUString::valueOf( ++m_nRootAddonPopupMenuId ));
886 [ # # ]: 0 : aPopupMenuURL = aBuf.makeStringAndClear();
887 : 0 : return aPopupMenuURL;
888 : : }
889 : :
890 : : //*****************************************************************************************************************
891 : : // private method
892 : : //*****************************************************************************************************************
893 : :
894 : 1284 : sal_Bool AddonsOptions_Impl::ReadMenuMergeInstructions( MergeMenuInstructionContainer& aContainer )
895 : : {
896 [ + - ]: 1284 : const ::rtl::OUString aMenuMergeRootName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/OfficeMenuBarMerging/" ));
897 : :
898 [ + - ]: 1284 : Sequence< ::rtl::OUString > aAddonMergeNodesSeq = GetNodeNames( aMenuMergeRootName );
899 : 1284 : ::rtl::OUString aAddonMergeNode( aMenuMergeRootName );
900 : :
901 : 1284 : sal_uInt32 nCount = aAddonMergeNodesSeq.getLength();
902 : :
903 : : // Init the property value sequence
904 [ + - ]: 1284 : Sequence< ::rtl::OUString > aNodePropNames( 5 );
905 : 1284 : ::rtl::OUString aURL;
906 : :
907 [ + + ]: 2174 : for ( sal_uInt32 i = 0; i < nCount; i++ )
908 : : {
909 [ + - ]: 890 : ::rtl::OUString aMergeAddonInstructions( aAddonMergeNode + aAddonMergeNodesSeq[i] );
910 : :
911 [ + - ]: 890 : Sequence< ::rtl::OUString > aAddonInstMergeNodesSeq = GetNodeNames( aMergeAddonInstructions );
912 : 890 : sal_uInt32 nCountAddons = aAddonInstMergeNodesSeq.getLength();
913 : :
914 [ + + ]: 1780 : for ( sal_uInt32 j = 0; j < nCountAddons; j++ )
915 : : {
916 [ + - ]: 890 : ::rtl::OUStringBuffer aMergeAddonInstructionBase( aMergeAddonInstructions );
917 [ + - ]: 890 : aMergeAddonInstructionBase.append( m_aPathDelimiter );
918 [ + - ][ + - ]: 890 : aMergeAddonInstructionBase.append( aAddonInstMergeNodesSeq[j] );
919 [ + - ]: 890 : aMergeAddonInstructionBase.append( m_aPathDelimiter );
920 : :
921 : : // Create sequence for data access
922 [ + - ]: 890 : ::rtl::OUStringBuffer aBuffer( aMergeAddonInstructionBase );
923 [ + - ]: 890 : aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGEPOINT ] );
924 [ + - ][ + - ]: 890 : aNodePropNames[0] = aBuffer.makeStringAndClear();
925 : :
926 [ + - ]: 890 : aBuffer = aMergeAddonInstructionBase;
927 [ + - ]: 890 : aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECOMMAND ] );
928 [ + - ][ + - ]: 890 : aNodePropNames[1] = aBuffer.makeStringAndClear();
929 : :
930 [ + - ]: 890 : aBuffer = aMergeAddonInstructionBase;
931 [ + - ]: 890 : aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECOMMANDPARAMETER ] );
932 [ + - ][ + - ]: 890 : aNodePropNames[2] = aBuffer.makeStringAndClear();
933 : :
934 [ + - ]: 890 : aBuffer = aMergeAddonInstructionBase;
935 [ + - ]: 890 : aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGEFALLBACK ] );
936 [ + - ][ + - ]: 890 : aNodePropNames[3] = aBuffer.makeStringAndClear();
937 : :
938 [ + - ]: 890 : aBuffer = aMergeAddonInstructionBase;
939 [ + - ]: 890 : aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECONTEXT ] );
940 [ + - ][ + - ]: 890 : aNodePropNames[4] = aBuffer.makeStringAndClear();
941 : :
942 [ + - ]: 890 : Sequence< Any > aNodePropValues = GetProperties( aNodePropNames );
943 : :
944 [ + - ]: 890 : MergeMenuInstruction aMergeMenuInstruction;
945 [ + - ]: 890 : aNodePropValues[0] >>= aMergeMenuInstruction.aMergePoint;
946 [ + - ]: 890 : aNodePropValues[1] >>= aMergeMenuInstruction.aMergeCommand;
947 [ + - ]: 890 : aNodePropValues[2] >>= aMergeMenuInstruction.aMergeCommandParameter;
948 [ + - ]: 890 : aNodePropValues[3] >>= aMergeMenuInstruction.aMergeFallback;
949 [ + - ]: 890 : aNodePropValues[4] >>= aMergeMenuInstruction.aMergeContext;
950 : :
951 [ + - ]: 890 : ::rtl::OUString aMergeMenuBase = aMergeAddonInstructionBase.makeStringAndClear();
952 [ + - ]: 890 : ReadMergeMenuData( aMergeMenuBase, aMergeMenuInstruction.aMergeMenu );
953 : :
954 [ + - ]: 890 : aContainer.push_back( aMergeMenuInstruction );
955 [ + - ][ + - ]: 890 : }
956 [ + - ]: 890 : }
957 : :
958 [ + - ][ + - ]: 1284 : return sal_True;
959 : : }
960 : :
961 : : //*****************************************************************************************************************
962 : : // private method
963 : : //*****************************************************************************************************************
964 : 890 : sal_Bool AddonsOptions_Impl::ReadMergeMenuData( const ::rtl::OUString& aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeMenu )
965 : : {
966 : 890 : ::rtl::OUString aMergeMenuBaseNode( aMergeAddonInstructionBase+m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MENUITEMS ] );
967 : :
968 [ + - ]: 890 : Sequence< ::rtl::OUString > aSubMenuNodeNames = GetNodeNames( aMergeMenuBaseNode );
969 : 890 : aMergeMenuBaseNode += m_aPathDelimiter;
970 : :
971 : : // extend the node names to have full path strings
972 [ + + ]: 2670 : for ( sal_uInt32 i = 0; i < (sal_uInt32)aSubMenuNodeNames.getLength(); i++ )
973 [ + - ][ + - ]: 1780 : aSubMenuNodeNames[i] = ::rtl::OUString( aMergeMenuBaseNode + aSubMenuNodeNames[i] );
974 : :
975 [ + - ][ + - ]: 890 : return ReadSubMenuEntries( aSubMenuNodeNames, rMergeMenu );
976 : : }
977 : :
978 : : //*****************************************************************************************************************
979 : : // private method
980 : : //*****************************************************************************************************************
981 : 1284 : sal_Bool AddonsOptions_Impl::ReadToolbarMergeInstructions( ToolbarMergingInstructions& rCachedToolbarMergingInstructions )
982 : : {
983 [ + - ]: 1284 : const ::rtl::OUString aToolbarMergeRootName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/OfficeToolbarMerging/" ));
984 : :
985 [ + - ]: 1284 : Sequence< ::rtl::OUString > aAddonMergeNodesSeq = GetNodeNames( aToolbarMergeRootName );
986 : 1284 : ::rtl::OUString aAddonMergeNode( aToolbarMergeRootName );
987 : :
988 : 1284 : sal_uInt32 nCount = aAddonMergeNodesSeq.getLength();
989 : :
990 : : // Init the property value sequence
991 [ + - ]: 1284 : Sequence< ::rtl::OUString > aNodePropNames( 6 );
992 : 1284 : ::rtl::OUString aURL;
993 : :
994 [ - + ]: 1284 : for ( sal_uInt32 i = 0; i < nCount; i++ )
995 : : {
996 [ # # ]: 0 : ::rtl::OUString aMergeAddonInstructions( aAddonMergeNode + aAddonMergeNodesSeq[i] );
997 : :
998 [ # # ]: 0 : Sequence< ::rtl::OUString > aAddonInstMergeNodesSeq = GetNodeNames( aMergeAddonInstructions );
999 : 0 : sal_uInt32 nCountAddons = aAddonInstMergeNodesSeq.getLength();
1000 : :
1001 [ # # ]: 0 : for ( sal_uInt32 j = 0; j < nCountAddons; j++ )
1002 : : {
1003 [ # # ]: 0 : ::rtl::OUStringBuffer aMergeAddonInstructionBase( aMergeAddonInstructions );
1004 [ # # ]: 0 : aMergeAddonInstructionBase.append( m_aPathDelimiter );
1005 [ # # ][ # # ]: 0 : aMergeAddonInstructionBase.append( aAddonInstMergeNodesSeq[j] );
1006 [ # # ]: 0 : aMergeAddonInstructionBase.append( m_aPathDelimiter );
1007 : :
1008 : : // Create sequence for data access
1009 [ # # ]: 0 : ::rtl::OUStringBuffer aBuffer( aMergeAddonInstructionBase );
1010 [ # # ]: 0 : aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBAR ] );
1011 [ # # ][ # # ]: 0 : aNodePropNames[0] = aBuffer.makeStringAndClear();
1012 : :
1013 [ # # ]: 0 : aBuffer = aMergeAddonInstructionBase;
1014 [ # # ]: 0 : aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGEPOINT ] );
1015 [ # # ][ # # ]: 0 : aNodePropNames[1] = aBuffer.makeStringAndClear();
1016 : :
1017 [ # # ]: 0 : aBuffer = aMergeAddonInstructionBase;
1018 [ # # ]: 0 : aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECOMMAND ] );
1019 [ # # ][ # # ]: 0 : aNodePropNames[2] = aBuffer.makeStringAndClear();
1020 : :
1021 [ # # ]: 0 : aBuffer = aMergeAddonInstructionBase;
1022 [ # # ]: 0 : aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECOMMANDPARAMETER ] );
1023 [ # # ][ # # ]: 0 : aNodePropNames[3] = aBuffer.makeStringAndClear();
1024 : :
1025 [ # # ]: 0 : aBuffer = aMergeAddonInstructionBase;
1026 [ # # ]: 0 : aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGEFALLBACK ] );
1027 [ # # ][ # # ]: 0 : aNodePropNames[4] = aBuffer.makeStringAndClear();
1028 : :
1029 [ # # ]: 0 : aBuffer = aMergeAddonInstructionBase;
1030 [ # # ]: 0 : aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECONTEXT ] );
1031 [ # # ][ # # ]: 0 : aNodePropNames[5] = aBuffer.makeStringAndClear();
1032 : :
1033 [ # # ]: 0 : Sequence< Any > aNodePropValues = GetProperties( aNodePropNames );
1034 : :
1035 [ # # ]: 0 : MergeToolbarInstruction aMergeToolbarInstruction;
1036 [ # # ]: 0 : aNodePropValues[0] >>= aMergeToolbarInstruction.aMergeToolbar;
1037 [ # # ]: 0 : aNodePropValues[1] >>= aMergeToolbarInstruction.aMergePoint;
1038 [ # # ]: 0 : aNodePropValues[2] >>= aMergeToolbarInstruction.aMergeCommand;
1039 [ # # ]: 0 : aNodePropValues[3] >>= aMergeToolbarInstruction.aMergeCommandParameter;
1040 [ # # ]: 0 : aNodePropValues[4] >>= aMergeToolbarInstruction.aMergeFallback;
1041 [ # # ]: 0 : aNodePropValues[5] >>= aMergeToolbarInstruction.aMergeContext;
1042 : :
1043 : : ReadMergeToolbarData( aMergeAddonInstructionBase.makeStringAndClear(),
1044 [ # # ][ # # ]: 0 : aMergeToolbarInstruction.aMergeToolbarItems );
1045 : :
1046 [ # # ]: 0 : MergeToolbarInstructionContainer& rVector = rCachedToolbarMergingInstructions[ aMergeToolbarInstruction.aMergeToolbar ];
1047 [ # # ]: 0 : rVector.push_back( aMergeToolbarInstruction );
1048 [ # # ][ # # ]: 0 : }
1049 [ # # ]: 0 : }
1050 : :
1051 [ + - ][ + - ]: 1284 : return sal_True;
1052 : : }
1053 : :
1054 : : //*****************************************************************************************************************
1055 : : // private method
1056 : : //*****************************************************************************************************************
1057 : 0 : sal_Bool AddonsOptions_Impl::ReadMergeToolbarData( const ::rtl::OUString& aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeToolbarItems )
1058 : : {
1059 [ # # ]: 0 : ::rtl::OUStringBuffer aBuffer( aMergeAddonInstructionBase );
1060 [ # # ]: 0 : aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBARITEMS ] );
1061 : :
1062 [ # # ]: 0 : ::rtl::OUString aMergeToolbarBaseNode = aBuffer.makeStringAndClear();
1063 : :
1064 [ # # ]: 0 : return ReadToolBarItemSet( aMergeToolbarBaseNode, rMergeToolbarItems );
1065 : : }
1066 : :
1067 : : //*****************************************************************************************************************
1068 : : // private method
1069 : : //*****************************************************************************************************************
1070 : 1780 : sal_Bool AddonsOptions_Impl::ReadMenuItem( const ::rtl::OUString& aMenuNodeName, Sequence< PropertyValue >& aMenuItem, sal_Bool bIgnoreSubMenu )
1071 : : {
1072 : 1780 : sal_Bool bResult = sal_False;
1073 : 1780 : ::rtl::OUString aStrValue;
1074 : 1780 : ::rtl::OUString aAddonMenuItemTreeNode( aMenuNodeName + m_aPathDelimiter );
1075 [ + - ]: 1780 : Sequence< Any > aMenuItemNodePropValues;
1076 : :
1077 [ + - ][ + - ]: 1780 : aMenuItemNodePropValues = GetProperties( GetPropertyNamesMenuItem( aAddonMenuItemTreeNode ) );
[ + - ][ + - ]
[ + - ]
1078 [ + - ][ + + ]: 1780 : if (( aMenuItemNodePropValues[ OFFSET_MENUITEM_TITLE ] >>= aStrValue ) && !aStrValue.isEmpty() )
[ + - ][ + + ]
1079 : : {
1080 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_TITLE ].Value <<= aStrValue;
1081 : :
1082 : 890 : ::rtl::OUString aRootSubMenuName( aAddonMenuItemTreeNode + m_aPropNames[ INDEX_SUBMENU ] );
1083 [ + - ]: 890 : Sequence< ::rtl::OUString > aRootSubMenuNodeNames = GetNodeNames( aRootSubMenuName );
1084 [ - + ][ # # ]: 890 : if ( aRootSubMenuNodeNames.getLength() > 0 && !bIgnoreSubMenu )
[ - + ]
1085 : : {
1086 : : // Set a unique prefixed Add-On popup menu URL so it can be identified later
1087 [ # # ]: 0 : ::rtl::OUString aPopupMenuURL = GeneratePrefixURL();
1088 : 0 : ::rtl::OUString aPopupMenuImageId;
1089 : :
1090 [ # # ]: 0 : aMenuItemNodePropValues[ OFFSET_MENUITEM_IMAGEIDENTIFIER ] >>= aPopupMenuImageId;
1091 [ # # ]: 0 : ReadAndAssociateImages( aPopupMenuURL, aPopupMenuImageId );
1092 : :
1093 : : // A popup menu must have a title and can have a URL and ImageIdentifier
1094 : : // Set the other property values to empty
1095 [ # # ][ # # ]: 0 : aMenuItem[ OFFSET_MENUITEM_URL ].Value <<= aPopupMenuURL;
1096 [ # # ][ # # ]: 0 : aMenuItem[ OFFSET_MENUITEM_TARGET ].Value <<= m_aEmpty;
1097 [ # # ][ # # ]: 0 : aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Value <<= aPopupMenuImageId;
1098 [ # # ][ # # ]: 0 : aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Value <<= aMenuItemNodePropValues[ OFFSET_MENUITEM_CONTEXT ];
[ # # ]
1099 : :
1100 : : // Continue to read the sub menu nodes
1101 [ # # ]: 0 : Sequence< Sequence< PropertyValue > > aSubMenuSeq;
1102 : 0 : ::rtl::OUString aSubMenuRootNodeName( aRootSubMenuName + m_aPathDelimiter );
1103 [ # # ]: 0 : for ( sal_uInt32 n = 0; n < (sal_uInt32)aRootSubMenuNodeNames.getLength(); n++ )
1104 [ # # ][ # # ]: 0 : aRootSubMenuNodeNames[n] = ::rtl::OUString( aSubMenuRootNodeName + aRootSubMenuNodeNames[n] );
1105 [ # # ]: 0 : ReadSubMenuEntries( aRootSubMenuNodeNames, aSubMenuSeq );
1106 [ # # ][ # # ]: 0 : aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Value <<= aSubMenuSeq;
1107 [ # # ]: 0 : bResult = sal_True;
1108 : : }
1109 [ + - ][ + - ]: 890 : else if (( aMenuItemNodePropValues[ OFFSET_MENUITEM_URL ] >>= aStrValue ) && !aStrValue.isEmpty() )
[ + - ][ + - ]
1110 : : {
1111 : : // A simple menu item => read the other properties;
1112 : 890 : ::rtl::OUString aMenuImageId;
1113 : :
1114 [ + - ]: 890 : aMenuItemNodePropValues[ OFFSET_MENUITEM_IMAGEIDENTIFIER ] >>= aMenuImageId;
1115 [ + - ]: 890 : ReadAndAssociateImages( aStrValue, aMenuImageId );
1116 : :
1117 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_URL ].Value <<= aStrValue;
1118 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_TARGET ].Value <<= aMenuItemNodePropValues[ OFFSET_MENUITEM_TARGET ];
[ + - ]
1119 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Value <<= aMenuImageId;
1120 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Value <<= aMenuItemNodePropValues[ OFFSET_MENUITEM_CONTEXT ];
[ + - ]
1121 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Value <<= Sequence< Sequence< PropertyValue > >(); // Submenu set!
[ + - ][ + - ]
1122 : :
1123 : 890 : bResult = sal_True;
1124 [ + - ]: 890 : }
1125 : : }
1126 [ + - ]: 1780 : else if (( aMenuItemNodePropValues[ OFFSET_MENUITEM_URL ] >>= aStrValue ) &&
[ + - + - ]
[ + - ]
1127 : 890 : aStrValue.equalsAsciiL( SEPARATOR_URL_STR, SEPARATOR_URL_LEN ))
1128 : : {
1129 : : // Separator
1130 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_URL ].Value <<= aStrValue;
1131 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_TARGET ].Value <<= m_aEmpty;
1132 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Value <<= m_aEmpty;
1133 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Value <<= m_aEmpty;
1134 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Value <<= Sequence< Sequence< PropertyValue > >(); // Submenu set!
[ + - ][ + - ]
1135 : 890 : bResult = sal_True;
1136 : : }
1137 : :
1138 [ + - ]: 1780 : return bResult;
1139 : : }
1140 : :
1141 : : //*****************************************************************************************************************
1142 : : // private method
1143 : : //*****************************************************************************************************************
1144 : 0 : sal_Bool AddonsOptions_Impl::ReadPopupMenu( const ::rtl::OUString& aPopupMenuNodeName, Sequence< PropertyValue >& aPopupMenu )
1145 : : {
1146 : 0 : sal_Bool bResult = sal_False;
1147 : 0 : ::rtl::OUString aStrValue;
1148 : 0 : ::rtl::OUString aAddonPopupMenuTreeNode( aPopupMenuNodeName + m_aPathDelimiter );
1149 [ # # ]: 0 : Sequence< Any > aPopupMenuNodePropValues;
1150 : :
1151 [ # # ][ # # ]: 0 : aPopupMenuNodePropValues = GetProperties( GetPropertyNamesPopupMenu( aAddonPopupMenuTreeNode ) );
[ # # ][ # # ]
[ # # ]
1152 [ # # ]: 0 : if (( aPopupMenuNodePropValues[ OFFSET_POPUPMENU_TITLE ] >>= aStrValue ) &&
[ # # # # ]
[ # # ]
1153 : 0 : !aStrValue.isEmpty() )
1154 : : {
1155 [ # # ][ # # ]: 0 : aPopupMenu[ OFFSET_POPUPMENU_TITLE ].Value <<= aStrValue;
1156 : :
1157 : 0 : ::rtl::OUString aRootSubMenuName( aAddonPopupMenuTreeNode + m_aPropNames[ INDEX_SUBMENU ] );
1158 [ # # ]: 0 : Sequence< ::rtl::OUString > aRootSubMenuNodeNames = GetNodeNames( aRootSubMenuName );
1159 [ # # ]: 0 : if ( aRootSubMenuNodeNames.getLength() > 0 )
1160 : : {
1161 : : // A top-level popup menu needs a title
1162 : : // Set a unique prefixed Add-On popup menu URL so it can be identified later
1163 [ # # ]: 0 : ::rtl::OUString aPopupMenuURL = GeneratePrefixURL();
1164 : :
1165 [ # # ][ # # ]: 0 : aPopupMenu[ OFFSET_POPUPMENU_URL ].Value <<= aPopupMenuURL;
1166 [ # # ][ # # ]: 0 : aPopupMenu[ OFFSET_POPUPMENU_CONTEXT ].Value <<= aPopupMenuNodePropValues[ OFFSET_POPUPMENU_CONTEXT ];
[ # # ]
1167 : :
1168 : : // Continue to read the sub menu nodes
1169 [ # # ]: 0 : Sequence< Sequence< PropertyValue > > aSubMenuSeq;
1170 : 0 : ::rtl::OUString aSubMenuRootNodeName( aRootSubMenuName + m_aPathDelimiter );
1171 [ # # ]: 0 : for ( sal_uInt32 n = 0; n < (sal_uInt32)aRootSubMenuNodeNames.getLength(); n++ )
1172 [ # # ][ # # ]: 0 : aRootSubMenuNodeNames[n] = ::rtl::OUString( aSubMenuRootNodeName + aRootSubMenuNodeNames[n] );
1173 [ # # ]: 0 : ReadSubMenuEntries( aRootSubMenuNodeNames, aSubMenuSeq );
1174 [ # # ][ # # ]: 0 : aPopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Value <<= aSubMenuSeq;
1175 [ # # ]: 0 : bResult = sal_True;
1176 [ # # ]: 0 : }
1177 : : }
1178 : :
1179 [ # # ]: 0 : return bResult;
1180 : : }
1181 : :
1182 : : //*****************************************************************************************************************
1183 : : // private method
1184 : : //*****************************************************************************************************************
1185 : 0 : sal_Bool AddonsOptions_Impl::AppendPopupMenu( Sequence< PropertyValue >& rTargetPopupMenu, const Sequence< PropertyValue >& rSourcePopupMenu )
1186 : : {
1187 [ # # ]: 0 : Sequence< Sequence< PropertyValue > > aTargetSubMenuSeq;
1188 [ # # ]: 0 : Sequence< Sequence< PropertyValue > > aSourceSubMenuSeq;
1189 : :
1190 [ # # ][ # # ]: 0 : if (( rTargetPopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Value >>= aTargetSubMenuSeq ) &&
[ # # ][ # # ]
[ # # ]
1191 [ # # ]: 0 : ( rSourcePopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Value >>= aSourceSubMenuSeq ))
1192 : : {
1193 : 0 : sal_uInt32 nIndex = aTargetSubMenuSeq.getLength();
1194 [ # # ]: 0 : aTargetSubMenuSeq.realloc( nIndex + aSourceSubMenuSeq.getLength() );
1195 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < sal_uInt32( aSourceSubMenuSeq.getLength() ); i++ )
1196 [ # # ][ # # ]: 0 : aTargetSubMenuSeq[nIndex++] = aSourceSubMenuSeq[i];
[ # # ]
1197 [ # # ][ # # ]: 0 : rTargetPopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Value <<= aTargetSubMenuSeq;
1198 : : }
1199 : :
1200 [ # # ][ # # ]: 0 : return sal_True;
1201 : : }
1202 : :
1203 : : //*****************************************************************************************************************
1204 : : // private method
1205 : : //*****************************************************************************************************************
1206 : 0 : sal_Bool AddonsOptions_Impl::ReadToolBarItem( const ::rtl::OUString& aToolBarItemNodeName, Sequence< PropertyValue >& aToolBarItem )
1207 : : {
1208 : 0 : sal_Bool bResult = sal_False;
1209 : 0 : ::rtl::OUString aTitle;
1210 : 0 : ::rtl::OUString aURL;
1211 : 0 : ::rtl::OUString aAddonToolBarItemTreeNode( aToolBarItemNodeName + m_aPathDelimiter );
1212 [ # # ]: 0 : Sequence< Any > aToolBarItemNodePropValues;
1213 : :
1214 [ # # ][ # # ]: 0 : aToolBarItemNodePropValues = GetProperties( GetPropertyNamesToolBarItem( aAddonToolBarItemTreeNode ) );
[ # # ][ # # ]
[ # # ]
1215 : :
1216 : : // A toolbar item must have a command URL
1217 [ # # ][ # # ]: 0 : if (( aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_URL ] >>= aURL ) && !aURL.isEmpty() )
[ # # ][ # # ]
1218 : : {
1219 [ # # ][ # # ]: 0 : if ( aURL.equals( SEPARATOR_URL ))
1220 : : {
1221 : : // A speparator toolbar item only needs a URL
1222 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_URL ].Value <<= aURL;
1223 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Value <<= m_aEmpty;
1224 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Value <<= m_aEmpty;
1225 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Value <<= m_aEmpty;
1226 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Value <<= m_aEmpty;
1227 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_CONTROLTYPE ].Value <<= m_aEmpty;
1228 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_WIDTH ].Value <<= sal_Int32( 0 );
1229 : :
1230 : 0 : bResult = sal_True;
1231 : : }
1232 [ # # ][ # # ]: 0 : else if (( aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_TITLE ] >>= aTitle ) && !aTitle.isEmpty() )
[ # # ][ # # ]
1233 : : {
1234 : : // A normal toolbar item must also have title => read the other properties;
1235 : 0 : ::rtl::OUString aImageId;
1236 : :
1237 : : // Try to map a user-defined image URL to our internal private image URL
1238 [ # # ]: 0 : aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ] >>= aImageId;
1239 [ # # ]: 0 : ReadAndAssociateImages( aURL, aImageId );
1240 : :
1241 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_URL ].Value <<= aURL;
1242 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Value <<= aTitle;
1243 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Value <<= aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_TARGET ];
[ # # ]
1244 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Value <<= aImageId;
1245 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Value <<= aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_CONTEXT ];
[ # # ]
1246 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_CONTROLTYPE ].Value <<= aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_CONTROLTYPE ];
[ # # ]
1247 : :
1248 : : // Configuration uses hyper for long. Therefore transform into sal_Int32
1249 : 0 : sal_Int64 nValue( 0 );
1250 [ # # ]: 0 : aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_WIDTH ] >>= nValue;
1251 [ # # ][ # # ]: 0 : aToolBarItem[ OFFSET_TOOLBARITEM_WIDTH ].Value <<= sal_Int32( nValue );
1252 : :
1253 : 0 : bResult = sal_True;
1254 : : }
1255 : : }
1256 : :
1257 [ # # ]: 0 : return bResult;
1258 : : }
1259 : :
1260 : : //*****************************************************************************************************************
1261 : : // private method
1262 : : //*****************************************************************************************************************
1263 : 890 : sal_Bool AddonsOptions_Impl::ReadSubMenuEntries( const Sequence< ::rtl::OUString >& aSubMenuNodeNames, Sequence< Sequence< PropertyValue > >& rSubMenuSeq )
1264 : : {
1265 [ + - ]: 890 : Sequence< PropertyValue > aMenuItem( PROPERTYCOUNT_MENUITEM );
1266 : :
1267 : : // Init the property value sequence
1268 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_URL ].Name = PROPERTYNAME_URL;
1269 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_TITLE ].Name = PROPERTYNAME_TITLE;
1270 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_TARGET ].Name = PROPERTYNAME_TARGET;
1271 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Name = PROPERTYNAME_IMAGEIDENTIFIER;
1272 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Name = PROPERTYNAME_CONTEXT;
1273 [ + - ][ + - ]: 890 : aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Name = PROPERTYNAME_SUBMENU; // Submenu set!
1274 : :
1275 : 890 : sal_uInt32 nIndex = 0;
1276 : 890 : sal_uInt32 nCount = aSubMenuNodeNames.getLength();
1277 [ + + ]: 2670 : for ( sal_uInt32 n = 0; n < nCount; n++ )
1278 : : {
1279 [ + - ][ + - ]: 1780 : if ( ReadMenuItem( aSubMenuNodeNames[n], aMenuItem ))
1280 : : {
1281 : 1780 : sal_uInt32 nSubMenuCount = rSubMenuSeq.getLength() + 1;
1282 [ + - ]: 1780 : rSubMenuSeq.realloc( nSubMenuCount );
1283 [ + - ][ + - ]: 1780 : rSubMenuSeq[nIndex++] = aMenuItem;
1284 : : }
1285 : : }
1286 : :
1287 [ + - ]: 890 : return sal_True;
1288 : : }
1289 : :
1290 : : //*****************************************************************************************************************
1291 : : // private method
1292 : : //*****************************************************************************************************************
1293 : 890 : sal_Bool AddonsOptions_Impl::HasAssociatedImages( const ::rtl::OUString& aURL )
1294 : : {
1295 [ + - ]: 890 : ImageManager::const_iterator pIter = m_aImageManager.find( aURL );
1296 [ + - ]: 890 : return ( pIter != m_aImageManager.end() );
1297 : : }
1298 : :
1299 : : //*****************************************************************************************************************
1300 : : // private method
1301 : : //*****************************************************************************************************************
1302 : 3560 : void AddonsOptions_Impl::SubstituteVariables( ::rtl::OUString& aURL )
1303 : : {
1304 [ + - + - ]: 7120 : if (( aURL.compareToAscii( RTL_CONSTASCII_STRINGPARAM( EXPAND_PROTOCOL )) == 0 ) &&
[ + - ]
1305 : 3560 : m_xMacroExpander.is() )
1306 : : {
1307 : : // cut protocol
1308 : 3560 : ::rtl::OUString macro( aURL.copy( sizeof ( EXPAND_PROTOCOL ) -1 ) );
1309 : : // decode uric class chars
1310 : : macro = ::rtl::Uri::decode(
1311 : 3560 : macro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
1312 : : // expand macro string
1313 [ + - ][ + - ]: 3560 : aURL = m_xMacroExpander->expandMacros( macro );
1314 : : }
1315 : 3560 : }
1316 : :
1317 : : //*****************************************************************************************************************
1318 : : // private method
1319 : : //*****************************************************************************************************************
1320 : 3560 : void AddonsOptions_Impl::ReadImageFromURL( ImageSize nImageSize, const ::rtl::OUString& aImageURL, Image& aImage, Image& aImageNoScale )
1321 : : {
1322 [ + - ]: 3560 : SvStream* pStream = UcbStreamHelper::CreateStream( aImageURL, STREAM_STD_READ );
1323 [ + + ][ + + ]: 3560 : if ( pStream && ( pStream->GetErrorCode() == 0 ))
[ + - ]
1324 : : {
1325 : : // Use graphic class to also support more graphic formats (bmp,png,...)
1326 [ + - ]: 1780 : Graphic aGraphic;
1327 : :
1328 [ + - ]: 1780 : GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
1329 [ + - ][ + - ]: 1780 : rGF.ImportGraphic( aGraphic, String(), *pStream, GRFILTER_FORMAT_DONTKNOW );
[ + - ]
1330 : :
1331 [ + - ]: 1780 : BitmapEx aBitmapEx = aGraphic.GetBitmapEx();
1332 : :
1333 [ + + ]: 1780 : const Size aSize = ( nImageSize == IMGSIZE_SMALL ) ? aImageSizeSmall : aImageSizeBig; // Sizes used for menu/toolbox images
1334 : :
1335 : 1780 : Size aBmpSize = aBitmapEx.GetSizePixel();
1336 [ + - ][ + - ]: 1780 : if ( aBmpSize.Width() > 0 && aBmpSize.Height() > 0 )
[ + - ]
1337 : : {
1338 : : // Support non-transparent bitmaps to be downward compatible with OOo 1.1.x addons
1339 [ + - ][ - + ]: 1780 : if( !aBitmapEx.IsTransparent() )
1340 [ # # ][ # # ]: 0 : aBitmapEx = BitmapEx( aBitmapEx.GetBitmap(), COL_LIGHTMAGENTA );
[ # # ][ # # ]
[ # # ]
1341 : :
1342 : : // A non-scaled bitmap can have a flexible width, but must have a defined height!
1343 : 1780 : Size aNoScaleSize( aBmpSize.Width(), aSize.Height() );
1344 [ - + ]: 1780 : if ( aBmpSize != aNoScaleSize )
1345 : : {
1346 [ # # ]: 0 : BitmapEx aNoScaleBmp( aBitmapEx );
1347 [ # # ][ # # ]: 0 : aNoScaleBmp.Scale( aNoScaleSize, BMP_SCALE_BEST );
1348 : : }
1349 : : else
1350 [ + - ][ + - ]: 1780 : aImageNoScale = Image( aBitmapEx );
[ + - ]
1351 : :
1352 [ - + ]: 1780 : if ( aBmpSize != aSize )
1353 [ # # ]: 0 : aBitmapEx.Scale( aSize, BMP_SCALE_BEST );
1354 : :
1355 [ + - ][ + - ]: 1780 : aImage = Image( aBitmapEx );
[ + - ]
1356 [ + - ][ + - ]: 1780 : }
1357 : : }
1358 : :
1359 [ + - ]: 3560 : delete pStream;
1360 : 3560 : }
1361 : :
1362 : : //*****************************************************************************************************************
1363 : : // private method
1364 : : //*****************************************************************************************************************
1365 : 890 : void AddonsOptions_Impl::ReadAndAssociateImages( const ::rtl::OUString& aURL, const ::rtl::OUString& aImageId )
1366 : : {
1367 : 890 : const int MAX_NUM_IMAGES = 2;
1368 : 890 : const char* aExtArray[MAX_NUM_IMAGES] = { "_16", "_26" };
1369 : 890 : const char* pBmpExt = ".bmp";
1370 : :
1371 [ - + ]: 890 : if ( aImageId.isEmpty() )
1372 : 890 : return;
1373 : :
1374 : 0 : bool bImageFound = true;
1375 [ # # ]: 0 : ImageEntry aImageEntry;
1376 : 0 : ::rtl::OUString aImageURL( aImageId );
1377 : :
1378 [ # # ]: 0 : SubstituteVariables( aImageURL );
1379 : :
1380 : : // Loop to create the four possible image names and try to read the bitmap files
1381 [ # # ]: 0 : for ( int i = 0; i < MAX_NUM_IMAGES; i++ )
1382 : : {
1383 [ # # ]: 0 : ::rtl::OUStringBuffer aFileURL( aImageURL );
1384 [ # # ]: 0 : aFileURL.appendAscii( aExtArray[i] );
1385 [ # # ]: 0 : aFileURL.appendAscii( pBmpExt );
1386 : :
1387 [ # # ]: 0 : Image aImage;
1388 [ # # ]: 0 : Image aImageNoScale;
1389 [ # # ][ # # ]: 0 : ReadImageFromURL( ((i==0)||(i==2)) ? IMGSIZE_SMALL : IMGSIZE_BIG, aFileURL.makeStringAndClear(), aImage, aImageNoScale );
[ # # ][ # # ]
1390 [ # # ]: 0 : if ( !!aImage )
1391 : : {
1392 : 0 : bImageFound = true;
1393 [ # # # ]: 0 : switch ( i )
1394 : : {
1395 : : case 0:
1396 [ # # ]: 0 : aImageEntry.aImageSmall = aImage;
1397 [ # # ]: 0 : aImageEntry.aImageSmallNoScale = aImageNoScale;
1398 : 0 : break;
1399 : : case 1:
1400 [ # # ]: 0 : aImageEntry.aImageBig = aImage;
1401 [ # # ]: 0 : aImageEntry.aImageBigNoScale = aImageNoScale;
1402 : 0 : break;
1403 : : }
1404 : : }
1405 [ # # ][ # # ]: 0 : }
1406 : :
1407 [ # # ]: 0 : if ( bImageFound )
1408 [ # # ][ # # ]: 890 : m_aImageManager.insert( ImageManager::value_type( aURL, aImageEntry ));
[ # # ][ # # ]
1409 : : }
1410 : :
1411 : : //*****************************************************************************************************************
1412 : : // private method
1413 : : //*****************************************************************************************************************
1414 : 890 : AddonsOptions_Impl::ImageEntry* AddonsOptions_Impl::ReadImageData( const ::rtl::OUString& aImagesNodeName )
1415 : : {
1416 [ + - ]: 890 : Sequence< ::rtl::OUString > aImageDataNodeNames = GetPropertyNamesImages( aImagesNodeName );
1417 [ + - ]: 890 : Sequence< Any > aPropertyData;
1418 [ + - ]: 890 : Sequence< sal_Int8 > aImageDataSeq;
1419 : 890 : ::rtl::OUString aImageURL;
1420 : :
1421 : 890 : ImageEntry* pEntry = NULL;
1422 : :
1423 : : // It is possible to use both forms (embedded image data and URLs to external bitmap files) at the
1424 : : // same time. Embedded image data has a higher priority.
1425 [ + - ][ + - ]: 890 : aPropertyData = GetProperties( aImageDataNodeNames );
[ + - ]
1426 [ + + ]: 8010 : for ( int i = 0; i < PROPERTYCOUNT_IMAGES; i++ )
1427 : : {
1428 [ + + ]: 7120 : if ( i < PROPERTYCOUNT_EMBEDDED_IMAGES )
1429 : : {
1430 : : // Extract image data from the embedded hex binary sequence
1431 [ + - ]: 3560 : Image aImage;
1432 [ + - ][ + - ]: 3560 : if (( aPropertyData[i] >>= aImageDataSeq ) &&
[ - + # # ]
[ # # ][ - + ]
1433 : 0 : aImageDataSeq.getLength() > 0 &&
1434 : : ( CreateImageFromSequence( aImage,
1435 : : ( i == OFFSET_IMAGES_BIG ),
1436 [ # # ]: 0 : aImageDataSeq )) )
1437 : : {
1438 [ # # ]: 0 : if ( !pEntry )
1439 [ # # ][ # # ]: 0 : pEntry = new ImageEntry;
1440 : :
1441 [ # # ]: 0 : if ( i == OFFSET_IMAGES_SMALL )
1442 [ # # ]: 0 : pEntry->aImageSmall = aImage;
1443 [ # # ]: 0 : else if ( i == OFFSET_IMAGES_BIG )
1444 [ # # ]: 0 : pEntry->aImageBig = aImage;
1445 [ + - ]: 3560 : }
1446 : : }
1447 : : else
1448 : : {
1449 : : // Retrieve image data from a external bitmap file. Make sure that embedded image data
1450 : : // has a higher priority.
1451 [ + - ]: 3560 : aPropertyData[i] >>= aImageURL;
1452 : :
1453 [ + - ]: 3560 : if ( !aImageURL.isEmpty() )
1454 : : {
1455 [ + - ]: 3560 : Image aImage;
1456 [ + - ]: 3560 : Image aImageNoScale;
1457 : :
1458 [ + - ]: 3560 : SubstituteVariables( aImageURL );
1459 : : ReadImageFromURL( ((i==OFFSET_IMAGES_SMALL_URL)||(i==OFFSET_IMAGES_SMALLHC_URL)) ? IMGSIZE_SMALL : IMGSIZE_BIG,
1460 [ + + ][ + + ]: 3560 : aImageURL, aImage, aImageNoScale );
[ + - ]
1461 [ + + ]: 3560 : if ( !!aImage )
1462 : : {
1463 [ + + ]: 1780 : if ( !pEntry )
1464 [ + - ][ + - ]: 890 : pEntry = new ImageEntry;
1465 : :
1466 [ + + ][ + - ]: 1780 : if ( i == OFFSET_IMAGES_SMALL_URL && !pEntry->aImageSmall )
[ + + ]
1467 : : {
1468 [ + - ]: 890 : pEntry->aImageSmall = aImage;
1469 [ + - ]: 890 : pEntry->aImageSmallNoScale = aImageNoScale;
1470 : : }
1471 [ + - ]: 890 : else if ( !pEntry->aImageBig )
1472 : : {
1473 [ + - ]: 890 : pEntry->aImageBig = aImage;
1474 [ + - ]: 890 : pEntry->aImageBigNoScale = aImageNoScale;
1475 : : }
1476 [ + - ][ + - ]: 3560 : }
1477 : : }
1478 : : }
1479 : : }
1480 : :
1481 [ + - ][ + - ]: 890 : return pEntry;
[ + - ]
1482 : : }
1483 : :
1484 : : //*****************************************************************************************************************
1485 : : // private method
1486 : : //*****************************************************************************************************************
1487 : 0 : sal_Bool AddonsOptions_Impl::CreateImageFromSequence( Image& rImage, sal_Bool bBig, Sequence< sal_Int8 >& rBitmapDataSeq ) const
1488 : : {
1489 : 0 : sal_Bool bResult = sal_False;
1490 [ # # ]: 0 : Size aSize = bBig ? aImageSizeBig : aImageSizeSmall; // Sizes used for menu/toolbox images
1491 : :
1492 [ # # ]: 0 : if ( rBitmapDataSeq.getLength() > 0 )
1493 : : {
1494 [ # # ][ # # ]: 0 : SvMemoryStream aMemStream( rBitmapDataSeq.getArray(), rBitmapDataSeq.getLength(), STREAM_STD_READ );
1495 [ # # ]: 0 : BitmapEx aBitmapEx;
1496 : :
1497 [ # # ]: 0 : aMemStream >> aBitmapEx;
1498 : :
1499 : : // Scale bitmap to fit the correct size for the menu/toolbar. Use best quality
1500 [ # # ]: 0 : if ( aBitmapEx.GetSizePixel() != aSize )
1501 [ # # ]: 0 : aBitmapEx.Scale( aSize, BMP_SCALE_BEST );
1502 : :
1503 [ # # ][ # # ]: 0 : if( !aBitmapEx.IsTransparent() )
1504 : : {
1505 : : // Support non-transparent bitmaps to be downward compatible with OOo 1.1.x addons
1506 [ # # ][ # # ]: 0 : aBitmapEx = BitmapEx( aBitmapEx.GetBitmap(), COL_LIGHTMAGENTA );
[ # # ][ # # ]
[ # # ]
1507 : : }
1508 : :
1509 [ # # ][ # # ]: 0 : rImage = Image( aBitmapEx );
[ # # ]
1510 [ # # ][ # # ]: 0 : bResult = sal_True;
1511 : : }
1512 : :
1513 : 0 : return bResult;
1514 : : }
1515 : :
1516 : 1780 : Sequence< ::rtl::OUString > AddonsOptions_Impl::GetPropertyNamesMenuItem( const ::rtl::OUString& aPropertyRootNode ) const
1517 : : {
1518 : 1780 : Sequence< ::rtl::OUString > lResult( PROPERTYCOUNT_MENUITEM );
1519 : :
1520 : : // Create property names dependent from the root node name
1521 [ + - ]: 1780 : lResult[OFFSET_MENUITEM_URL] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_URL ] );
1522 [ + - ]: 1780 : lResult[OFFSET_MENUITEM_TITLE] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_TITLE ] );
1523 [ + - ]: 1780 : lResult[OFFSET_MENUITEM_IMAGEIDENTIFIER] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_IMAGEIDENTIFIER ] );
1524 [ + - ]: 1780 : lResult[OFFSET_MENUITEM_TARGET] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_TARGET ] );
1525 [ + - ]: 1780 : lResult[OFFSET_MENUITEM_CONTEXT] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ] );
1526 [ + - ]: 1780 : lResult[OFFSET_MENUITEM_SUBMENU] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_SUBMENU ] );
1527 : :
1528 : 1780 : return lResult;
1529 : : }
1530 : :
1531 : : //*****************************************************************************************************************
1532 : : // private method
1533 : : //*****************************************************************************************************************
1534 : 0 : Sequence< ::rtl::OUString > AddonsOptions_Impl::GetPropertyNamesPopupMenu( const ::rtl::OUString& aPropertyRootNode ) const
1535 : : {
1536 : : // The URL is automatically set and not read from the configuration.
1537 : 0 : Sequence< ::rtl::OUString > lResult( PROPERTYCOUNT_POPUPMENU-1 );
1538 : :
1539 : : // Create property names dependent from the root node name
1540 [ # # ]: 0 : lResult[OFFSET_POPUPMENU_TITLE] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_TITLE ] );
1541 [ # # ]: 0 : lResult[OFFSET_POPUPMENU_CONTEXT] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ] );
1542 [ # # ]: 0 : lResult[OFFSET_POPUPMENU_SUBMENU] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_SUBMENU ] );
1543 : :
1544 : 0 : return lResult;
1545 : : }
1546 : :
1547 : : //*****************************************************************************************************************
1548 : : // private method
1549 : : //*****************************************************************************************************************
1550 : 0 : Sequence< ::rtl::OUString > AddonsOptions_Impl::GetPropertyNamesToolBarItem( const ::rtl::OUString& aPropertyRootNode ) const
1551 : : {
1552 : 0 : Sequence< ::rtl::OUString > lResult( PROPERTYCOUNT_TOOLBARITEM );
1553 : :
1554 : : // Create property names dependent from the root node name
1555 [ # # ]: 0 : lResult[0] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_URL ] );
1556 [ # # ]: 0 : lResult[1] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_TITLE ] );
1557 [ # # ]: 0 : lResult[2] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_IMAGEIDENTIFIER] );
1558 [ # # ]: 0 : lResult[3] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_TARGET ] );
1559 [ # # ]: 0 : lResult[4] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ] );
1560 [ # # ]: 0 : lResult[5] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_CONTROLTYPE ] );
1561 [ # # ]: 0 : lResult[6] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_WIDTH ] );
1562 : :
1563 : 0 : return lResult;
1564 : : }
1565 : :
1566 : : //*****************************************************************************************************************
1567 : : // private method
1568 : : //*****************************************************************************************************************
1569 : 890 : Sequence< ::rtl::OUString > AddonsOptions_Impl::GetPropertyNamesImages( const ::rtl::OUString& aPropertyRootNode ) const
1570 : : {
1571 : 890 : Sequence< ::rtl::OUString > lResult( PROPERTYCOUNT_IMAGES );
1572 : :
1573 : : // Create property names dependent from the root node name
1574 [ + - ]: 890 : lResult[0] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALL ] );
1575 [ + - ]: 890 : lResult[1] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIG ] );
1576 [ + - ]: 890 : lResult[2] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALLHC ] );
1577 [ + - ]: 890 : lResult[3] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIGHC ] );
1578 [ + - ]: 890 : lResult[4] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALL_URL ] );
1579 [ + - ]: 890 : lResult[5] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIG_URL ] );
1580 [ + - ]: 890 : lResult[6] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALLHC_URL] );
1581 [ + - ]: 890 : lResult[7] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIGHC_URL ] );
1582 : :
1583 : 890 : return lResult;
1584 : : }
1585 : :
1586 : : //*****************************************************************************************************************
1587 : : // initialize static member
1588 : : // DON'T DO IT IN YOUR HEADER!
1589 : : // see definition for further informations
1590 : : //*****************************************************************************************************************
1591 : : AddonsOptions_Impl* AddonsOptions::m_pDataContainer = NULL ;
1592 : : sal_Int32 AddonsOptions::m_nRefCount = 0 ;
1593 : :
1594 : : //*****************************************************************************************************************
1595 : : // constructor
1596 : : //*****************************************************************************************************************
1597 : 11371 : AddonsOptions::AddonsOptions()
1598 : : {
1599 : : // Global access, must be guarded (multithreading!).
1600 [ + - ][ + - ]: 11371 : MutexGuard aGuard( GetOwnStaticMutex() );
1601 : : // Increase ouer refcount ...
1602 : 11371 : ++m_nRefCount;
1603 : : // ... and initialize ouer data container only if it not already exist!
1604 [ + + ]: 11371 : if( m_pDataContainer == NULL )
1605 : : {
1606 [ + - ][ + - ]: 1284 : m_pDataContainer = new AddonsOptions_Impl;
1607 [ + - ]: 11371 : }
1608 : 11371 : }
1609 : :
1610 : : //*****************************************************************************************************************
1611 : : // destructor
1612 : : //*****************************************************************************************************************
1613 : 11280 : AddonsOptions::~AddonsOptions()
1614 : : {
1615 : : // Global access, must be guarded (multithreading!)
1616 [ + - ][ + - ]: 11280 : MutexGuard aGuard( GetOwnStaticMutex() );
1617 : : // Decrease ouer refcount.
1618 : 11280 : --m_nRefCount;
1619 : : // If last instance was deleted ...
1620 : : // we must destroy ouer static data container!
1621 [ + + ]: 11280 : if( m_nRefCount <= 0 )
1622 : : {
1623 [ + - ][ + - ]: 1274 : delete m_pDataContainer;
1624 : 1274 : m_pDataContainer = NULL;
1625 [ + - ]: 11280 : }
1626 : 11280 : }
1627 : :
1628 : : //*****************************************************************************************************************
1629 : : // public method
1630 : : //*****************************************************************************************************************
1631 : 1159 : sal_Bool AddonsOptions::HasAddonsMenu() const
1632 : : {
1633 [ + - ][ + - ]: 1159 : MutexGuard aGuard( GetOwnStaticMutex() );
1634 [ + - ][ + - ]: 1159 : return m_pDataContainer->HasAddonsMenu();
1635 : : }
1636 : :
1637 : : //*****************************************************************************************************************
1638 : : // public method
1639 : : //*****************************************************************************************************************
1640 : :
1641 : 3518 : sal_Int32 AddonsOptions::GetAddonsToolBarCount() const
1642 : : {
1643 [ + - ][ + - ]: 3518 : MutexGuard aGuard( GetOwnStaticMutex() );
1644 [ + - ]: 3518 : return m_pDataContainer->GetAddonsToolBarCount();
1645 : : }
1646 : :
1647 : : //*****************************************************************************************************************
1648 : : // public method
1649 : : //*****************************************************************************************************************
1650 : 0 : const Sequence< Sequence< PropertyValue > >& AddonsOptions::GetAddonsMenu() const
1651 : : {
1652 [ # # ][ # # ]: 0 : MutexGuard aGuard( GetOwnStaticMutex() );
1653 [ # # ]: 0 : return m_pDataContainer->GetAddonsMenu();
1654 : : }
1655 : :
1656 : : //*****************************************************************************************************************
1657 : : // public method
1658 : : //*****************************************************************************************************************
1659 : 1159 : const Sequence< Sequence< PropertyValue > >& AddonsOptions::GetAddonsMenuBarPart() const
1660 : : {
1661 [ + - ][ + - ]: 1159 : MutexGuard aGuard( GetOwnStaticMutex() );
1662 [ + - ]: 1159 : return m_pDataContainer->GetAddonsMenuBarPart();
1663 : : }
1664 : :
1665 : : //*****************************************************************************************************************
1666 : : // public method
1667 : : //*****************************************************************************************************************
1668 : 0 : const Sequence< Sequence< PropertyValue > >& AddonsOptions::GetAddonsToolBarPart( sal_uInt32 nIndex ) const
1669 : : {
1670 [ # # ][ # # ]: 0 : MutexGuard aGuard( GetOwnStaticMutex() );
1671 [ # # ][ # # ]: 0 : return m_pDataContainer->GetAddonsToolBarPart( nIndex );
1672 : : }
1673 : :
1674 : : //*****************************************************************************************************************
1675 : : // public method
1676 : : //*****************************************************************************************************************
1677 : 0 : const ::rtl::OUString AddonsOptions::GetAddonsToolbarResourceName( sal_uInt32 nIndex ) const
1678 : : {
1679 [ # # ][ # # ]: 0 : MutexGuard aGuard( GetOwnStaticMutex() );
1680 [ # # ][ # # ]: 0 : return m_pDataContainer->GetAddonsToolbarResourceName( nIndex );
1681 : : }
1682 : :
1683 : : //*****************************************************************************************************************
1684 : : // public method
1685 : : //*****************************************************************************************************************
1686 : 1159 : const Sequence< Sequence< PropertyValue > >& AddonsOptions::GetAddonsHelpMenu() const
1687 : : {
1688 [ + - ][ + - ]: 1159 : MutexGuard aGuard( GetOwnStaticMutex() );
1689 [ + - ]: 1159 : return m_pDataContainer->GetAddonsHelpMenu();
1690 : : }
1691 : :
1692 : : //*****************************************************************************************************************
1693 : : // public method
1694 : : //*****************************************************************************************************************
1695 : 1159 : const MergeMenuInstructionContainer& AddonsOptions::GetMergeMenuInstructions() const
1696 : : {
1697 [ + - ][ + - ]: 1159 : MutexGuard aGuard( GetOwnStaticMutex() );
1698 [ + - ]: 1159 : return m_pDataContainer->GetMergeMenuInstructions();
1699 : : }
1700 : :
1701 : : //*****************************************************************************************************************
1702 : : // public method
1703 : : //*****************************************************************************************************************
1704 : 2548 : bool AddonsOptions::GetMergeToolbarInstructions(
1705 : : const ::rtl::OUString& rToolbarName,
1706 : : MergeToolbarInstructionContainer& rToolbarInstructions ) const
1707 : : {
1708 [ + - ][ + - ]: 2548 : MutexGuard aGuard( GetOwnStaticMutex() );
1709 : : return m_pDataContainer->GetMergeToolbarInstructions(
1710 [ + - ][ + - ]: 2548 : rToolbarName, rToolbarInstructions );
1711 : : }
1712 : :
1713 : : //*****************************************************************************************************************
1714 : : // public method
1715 : : //*****************************************************************************************************************
1716 : 1343 : Image AddonsOptions::GetImageFromURL( const rtl::OUString& aURL, sal_Bool bBig, sal_Bool bNoScale ) const
1717 : : {
1718 [ + - ][ + - ]: 1343 : MutexGuard aGuard( GetOwnStaticMutex() );
1719 [ + - ][ + - ]: 1343 : return m_pDataContainer->GetImageFromURL( aURL, bBig, bNoScale );
1720 : : }
1721 : :
1722 : : //*****************************************************************************************************************
1723 : : // public method
1724 : : //*****************************************************************************************************************
1725 : 1343 : Image AddonsOptions::GetImageFromURL( const rtl::OUString& aURL, sal_Bool bBig ) const
1726 : : {
1727 : 1343 : return GetImageFromURL( aURL, bBig, sal_False );
1728 : : }
1729 : :
1730 : : //*****************************************************************************************************************
1731 : : // private method
1732 : : //*****************************************************************************************************************
1733 : 34696 : Mutex& AddonsOptions::GetOwnStaticMutex()
1734 : : {
1735 : : // Initialize static mutex only for one time!
1736 : : static Mutex* pMutex = NULL;
1737 : : // If these method first called (Mutex not already exist!) ...
1738 [ + + ]: 34696 : if( pMutex == NULL )
1739 : : {
1740 : : // ... we must create a new one. Protect follow code with the global mutex -
1741 : : // It must be - we create a static variable!
1742 [ + - ][ + - ]: 113 : MutexGuard aGuard( Mutex::getGlobalMutex() );
1743 : : // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
1744 [ + - ]: 113 : if( pMutex == NULL )
1745 : : {
1746 : : // Create the new mutex and set it for return on static variable.
1747 [ + - ][ + - ]: 113 : static Mutex aMutex;
[ + - ][ # # ]
1748 : 113 : pMutex = &aMutex;
1749 [ + - ]: 113 : }
1750 : : }
1751 : : // Return new created or already existing mutex object.
1752 : 34696 : return *pMutex;
1753 : : }
1754 : :
1755 : : //*****************************************************************************************************************
1756 : : // private method
1757 : : //*****************************************************************************************************************
1758 : 0 : IMPL_STATIC_LINK_NOINSTANCE( AddonsOptions, Notify, void*, EMPTYARG )
1759 : : {
1760 [ # # ][ # # ]: 0 : MutexGuard aGuard( GetOwnStaticMutex() );
1761 [ # # ]: 0 : m_pDataContainer->ReadConfigurationData();
1762 [ # # ]: 0 : return 0;
1763 : : }
1764 : :
1765 [ + - ][ + - ]: 735 : }
1766 : :
1767 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|