1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_unotools.hxx" 30*cdf0e10cSrcweir #ifndef GCC 31*cdf0e10cSrcweir #endif 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 34*cdf0e10cSrcweir // includes 35*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <unotools/workingsetoptions.hxx> 38*cdf0e10cSrcweir #include <unotools/configmgr.hxx> 39*cdf0e10cSrcweir #include <unotools/configitem.hxx> 40*cdf0e10cSrcweir #include <tools/debug.hxx> 41*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 42*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include <itemholder1.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 47*cdf0e10cSrcweir // namespaces 48*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir using namespace ::utl ; 51*cdf0e10cSrcweir using namespace ::rtl ; 52*cdf0e10cSrcweir using namespace ::osl ; 53*cdf0e10cSrcweir using namespace ::com::sun::star::uno ; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 56*cdf0e10cSrcweir // const 57*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir #define ROOTNODE_WORKINGSET OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/WorkingSet")) 60*cdf0e10cSrcweir #define DEFAULT_WINDOWLIST Sequence< OUString >() 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir #define PROPERTYNAME_WINDOWLIST OUString(RTL_CONSTASCII_USTRINGPARAM("WindowList" )) 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir #define PROPERTYHANDLE_WINDOWLIST 0 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir #define PROPERTYCOUNT 1 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 69*cdf0e10cSrcweir // private declarations! 70*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir class SvtWorkingSetOptions_Impl : public ConfigItem 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 75*cdf0e10cSrcweir // public methods 76*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir public: 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 81*cdf0e10cSrcweir // constructor / destructor 82*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir SvtWorkingSetOptions_Impl(); 85*cdf0e10cSrcweir ~SvtWorkingSetOptions_Impl(); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 88*cdf0e10cSrcweir // overloaded methods of baseclass 89*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir /*-****************************************************************************************************//** 92*cdf0e10cSrcweir @short called for notify of configmanager 93*cdf0e10cSrcweir @descr These method is called from the ConfigManager before application ends or from the 94*cdf0e10cSrcweir PropertyChangeListener if the sub tree broadcasts changes. You must update your 95*cdf0e10cSrcweir internal values. 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir @seealso baseclass ConfigItem 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir @param "seqPropertyNames" is the list of properties which should be updated. 100*cdf0e10cSrcweir @return - 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir @onerror - 103*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir virtual void Notify( const Sequence< OUString >& seqPropertyNames ); 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir /*-****************************************************************************************************//** 108*cdf0e10cSrcweir @short write changes to configuration 109*cdf0e10cSrcweir @descr These method writes the changed values into the sub tree 110*cdf0e10cSrcweir and should always called in our destructor to guarantee consistency of config data. 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir @seealso baseclass ConfigItem 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir @param - 115*cdf0e10cSrcweir @return - 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir @onerror - 118*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir virtual void Commit(); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 123*cdf0e10cSrcweir // public interface 124*cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir /*-****************************************************************************************************//** 127*cdf0e10cSrcweir @short access method to get internal values 128*cdf0e10cSrcweir @descr These method give us a chance to regulate acces to ouer internal values. 129*cdf0e10cSrcweir It's not used in the moment - but it's possible for the feature! 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir @seealso - 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir @param - 134*cdf0e10cSrcweir @return - 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir @onerror - 137*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir Sequence< OUString > GetWindowList( ) const ; 140*cdf0e10cSrcweir void SetWindowList( const Sequence< OUString >& seqWindowList ) ; 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 143*cdf0e10cSrcweir // private methods 144*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir private: 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir /*-****************************************************************************************************//** 149*cdf0e10cSrcweir @short return list of key names of ouer configuration management which represent oue module tree 150*cdf0e10cSrcweir @descr These methods return a static const list of key names. We need it to get needed values from our 151*cdf0e10cSrcweir configuration management. 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir @seealso - 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir @param - 156*cdf0e10cSrcweir @return A list of needed configuration keys is returned. 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir @onerror - 159*cdf0e10cSrcweir *//*-*****************************************************************************************************/ 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir static Sequence< OUString > GetPropertyNames(); 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 164*cdf0e10cSrcweir // private member 165*cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir private: 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir Sequence< OUString > m_seqWindowList ; 170*cdf0e10cSrcweir }; 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 173*cdf0e10cSrcweir // definitions 174*cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir //***************************************************************************************************************** 177*cdf0e10cSrcweir // constructor 178*cdf0e10cSrcweir //***************************************************************************************************************** 179*cdf0e10cSrcweir SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl() 180*cdf0e10cSrcweir // Init baseclasses first 181*cdf0e10cSrcweir : ConfigItem ( ROOTNODE_WORKINGSET ) 182*cdf0e10cSrcweir // Init member then. 183*cdf0e10cSrcweir , m_seqWindowList ( DEFAULT_WINDOWLIST ) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir // Use our static list of configuration keys to get his values. 186*cdf0e10cSrcweir Sequence< OUString > seqNames = GetPropertyNames ( ); 187*cdf0e10cSrcweir Sequence< Any > seqValues = GetProperties ( seqNames ); 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir // Safe impossible cases. 190*cdf0e10cSrcweir // We need values from ALL configuration keys. 191*cdf0e10cSrcweir // Follow assignment use order of values in relation to our list of key names! 192*cdf0e10cSrcweir DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl()\nI miss some values of configuration keys!\n" ); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir // Copy values from list in right order to ouer internal member. 195*cdf0e10cSrcweir sal_Int32 nPropertyCount = seqValues.getLength(); 196*cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir // Safe impossible cases. 199*cdf0e10cSrcweir // Check any for valid value. 200*cdf0e10cSrcweir DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl()\nInvalid property value detected!\n" ); 201*cdf0e10cSrcweir switch( nProperty ) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir case PROPERTYHANDLE_WINDOWLIST : { 204*cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SEQUENCE), "SvtWorkingSetOptions_Impl::SvtWorkingSetOptions_Impl()\nWho has changed the value type of \"Office.Common\\WorkingSet\\WindowList\"?" ); 205*cdf0e10cSrcweir seqValues[nProperty] >>= m_seqWindowList; 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir break; 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir // Enable notification mechanism of ouer baseclass. 212*cdf0e10cSrcweir // We need it to get information about changes outside these class on ouer used configuration keys! 213*cdf0e10cSrcweir EnableNotification( seqNames ); 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir //***************************************************************************************************************** 217*cdf0e10cSrcweir // destructor 218*cdf0e10cSrcweir //***************************************************************************************************************** 219*cdf0e10cSrcweir SvtWorkingSetOptions_Impl::~SvtWorkingSetOptions_Impl() 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir // We must save our current values .. if user forget it! 222*cdf0e10cSrcweir if( IsModified() == sal_True ) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir Commit(); 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir //***************************************************************************************************************** 229*cdf0e10cSrcweir // public method 230*cdf0e10cSrcweir //***************************************************************************************************************** 231*cdf0e10cSrcweir void SvtWorkingSetOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames ) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir // Use given list of updated properties to get his values from configuration directly! 234*cdf0e10cSrcweir Sequence< Any > seqValues = GetProperties( seqPropertyNames ); 235*cdf0e10cSrcweir // Safe impossible cases. 236*cdf0e10cSrcweir // We need values from ALL notified configuration keys. 237*cdf0e10cSrcweir DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtWorkingSetOptions_Impl::Notify()\nI miss some values of configuration keys!\n" ); 238*cdf0e10cSrcweir // Step over list of property names and get right value from coreesponding value list to set it on internal members! 239*cdf0e10cSrcweir sal_Int32 nCount = seqPropertyNames.getLength(); 240*cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir if( seqPropertyNames[nProperty] == PROPERTYNAME_WINDOWLIST ) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SEQUENCE), "SvtWorkingSetOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\WorkingSet\\WindowList\"?" ); 245*cdf0e10cSrcweir seqValues[nProperty] >>= m_seqWindowList; 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 248*cdf0e10cSrcweir else DBG_ASSERT( sal_False, "SvtWorkingSetOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" ); 249*cdf0e10cSrcweir #endif 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir //***************************************************************************************************************** 254*cdf0e10cSrcweir // public method 255*cdf0e10cSrcweir //***************************************************************************************************************** 256*cdf0e10cSrcweir void SvtWorkingSetOptions_Impl::Commit() 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir // Get names of supported properties, create a list for values and copy current values to it. 259*cdf0e10cSrcweir Sequence< OUString > seqNames = GetPropertyNames (); 260*cdf0e10cSrcweir sal_Int32 nCount = seqNames.getLength(); 261*cdf0e10cSrcweir Sequence< Any > seqValues ( nCount ); 262*cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir switch( nProperty ) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir case PROPERTYHANDLE_WINDOWLIST : { 267*cdf0e10cSrcweir seqValues[nProperty] <<= m_seqWindowList; 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir break; 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir // Set properties in configuration. 273*cdf0e10cSrcweir PutProperties( seqNames, seqValues ); 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir //***************************************************************************************************************** 277*cdf0e10cSrcweir // public method 278*cdf0e10cSrcweir //***************************************************************************************************************** 279*cdf0e10cSrcweir Sequence< OUString > SvtWorkingSetOptions_Impl::GetWindowList() const 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir return m_seqWindowList; 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir //***************************************************************************************************************** 285*cdf0e10cSrcweir // public method 286*cdf0e10cSrcweir //***************************************************************************************************************** 287*cdf0e10cSrcweir void SvtWorkingSetOptions_Impl::SetWindowList( const Sequence< OUString >& seqWindowList ) 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir m_seqWindowList = seqWindowList; 290*cdf0e10cSrcweir SetModified(); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir //***************************************************************************************************************** 294*cdf0e10cSrcweir // private method 295*cdf0e10cSrcweir //***************************************************************************************************************** 296*cdf0e10cSrcweir Sequence< OUString > SvtWorkingSetOptions_Impl::GetPropertyNames() 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir // Build static list of configuration key names. 299*cdf0e10cSrcweir static const OUString pProperties[] = 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir PROPERTYNAME_WINDOWLIST , 302*cdf0e10cSrcweir }; 303*cdf0e10cSrcweir // Initialize return sequence with these list ... 304*cdf0e10cSrcweir static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT ); 305*cdf0e10cSrcweir // ... and return it. 306*cdf0e10cSrcweir return seqPropertyNames; 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir //***************************************************************************************************************** 310*cdf0e10cSrcweir // initialize static member 311*cdf0e10cSrcweir // DON'T DO IT IN YOUR HEADER! 312*cdf0e10cSrcweir // see definition for further informations 313*cdf0e10cSrcweir //***************************************************************************************************************** 314*cdf0e10cSrcweir SvtWorkingSetOptions_Impl* SvtWorkingSetOptions::m_pDataContainer = NULL ; 315*cdf0e10cSrcweir sal_Int32 SvtWorkingSetOptions::m_nRefCount = 0 ; 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir //***************************************************************************************************************** 318*cdf0e10cSrcweir // constructor 319*cdf0e10cSrcweir //***************************************************************************************************************** 320*cdf0e10cSrcweir SvtWorkingSetOptions::SvtWorkingSetOptions() 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir // Global access, must be guarded (multithreading!). 323*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 324*cdf0e10cSrcweir // Increase ouer refcount ... 325*cdf0e10cSrcweir ++m_nRefCount; 326*cdf0e10cSrcweir // ... and initialize ouer data container only if it not already exist! 327*cdf0e10cSrcweir if( m_pDataContainer == NULL ) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir m_pDataContainer = new SvtWorkingSetOptions_Impl; 330*cdf0e10cSrcweir ItemHolder1::holdConfigItem(E_WORKINGSETOPTIONS); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir //***************************************************************************************************************** 335*cdf0e10cSrcweir // destructor 336*cdf0e10cSrcweir //***************************************************************************************************************** 337*cdf0e10cSrcweir SvtWorkingSetOptions::~SvtWorkingSetOptions() 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir // Global access, must be guarded (multithreading!) 340*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 341*cdf0e10cSrcweir // Decrease ouer refcount. 342*cdf0e10cSrcweir --m_nRefCount; 343*cdf0e10cSrcweir // If last instance was deleted ... 344*cdf0e10cSrcweir // we must destroy ouer static data container! 345*cdf0e10cSrcweir if( m_nRefCount <= 0 ) 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir delete m_pDataContainer; 348*cdf0e10cSrcweir m_pDataContainer = NULL; 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir //***************************************************************************************************************** 353*cdf0e10cSrcweir // public method 354*cdf0e10cSrcweir //***************************************************************************************************************** 355*cdf0e10cSrcweir Sequence< OUString > SvtWorkingSetOptions::GetWindowList() const 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 358*cdf0e10cSrcweir return m_pDataContainer->GetWindowList(); 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir //***************************************************************************************************************** 362*cdf0e10cSrcweir // public method 363*cdf0e10cSrcweir //***************************************************************************************************************** 364*cdf0e10cSrcweir void SvtWorkingSetOptions::SetWindowList( const Sequence< OUString >& seqWindowList ) 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 367*cdf0e10cSrcweir m_pDataContainer->SetWindowList( seqWindowList ); 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir //***************************************************************************************************************** 371*cdf0e10cSrcweir // private method 372*cdf0e10cSrcweir //***************************************************************************************************************** 373*cdf0e10cSrcweir Mutex& SvtWorkingSetOptions::GetOwnStaticMutex() 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir // Initialize static mutex only for one time! 376*cdf0e10cSrcweir static Mutex* pMutex = NULL; 377*cdf0e10cSrcweir // If these method first called (Mutex not already exist!) ... 378*cdf0e10cSrcweir if( pMutex == NULL ) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir // ... we must create a new one. Protect follow code with the global mutex - 381*cdf0e10cSrcweir // It must be - we create a static variable! 382*cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() ); 383*cdf0e10cSrcweir // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these! 384*cdf0e10cSrcweir if( pMutex == NULL ) 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir // Create the new mutex and set it for return on static variable. 387*cdf0e10cSrcweir static Mutex aMutex; 388*cdf0e10cSrcweir pMutex = &aMutex; 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir // Return new created or already existing mutex object. 392*cdf0e10cSrcweir return *pMutex; 393*cdf0e10cSrcweir } 394