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