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