1*b5088357SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b5088357SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b5088357SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b5088357SAndrew Rist * distributed with this work for additional information 6*b5088357SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b5088357SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b5088357SAndrew Rist * "License"); you may not use this file except in compliance 9*b5088357SAndrew Rist * with the License. You may obtain a copy of the License at 10*b5088357SAndrew Rist * 11*b5088357SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*b5088357SAndrew Rist * 13*b5088357SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b5088357SAndrew Rist * software distributed under the License is distributed on an 15*b5088357SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b5088357SAndrew Rist * KIND, either express or implied. See the License for the 17*b5088357SAndrew Rist * specific language governing permissions and limitations 18*b5088357SAndrew Rist * under the License. 19*b5088357SAndrew Rist * 20*b5088357SAndrew Rist *************************************************************/ 21*b5088357SAndrew Rist 22*b5088357SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_unotools.hxx" 26cdf0e10cSrcweir #ifndef GCC 27cdf0e10cSrcweir #endif 28cdf0e10cSrcweir 29cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 30cdf0e10cSrcweir // includes 31cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <unotools/startoptions.hxx> 34cdf0e10cSrcweir #include <unotools/configmgr.hxx> 35cdf0e10cSrcweir #include <unotools/configitem.hxx> 36cdf0e10cSrcweir #include <tools/debug.hxx> 37cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 38cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <rtl/logfile.hxx> 41cdf0e10cSrcweir #include "itemholder1.hxx" 42cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 43cdf0e10cSrcweir // namespaces 44cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 45cdf0e10cSrcweir 46cdf0e10cSrcweir using namespace ::utl ; 47cdf0e10cSrcweir using namespace ::rtl ; 48cdf0e10cSrcweir using namespace ::osl ; 49cdf0e10cSrcweir using namespace ::com::sun::star::uno ; 50cdf0e10cSrcweir 51cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 52cdf0e10cSrcweir // const 53cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 54cdf0e10cSrcweir 55cdf0e10cSrcweir #define DEFAULT_SHOWINTRO sal_True 56cdf0e10cSrcweir #define DEFAULT_CONNECTIONURL OUString() 57cdf0e10cSrcweir 58cdf0e10cSrcweir #define ROOTNODE_START OUString(RTL_CONSTASCII_USTRINGPARAM("Setup/Office" )) 59cdf0e10cSrcweir #define PROPERTYNAME_SHOWINTRO OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupShowIntro" )) 60cdf0e10cSrcweir #define PROPERTYNAME_CONNECTIONURL OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupConnectionURL" )) 61cdf0e10cSrcweir 62cdf0e10cSrcweir #define PROPERTYHANDLE_SHOWINTRO 0 63cdf0e10cSrcweir #define PROPERTYHANDLE_CONNECTIONURL 1 64cdf0e10cSrcweir 65cdf0e10cSrcweir #define PROPERTYCOUNT 2 66cdf0e10cSrcweir 67cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 68cdf0e10cSrcweir // private declarations! 69cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 70cdf0e10cSrcweir 71cdf0e10cSrcweir class SvtStartOptions_Impl : public ConfigItem 72cdf0e10cSrcweir { 73cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 74cdf0e10cSrcweir // public methods 75cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 76cdf0e10cSrcweir 77cdf0e10cSrcweir public: 78cdf0e10cSrcweir 79cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 80cdf0e10cSrcweir // constructor / destructor 81cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 82cdf0e10cSrcweir 83cdf0e10cSrcweir SvtStartOptions_Impl(); 84cdf0e10cSrcweir ~SvtStartOptions_Impl(); 85cdf0e10cSrcweir 86cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 87cdf0e10cSrcweir // overloaded methods of baseclass 88cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 89cdf0e10cSrcweir 90cdf0e10cSrcweir /*-****************************************************************************************************//** 91cdf0e10cSrcweir @short called for notify of configmanager 92cdf0e10cSrcweir @descr These method is called from the ConfigManager before application ends or from the 93cdf0e10cSrcweir PropertyChangeListener if the sub tree broadcasts changes. You must update your 94cdf0e10cSrcweir internal values. 95cdf0e10cSrcweir 96cdf0e10cSrcweir @ATTENTION We don't implement these method - because we support readonly values at runtime only! 97cdf0e10cSrcweir 98cdf0e10cSrcweir @seealso baseclass ConfigItem 99cdf0e10cSrcweir 100cdf0e10cSrcweir @param "seqPropertyNames" is the list of properties which should be updated. 101cdf0e10cSrcweir @return - 102cdf0e10cSrcweir 103cdf0e10cSrcweir @onerror - 104cdf0e10cSrcweir *//*-*****************************************************************************************************/ 105cdf0e10cSrcweir 106cdf0e10cSrcweir virtual void Notify( const Sequence< OUString >& seqPropertyNames ); 107cdf0e10cSrcweir 108cdf0e10cSrcweir /*-****************************************************************************************************//** 109cdf0e10cSrcweir @short write changes to configuration 110cdf0e10cSrcweir @descr These method writes the changed values into the sub tree 111cdf0e10cSrcweir and should always called in our destructor to guarantee consistency of config data. 112cdf0e10cSrcweir 113cdf0e10cSrcweir @ATTENTION We don't implement these method - because we support readonly values at runtime only! 114cdf0e10cSrcweir 115cdf0e10cSrcweir @seealso baseclass ConfigItem 116cdf0e10cSrcweir 117cdf0e10cSrcweir @param - 118cdf0e10cSrcweir @return - 119cdf0e10cSrcweir 120cdf0e10cSrcweir @onerror - 121cdf0e10cSrcweir *//*-*****************************************************************************************************/ 122cdf0e10cSrcweir 123cdf0e10cSrcweir virtual void Commit(); 124cdf0e10cSrcweir 125cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 126cdf0e10cSrcweir // public interface 127cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 128cdf0e10cSrcweir 129cdf0e10cSrcweir /*-****************************************************************************************************//** 130cdf0e10cSrcweir @short access method to get internal values 131cdf0e10cSrcweir @descr These method give us a chance to regulate acces to ouer internal values. 132cdf0e10cSrcweir It's not used in the moment - but it's possible for the feature! 133cdf0e10cSrcweir 134cdf0e10cSrcweir @seealso - 135cdf0e10cSrcweir 136cdf0e10cSrcweir @param - 137cdf0e10cSrcweir @return - 138cdf0e10cSrcweir 139cdf0e10cSrcweir @onerror - 140cdf0e10cSrcweir *//*-*****************************************************************************************************/ 141cdf0e10cSrcweir 142cdf0e10cSrcweir sal_Bool IsIntroEnabled ( ) const ; 143cdf0e10cSrcweir void EnableIntro ( sal_Bool bState ) ; 144cdf0e10cSrcweir OUString GetConnectionURL( ) const ; 145cdf0e10cSrcweir void SetConnectionURL( const OUString& sURL ) ; 146cdf0e10cSrcweir 147cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 148cdf0e10cSrcweir // private methods 149cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 150cdf0e10cSrcweir 151cdf0e10cSrcweir private: 152cdf0e10cSrcweir 153cdf0e10cSrcweir /*-****************************************************************************************************//** 154cdf0e10cSrcweir @short return list of fix key names of ouer configuration management which represent oue module tree 155cdf0e10cSrcweir @descr These methods return a static const list of key names. We need it to get needed values from our 156cdf0e10cSrcweir configuration management. We return well known key names only - because the "UserData" node 157cdf0e10cSrcweir is handled in a special way! 158cdf0e10cSrcweir 159cdf0e10cSrcweir @seealso - 160cdf0e10cSrcweir 161cdf0e10cSrcweir @param - 162cdf0e10cSrcweir @return A list of needed configuration keys is returned. 163cdf0e10cSrcweir 164cdf0e10cSrcweir @onerror - 165cdf0e10cSrcweir *//*-*****************************************************************************************************/ 166cdf0e10cSrcweir 167cdf0e10cSrcweir static Sequence< OUString > impl_GetPropertyNames(); 168cdf0e10cSrcweir 169cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 170cdf0e10cSrcweir // private member 171cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 172cdf0e10cSrcweir 173cdf0e10cSrcweir private: 174cdf0e10cSrcweir 175cdf0e10cSrcweir sal_Bool m_bShowIntro ; /// cache "ShowIntro" of Start section 176cdf0e10cSrcweir OUString m_sConnectionURL ; /// cache "Connection" of Start section 177cdf0e10cSrcweir }; 178cdf0e10cSrcweir 179cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 180cdf0e10cSrcweir // definitions 181cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 182cdf0e10cSrcweir 183cdf0e10cSrcweir //***************************************************************************************************************** 184cdf0e10cSrcweir // constructor 185cdf0e10cSrcweir //***************************************************************************************************************** 186cdf0e10cSrcweir SvtStartOptions_Impl::SvtStartOptions_Impl() 187cdf0e10cSrcweir // Init baseclasses first 188cdf0e10cSrcweir : ConfigItem ( ROOTNODE_START ) 189cdf0e10cSrcweir // Init member then. 190cdf0e10cSrcweir , m_bShowIntro ( DEFAULT_SHOWINTRO ) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir // Use our static list of configuration keys to get his values. 193cdf0e10cSrcweir Sequence< OUString > seqNames = impl_GetPropertyNames(); 194cdf0e10cSrcweir Sequence< Any > seqValues = GetProperties( seqNames ) ; 195cdf0e10cSrcweir 196cdf0e10cSrcweir // Safe impossible cases. 197cdf0e10cSrcweir // We need values from ALL configuration keys. 198cdf0e10cSrcweir // Follow assignment use order of values in relation to our list of key names! 199cdf0e10cSrcweir DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtStartOptions_Impl::SvtStartOptions_Impl()\nI miss some values of configuration keys!\n" ); 200cdf0e10cSrcweir 201cdf0e10cSrcweir // Copy values from list in right order to ouer internal member. 202cdf0e10cSrcweir sal_Int32 nPropertyCount = seqValues.getLength() ; 203cdf0e10cSrcweir sal_Int32 nProperty = 0 ; 204cdf0e10cSrcweir for( nProperty=0; nProperty<nPropertyCount; ++nProperty ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir // Safe impossible cases. 207cdf0e10cSrcweir // Check any for valid value. 208cdf0e10cSrcweir DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtStartOptions_Impl::SvtStartOptions_Impl()\nInvalid property value for property detected!\n" ); 209cdf0e10cSrcweir switch( nProperty ) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir case PROPERTYHANDLE_SHOWINTRO : { 212cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtStartOptions_Impl::SvtStartOptions_Impl()\nWho has changed the value type of \"Office.Common\\Start\\ShowIntro\"?" ); 213cdf0e10cSrcweir seqValues[nProperty] >>= m_bShowIntro; 214cdf0e10cSrcweir } 215cdf0e10cSrcweir break; 216cdf0e10cSrcweir 217cdf0e10cSrcweir case PROPERTYHANDLE_CONNECTIONURL : { 218cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_STRING), "SvtStartOptions_Impl::SvtStartOptions_Impl()\nWho has changed the value type of \"Office.Common\\Start\\Connection\"?" ); 219cdf0e10cSrcweir seqValues[nProperty] >>= m_sConnectionURL; 220cdf0e10cSrcweir } 221cdf0e10cSrcweir break; 222cdf0e10cSrcweir } 223cdf0e10cSrcweir } 224cdf0e10cSrcweir 225cdf0e10cSrcweir // Don't enable notification mechanism of ouer baseclass! 226cdf0e10cSrcweir // We support readonly variables in the moment. 227cdf0e10cSrcweir } 228cdf0e10cSrcweir 229cdf0e10cSrcweir //***************************************************************************************************************** 230cdf0e10cSrcweir // destructor 231cdf0e10cSrcweir //***************************************************************************************************************** 232cdf0e10cSrcweir SvtStartOptions_Impl::~SvtStartOptions_Impl() 233cdf0e10cSrcweir { 234cdf0e10cSrcweir // We must save our current values .. if user forget it! 235cdf0e10cSrcweir if( IsModified() == sal_True ) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir Commit(); 238cdf0e10cSrcweir } 239cdf0e10cSrcweir } 240cdf0e10cSrcweir 241cdf0e10cSrcweir //***************************************************************************************************************** 242cdf0e10cSrcweir // public method 243cdf0e10cSrcweir //***************************************************************************************************************** 244cdf0e10cSrcweir void SvtStartOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames ) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir // Use given list of updated properties to get his values from configuration directly! 247cdf0e10cSrcweir Sequence< Any > seqValues = GetProperties( seqPropertyNames ); 248cdf0e10cSrcweir // Safe impossible cases. 249cdf0e10cSrcweir // We need values from ALL notified configuration keys. 250cdf0e10cSrcweir DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtStartOptions_Impl::Notify()\nI miss some values of configuration keys!\n" ); 251cdf0e10cSrcweir // Step over list of property names and get right value from coreesponding value list to set it on internal members! 252cdf0e10cSrcweir sal_Int32 nCount = seqPropertyNames.getLength(); 253cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) 254cdf0e10cSrcweir { 255cdf0e10cSrcweir if( seqPropertyNames[nProperty] == PROPERTYNAME_SHOWINTRO ) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtStartOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Start\\ShowIntro\"?" ); 258cdf0e10cSrcweir seqValues[nProperty] >>= m_bShowIntro; 259cdf0e10cSrcweir } 260cdf0e10cSrcweir else 261cdf0e10cSrcweir if( seqPropertyNames[nProperty] == PROPERTYNAME_CONNECTIONURL ) 262cdf0e10cSrcweir { 263cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_STRING), "SvtStartOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\Start\\Connection\"?" ); 264cdf0e10cSrcweir seqValues[nProperty] >>= m_sConnectionURL; 265cdf0e10cSrcweir } 266cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 267cdf0e10cSrcweir else DBG_ASSERT( sal_False, "SvtStartOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" ); 268cdf0e10cSrcweir #endif 269cdf0e10cSrcweir } 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir //***************************************************************************************************************** 273cdf0e10cSrcweir // public method 274cdf0e10cSrcweir //***************************************************************************************************************** 275cdf0e10cSrcweir void SvtStartOptions_Impl::Commit() 276cdf0e10cSrcweir { 277cdf0e10cSrcweir // Get names of supported properties, create a list for values and copy current values to it. 278cdf0e10cSrcweir Sequence< OUString > seqNames = impl_GetPropertyNames(); 279cdf0e10cSrcweir sal_Int32 nCount = seqNames.getLength(); 280cdf0e10cSrcweir Sequence< Any > seqValues ( nCount ); 281cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir switch( nProperty ) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir case PROPERTYHANDLE_SHOWINTRO : { 286cdf0e10cSrcweir seqValues[nProperty] <<= m_bShowIntro; 287cdf0e10cSrcweir } 288cdf0e10cSrcweir break; 289cdf0e10cSrcweir case PROPERTYHANDLE_CONNECTIONURL : { 290cdf0e10cSrcweir seqValues[nProperty] <<= m_sConnectionURL; 291cdf0e10cSrcweir } 292cdf0e10cSrcweir break; 293cdf0e10cSrcweir } 294cdf0e10cSrcweir } 295cdf0e10cSrcweir // Set properties in configuration. 296cdf0e10cSrcweir PutProperties( seqNames, seqValues ); 297cdf0e10cSrcweir } 298cdf0e10cSrcweir 299cdf0e10cSrcweir //***************************************************************************************************************** 300cdf0e10cSrcweir // public method 301cdf0e10cSrcweir //***************************************************************************************************************** 302cdf0e10cSrcweir sal_Bool SvtStartOptions_Impl::IsIntroEnabled() const 303cdf0e10cSrcweir { 304cdf0e10cSrcweir return m_bShowIntro; 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir //***************************************************************************************************************** 308cdf0e10cSrcweir // public method 309cdf0e10cSrcweir //***************************************************************************************************************** 310cdf0e10cSrcweir void SvtStartOptions_Impl::EnableIntro( sal_Bool bState ) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir m_bShowIntro = bState; 313cdf0e10cSrcweir SetModified(); 314cdf0e10cSrcweir } 315cdf0e10cSrcweir 316cdf0e10cSrcweir //***************************************************************************************************************** 317cdf0e10cSrcweir // public method 318cdf0e10cSrcweir //***************************************************************************************************************** 319cdf0e10cSrcweir OUString SvtStartOptions_Impl::GetConnectionURL() const 320cdf0e10cSrcweir { 321cdf0e10cSrcweir return m_sConnectionURL; 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir //***************************************************************************************************************** 325cdf0e10cSrcweir // public method 326cdf0e10cSrcweir //***************************************************************************************************************** 327cdf0e10cSrcweir void SvtStartOptions_Impl::SetConnectionURL( const OUString& sURL ) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir m_sConnectionURL = sURL; 330cdf0e10cSrcweir SetModified(); 331cdf0e10cSrcweir } 332cdf0e10cSrcweir 333cdf0e10cSrcweir //***************************************************************************************************************** 334cdf0e10cSrcweir // private method 335cdf0e10cSrcweir //***************************************************************************************************************** 336cdf0e10cSrcweir Sequence< OUString > SvtStartOptions_Impl::impl_GetPropertyNames() 337cdf0e10cSrcweir { 338cdf0e10cSrcweir // Build static list of configuration key names. 339cdf0e10cSrcweir static const OUString pProperties[] = 340cdf0e10cSrcweir { 341cdf0e10cSrcweir PROPERTYNAME_SHOWINTRO , 342cdf0e10cSrcweir PROPERTYNAME_CONNECTIONURL , 343cdf0e10cSrcweir }; 344cdf0e10cSrcweir // Initialize return sequence with these list ... 345cdf0e10cSrcweir static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT ); 346cdf0e10cSrcweir // ... and return it. 347cdf0e10cSrcweir return seqPropertyNames; 348cdf0e10cSrcweir } 349cdf0e10cSrcweir 350cdf0e10cSrcweir //***************************************************************************************************************** 351cdf0e10cSrcweir // initialize static member 352cdf0e10cSrcweir // DON'T DO IT IN YOUR HEADER! 353cdf0e10cSrcweir // see definition for further informations 354cdf0e10cSrcweir //***************************************************************************************************************** 355cdf0e10cSrcweir SvtStartOptions_Impl* SvtStartOptions::m_pDataContainer = NULL ; 356cdf0e10cSrcweir sal_Int32 SvtStartOptions::m_nRefCount = 0 ; 357cdf0e10cSrcweir 358cdf0e10cSrcweir //***************************************************************************************************************** 359cdf0e10cSrcweir // constructor 360cdf0e10cSrcweir //***************************************************************************************************************** 361cdf0e10cSrcweir SvtStartOptions::SvtStartOptions() 362cdf0e10cSrcweir { 363cdf0e10cSrcweir // Global access, must be guarded (multithreading!). 364cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 365cdf0e10cSrcweir // Increase ouer refcount ... 366cdf0e10cSrcweir ++m_nRefCount; 367cdf0e10cSrcweir // ... and initialize ouer data container only if it not already! 368cdf0e10cSrcweir if( m_pDataContainer == NULL ) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtStartOptions_Impl::ctor()"); 371cdf0e10cSrcweir m_pDataContainer = new SvtStartOptions_Impl(); 372cdf0e10cSrcweir 373cdf0e10cSrcweir ItemHolder1::holdConfigItem(E_STARTOPTIONS); 374cdf0e10cSrcweir } 375cdf0e10cSrcweir } 376cdf0e10cSrcweir 377cdf0e10cSrcweir //***************************************************************************************************************** 378cdf0e10cSrcweir // destructor 379cdf0e10cSrcweir //***************************************************************************************************************** 380cdf0e10cSrcweir SvtStartOptions::~SvtStartOptions() 381cdf0e10cSrcweir { 382cdf0e10cSrcweir // Global access, must be guarded (multithreading!) 383cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 384cdf0e10cSrcweir // Decrease ouer refcount. 385cdf0e10cSrcweir --m_nRefCount; 386cdf0e10cSrcweir // If last instance was deleted ... 387cdf0e10cSrcweir // we must destroy ouer static data container! 388cdf0e10cSrcweir if( m_nRefCount <= 0 ) 389cdf0e10cSrcweir { 390cdf0e10cSrcweir delete m_pDataContainer; 391cdf0e10cSrcweir m_pDataContainer = NULL; 392cdf0e10cSrcweir } 393cdf0e10cSrcweir } 394cdf0e10cSrcweir 395cdf0e10cSrcweir //***************************************************************************************************************** 396cdf0e10cSrcweir // public method 397cdf0e10cSrcweir //***************************************************************************************************************** 398cdf0e10cSrcweir sal_Bool SvtStartOptions::IsIntroEnabled() const 399cdf0e10cSrcweir { 400cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 401cdf0e10cSrcweir return m_pDataContainer->IsIntroEnabled(); 402cdf0e10cSrcweir } 403cdf0e10cSrcweir 404cdf0e10cSrcweir //***************************************************************************************************************** 405cdf0e10cSrcweir // public method 406cdf0e10cSrcweir //***************************************************************************************************************** 407cdf0e10cSrcweir void SvtStartOptions::EnableIntro( sal_Bool bState ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 410cdf0e10cSrcweir m_pDataContainer->EnableIntro( bState ); 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 413cdf0e10cSrcweir //***************************************************************************************************************** 414cdf0e10cSrcweir // public method 415cdf0e10cSrcweir //***************************************************************************************************************** 416cdf0e10cSrcweir OUString SvtStartOptions::GetConnectionURL() const 417cdf0e10cSrcweir { 418cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 419cdf0e10cSrcweir return m_pDataContainer->GetConnectionURL(); 420cdf0e10cSrcweir } 421cdf0e10cSrcweir 422cdf0e10cSrcweir //***************************************************************************************************************** 423cdf0e10cSrcweir // public method 424cdf0e10cSrcweir //***************************************************************************************************************** 425cdf0e10cSrcweir void SvtStartOptions::SetConnectionURL( const OUString& sURL ) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 428cdf0e10cSrcweir m_pDataContainer->SetConnectionURL( sURL ); 429cdf0e10cSrcweir } 430cdf0e10cSrcweir 431cdf0e10cSrcweir //***************************************************************************************************************** 432cdf0e10cSrcweir // private method 433cdf0e10cSrcweir //***************************************************************************************************************** 434cdf0e10cSrcweir Mutex& SvtStartOptions::GetOwnStaticMutex() 435cdf0e10cSrcweir { 436cdf0e10cSrcweir // Initialize static mutex only for one time! 437cdf0e10cSrcweir static Mutex* pMutex = NULL; 438cdf0e10cSrcweir // If these method first called (Mutex not already exist!) ... 439cdf0e10cSrcweir if( pMutex == NULL ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir // ... we must create a new one. Protect follow code with the global mutex - 442cdf0e10cSrcweir // It must be - we create a static variable! 443cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() ); 444cdf0e10cSrcweir // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these! 445cdf0e10cSrcweir if( pMutex == NULL ) 446cdf0e10cSrcweir { 447cdf0e10cSrcweir // Create the new mutex and set it for return on static variable. 448cdf0e10cSrcweir static Mutex aMutex; 449cdf0e10cSrcweir pMutex = &aMutex; 450cdf0e10cSrcweir } 451cdf0e10cSrcweir } 452cdf0e10cSrcweir // Return new created or already existing mutex object. 453cdf0e10cSrcweir return *pMutex; 454cdf0e10cSrcweir } 455