Update ooo320-m1
[ooovba.git] / framework / source / classes / addonsoptions.cxx
blobb94d47c988f7c8b36f3d5f36bcfe0f0c709219bd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: addonsoptions.cxx,v $
10 * $Revision: 1.17 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
34 //_________________________________________________________________________________________________________________
35 // includes
36 //_________________________________________________________________________________________________________________
37 #include <classes/addonsoptions.hxx>
38 #include <unotools/configmgr.hxx>
39 #include <unotools/configitem.hxx>
40 #include <unotools/ucbstreamhelper.hxx>
41 #include <tools/debug.hxx>
42 #include <tools/stream.hxx>
43 #include <tools/color.hxx>
44 #include <com/sun/star/uno/Any.hxx>
45 #include <com/sun/star/uno/Sequence.hxx>
46 #include "com/sun/star/util/XMacroExpander.hpp"
47 #include "com/sun/star/uno/XComponentContext.hpp"
48 #include "com/sun/star/beans/XPropertySet.hpp"
49 #include <rtl/ustrbuf.hxx>
50 #include <rtl/uri.hxx>
51 #include <comphelper/processfactory.hxx>
52 #include <vcl/graph.hxx>
53 #include <svtools/filter.hxx>
55 #include <hash_map>
56 #include <algorithm>
57 #include <vector>
59 //_________________________________________________________________________________________________________________
60 // namespaces
61 //_________________________________________________________________________________________________________________
63 using namespace ::std ;
64 using namespace ::utl ;
65 using namespace ::osl ;
66 using namespace ::com::sun::star::uno ;
67 using namespace ::com::sun::star::beans ;
68 using namespace ::com::sun::star::lang ;
70 //_________________________________________________________________________________________________________________
71 // const
72 //_________________________________________________________________________________________________________________
74 #define ROOTNODE_ADDONMENU ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Addons" ))
75 #define PATHDELIMITER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/" ))
76 #define TOOLBARITEMS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ToolBarItems" ))
77 #define SEPARATOR_URL_STR "private:separator"
78 #define SEPARATOR_URL_LEN 17
79 #define SEPARATOR_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SEPARATOR_URL_STR ))
81 #define PROPERTYNAME_URL ADDONSMENUITEM_PROPERTYNAME_URL
82 #define PROPERTYNAME_TITLE ADDONSMENUITEM_PROPERTYNAME_TITLE
83 #define PROPERTYNAME_TARGET ADDONSMENUITEM_PROPERTYNAME_TARGET
84 #define PROPERTYNAME_IMAGEIDENTIFIER ADDONSMENUITEM_PROPERTYNAME_IMAGEIDENTIFIER
85 #define PROPERTYNAME_CONTEXT ADDONSMENUITEM_PROPERTYNAME_CONTEXT
86 #define PROPERTYNAME_SUBMENU ADDONSMENUITEM_PROPERTYNAME_SUBMENU
87 #define PROPERTYNAME_CONTROLTYPE ADDONSMENUITEM_PROPERTYNAME_CONTROLTYPE
88 #define PROPERTYNAME_WIDTH ADDONSMENUITEM_PROPERTYNAME_WIDTH
90 #define PROPERTYNAME_IMAGESMALL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageSmall" ))
91 #define PROPERTYNAME_IMAGEBIG ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageBig" ))
92 #define PROPERTYNAME_IMAGESMALLHC ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageSmallHC" ))
93 #define PROPERTYNAME_IMAGEBIGHC ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageBigHC" ))
94 #define PROPERTYNAME_IMAGESMALL_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageSmallURL" ))
95 #define PROPERTYNAME_IMAGEBIG_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageBigURL" ))
96 #define PROPERTYNAME_IMAGESMALLHC_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageSmallHCURL" ))
97 #define PROPERTYNAME_IMAGEBIGHC_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageBigHCURL" ))
99 #define IMAGES_NODENAME ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UserDefinedImages" ))
100 #define PRIVATE_IMAGE_URL ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:image/" ))
102 #define PROPERTYNAME_MERGEMENU_MERGEPOINT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergePoint" ))
103 #define PROPERTYNAME_MERGEMENU_MERGECOMMAND ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeCommand" ))
104 #define PROPERTYNAME_MERGEMENU_MERGECOMMANDPARAMETER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeCommandParameter" ))
105 #define PROPERTYNAME_MERGEMENU_MERGEFALLBACK ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeFallback" ))
106 #define PROPERTYNAME_MERGEMENU_MERGECONTEXT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeContext" ))
107 #define PROPERTYNAME_MERGEMENU_MENUITEMS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MenuItems" ))
108 #define MERGEMENU_MERGEPOINT_SEPARATOR '\\'
110 #define PROPERTYNAME_MERGETOOLBAR_TOOLBAR ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeToolBar" ))
111 #define PROPERTYNAME_MERGETOOLBAR_MERGEPOINT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergePoint" ))
112 #define PROPERTYNAME_MERGETOOLBAR_MERGECOMMAND ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeCommand" ))
113 #define PROPERTYNAME_MERGETOOLBAR_MERGECOMMANDPARAMETER ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeCommandParameter" ))
114 #define PROPERTYNAME_MERGETOOLBAR_MERGEFALLBACK ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeFallback" ))
115 #define PROPERTYNAME_MERGETOOLBAR_MERGECONTEXT ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MergeContext" ))
116 #define PROPERTYNAME_MERGETOOLBAR_TOOLBARITEMS ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ToolBarItems" ))
118 // The following order is mandatory. Please add properties at the end!
119 #define INDEX_URL 0
120 #define INDEX_TITLE 1
121 #define INDEX_IMAGEIDENTIFIER 2
122 #define INDEX_TARGET 3
123 #define INDEX_CONTEXT 4
124 #define INDEX_SUBMENU 5
125 #define INDEX_CONTROLTYPE 6
126 #define INDEX_WIDTH 7
127 #define PROPERTYCOUNT_INDEX 8
129 // The following order is mandatory. Please add properties at the end!
130 #define PROPERTYCOUNT_MENUITEM 6
131 #define OFFSET_MENUITEM_URL 0
132 #define OFFSET_MENUITEM_TITLE 1
133 #define OFFSET_MENUITEM_IMAGEIDENTIFIER 2
134 #define OFFSET_MENUITEM_TARGET 3
135 #define OFFSET_MENUITEM_CONTEXT 4
136 #define OFFSET_MENUITEM_SUBMENU 5
138 // The following order is mandatory. Please add properties at the end!
139 #define PROPERTYCOUNT_POPUPMENU 4
140 #define OFFSET_POPUPMENU_TITLE 0
141 #define OFFSET_POPUPMENU_CONTEXT 1
142 #define OFFSET_POPUPMENU_SUBMENU 2
143 #define OFFSET_POPUPMENU_URL 3 // Used for property set
145 // The following order is mandatory. Please add properties at the end!
146 #define PROPERTYCOUNT_TOOLBARITEM 7
147 #define OFFSET_TOOLBARITEM_URL 0
148 #define OFFSET_TOOLBARITEM_TITLE 1
149 #define OFFSET_TOOLBARITEM_IMAGEIDENTIFIER 2
150 #define OFFSET_TOOLBARITEM_TARGET 3
151 #define OFFSET_TOOLBARITEM_CONTEXT 4
152 #define OFFSET_TOOLBARITEM_CONTROLTYPE 5
153 #define OFFSET_TOOLBARITEM_WIDTH 6
155 // The following order is mandatory. Please add properties at the end!
156 #define PROPERTYCOUNT_IMAGES 8
157 #define PROPERTYCOUNT_EMBEDDED_IMAGES 4
158 #define OFFSET_IMAGES_SMALL 0
159 #define OFFSET_IMAGES_BIG 1
160 #define OFFSET_IMAGES_SMALLHC 2
161 #define OFFSET_IMAGES_BIGHC 3
162 #define OFFSET_IMAGES_SMALL_URL 4
163 #define OFFSET_IMAGES_BIG_URL 5
164 #define OFFSET_IMAGES_SMALLHC_URL 6
165 #define OFFSET_IMAGES_BIGHC_URL 7
167 #define PROPERTYCOUNT_MERGE_MENUBAR 6
168 #define OFFSET_MERGEMENU_MERGEPOINT 0
169 #define OFFSET_MERGEMENU_MERGECOMMAND 1
170 #define OFFSET_MERGEMENU_MERGECOMMANDPARAMETER 2
171 #define OFFSET_MERGEMENU_MERGEFALLBACK 3
172 #define OFFSET_MERGEMENU_MERGECONTEXT 4
173 #define OFFSET_MERGEMENU_MENUITEMS 5
175 #define PROPERTYCOUNT_MERGE_TOOLBAR 7
176 #define OFFSET_MERGETOOLBAR_TOOLBAR 0
177 #define OFFSET_MERGETOOLBAR_MERGEPOINT 1
178 #define OFFSET_MERGETOOLBAR_MERGECOMMAND 2
179 #define OFFSET_MERGETOOLBAR_MERGECOMMANDPARAMETER 3
180 #define OFFSET_MERGETOOLBAR_MERGEFALLBACK 4
181 #define OFFSET_MERGETOOLBAR_MERGECONTEXT 5
182 #define OFFSET_MERGETOOLBAR_TOOLBARITEMS 6
184 #define EXPAND_PROTOCOL "vnd.sun.star.expand:"
186 const Size aImageSizeSmall( 16, 16 );
187 const Size aImageSizeBig( 26, 26 );
189 //_________________________________________________________________________________________________________________
190 // private declarations!
191 //_________________________________________________________________________________________________________________
193 /*-****************************************************************************************************************
194 @descr struct to hold information about one menu entry.
195 ****************************************************************************************************************-*/
197 namespace framework
200 class AddonsOptions_Impl : public ConfigItem
202 //-------------------------------------------------------------------------------------------------------------
203 // public methods
204 //-------------------------------------------------------------------------------------------------------------
206 public:
207 //---------------------------------------------------------------------------------------------------------
208 // constructor / destructor
209 //---------------------------------------------------------------------------------------------------------
211 AddonsOptions_Impl();
212 ~AddonsOptions_Impl();
214 //---------------------------------------------------------------------------------------------------------
215 // overloaded methods of baseclass
216 //---------------------------------------------------------------------------------------------------------
218 /*-****************************************************************************************************//**
219 @short called for notify of configmanager
220 @descr These method is called from the ConfigManager before application ends or from the
221 PropertyChangeListener if the sub tree broadcasts changes. You must update your
222 internal values.
224 @seealso baseclass ConfigItem
226 @param "lPropertyNames" is the list of properties which should be updated.
227 @return -
229 @onerror -
230 *//*-*****************************************************************************************************/
232 virtual void Notify( const Sequence< ::rtl::OUString >& lPropertyNames );
234 /*-****************************************************************************************************//**
235 @short write changes to configuration
236 @descr These method writes the changed values into the sub tree
237 and should always called in our destructor to guarantee consistency of config data.
239 @seealso baseclass ConfigItem
241 @param -
242 @return -
244 @onerror -
245 *//*-*****************************************************************************************************/
247 virtual void Commit();
249 //---------------------------------------------------------------------------------------------------------
250 // public interface
251 //---------------------------------------------------------------------------------------------------------
253 /*-****************************************************************************************************//**
254 @short base implementation of public interface for "SvtDynamicMenuOptions"!
255 @descr These class is used as static member of "SvtDynamicMenuOptions" ...
256 => The code exist only for one time and isn't duplicated for every instance!
258 @seealso -
260 @param -
261 @return -
263 @onerror -
264 *//*-*****************************************************************************************************/
266 sal_Bool HasAddonsMenu () const ;
267 sal_Bool HasAddonsHelpMenu () const ;
268 sal_Int32 GetAddonsToolBarCount() const ;
269 const Sequence< Sequence< PropertyValue > >& GetAddonsMenu () const ;
270 const Sequence< Sequence< PropertyValue > >& GetAddonsMenuBarPart () const ;
271 const Sequence< Sequence< PropertyValue > >& GetAddonsToolBarPart ( sal_uInt32 nIndex ) const ;
272 const ::rtl::OUString GetAddonsToolbarResourceName( sal_uInt32 nIndex ) const;
273 const Sequence< Sequence< PropertyValue > >& GetAddonsHelpMenu () const ;
274 Image GetImageFromURL( const rtl::OUString& aURL, sal_Bool bBig, sal_Bool bHiContrast, sal_Bool bNoScale ) const;
275 const MergeMenuInstructionContainer& GetMergeMenuInstructions() const;
276 bool GetMergeToolbarInstructions( const ::rtl::OUString& rToolbarName, MergeToolbarInstructionContainer& rToolbarInstructions ) const;
278 void ReadConfigurationData();
280 //-------------------------------------------------------------------------------------------------------------
281 // private methods
282 //-------------------------------------------------------------------------------------------------------------
284 private:
285 struct OUStringHashCode
287 size_t operator()( const ::rtl::OUString& sString ) const
289 return sString.hashCode();
293 struct ImageEntry
295 Image aImageSmall;
296 Image aImageBig;
297 Image aImageSmallHC;
298 Image aImageBigHC;
300 Image aImageSmallNoScale;
301 Image aImageBigNoScale;
302 Image aImageSmallHCNoScale;
303 Image aImageBigHCNoScale;
306 typedef std::hash_map< ::rtl::OUString, ImageEntry, OUStringHashCode, ::std::equal_to< ::rtl::OUString > > ImageManager;
307 typedef std::hash_map< ::rtl::OUString, sal_uInt32, OUStringHashCode, ::std::equal_to< ::rtl::OUString > > StringToIndexMap;
308 typedef std::vector< Sequence< Sequence< PropertyValue > > > AddonToolBars;
309 typedef ::std::hash_map< ::rtl::OUString, MergeToolbarInstructionContainer, OUStringHashCode, ::std::equal_to< ::rtl::OUString > > ToolbarMergingInstructions;
311 enum ImageSize
313 IMGSIZE_SMALL,
314 IMGSIZE_BIG
317 /*-****************************************************************************************************//**
318 @short return list of key names of our configuration management which represent oue module tree
319 @descr These methods return the current list of key names! We need it to get needed values from our
320 configuration management!
322 @seealso -
324 @param "nCount" , returns count of menu entries for "new"
325 @return A list of configuration key names is returned.
327 @onerror -
328 *//*-*****************************************************************************************************/
330 sal_Bool ReadAddonMenuSet( Sequence< Sequence< PropertyValue > >& aAddonMenuSeq );
331 sal_Bool ReadOfficeMenuBarSet( Sequence< Sequence< PropertyValue > >& aAddonOfficeMenuBarSeq );
332 sal_Bool ReadOfficeToolBarSet( AddonToolBars& rAddonOfficeToolBars, std::vector< rtl::OUString >& rAddonOfficeToolBarResNames );
333 sal_Bool ReadToolBarItemSet( const rtl::OUString rToolBarItemSetNodeName, Sequence< Sequence< PropertyValue > >& aAddonOfficeToolBarSeq );
334 sal_Bool ReadOfficeHelpSet( Sequence< Sequence< PropertyValue > >& aAddonOfficeHelpMenuSeq );
335 sal_Bool ReadImages( ImageManager& aImageManager );
336 sal_Bool ReadMenuMergeInstructions( MergeMenuInstructionContainer& rContainer );
337 sal_Bool ReadToolbarMergeInstructions( ToolbarMergingInstructions& rToolbarMergeMap );
339 sal_Bool ReadMergeMenuData( const ::rtl::OUString& aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeMenu );
340 sal_Bool ReadMergeToolbarData( const ::rtl::OUString& aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeToolbarItems );
341 sal_Bool ReadMenuItem( const ::rtl::OUString& aMenuItemNodeName, Sequence< PropertyValue >& aMenuItem, sal_Bool bIgnoreSubMenu = sal_False );
342 sal_Bool ReadPopupMenu( const ::rtl::OUString& aPopupMenuNodeName, Sequence< PropertyValue >& aPopupMenu );
343 sal_Bool AppendPopupMenu( Sequence< PropertyValue >& aTargetPopupMenu, const Sequence< PropertyValue >& rSourcePopupMenu );
344 sal_Bool ReadToolBarItem( const ::rtl::OUString& aToolBarItemNodeName, Sequence< PropertyValue >& aToolBarItem );
345 sal_Bool ReadImagesItem( const ::rtl::OUString& aImagesItemNodeName, Sequence< PropertyValue >& aImagesItem );
346 ImageEntry* ReadImageData( const ::rtl::OUString& aImagesNodeName );
347 void ReadAndAssociateImages( const ::rtl::OUString& aURL, const ::rtl::OUString& aImageId );
348 void ReadImageFromURL( ImageSize nImageSize, const ::rtl::OUString& aURL, Image& aImage, Image& aNoScaleImage );
349 sal_Bool HasAssociatedImages( const ::rtl::OUString& aURL );
350 void SubstituteVariables( ::rtl::OUString& aURL );
352 sal_Bool ReadSubMenuEntries( const Sequence< ::rtl::OUString >& aSubMenuNodeNames, Sequence< Sequence< PropertyValue > >& rSubMenu );
353 void InsertToolBarSeparator( Sequence< Sequence< PropertyValue > >& rAddonOfficeToolBarSeq );
354 ::rtl::OUString GeneratePrefixURL();
356 Sequence< ::rtl::OUString > GetPropertyNamesMergeMenuInstruction( const ::rtl::OUString& aPropertyRootName ) const;
357 Sequence< ::rtl::OUString > GetPropertyNamesMenuItem( const ::rtl::OUString& aPropertyRootNode ) const;
358 Sequence< ::rtl::OUString > GetPropertyNamesPopupMenu( const ::rtl::OUString& aPropertyRootNode ) const;
359 Sequence< ::rtl::OUString > GetPropertyNamesToolBarItem( const ::rtl::OUString& aPropertyRootNode ) const;
360 Sequence< ::rtl::OUString > GetPropertyNamesImages( const ::rtl::OUString& aPropertyRootNode ) const;
361 sal_Bool CreateImageFromSequence( Image& rImage, sal_Bool bBig, Sequence< sal_Int8 >& rBitmapDataSeq ) const;
363 //-------------------------------------------------------------------------------------------------------------
364 // private member
365 //-------------------------------------------------------------------------------------------------------------
367 private:
368 ImageEntry* ReadOptionalImageData( const ::rtl::OUString& aMenuNodeName );
370 sal_Int32 m_nRootAddonPopupMenuId;
371 ::rtl::OUString m_aPropNames[PROPERTYCOUNT_INDEX];
372 ::rtl::OUString m_aPropImagesNames[PROPERTYCOUNT_IMAGES];
373 ::rtl::OUString m_aPropMergeMenuNames[PROPERTYCOUNT_MERGE_MENUBAR];
374 ::rtl::OUString m_aPropMergeToolbarNames[PROPERTYCOUNT_MERGE_TOOLBAR];
375 ::rtl::OUString m_aEmpty;
376 ::rtl::OUString m_aPathDelimiter;
377 ::rtl::OUString m_aSeparator;
378 ::rtl::OUString m_aRootAddonPopupMenuURLPrexfix;
379 ::rtl::OUString m_aPrivateImageURL;
380 Sequence< Sequence< PropertyValue > > m_aCachedMenuProperties;
381 Sequence< Sequence< PropertyValue > > m_aCachedMenuBarPartProperties;
382 AddonToolBars m_aCachedToolBarPartProperties;
383 std::vector< rtl::OUString > m_aCachedToolBarPartResourceNames;
384 Sequence< Sequence< PropertyValue > > m_aCachedHelpMenuProperties;
385 Reference< com::sun::star::util::XMacroExpander > m_xMacroExpander;
386 ImageManager m_aImageManager;
387 Sequence< Sequence< PropertyValue > > m_aEmptyAddonToolBar;
388 MergeMenuInstructionContainer m_aCachedMergeMenuInsContainer;
389 ToolbarMergingInstructions m_aCachedToolbarMergingInstructions;
392 //_________________________________________________________________________________________________________________
393 // definitions
394 //_________________________________________________________________________________________________________________
396 //*****************************************************************************************************************
397 // constructor
398 //*****************************************************************************************************************
399 AddonsOptions_Impl::AddonsOptions_Impl()
400 // Init baseclasses first
401 : ConfigItem( ROOTNODE_ADDONMENU ),
402 m_nRootAddonPopupMenuId( 0 ),
403 m_aPathDelimiter( PATHDELIMITER ),
404 m_aSeparator( SEPARATOR_URL ),
405 m_aRootAddonPopupMenuURLPrexfix( ADDONSPOPUPMENU_URL_PREFIX ),
406 m_aPrivateImageURL( PRIVATE_IMAGE_URL )
408 // initialize array with fixed property names
409 m_aPropNames[ INDEX_URL ] = PROPERTYNAME_URL;
410 m_aPropNames[ INDEX_TITLE ] = PROPERTYNAME_TITLE;
411 m_aPropNames[ INDEX_TARGET ] = PROPERTYNAME_TARGET;
412 m_aPropNames[ INDEX_IMAGEIDENTIFIER ] = PROPERTYNAME_IMAGEIDENTIFIER;
413 m_aPropNames[ INDEX_CONTEXT ] = PROPERTYNAME_CONTEXT;
414 m_aPropNames[ INDEX_SUBMENU ] = PROPERTYNAME_SUBMENU; // Submenu set!
415 m_aPropNames[ INDEX_CONTROLTYPE ] = PROPERTYNAME_CONTROLTYPE;
416 m_aPropNames[ INDEX_WIDTH ] = PROPERTYNAME_WIDTH;
418 // initialize array with fixed images property names
419 m_aPropImagesNames[ OFFSET_IMAGES_SMALL ] = PROPERTYNAME_IMAGESMALL;
420 m_aPropImagesNames[ OFFSET_IMAGES_BIG ] = PROPERTYNAME_IMAGEBIG;
421 m_aPropImagesNames[ OFFSET_IMAGES_SMALLHC ] = PROPERTYNAME_IMAGESMALLHC;
422 m_aPropImagesNames[ OFFSET_IMAGES_BIGHC ] = PROPERTYNAME_IMAGEBIGHC;
423 m_aPropImagesNames[ OFFSET_IMAGES_SMALL_URL ] = PROPERTYNAME_IMAGESMALL_URL;
424 m_aPropImagesNames[ OFFSET_IMAGES_BIG_URL ] = PROPERTYNAME_IMAGEBIG_URL;
425 m_aPropImagesNames[ OFFSET_IMAGES_SMALLHC_URL ] = PROPERTYNAME_IMAGESMALLHC_URL;
426 m_aPropImagesNames[ OFFSET_IMAGES_BIGHC_URL ] = PROPERTYNAME_IMAGEBIGHC_URL;
428 // initialize array with fixed merge menu property names
429 m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGEPOINT ] = PROPERTYNAME_MERGEMENU_MERGEPOINT;
430 m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECOMMAND ] = PROPERTYNAME_MERGEMENU_MERGECOMMAND;
431 m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECOMMANDPARAMETER ] = PROPERTYNAME_MERGEMENU_MERGECOMMANDPARAMETER;
432 m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGEFALLBACK ] = PROPERTYNAME_MERGEMENU_MERGEFALLBACK;
433 m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECONTEXT ] = PROPERTYNAME_MERGEMENU_MERGECONTEXT;
434 m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MENUITEMS ] = PROPERTYNAME_MERGEMENU_MENUITEMS;
436 m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBAR ] = PROPERTYNAME_MERGETOOLBAR_TOOLBAR;
437 m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGEPOINT ] = PROPERTYNAME_MERGETOOLBAR_MERGEPOINT;
438 m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECOMMAND ] = PROPERTYNAME_MERGETOOLBAR_MERGECOMMAND;
439 m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECOMMANDPARAMETER ] = PROPERTYNAME_MERGETOOLBAR_MERGECOMMANDPARAMETER;
440 m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGEFALLBACK ] = PROPERTYNAME_MERGETOOLBAR_MERGEFALLBACK;
441 m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECONTEXT ] = PROPERTYNAME_MERGETOOLBAR_MERGECONTEXT;
442 m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBARITEMS ] = PROPERTYNAME_MERGETOOLBAR_TOOLBARITEMS;
444 Reference< XComponentContext > xContext;
445 Reference< com::sun::star::beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
446 xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xContext;
447 if ( xContext.is() )
449 m_xMacroExpander = Reference< com::sun::star::util::XMacroExpander >( xContext->getValueByName(
450 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.util.theMacroExpander"))),
451 UNO_QUERY );
454 ReadConfigurationData();
456 // Enable notification mechanism of ouer baseclass.
457 // We need it to get information about changes outside these class on ouer used configuration keys!
458 Sequence< rtl::OUString > aNotifySeq( 1 );
459 aNotifySeq[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AddonUI" ));
460 EnableNotification( aNotifySeq );
463 //*****************************************************************************************************************
464 // destructor
465 //*****************************************************************************************************************
466 AddonsOptions_Impl::~AddonsOptions_Impl()
468 // We must save our current values .. if user forget it!
469 if( IsModified() == sal_True )
471 Commit();
475 void AddonsOptions_Impl::ReadConfigurationData()
477 // reset members to be read again from configuration
478 m_aCachedMenuProperties = Sequence< Sequence< PropertyValue > >();
479 m_aCachedMenuBarPartProperties = Sequence< Sequence< PropertyValue > >();
480 m_aCachedToolBarPartProperties = AddonToolBars();
481 m_aCachedHelpMenuProperties = Sequence< Sequence< PropertyValue > >();
482 m_aCachedToolBarPartResourceNames.clear();
483 m_aImageManager = ImageManager();
485 ReadAddonMenuSet( m_aCachedMenuProperties );
486 ReadOfficeMenuBarSet( m_aCachedMenuBarPartProperties );
487 ReadOfficeToolBarSet( m_aCachedToolBarPartProperties, m_aCachedToolBarPartResourceNames );
488 ReadOfficeHelpSet( m_aCachedHelpMenuProperties );
489 ReadImages( m_aImageManager );
491 m_aCachedMergeMenuInsContainer.clear();
492 m_aCachedToolbarMergingInstructions.clear();
494 ReadMenuMergeInstructions( m_aCachedMergeMenuInsContainer );
495 ReadToolbarMergeInstructions( m_aCachedToolbarMergingInstructions );
498 //*****************************************************************************************************************
499 // public method
500 //*****************************************************************************************************************
501 void AddonsOptions_Impl::Notify( const Sequence< ::rtl::OUString >& /*lPropertyNames*/ )
503 Application::PostUserEvent( STATIC_LINK( 0, AddonsOptions, Notify ) );
506 //*****************************************************************************************************************
507 // public method
508 //*****************************************************************************************************************
509 void AddonsOptions_Impl::Commit()
511 DBG_ERROR( "AddonsOptions_Impl::Commit()\nNot implemented yet!\n" );
514 //*****************************************************************************************************************
515 // public method
516 //*****************************************************************************************************************
517 sal_Bool AddonsOptions_Impl::HasAddonsMenu() const
519 return ( m_aCachedMenuProperties.getLength() > 0 );
522 //*****************************************************************************************************************
523 // public method
524 //*****************************************************************************************************************
525 sal_Bool AddonsOptions_Impl::HasAddonsHelpMenu () const
527 return ( m_aCachedHelpMenuProperties.getLength() > 0 );
530 //*****************************************************************************************************************
531 // public method
532 //*****************************************************************************************************************
533 sal_Int32 AddonsOptions_Impl::GetAddonsToolBarCount() const
535 return m_aCachedToolBarPartProperties.size();
538 //*****************************************************************************************************************
539 // public method
540 //*****************************************************************************************************************
541 const Sequence< Sequence< PropertyValue > >& AddonsOptions_Impl::GetAddonsMenu() const
543 return m_aCachedMenuProperties;
546 //*****************************************************************************************************************
547 // public method
548 //*****************************************************************************************************************
549 const Sequence< Sequence< PropertyValue > >& AddonsOptions_Impl::GetAddonsMenuBarPart() const
551 return m_aCachedMenuBarPartProperties;
554 //*****************************************************************************************************************
555 // public method
556 //*****************************************************************************************************************
557 const Sequence< Sequence< PropertyValue > >& AddonsOptions_Impl::GetAddonsToolBarPart( sal_uInt32 nIndex ) const
559 if ( /*nIndex >= 0 &&*/ nIndex < m_aCachedToolBarPartProperties.size() )
560 return m_aCachedToolBarPartProperties[nIndex];
561 else
562 return m_aEmptyAddonToolBar;
565 //*****************************************************************************************************************
566 // public method
567 //*****************************************************************************************************************
568 const ::rtl::OUString AddonsOptions_Impl::GetAddonsToolbarResourceName( sal_uInt32 nIndex ) const
570 if ( nIndex < m_aCachedToolBarPartResourceNames.size() )
571 return m_aCachedToolBarPartResourceNames[nIndex];
572 else
573 return rtl::OUString();
576 //*****************************************************************************************************************
577 // public method
578 //*****************************************************************************************************************
579 const Sequence< Sequence< PropertyValue > >& AddonsOptions_Impl::GetAddonsHelpMenu () const
581 return m_aCachedHelpMenuProperties;
584 //*****************************************************************************************************************
585 // public method
586 //*****************************************************************************************************************
587 const MergeMenuInstructionContainer& AddonsOptions_Impl::GetMergeMenuInstructions() const
589 return m_aCachedMergeMenuInsContainer;
592 //*****************************************************************************************************************
593 // public method
594 //*****************************************************************************************************************
595 bool AddonsOptions_Impl::GetMergeToolbarInstructions(
596 const ::rtl::OUString& rToolbarName,
597 MergeToolbarInstructionContainer& rToolbarInstructions ) const
599 ToolbarMergingInstructions::const_iterator pIter = m_aCachedToolbarMergingInstructions.find( rToolbarName );
600 if ( pIter != m_aCachedToolbarMergingInstructions.end() )
602 rToolbarInstructions = pIter->second;
603 return true;
605 else
606 return false;
609 //*****************************************************************************************************************
610 // public method
611 //*****************************************************************************************************************
612 Image AddonsOptions_Impl::GetImageFromURL( const rtl::OUString& aURL, sal_Bool bBig, sal_Bool bHiContrast, sal_Bool bNoScale ) const
614 Image aImage;
616 ImageManager::const_iterator pIter = m_aImageManager.find( aURL );
617 if ( pIter != m_aImageManager.end() )
619 if ( !bHiContrast )
621 if ( bNoScale )
622 aImage = ( bBig ? pIter->second.aImageBigNoScale : pIter->second.aImageSmallNoScale );
623 if ( !aImage )
624 aImage = ( bBig ? pIter->second.aImageBig : pIter->second.aImageSmall );
626 else
628 if ( bNoScale )
629 aImage = ( bBig ? pIter->second.aImageBigHCNoScale : pIter->second.aImageSmallHCNoScale );
630 if ( !aImage )
631 aImage = ( bBig ? pIter->second.aImageBigHC : pIter->second.aImageSmallHC );
635 return aImage;
638 //*****************************************************************************************************************
639 // private method
640 //*****************************************************************************************************************
641 sal_Bool AddonsOptions_Impl::ReadAddonMenuSet( Sequence< Sequence< PropertyValue > >& rAddonMenuSeq )
643 // Read the AddonMenu set and fill property sequences
644 ::rtl::OUString aAddonMenuNodeName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/AddonMenu" ));
645 Sequence< ::rtl::OUString > aAddonMenuNodeSeq = GetNodeNames( aAddonMenuNodeName );
646 ::rtl::OUString aAddonMenuItemNode( aAddonMenuNodeName + m_aPathDelimiter );
648 sal_uInt32 nCount = aAddonMenuNodeSeq.getLength();
649 sal_uInt32 nIndex = 0;
650 Sequence< PropertyValue > aMenuItem( PROPERTYCOUNT_MENUITEM );
652 // Init the property value sequence
653 aMenuItem[ OFFSET_MENUITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
654 aMenuItem[ OFFSET_MENUITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
655 aMenuItem[ OFFSET_MENUITEM_TARGET ].Name = m_aPropNames[ INDEX_TARGET ];
656 aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Name = m_aPropNames[ INDEX_IMAGEIDENTIFIER];
657 aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
658 aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Name = m_aPropNames[ INDEX_SUBMENU ]; // Submenu set!
660 for ( sal_uInt32 n = 0; n < nCount; n++ )
662 ::rtl::OUString aRootMenuItemNode( aAddonMenuItemNode + aAddonMenuNodeSeq[n] );
664 // Read the MenuItem
665 if ( ReadMenuItem( aRootMenuItemNode, aMenuItem ) )
667 // Successfully read a menu item, append to our list
668 sal_uInt32 nMenuItemCount = rAddonMenuSeq.getLength() + 1;
669 rAddonMenuSeq.realloc( nMenuItemCount );
670 rAddonMenuSeq[nIndex++] = aMenuItem;
674 return ( rAddonMenuSeq.getLength() > 0 );
677 //*****************************************************************************************************************
678 // private method
679 //*****************************************************************************************************************
680 sal_Bool AddonsOptions_Impl::ReadOfficeHelpSet( Sequence< Sequence< PropertyValue > >& rAddonOfficeHelpMenuSeq )
682 // Read the AddonMenu set and fill property sequences
683 ::rtl::OUString aAddonHelpMenuNodeName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/OfficeHelp" ));
684 Sequence< ::rtl::OUString > aAddonHelpMenuNodeSeq = GetNodeNames( aAddonHelpMenuNodeName );
685 ::rtl::OUString aAddonHelpMenuItemNode( aAddonHelpMenuNodeName + m_aPathDelimiter );
687 sal_uInt32 nCount = aAddonHelpMenuNodeSeq.getLength();
688 sal_uInt32 nIndex = 0;
689 Sequence< PropertyValue > aMenuItem( PROPERTYCOUNT_MENUITEM );
691 // Init the property value sequence
692 aMenuItem[ OFFSET_MENUITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
693 aMenuItem[ OFFSET_MENUITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
694 aMenuItem[ OFFSET_MENUITEM_TARGET ].Name = m_aPropNames[ INDEX_TARGET ];
695 aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Name = m_aPropNames[ INDEX_IMAGEIDENTIFIER];
696 aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
697 aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Name = m_aPropNames[ INDEX_SUBMENU ]; // Submenu set!
699 for ( sal_uInt32 n = 0; n < nCount; n++ )
701 ::rtl::OUString aRootMenuItemNode( aAddonHelpMenuItemNode + aAddonHelpMenuNodeSeq[n] );
703 // Read the MenuItem
704 if ( ReadMenuItem( aRootMenuItemNode, aMenuItem, sal_True ) )
706 // Successfully read a menu item, append to our list
707 sal_uInt32 nMenuItemCount = rAddonOfficeHelpMenuSeq.getLength() + 1;
708 rAddonOfficeHelpMenuSeq.realloc( nMenuItemCount );
709 rAddonOfficeHelpMenuSeq[nIndex++] = aMenuItem;
713 return ( rAddonOfficeHelpMenuSeq.getLength() > 0 );
716 //*****************************************************************************************************************
717 // private method
718 //*****************************************************************************************************************
719 sal_Bool AddonsOptions_Impl::ReadOfficeMenuBarSet( Sequence< Sequence< PropertyValue > >& rAddonOfficeMenuBarSeq )
721 // Read the OfficeMenuBar set and fill property sequences
722 ::rtl::OUString aAddonMenuBarNodeName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/OfficeMenuBar" ));
723 Sequence< ::rtl::OUString > aAddonMenuBarNodeSeq = GetNodeNames( aAddonMenuBarNodeName );
724 ::rtl::OUString aAddonMenuBarNode( aAddonMenuBarNodeName + m_aPathDelimiter );
726 sal_uInt32 nCount = aAddonMenuBarNodeSeq.getLength();
727 sal_uInt32 nIndex = 0;
728 Sequence< PropertyValue > aPopupMenu( PROPERTYCOUNT_POPUPMENU );
730 // Init the property value sequence
731 aPopupMenu[ OFFSET_POPUPMENU_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
732 aPopupMenu[ OFFSET_POPUPMENU_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT];
733 aPopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Name = m_aPropNames[ INDEX_SUBMENU];
734 aPopupMenu[ OFFSET_POPUPMENU_URL ].Name = m_aPropNames[ INDEX_URL ];
736 StringToIndexMap aTitleToIndexMap;
738 for ( sal_uInt32 n = 0; n < nCount; n++ )
740 ::rtl::OUString aPopupMenuNode( aAddonMenuBarNode + aAddonMenuBarNodeSeq[n] );
742 // Read the MenuItem
743 if ( ReadPopupMenu( aPopupMenuNode, aPopupMenu ) )
745 // Successfully read a popup menu, append to our list
746 ::rtl::OUString aPopupTitle;
747 if ( aPopupMenu[OFFSET_POPUPMENU_TITLE].Value >>= aPopupTitle )
749 StringToIndexMap::const_iterator pIter = aTitleToIndexMap.find( aPopupTitle );
750 if ( pIter != aTitleToIndexMap.end() )
752 // title already there => concat both popup menus
753 Sequence< PropertyValue >& rOldPopupMenu = rAddonOfficeMenuBarSeq[pIter->second];
754 AppendPopupMenu( rOldPopupMenu, aPopupMenu );
756 else
758 // not found
759 sal_uInt32 nMenuItemCount = rAddonOfficeMenuBarSeq.getLength() + 1;
760 rAddonOfficeMenuBarSeq.realloc( nMenuItemCount );
761 rAddonOfficeMenuBarSeq[nIndex] = aPopupMenu;
762 aTitleToIndexMap.insert( StringToIndexMap::value_type( aPopupTitle, nIndex ));
763 ++nIndex;
769 return ( rAddonOfficeMenuBarSeq.getLength() > 0 );
772 //*****************************************************************************************************************
773 // private method
774 //*****************************************************************************************************************
775 sal_Bool AddonsOptions_Impl::ReadOfficeToolBarSet( AddonToolBars& rAddonOfficeToolBars, std::vector< rtl::OUString >& rAddonOfficeToolBarResNames )
777 // Read the OfficeToolBar set and fill property sequences
778 ::rtl::OUString aAddonToolBarNodeName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/OfficeToolBar" ));
779 Sequence< ::rtl::OUString > aAddonToolBarNodeSeq = GetNodeNames( aAddonToolBarNodeName );
780 ::rtl::OUString aAddonToolBarNode( aAddonToolBarNodeName + m_aPathDelimiter );
782 sal_uInt32 nCount = aAddonToolBarNodeSeq.getLength();
784 for ( sal_uInt32 n = 0; n < nCount; n++ )
786 ::rtl::OUString aToolBarItemNode( aAddonToolBarNode + aAddonToolBarNodeSeq[n] );
787 rAddonOfficeToolBarResNames.push_back( aAddonToolBarNodeSeq[n] );
788 rAddonOfficeToolBars.push_back( m_aEmptyAddonToolBar );
789 ReadToolBarItemSet( aToolBarItemNode, rAddonOfficeToolBars[n] );
792 return ( !rAddonOfficeToolBars.empty() );
796 //*****************************************************************************************************************
797 // private method
798 //*****************************************************************************************************************
799 sal_Bool AddonsOptions_Impl::ReadToolBarItemSet( const rtl::OUString rToolBarItemSetNodeName, Sequence< Sequence< PropertyValue > >& rAddonOfficeToolBarSeq )
801 sal_Bool bInsertSeparator = sal_False;
802 sal_uInt32 nToolBarItemCount = rAddonOfficeToolBarSeq.getLength();
803 ::rtl::OUString aAddonToolBarItemSetNode( rToolBarItemSetNodeName + m_aPathDelimiter );
804 Sequence< ::rtl::OUString > aAddonToolBarItemSetNodeSeq = GetNodeNames( rToolBarItemSetNodeName );
805 Sequence< PropertyValue > aToolBarItem( PROPERTYCOUNT_TOOLBARITEM );
807 // Init the property value sequence
808 aToolBarItem[ OFFSET_TOOLBARITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
809 aToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
810 aToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Name = m_aPropNames[ INDEX_IMAGEIDENTIFIER];
811 aToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Name = m_aPropNames[ INDEX_TARGET ];
812 aToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
813 aToolBarItem[ OFFSET_TOOLBARITEM_CONTROLTYPE ].Name = m_aPropNames[ INDEX_CONTROLTYPE ];
814 aToolBarItem[ OFFSET_TOOLBARITEM_WIDTH ].Name = m_aPropNames[ INDEX_WIDTH ];
816 sal_uInt32 nCount = aAddonToolBarItemSetNodeSeq.getLength();
817 for ( sal_uInt32 n = 0; n < nCount; n++ )
819 ::rtl::OUString aToolBarItemNode( aAddonToolBarItemSetNode + aAddonToolBarItemSetNodeSeq[n] );
821 // Read the ToolBarItem
822 if ( ReadToolBarItem( aToolBarItemNode, aToolBarItem ) )
824 if ( bInsertSeparator )
826 bInsertSeparator = sal_False;
827 InsertToolBarSeparator( rAddonOfficeToolBarSeq );
830 // Successfully read a toolbar item, append to our list
831 sal_uInt32 nAddonCount = rAddonOfficeToolBarSeq.getLength();
832 rAddonOfficeToolBarSeq.realloc( nAddonCount+1 );
833 rAddonOfficeToolBarSeq[nAddonCount] = aToolBarItem;
837 return ( (sal_uInt32)rAddonOfficeToolBarSeq.getLength() > nToolBarItemCount );
840 //*****************************************************************************************************************
841 // private method
842 //*****************************************************************************************************************
843 void AddonsOptions_Impl::InsertToolBarSeparator( Sequence< Sequence< PropertyValue > >& rAddonOfficeToolBarSeq )
845 Sequence< PropertyValue > aToolBarItem( PROPERTYCOUNT_TOOLBARITEM );
847 aToolBarItem[ OFFSET_TOOLBARITEM_URL ].Name = m_aPropNames[ INDEX_URL ];
848 aToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Name = m_aPropNames[ INDEX_TITLE ];
849 aToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Name = m_aPropNames[ INDEX_IMAGEIDENTIFIER];
850 aToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Name = m_aPropNames[ INDEX_TARGET ];
851 aToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Name = m_aPropNames[ INDEX_CONTEXT ];
853 aToolBarItem[ OFFSET_TOOLBARITEM_URL ].Value <<= SEPARATOR_URL;
854 aToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Value <<= m_aEmpty;
855 aToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Value <<= m_aEmpty;
856 aToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Value <<= m_aEmpty;
857 aToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Value <<= m_aEmpty;
859 sal_uInt32 nToolBarItemCount = rAddonOfficeToolBarSeq.getLength();
860 rAddonOfficeToolBarSeq.realloc( nToolBarItemCount+1 );
861 rAddonOfficeToolBarSeq[nToolBarItemCount] = aToolBarItem;
864 //*****************************************************************************************************************
865 // private method
866 //*****************************************************************************************************************
867 sal_Bool AddonsOptions_Impl::ReadImages( ImageManager& aImageManager )
869 // Read the user-defined Images set and fill image manager
870 ::rtl::OUString aAddonImagesNodeName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/Images" ));
871 Sequence< ::rtl::OUString > aAddonImagesNodeSeq = GetNodeNames( aAddonImagesNodeName );
872 ::rtl::OUString aAddonImagesNode( aAddonImagesNodeName + m_aPathDelimiter );
874 sal_uInt32 nCount = aAddonImagesNodeSeq.getLength();
876 // Init the property value sequence
877 Sequence< ::rtl::OUString > aAddonImageItemNodePropNames( 1 );
878 ::rtl::OUString aURL;
880 for ( sal_uInt32 n = 0; n < nCount; n++ )
882 ::rtl::OUString aImagesItemNode( aAddonImagesNode + aAddonImagesNodeSeq[n] );
884 // Create sequence for data access
885 ::rtl::OUStringBuffer aBuffer( aImagesItemNode );
886 aBuffer.append( m_aPathDelimiter );
887 aBuffer.append( m_aPropNames[ OFFSET_MENUITEM_URL ] );
888 aAddonImageItemNodePropNames[0] = aBuffer.makeStringAndClear();
890 Sequence< Any > aAddonImageItemNodeValues = GetProperties( aAddonImageItemNodePropNames );
892 // An user-defined image entry must have an URL. As "ImageIdentifier" has a higher priority
893 // we also check if we already have an images association.
894 if (( aAddonImageItemNodeValues[0] >>= aURL ) &&
895 aURL.getLength() > 0 &&
896 !HasAssociatedImages( aURL ))
898 ::rtl::OUStringBuffer aBuf( aImagesItemNode );
899 aBuf.append( m_aPathDelimiter );
900 aBuf.append( IMAGES_NODENAME );
901 aBuf.append( m_aPathDelimiter );
902 ::rtl::OUString aImagesUserDefinedItemNode = aBuf.makeStringAndClear();
904 // Read a user-defined images data
905 ImageEntry* pImageEntry = ReadImageData( aImagesUserDefinedItemNode );
906 if ( pImageEntry )
908 // Successfully read a user-defined images item, put it into our image manager
909 aImageManager.insert( ImageManager::value_type( aURL, *pImageEntry ));
910 delete pImageEntry; // We have the ownership of the pointer
915 return sal_True;
918 //*****************************************************************************************************************
919 // private method
920 //*****************************************************************************************************************
922 ::rtl::OUString AddonsOptions_Impl::GeneratePrefixURL()
924 // Create an unique prefixed Add-On popup menu URL so it can be identified later as a runtime popup menu.
925 // They use a different image manager, so they must be identified by the sfx2/framework code.
926 ::rtl::OUString aPopupMenuURL;
927 ::rtl::OUStringBuffer aBuf( m_aRootAddonPopupMenuURLPrexfix.getLength() + 3 );
928 aBuf.append( m_aRootAddonPopupMenuURLPrexfix );
929 aBuf.append( ::rtl::OUString::valueOf( ++m_nRootAddonPopupMenuId ));
930 aPopupMenuURL = aBuf.makeStringAndClear();
931 return aPopupMenuURL;
934 //*****************************************************************************************************************
935 // private method
936 //*****************************************************************************************************************
938 sal_Bool AddonsOptions_Impl::ReadMenuMergeInstructions( MergeMenuInstructionContainer& aContainer )
940 const ::rtl::OUString aMenuMergeRootName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/OfficeMenuBarMerging/" ));
942 Sequence< ::rtl::OUString > aAddonMergeNodesSeq = GetNodeNames( aMenuMergeRootName );
943 ::rtl::OUString aAddonMergeNode( aMenuMergeRootName );
945 sal_uInt32 nCount = aAddonMergeNodesSeq.getLength();
947 // Init the property value sequence
948 Sequence< ::rtl::OUString > aNodePropNames( 5 );
949 ::rtl::OUString aURL;
951 for ( sal_uInt32 i = 0; i < nCount; i++ )
953 ::rtl::OUString aMergeAddonInstructions( aAddonMergeNode + aAddonMergeNodesSeq[i] );
955 Sequence< ::rtl::OUString > aAddonInstMergeNodesSeq = GetNodeNames( aMergeAddonInstructions );
956 sal_uInt32 nCountAddons = aAddonInstMergeNodesSeq.getLength();
958 for ( sal_uInt32 j = 0; j < nCountAddons; j++ )
960 ::rtl::OUStringBuffer aMergeAddonInstructionBase( aMergeAddonInstructions );
961 aMergeAddonInstructionBase.append( m_aPathDelimiter );
962 aMergeAddonInstructionBase.append( aAddonInstMergeNodesSeq[j] );
963 aMergeAddonInstructionBase.append( m_aPathDelimiter );
965 // Create sequence for data access
966 ::rtl::OUStringBuffer aBuffer( aMergeAddonInstructionBase );
967 aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGEPOINT ] );
968 aNodePropNames[0] = aBuffer.makeStringAndClear();
970 aBuffer = aMergeAddonInstructionBase;
971 aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECOMMAND ] );
972 aNodePropNames[1] = aBuffer.makeStringAndClear();
974 aBuffer = aMergeAddonInstructionBase;
975 aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECOMMANDPARAMETER ] );
976 aNodePropNames[2] = aBuffer.makeStringAndClear();
978 aBuffer = aMergeAddonInstructionBase;
979 aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGEFALLBACK ] );
980 aNodePropNames[3] = aBuffer.makeStringAndClear();
982 aBuffer = aMergeAddonInstructionBase;
983 aBuffer.append( m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECONTEXT ] );
984 aNodePropNames[4] = aBuffer.makeStringAndClear();
986 Sequence< Any > aNodePropValues = GetProperties( aNodePropNames );
988 MergeMenuInstruction aMergeMenuInstruction;
989 aNodePropValues[0] >>= aMergeMenuInstruction.aMergePoint;
990 aNodePropValues[1] >>= aMergeMenuInstruction.aMergeCommand;
991 aNodePropValues[2] >>= aMergeMenuInstruction.aMergeCommandParameter;
992 aNodePropValues[3] >>= aMergeMenuInstruction.aMergeFallback;
993 aNodePropValues[4] >>= aMergeMenuInstruction.aMergeContext;
995 ::rtl::OUString aMergeMenuBase = aMergeAddonInstructionBase.makeStringAndClear();
996 ReadMergeMenuData( aMergeMenuBase, aMergeMenuInstruction.aMergeMenu );
998 aContainer.push_back( aMergeMenuInstruction );
1002 return sal_True;
1005 //*****************************************************************************************************************
1006 // private method
1007 //*****************************************************************************************************************
1008 sal_Bool AddonsOptions_Impl::ReadMergeMenuData( const ::rtl::OUString& aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeMenu )
1010 ::rtl::OUString aMergeMenuBaseNode( aMergeAddonInstructionBase+m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MENUITEMS ] );
1012 Sequence< ::rtl::OUString > aSubMenuNodeNames = GetNodeNames( aMergeMenuBaseNode );
1013 aMergeMenuBaseNode += m_aPathDelimiter;
1015 // extend the node names to have full path strings
1016 for ( sal_uInt32 i = 0; i < (sal_uInt32)aSubMenuNodeNames.getLength(); i++ )
1017 aSubMenuNodeNames[i] = ::rtl::OUString( aMergeMenuBaseNode + aSubMenuNodeNames[i] );
1019 return ReadSubMenuEntries( aSubMenuNodeNames, rMergeMenu );
1022 //*****************************************************************************************************************
1023 // private method
1024 //*****************************************************************************************************************
1025 sal_Bool AddonsOptions_Impl::ReadToolbarMergeInstructions( ToolbarMergingInstructions& rCachedToolbarMergingInstructions )
1027 const ::rtl::OUString aToolbarMergeRootName( RTL_CONSTASCII_USTRINGPARAM( "AddonUI/OfficeToolbarMerging/" ));
1029 Sequence< ::rtl::OUString > aAddonMergeNodesSeq = GetNodeNames( aToolbarMergeRootName );
1030 ::rtl::OUString aAddonMergeNode( aToolbarMergeRootName );
1032 sal_uInt32 nCount = aAddonMergeNodesSeq.getLength();
1034 // Init the property value sequence
1035 Sequence< ::rtl::OUString > aNodePropNames( 6 );
1036 ::rtl::OUString aURL;
1038 for ( sal_uInt32 i = 0; i < nCount; i++ )
1040 ::rtl::OUString aMergeAddonInstructions( aAddonMergeNode + aAddonMergeNodesSeq[i] );
1042 Sequence< ::rtl::OUString > aAddonInstMergeNodesSeq = GetNodeNames( aMergeAddonInstructions );
1043 sal_uInt32 nCountAddons = aAddonInstMergeNodesSeq.getLength();
1045 for ( sal_uInt32 j = 0; j < nCountAddons; j++ )
1047 ::rtl::OUStringBuffer aMergeAddonInstructionBase( aMergeAddonInstructions );
1048 aMergeAddonInstructionBase.append( m_aPathDelimiter );
1049 aMergeAddonInstructionBase.append( aAddonInstMergeNodesSeq[j] );
1050 aMergeAddonInstructionBase.append( m_aPathDelimiter );
1052 // Create sequence for data access
1053 ::rtl::OUStringBuffer aBuffer( aMergeAddonInstructionBase );
1054 aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBAR ] );
1055 aNodePropNames[0] = aBuffer.makeStringAndClear();
1057 aBuffer = aMergeAddonInstructionBase;
1058 aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGEPOINT ] );
1059 aNodePropNames[1] = aBuffer.makeStringAndClear();
1061 aBuffer = aMergeAddonInstructionBase;
1062 aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECOMMAND ] );
1063 aNodePropNames[2] = aBuffer.makeStringAndClear();
1065 aBuffer = aMergeAddonInstructionBase;
1066 aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECOMMANDPARAMETER ] );
1067 aNodePropNames[3] = aBuffer.makeStringAndClear();
1069 aBuffer = aMergeAddonInstructionBase;
1070 aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGEFALLBACK ] );
1071 aNodePropNames[4] = aBuffer.makeStringAndClear();
1073 aBuffer = aMergeAddonInstructionBase;
1074 aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECONTEXT ] );
1075 aNodePropNames[5] = aBuffer.makeStringAndClear();
1077 Sequence< Any > aNodePropValues = GetProperties( aNodePropNames );
1079 MergeToolbarInstruction aMergeToolbarInstruction;
1080 aNodePropValues[0] >>= aMergeToolbarInstruction.aMergeToolbar;
1081 aNodePropValues[1] >>= aMergeToolbarInstruction.aMergePoint;
1082 aNodePropValues[2] >>= aMergeToolbarInstruction.aMergeCommand;
1083 aNodePropValues[3] >>= aMergeToolbarInstruction.aMergeCommandParameter;
1084 aNodePropValues[4] >>= aMergeToolbarInstruction.aMergeFallback;
1085 aNodePropValues[5] >>= aMergeToolbarInstruction.aMergeContext;
1087 ReadMergeToolbarData( aMergeAddonInstructionBase.makeStringAndClear(),
1088 aMergeToolbarInstruction.aMergeToolbarItems );
1090 MergeToolbarInstructionContainer& rVector = rCachedToolbarMergingInstructions[ aMergeToolbarInstruction.aMergeToolbar ];
1091 rVector.push_back( aMergeToolbarInstruction );
1095 return sal_True;
1098 //*****************************************************************************************************************
1099 // private method
1100 //*****************************************************************************************************************
1101 sal_Bool AddonsOptions_Impl::ReadMergeToolbarData( const ::rtl::OUString& aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeToolbarItems )
1103 ::rtl::OUStringBuffer aBuffer( aMergeAddonInstructionBase );
1104 aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBARITEMS ] );
1106 ::rtl::OUString aMergeToolbarBaseNode = aBuffer.makeStringAndClear();
1108 return ReadToolBarItemSet( aMergeToolbarBaseNode, rMergeToolbarItems );
1111 //*****************************************************************************************************************
1112 // private method
1113 //*****************************************************************************************************************
1114 sal_Bool AddonsOptions_Impl::ReadMenuItem( const ::rtl::OUString& aMenuNodeName, Sequence< PropertyValue >& aMenuItem, sal_Bool bIgnoreSubMenu )
1116 sal_Bool bResult = sal_False;
1117 ::rtl::OUString aStrValue;
1118 ::rtl::OUString aAddonMenuItemTreeNode( aMenuNodeName + m_aPathDelimiter );
1119 Sequence< Any > aMenuItemNodePropValues;
1121 aMenuItemNodePropValues = GetProperties( GetPropertyNamesMenuItem( aAddonMenuItemTreeNode ) );
1122 if (( aMenuItemNodePropValues[ OFFSET_MENUITEM_TITLE ] >>= aStrValue ) && aStrValue.getLength() > 0 )
1124 aMenuItem[ OFFSET_MENUITEM_TITLE ].Value <<= aStrValue;
1126 ::rtl::OUString aRootSubMenuName( aAddonMenuItemTreeNode + m_aPropNames[ INDEX_SUBMENU ] );
1127 Sequence< ::rtl::OUString > aRootSubMenuNodeNames = GetNodeNames( aRootSubMenuName );
1128 if ( aRootSubMenuNodeNames.getLength() > 0 && !bIgnoreSubMenu )
1130 // Set a unique prefixed Add-On popup menu URL so it can be identified later
1131 ::rtl::OUString aPopupMenuURL = GeneratePrefixURL();
1132 ::rtl::OUString aPopupMenuImageId;
1134 aMenuItemNodePropValues[ OFFSET_MENUITEM_IMAGEIDENTIFIER ] >>= aPopupMenuImageId;
1135 ReadAndAssociateImages( aPopupMenuURL, aPopupMenuImageId );
1137 // A popup menu must have a title and can have a URL and ImageIdentifier
1138 // Set the other property values to empty
1139 aMenuItem[ OFFSET_MENUITEM_URL ].Value <<= aPopupMenuURL;
1140 aMenuItem[ OFFSET_MENUITEM_TARGET ].Value <<= m_aEmpty;
1141 aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Value <<= aPopupMenuImageId;
1142 aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Value <<= aMenuItemNodePropValues[ OFFSET_MENUITEM_CONTEXT ];
1144 // Continue to read the sub menu nodes
1145 Sequence< Sequence< PropertyValue > > aSubMenuSeq;
1146 ::rtl::OUString aSubMenuRootNodeName( aRootSubMenuName + m_aPathDelimiter );
1147 for ( sal_uInt32 n = 0; n < (sal_uInt32)aRootSubMenuNodeNames.getLength(); n++ )
1148 aRootSubMenuNodeNames[n] = ::rtl::OUString( aSubMenuRootNodeName + aRootSubMenuNodeNames[n] );
1149 ReadSubMenuEntries( aRootSubMenuNodeNames, aSubMenuSeq );
1150 aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Value <<= aSubMenuSeq;
1151 bResult = sal_True;
1153 else if (( aMenuItemNodePropValues[ OFFSET_MENUITEM_URL ] >>= aStrValue ) && aStrValue.getLength() > 0 )
1155 // A simple menu item => read the other properties;
1156 ::rtl::OUString aMenuImageId;
1158 aMenuItemNodePropValues[ OFFSET_MENUITEM_IMAGEIDENTIFIER ] >>= aMenuImageId;
1159 ReadAndAssociateImages( aStrValue, aMenuImageId );
1161 aMenuItem[ OFFSET_MENUITEM_URL ].Value <<= aStrValue;
1162 aMenuItem[ OFFSET_MENUITEM_TARGET ].Value <<= aMenuItemNodePropValues[ OFFSET_MENUITEM_TARGET ];
1163 aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Value <<= aMenuImageId;
1164 aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Value <<= aMenuItemNodePropValues[ OFFSET_MENUITEM_CONTEXT ];
1165 aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Value <<= Sequence< Sequence< PropertyValue > >(); // Submenu set!
1167 bResult = sal_True;
1170 else if (( aMenuItemNodePropValues[ OFFSET_MENUITEM_URL ] >>= aStrValue ) &&
1171 aStrValue.equalsAsciiL( SEPARATOR_URL_STR, SEPARATOR_URL_LEN ))
1173 // Separator
1174 aMenuItem[ OFFSET_MENUITEM_URL ].Value <<= aStrValue;
1175 aMenuItem[ OFFSET_MENUITEM_TARGET ].Value <<= m_aEmpty;
1176 aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Value <<= m_aEmpty;
1177 aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Value <<= m_aEmpty;
1178 aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Value <<= Sequence< Sequence< PropertyValue > >(); // Submenu set!
1179 bResult = sal_True;
1182 return bResult;
1185 //*****************************************************************************************************************
1186 // private method
1187 //*****************************************************************************************************************
1188 sal_Bool AddonsOptions_Impl::ReadPopupMenu( const ::rtl::OUString& aPopupMenuNodeName, Sequence< PropertyValue >& aPopupMenu )
1190 sal_Bool bResult = sal_False;
1191 ::rtl::OUString aStrValue;
1192 ::rtl::OUString aAddonPopupMenuTreeNode( aPopupMenuNodeName + m_aPathDelimiter );
1193 Sequence< Any > aPopupMenuNodePropValues;
1195 aPopupMenuNodePropValues = GetProperties( GetPropertyNamesPopupMenu( aAddonPopupMenuTreeNode ) );
1196 if (( aPopupMenuNodePropValues[ OFFSET_POPUPMENU_TITLE ] >>= aStrValue ) &&
1197 aStrValue.getLength() > 0 )
1199 aPopupMenu[ OFFSET_POPUPMENU_TITLE ].Value <<= aStrValue;
1201 ::rtl::OUString aRootSubMenuName( aAddonPopupMenuTreeNode + m_aPropNames[ INDEX_SUBMENU ] );
1202 Sequence< ::rtl::OUString > aRootSubMenuNodeNames = GetNodeNames( aRootSubMenuName );
1203 if ( aRootSubMenuNodeNames.getLength() > 0 )
1205 // A top-level popup menu needs a title
1206 // Set a unique prefixed Add-On popup menu URL so it can be identified later
1207 ::rtl::OUString aPopupMenuURL = GeneratePrefixURL();
1209 aPopupMenu[ OFFSET_POPUPMENU_URL ].Value <<= aPopupMenuURL;
1210 aPopupMenu[ OFFSET_POPUPMENU_CONTEXT ].Value <<= aPopupMenuNodePropValues[ OFFSET_POPUPMENU_CONTEXT ];
1212 // Continue to read the sub menu nodes
1213 Sequence< Sequence< PropertyValue > > aSubMenuSeq;
1214 ::rtl::OUString aSubMenuRootNodeName( aRootSubMenuName + m_aPathDelimiter );
1215 for ( sal_uInt32 n = 0; n < (sal_uInt32)aRootSubMenuNodeNames.getLength(); n++ )
1216 aRootSubMenuNodeNames[n] = ::rtl::OUString( aSubMenuRootNodeName + aRootSubMenuNodeNames[n] );
1217 ReadSubMenuEntries( aRootSubMenuNodeNames, aSubMenuSeq );
1218 aPopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Value <<= aSubMenuSeq;
1219 bResult = sal_True;
1223 return bResult;
1226 //*****************************************************************************************************************
1227 // private method
1228 //*****************************************************************************************************************
1229 sal_Bool AddonsOptions_Impl::AppendPopupMenu( Sequence< PropertyValue >& rTargetPopupMenu, const Sequence< PropertyValue >& rSourcePopupMenu )
1231 Sequence< Sequence< PropertyValue > > aTargetSubMenuSeq;
1232 Sequence< Sequence< PropertyValue > > aSourceSubMenuSeq;
1234 if (( rTargetPopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Value >>= aTargetSubMenuSeq ) &&
1235 ( rSourcePopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Value >>= aSourceSubMenuSeq ))
1237 sal_uInt32 nIndex = aTargetSubMenuSeq.getLength();
1238 aTargetSubMenuSeq.realloc( nIndex + aSourceSubMenuSeq.getLength() );
1239 for ( sal_uInt32 i = 0; i < sal_uInt32( aSourceSubMenuSeq.getLength() ); i++ )
1240 aTargetSubMenuSeq[nIndex++] = aSourceSubMenuSeq[i];
1241 rTargetPopupMenu[ OFFSET_POPUPMENU_SUBMENU ].Value <<= aTargetSubMenuSeq;
1244 return sal_True;
1247 //*****************************************************************************************************************
1248 // private method
1249 //*****************************************************************************************************************
1250 sal_Bool AddonsOptions_Impl::ReadToolBarItem( const ::rtl::OUString& aToolBarItemNodeName, Sequence< PropertyValue >& aToolBarItem )
1252 sal_Bool bResult = sal_False;
1253 ::rtl::OUString aTitle;
1254 ::rtl::OUString aURL;
1255 ::rtl::OUString aAddonToolBarItemTreeNode( aToolBarItemNodeName + m_aPathDelimiter );
1256 Sequence< Any > aToolBarItemNodePropValues;
1258 aToolBarItemNodePropValues = GetProperties( GetPropertyNamesToolBarItem( aAddonToolBarItemTreeNode ) );
1260 // A toolbar item must have a command URL
1261 if (( aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_URL ] >>= aURL ) && aURL.getLength() > 0 )
1263 if ( aURL.equals( SEPARATOR_URL ))
1265 // A speparator toolbar item only needs a URL
1266 aToolBarItem[ OFFSET_TOOLBARITEM_URL ].Value <<= aURL;
1267 aToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Value <<= m_aEmpty;
1268 aToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Value <<= m_aEmpty;
1269 aToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Value <<= m_aEmpty;
1270 aToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Value <<= m_aEmpty;
1271 aToolBarItem[ OFFSET_TOOLBARITEM_CONTROLTYPE ].Value <<= m_aEmpty;
1272 aToolBarItem[ OFFSET_TOOLBARITEM_WIDTH ].Value <<= sal_Int32( 0 );
1274 bResult = sal_True;
1276 else if (( aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_TITLE ] >>= aTitle ) && aTitle.getLength() > 0 )
1278 // A normal toolbar item must also have title => read the other properties;
1279 ::rtl::OUString aImageId;
1281 // Try to map a user-defined image URL to our internal private image URL
1282 aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ] >>= aImageId;
1283 ReadAndAssociateImages( aURL, aImageId );
1285 aToolBarItem[ OFFSET_TOOLBARITEM_URL ].Value <<= aURL;
1286 aToolBarItem[ OFFSET_TOOLBARITEM_TITLE ].Value <<= aTitle;
1287 aToolBarItem[ OFFSET_TOOLBARITEM_TARGET ].Value <<= aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_TARGET ];
1288 aToolBarItem[ OFFSET_TOOLBARITEM_IMAGEIDENTIFIER ].Value <<= aImageId;
1289 aToolBarItem[ OFFSET_TOOLBARITEM_CONTEXT ].Value <<= aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_CONTEXT ];
1290 aToolBarItem[ OFFSET_TOOLBARITEM_CONTROLTYPE ].Value <<= aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_CONTROLTYPE ];
1292 // Configuration uses hyper for long. Therefore transform into sal_Int32
1293 sal_Int64 nValue( 0 );
1294 aToolBarItemNodePropValues[ OFFSET_TOOLBARITEM_WIDTH ] >>= nValue;
1295 aToolBarItem[ OFFSET_TOOLBARITEM_WIDTH ].Value <<= sal_Int32( nValue );
1297 bResult = sal_True;
1301 return bResult;
1304 //*****************************************************************************************************************
1305 // private method
1306 //*****************************************************************************************************************
1307 sal_Bool AddonsOptions_Impl::ReadSubMenuEntries( const Sequence< ::rtl::OUString >& aSubMenuNodeNames, Sequence< Sequence< PropertyValue > >& rSubMenuSeq )
1309 Sequence< PropertyValue > aMenuItem( PROPERTYCOUNT_MENUITEM );
1311 // Init the property value sequence
1312 aMenuItem[ OFFSET_MENUITEM_URL ].Name = PROPERTYNAME_URL;
1313 aMenuItem[ OFFSET_MENUITEM_TITLE ].Name = PROPERTYNAME_TITLE;
1314 aMenuItem[ OFFSET_MENUITEM_TARGET ].Name = PROPERTYNAME_TARGET;
1315 aMenuItem[ OFFSET_MENUITEM_IMAGEIDENTIFIER ].Name = PROPERTYNAME_IMAGEIDENTIFIER;
1316 aMenuItem[ OFFSET_MENUITEM_CONTEXT ].Name = PROPERTYNAME_CONTEXT;
1317 aMenuItem[ OFFSET_MENUITEM_SUBMENU ].Name = PROPERTYNAME_SUBMENU; // Submenu set!
1319 sal_uInt32 nIndex = 0;
1320 sal_uInt32 nCount = aSubMenuNodeNames.getLength();
1321 for ( sal_uInt32 n = 0; n < nCount; n++ )
1323 if ( ReadMenuItem( aSubMenuNodeNames[n], aMenuItem ))
1325 sal_uInt32 nSubMenuCount = rSubMenuSeq.getLength() + 1;
1326 rSubMenuSeq.realloc( nSubMenuCount );
1327 rSubMenuSeq[nIndex++] = aMenuItem;
1331 return sal_True;
1334 //*****************************************************************************************************************
1335 // private method
1336 //*****************************************************************************************************************
1337 sal_Bool AddonsOptions_Impl::HasAssociatedImages( const ::rtl::OUString& aURL )
1339 ImageManager::const_iterator pIter = m_aImageManager.find( aURL );
1340 return ( pIter != m_aImageManager.end() );
1343 //*****************************************************************************************************************
1344 // private method
1345 //*****************************************************************************************************************
1346 void AddonsOptions_Impl::SubstituteVariables( ::rtl::OUString& aURL )
1348 if (( aURL.compareToAscii( RTL_CONSTASCII_STRINGPARAM( EXPAND_PROTOCOL )) == 0 ) &&
1349 m_xMacroExpander.is() )
1351 // cut protocol
1352 ::rtl::OUString macro( aURL.copy( sizeof ( EXPAND_PROTOCOL ) -1 ) );
1353 // decode uric class chars
1354 macro = ::rtl::Uri::decode(
1355 macro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
1356 // expand macro string
1357 aURL = m_xMacroExpander->expandMacros( macro );
1361 //*****************************************************************************************************************
1362 // private method
1363 //*****************************************************************************************************************
1364 void AddonsOptions_Impl::ReadImageFromURL( ImageSize nImageSize, const ::rtl::OUString& aImageURL, Image& aImage, Image& aImageNoScale )
1366 SvStream* pStream = UcbStreamHelper::CreateStream( aImageURL, STREAM_STD_READ );
1367 if ( pStream && ( pStream->GetErrorCode() == 0 ))
1369 // Use graphic class to also support more graphic formats (bmp,png,...)
1370 Graphic aGraphic;
1372 GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
1373 pGF->ImportGraphic( aGraphic, String(), *pStream, GRFILTER_FORMAT_DONTKNOW );
1375 BitmapEx aBitmapEx = aGraphic.GetBitmapEx();
1377 const Size aSize = ( nImageSize == IMGSIZE_SMALL ) ? aImageSizeSmall : aImageSizeBig; // Sizes used for menu/toolbox images
1379 Size aBmpSize = aBitmapEx.GetSizePixel();
1380 if ( aBmpSize.Width() > 0 && aBmpSize.Height() > 0 )
1382 // Support non-transparent bitmaps to be downward compatible with OOo 1.1.x addons
1383 if( !aBitmapEx.IsTransparent() )
1384 aBitmapEx = BitmapEx( aBitmapEx.GetBitmap(), COL_LIGHTMAGENTA );
1386 // A non-scaled bitmap can have a flexible width, but must have a defined height!
1387 Size aNoScaleSize( aBmpSize.Width(), aSize.Height() );
1388 if ( aBmpSize != aNoScaleSize )
1390 BitmapEx aNoScaleBmp( aBitmapEx );
1391 aNoScaleBmp.Scale( aNoScaleSize, BMP_SCALE_INTERPOLATE );
1393 else
1394 aImageNoScale = Image( aBitmapEx );
1396 if ( aBmpSize != aSize )
1397 aBitmapEx.Scale( aSize, BMP_SCALE_INTERPOLATE );
1399 aImage = Image( aBitmapEx );
1403 delete pStream;
1406 //*****************************************************************************************************************
1407 // private method
1408 //*****************************************************************************************************************
1409 void AddonsOptions_Impl::ReadAndAssociateImages( const ::rtl::OUString& aURL, const ::rtl::OUString& aImageId )
1411 const int MAX_NUM_IMAGES = 4;
1412 const char* aExtArray[MAX_NUM_IMAGES] = { "_16", "_26", "_16h", "_26h" };
1413 const char* pBmpExt = ".bmp";
1415 if ( aImageId.getLength() == 0 )
1416 return;
1418 bool bImageFound = true;
1419 ImageEntry aImageEntry;
1420 ::rtl::OUString aImageURL( aImageId );
1422 SubstituteVariables( aImageURL );
1424 // Loop to create the four possible image names and try to read the bitmap files
1425 for ( int i = 0; i < MAX_NUM_IMAGES; i++ )
1427 ::rtl::OUStringBuffer aFileURL( aImageURL );
1428 aFileURL.appendAscii( aExtArray[i] );
1429 aFileURL.appendAscii( pBmpExt );
1431 Image aImage;
1432 Image aImageNoScale;
1433 ReadImageFromURL( ((i==0)||(i==2)) ? IMGSIZE_SMALL : IMGSIZE_BIG, aFileURL.makeStringAndClear(), aImage, aImageNoScale );
1434 if ( !!aImage )
1436 bImageFound = true;
1437 switch ( i )
1439 case 0:
1440 aImageEntry.aImageSmall = aImage;
1441 aImageEntry.aImageSmallNoScale = aImageNoScale;
1442 break;
1443 case 1:
1444 aImageEntry.aImageBig = aImage;
1445 aImageEntry.aImageBigNoScale = aImageNoScale;
1446 break;
1447 case 2:
1448 aImageEntry.aImageSmallHC = aImage;
1449 aImageEntry.aImageSmallHCNoScale = aImageNoScale;
1450 break;
1451 case 3:
1452 aImageEntry.aImageBigHC = aImage;
1453 aImageEntry.aImageBigHCNoScale = aImageNoScale;
1454 break;
1459 if ( bImageFound )
1460 m_aImageManager.insert( ImageManager::value_type( aURL, aImageEntry ));
1463 //*****************************************************************************************************************
1464 // private method
1465 //*****************************************************************************************************************
1466 AddonsOptions_Impl::ImageEntry* AddonsOptions_Impl::ReadImageData( const ::rtl::OUString& aImagesNodeName )
1468 Sequence< ::rtl::OUString > aImageDataNodeNames = GetPropertyNamesImages( aImagesNodeName );
1469 Sequence< Any > aPropertyData;
1470 Sequence< sal_Int8 > aImageDataSeq;
1471 ::rtl::OUString aImageURL;
1473 ImageEntry* pEntry = NULL;
1475 // It is possible to use both forms (embedded image data and URLs to external bitmap files) at the
1476 // same time. Embedded image data has a higher priority.
1477 aPropertyData = GetProperties( aImageDataNodeNames );
1478 for ( int i = 0; i < PROPERTYCOUNT_IMAGES; i++ )
1480 if ( i < PROPERTYCOUNT_EMBEDDED_IMAGES )
1482 // Extract image data from the embedded hex binary sequence
1483 Image aImage;
1484 if (( aPropertyData[i] >>= aImageDataSeq ) &&
1485 aImageDataSeq.getLength() > 0 &&
1486 ( CreateImageFromSequence( aImage,
1487 (( i == OFFSET_IMAGES_BIG ) ||
1488 ( i == OFFSET_IMAGES_BIGHC )),
1489 aImageDataSeq )) )
1491 if ( !pEntry )
1492 pEntry = new ImageEntry;
1494 if ( i == OFFSET_IMAGES_SMALL )
1495 pEntry->aImageSmall = aImage;
1496 else if ( i == OFFSET_IMAGES_BIG )
1497 pEntry->aImageBig = aImage;
1498 else if ( i == OFFSET_IMAGES_SMALLHC )
1499 pEntry->aImageSmallHC = aImage;
1500 else
1501 pEntry->aImageBigHC = aImage;
1504 else
1506 // Retrieve image data from a external bitmap file. Make sure that embedded image data
1507 // has a higher priority.
1508 aPropertyData[i] >>= aImageURL;
1510 if ( aImageURL.getLength() > 0 )
1512 Image aImage;
1513 Image aImageNoScale;
1515 SubstituteVariables( aImageURL );
1516 ReadImageFromURL( ((i==OFFSET_IMAGES_SMALL_URL)||(i==OFFSET_IMAGES_SMALLHC_URL)) ? IMGSIZE_SMALL : IMGSIZE_BIG,
1517 aImageURL, aImage, aImageNoScale );
1518 if ( !!aImage )
1520 if ( !pEntry )
1521 pEntry = new ImageEntry;
1523 if ( i == OFFSET_IMAGES_SMALL_URL && !pEntry->aImageSmall )
1525 pEntry->aImageSmall = aImage;
1526 pEntry->aImageSmallNoScale = aImageNoScale;
1528 else if ( i == OFFSET_IMAGES_BIG_URL && !pEntry->aImageBig )
1530 pEntry->aImageBig = aImage;
1531 pEntry->aImageBigNoScale = aImageNoScale;
1533 else if ( i == OFFSET_IMAGES_SMALLHC_URL && !pEntry->aImageSmallHC )
1535 pEntry->aImageSmallHC = aImage;
1536 pEntry->aImageSmallHCNoScale = aImageNoScale;
1538 else if ( !pEntry->aImageBigHC )
1540 pEntry->aImageBigHC = aImage;
1541 pEntry->aImageBigHCNoScale = aImageNoScale;
1548 return pEntry;
1551 //*****************************************************************************************************************
1552 // private method
1553 //*****************************************************************************************************************
1554 sal_Bool AddonsOptions_Impl::CreateImageFromSequence( Image& rImage, sal_Bool bBig, Sequence< sal_Int8 >& rBitmapDataSeq ) const
1556 sal_Bool bResult = sal_False;
1557 Size aSize = bBig ? aImageSizeBig : aImageSizeSmall; // Sizes used for menu/toolbox images
1559 if ( rBitmapDataSeq.getLength() > 0 )
1561 SvMemoryStream aMemStream( rBitmapDataSeq.getArray(), rBitmapDataSeq.getLength(), STREAM_STD_READ );
1562 BitmapEx aBitmapEx;
1564 aMemStream >> aBitmapEx;
1566 // Scale bitmap to fit the correct size for the menu/toolbar. Use best quality
1567 if ( aBitmapEx.GetSizePixel() != aSize )
1568 aBitmapEx.Scale( aSize, BMP_SCALE_INTERPOLATE );
1570 if( !aBitmapEx.IsTransparent() )
1572 // Support non-transparent bitmaps to be downward compatible with OOo 1.1.x addons
1573 aBitmapEx = BitmapEx( aBitmapEx.GetBitmap(), COL_LIGHTMAGENTA );
1576 rImage = Image( aBitmapEx );
1577 bResult = sal_True;
1580 return bResult;
1583 //*****************************************************************************************************************
1584 // private methods
1585 //*****************************************************************************************************************
1586 Sequence< ::rtl::OUString > AddonsOptions_Impl::GetPropertyNamesMergeMenuInstruction( const ::rtl::OUString& aPropertyRootNode ) const
1588 Sequence< ::rtl::OUString > lResult( PROPERTYCOUNT_MERGE_MENUBAR );
1590 // Create property names dependent from the root node name
1591 lResult[ OFFSET_MERGEMENU_MERGEPOINT ] = ::rtl::OUString( aPropertyRootNode + m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGEPOINT ] );
1592 lResult[ OFFSET_MERGEMENU_MERGECOMMAND ] = ::rtl::OUString( aPropertyRootNode + m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECOMMAND ] );
1593 lResult[ OFFSET_MERGEMENU_MERGECOMMANDPARAMETER ] = ::rtl::OUString( aPropertyRootNode + m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECOMMANDPARAMETER ] );
1594 lResult[ OFFSET_MERGEMENU_MERGEFALLBACK ] = ::rtl::OUString( aPropertyRootNode + m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGEFALLBACK ] );
1595 lResult[ OFFSET_MERGEMENU_MERGECONTEXT ] = ::rtl::OUString( aPropertyRootNode + m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MERGECONTEXT ] );
1596 lResult[ OFFSET_MERGEMENU_MENUITEMS ] = ::rtl::OUString( aPropertyRootNode + m_aPropMergeMenuNames[ OFFSET_MERGEMENU_MENUITEMS ] );
1598 return lResult;
1601 Sequence< ::rtl::OUString > AddonsOptions_Impl::GetPropertyNamesMenuItem( const ::rtl::OUString& aPropertyRootNode ) const
1603 Sequence< ::rtl::OUString > lResult( PROPERTYCOUNT_MENUITEM );
1605 // Create property names dependent from the root node name
1606 lResult[OFFSET_MENUITEM_URL] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_URL ] );
1607 lResult[OFFSET_MENUITEM_TITLE] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_TITLE ] );
1608 lResult[OFFSET_MENUITEM_IMAGEIDENTIFIER] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_IMAGEIDENTIFIER ] );
1609 lResult[OFFSET_MENUITEM_TARGET] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_TARGET ] );
1610 lResult[OFFSET_MENUITEM_CONTEXT] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ] );
1611 lResult[OFFSET_MENUITEM_SUBMENU] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_SUBMENU ] );
1613 return lResult;
1616 //*****************************************************************************************************************
1617 // private method
1618 //*****************************************************************************************************************
1619 Sequence< ::rtl::OUString > AddonsOptions_Impl::GetPropertyNamesPopupMenu( const ::rtl::OUString& aPropertyRootNode ) const
1621 // The URL is automatically set and not read from the configuration.
1622 Sequence< ::rtl::OUString > lResult( PROPERTYCOUNT_POPUPMENU-1 );
1624 // Create property names dependent from the root node name
1625 lResult[OFFSET_POPUPMENU_TITLE] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_TITLE ] );
1626 lResult[OFFSET_POPUPMENU_CONTEXT] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ] );
1627 lResult[OFFSET_POPUPMENU_SUBMENU] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_SUBMENU ] );
1629 return lResult;
1632 //*****************************************************************************************************************
1633 // private method
1634 //*****************************************************************************************************************
1635 Sequence< ::rtl::OUString > AddonsOptions_Impl::GetPropertyNamesToolBarItem( const ::rtl::OUString& aPropertyRootNode ) const
1637 Sequence< ::rtl::OUString > lResult( PROPERTYCOUNT_TOOLBARITEM );
1639 // Create property names dependent from the root node name
1640 lResult[0] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_URL ] );
1641 lResult[1] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_TITLE ] );
1642 lResult[2] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_IMAGEIDENTIFIER] );
1643 lResult[3] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_TARGET ] );
1644 lResult[4] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_CONTEXT ] );
1645 lResult[5] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_CONTROLTYPE ] );
1646 lResult[6] = ::rtl::OUString( aPropertyRootNode + m_aPropNames[ INDEX_WIDTH ] );
1648 return lResult;
1651 //*****************************************************************************************************************
1652 // private method
1653 //*****************************************************************************************************************
1654 Sequence< ::rtl::OUString > AddonsOptions_Impl::GetPropertyNamesImages( const ::rtl::OUString& aPropertyRootNode ) const
1656 Sequence< ::rtl::OUString > lResult( PROPERTYCOUNT_IMAGES );
1658 // Create property names dependent from the root node name
1659 lResult[0] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALL ] );
1660 lResult[1] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIG ] );
1661 lResult[2] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALLHC ] );
1662 lResult[3] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIGHC ] );
1663 lResult[4] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALL_URL ] );
1664 lResult[5] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIG_URL ] );
1665 lResult[6] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_SMALLHC_URL] );
1666 lResult[7] = ::rtl::OUString( aPropertyRootNode + m_aPropImagesNames[ OFFSET_IMAGES_BIGHC_URL ] );
1668 return lResult;
1671 //*****************************************************************************************************************
1672 // initialize static member
1673 // DON'T DO IT IN YOUR HEADER!
1674 // see definition for further informations
1675 //*****************************************************************************************************************
1676 AddonsOptions_Impl* AddonsOptions::m_pDataContainer = NULL ;
1677 sal_Int32 AddonsOptions::m_nRefCount = 0 ;
1679 //*****************************************************************************************************************
1680 // constructor
1681 //*****************************************************************************************************************
1682 AddonsOptions::AddonsOptions()
1684 // Global access, must be guarded (multithreading!).
1685 MutexGuard aGuard( GetOwnStaticMutex() );
1686 // Increase ouer refcount ...
1687 ++m_nRefCount;
1688 // ... and initialize ouer data container only if it not already exist!
1689 if( m_pDataContainer == NULL )
1691 m_pDataContainer = new AddonsOptions_Impl;
1695 //*****************************************************************************************************************
1696 // destructor
1697 //*****************************************************************************************************************
1698 AddonsOptions::~AddonsOptions()
1700 // Global access, must be guarded (multithreading!)
1701 MutexGuard aGuard( GetOwnStaticMutex() );
1702 // Decrease ouer refcount.
1703 --m_nRefCount;
1704 // If last instance was deleted ...
1705 // we must destroy ouer static data container!
1706 if( m_nRefCount <= 0 )
1708 delete m_pDataContainer;
1709 m_pDataContainer = NULL;
1713 //*****************************************************************************************************************
1714 // public method
1715 //*****************************************************************************************************************
1716 sal_Bool AddonsOptions::HasAddonsMenu() const
1718 MutexGuard aGuard( GetOwnStaticMutex() );
1719 return m_pDataContainer->HasAddonsMenu();
1722 //*****************************************************************************************************************
1723 // public method
1724 //*****************************************************************************************************************
1726 sal_Bool AddonsOptions::HasAddonsHelpMenu() const
1728 MutexGuard aGuard( GetOwnStaticMutex() );
1729 return m_pDataContainer->HasAddonsHelpMenu();
1732 //*****************************************************************************************************************
1733 // public method
1734 //*****************************************************************************************************************
1736 sal_Int32 AddonsOptions::GetAddonsToolBarCount() const
1738 MutexGuard aGuard( GetOwnStaticMutex() );
1739 return m_pDataContainer->GetAddonsToolBarCount();
1742 //*****************************************************************************************************************
1743 // public method
1744 //*****************************************************************************************************************
1745 const Sequence< Sequence< PropertyValue > >& AddonsOptions::GetAddonsMenu() const
1747 MutexGuard aGuard( GetOwnStaticMutex() );
1748 return m_pDataContainer->GetAddonsMenu();
1751 //*****************************************************************************************************************
1752 // public method
1753 //*****************************************************************************************************************
1754 const Sequence< Sequence< PropertyValue > >& AddonsOptions::GetAddonsMenuBarPart() const
1756 MutexGuard aGuard( GetOwnStaticMutex() );
1757 return m_pDataContainer->GetAddonsMenuBarPart();
1760 //*****************************************************************************************************************
1761 // public method
1762 //*****************************************************************************************************************
1763 const Sequence< Sequence< PropertyValue > >& AddonsOptions::GetAddonsToolBarPart( sal_uInt32 nIndex ) const
1765 MutexGuard aGuard( GetOwnStaticMutex() );
1766 return m_pDataContainer->GetAddonsToolBarPart( nIndex );
1769 //*****************************************************************************************************************
1770 // public method
1771 //*****************************************************************************************************************
1772 const ::rtl::OUString AddonsOptions::GetAddonsToolbarResourceName( sal_uInt32 nIndex ) const
1774 MutexGuard aGuard( GetOwnStaticMutex() );
1775 return m_pDataContainer->GetAddonsToolbarResourceName( nIndex );
1778 //*****************************************************************************************************************
1779 // public method
1780 //*****************************************************************************************************************
1781 const Sequence< Sequence< PropertyValue > >& AddonsOptions::GetAddonsHelpMenu() const
1783 MutexGuard aGuard( GetOwnStaticMutex() );
1784 return m_pDataContainer->GetAddonsHelpMenu();
1787 //*****************************************************************************************************************
1788 // public method
1789 //*****************************************************************************************************************
1790 const MergeMenuInstructionContainer& AddonsOptions::GetMergeMenuInstructions() const
1792 MutexGuard aGuard( GetOwnStaticMutex() );
1793 return m_pDataContainer->GetMergeMenuInstructions();
1796 //*****************************************************************************************************************
1797 // public method
1798 //*****************************************************************************************************************
1799 bool AddonsOptions::GetMergeToolbarInstructions(
1800 const ::rtl::OUString& rToolbarName,
1801 MergeToolbarInstructionContainer& rToolbarInstructions ) const
1803 MutexGuard aGuard( GetOwnStaticMutex() );
1804 return m_pDataContainer->GetMergeToolbarInstructions(
1805 rToolbarName, rToolbarInstructions );
1808 //*****************************************************************************************************************
1809 // public method
1810 //*****************************************************************************************************************
1811 Image AddonsOptions::GetImageFromURL( const rtl::OUString& aURL, sal_Bool bBig, sal_Bool bHiContrast, sal_Bool bNoScale ) const
1813 MutexGuard aGuard( GetOwnStaticMutex() );
1814 return m_pDataContainer->GetImageFromURL( aURL, bBig, bHiContrast, bNoScale );
1817 //*****************************************************************************************************************
1818 // public method
1819 //*****************************************************************************************************************
1820 Image AddonsOptions::GetImageFromURL( const rtl::OUString& aURL, sal_Bool bBig, sal_Bool bHiContrast ) const
1822 return GetImageFromURL( aURL, bBig, bHiContrast, sal_False );
1825 //*****************************************************************************************************************
1826 // private method
1827 //*****************************************************************************************************************
1828 Mutex& AddonsOptions::GetOwnStaticMutex()
1830 // Initialize static mutex only for one time!
1831 static Mutex* pMutex = NULL;
1832 // If these method first called (Mutex not already exist!) ...
1833 if( pMutex == NULL )
1835 // ... we must create a new one. Protect follow code with the global mutex -
1836 // It must be - we create a static variable!
1837 MutexGuard aGuard( Mutex::getGlobalMutex() );
1838 // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these!
1839 if( pMutex == NULL )
1841 // Create the new mutex and set it for return on static variable.
1842 static Mutex aMutex;
1843 pMutex = &aMutex;
1846 // Return new created or already existing mutex object.
1847 return *pMutex;
1850 //*****************************************************************************************************************
1851 // private method
1852 //*****************************************************************************************************************
1853 IMPL_STATIC_LINK_NOINSTANCE( AddonsOptions, Notify, void*, EMPTYARG )
1855 MutexGuard aGuard( GetOwnStaticMutex() );
1856 m_pDataContainer->ReadConfigurationData();
1857 return 0;