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/localisationoptions.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 //_________________________________________________________________________________________________________________ 44cdf0e10cSrcweir // namespaces 45cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 46cdf0e10cSrcweir 47cdf0e10cSrcweir using namespace ::utl ; 48cdf0e10cSrcweir using namespace ::rtl ; 49cdf0e10cSrcweir using namespace ::osl ; 50cdf0e10cSrcweir using namespace ::com::sun::star::uno ; 51cdf0e10cSrcweir 52cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 53cdf0e10cSrcweir // const 54cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 55cdf0e10cSrcweir 56cdf0e10cSrcweir #define ROOTNODE_LOCALISATION OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/View/Localisation")) 57cdf0e10cSrcweir #define DEFAULT_AUTOMNEMONIC sal_False 58cdf0e10cSrcweir #define DEFAULT_DIALOGSCALE 0 59cdf0e10cSrcweir 60cdf0e10cSrcweir #define PROPERTYNAME_AUTOMNEMONIC OUString(RTL_CONSTASCII_USTRINGPARAM("AutoMnemonic" )) 61cdf0e10cSrcweir #define PROPERTYNAME_DIALOGSCALE OUString(RTL_CONSTASCII_USTRINGPARAM("DialogScale" )) 62cdf0e10cSrcweir 63cdf0e10cSrcweir #define PROPERTYHANDLE_AUTOMNEMONIC 0 64cdf0e10cSrcweir #define PROPERTYHANDLE_DIALOGSCALE 1 65cdf0e10cSrcweir 66cdf0e10cSrcweir #define PROPERTYCOUNT 2 67cdf0e10cSrcweir 68cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 69cdf0e10cSrcweir // private declarations! 70cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 71cdf0e10cSrcweir 72cdf0e10cSrcweir class SvtLocalisationOptions_Impl : public ConfigItem 73cdf0e10cSrcweir { 74cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 75cdf0e10cSrcweir // public methods 76cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 77cdf0e10cSrcweir 78cdf0e10cSrcweir public: 79cdf0e10cSrcweir 80cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 81cdf0e10cSrcweir // constructor / destructor 82cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 83cdf0e10cSrcweir 84cdf0e10cSrcweir SvtLocalisationOptions_Impl(); 85cdf0e10cSrcweir ~SvtLocalisationOptions_Impl(); 86cdf0e10cSrcweir 87cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 88cdf0e10cSrcweir // overloaded methods of baseclass 89cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 90cdf0e10cSrcweir 91cdf0e10cSrcweir /*-****************************************************************************************************//** 92cdf0e10cSrcweir @short called for notify of configmanager 93cdf0e10cSrcweir @descr These method is called from the ConfigManager before application ends or from the 94cdf0e10cSrcweir PropertyChangeListener if the sub tree broadcasts changes. You must update your 95cdf0e10cSrcweir internal values. 96cdf0e10cSrcweir 97cdf0e10cSrcweir @seealso baseclass ConfigItem 98cdf0e10cSrcweir 99cdf0e10cSrcweir @param "seqPropertyNames" is the list of properties which should be updated. 100cdf0e10cSrcweir @return - 101cdf0e10cSrcweir 102cdf0e10cSrcweir @onerror - 103cdf0e10cSrcweir *//*-*****************************************************************************************************/ 104cdf0e10cSrcweir 105cdf0e10cSrcweir virtual void Notify( const Sequence< OUString >& seqPropertyNames ); 106cdf0e10cSrcweir 107cdf0e10cSrcweir /*-****************************************************************************************************//** 108cdf0e10cSrcweir @short write changes to configuration 109cdf0e10cSrcweir @descr These method writes the changed values into the sub tree 110cdf0e10cSrcweir and should always called in our destructor to guarantee consistency of config data. 111cdf0e10cSrcweir 112cdf0e10cSrcweir @seealso baseclass ConfigItem 113cdf0e10cSrcweir 114cdf0e10cSrcweir @param - 115cdf0e10cSrcweir @return - 116cdf0e10cSrcweir 117cdf0e10cSrcweir @onerror - 118cdf0e10cSrcweir *//*-*****************************************************************************************************/ 119cdf0e10cSrcweir 120cdf0e10cSrcweir virtual void Commit(); 121cdf0e10cSrcweir 122cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 123cdf0e10cSrcweir // public interface 124cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 125cdf0e10cSrcweir 126cdf0e10cSrcweir /*-****************************************************************************************************//** 127cdf0e10cSrcweir @short access method to get internal values 128cdf0e10cSrcweir @descr These method give us a chance to regulate acces to ouer internal values. 129cdf0e10cSrcweir It's not used in the moment - but it's possible for the feature! 130cdf0e10cSrcweir 131cdf0e10cSrcweir @seealso - 132cdf0e10cSrcweir 133cdf0e10cSrcweir @param - 134cdf0e10cSrcweir @return - 135cdf0e10cSrcweir 136cdf0e10cSrcweir @onerror - 137cdf0e10cSrcweir *//*-*****************************************************************************************************/ 138cdf0e10cSrcweir 139cdf0e10cSrcweir sal_Bool IsAutoMnemonic ( ) const ; 140cdf0e10cSrcweir void SetAutoMnemonic ( sal_Bool bState ) ; 141cdf0e10cSrcweir sal_Int32 GetDialogScale ( ) const ; 142cdf0e10cSrcweir void SetDialogScale ( sal_Int32 nScale ) ; 143cdf0e10cSrcweir 144cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 145cdf0e10cSrcweir // private methods 146cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 147cdf0e10cSrcweir 148cdf0e10cSrcweir private: 149cdf0e10cSrcweir 150cdf0e10cSrcweir /*-****************************************************************************************************//** 151cdf0e10cSrcweir @short return list of key names of ouer configuration management which represent oue module tree 152cdf0e10cSrcweir @descr These methods return a static const list of key names. We need it to get needed values from our 153cdf0e10cSrcweir configuration management. 154cdf0e10cSrcweir 155cdf0e10cSrcweir @seealso - 156cdf0e10cSrcweir 157cdf0e10cSrcweir @param - 158cdf0e10cSrcweir @return A list of needed configuration keys is returned. 159cdf0e10cSrcweir 160cdf0e10cSrcweir @onerror - 161cdf0e10cSrcweir *//*-*****************************************************************************************************/ 162cdf0e10cSrcweir 163cdf0e10cSrcweir static Sequence< OUString > GetPropertyNames(); 164cdf0e10cSrcweir 165cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 166cdf0e10cSrcweir // private member 167cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 168cdf0e10cSrcweir 169cdf0e10cSrcweir private: 170cdf0e10cSrcweir 171cdf0e10cSrcweir sal_Bool m_bAutoMnemonic ; 172cdf0e10cSrcweir sal_Int32 m_nDialogScale ; 173cdf0e10cSrcweir }; 174cdf0e10cSrcweir 175cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 176cdf0e10cSrcweir // definitions 177cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 178cdf0e10cSrcweir 179cdf0e10cSrcweir //***************************************************************************************************************** 180cdf0e10cSrcweir // constructor 181cdf0e10cSrcweir //***************************************************************************************************************** 182cdf0e10cSrcweir SvtLocalisationOptions_Impl::SvtLocalisationOptions_Impl() 183cdf0e10cSrcweir // Init baseclasses first 184cdf0e10cSrcweir : ConfigItem ( ROOTNODE_LOCALISATION ) 185cdf0e10cSrcweir // Init member then. 186cdf0e10cSrcweir , m_bAutoMnemonic ( DEFAULT_AUTOMNEMONIC ) 187cdf0e10cSrcweir , m_nDialogScale ( DEFAULT_DIALOGSCALE ) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir // Use our static list of configuration keys to get his values. 190cdf0e10cSrcweir Sequence< OUString > seqNames = GetPropertyNames ( ); 191cdf0e10cSrcweir Sequence< Any > seqValues = GetProperties ( seqNames ); 192cdf0e10cSrcweir 193cdf0e10cSrcweir // Safe impossible cases. 194cdf0e10cSrcweir // We need values from ALL configuration keys. 195cdf0e10cSrcweir // Follow assignment use order of values in relation to our list of key names! 196cdf0e10cSrcweir DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtLocalisationOptions_Impl::SvtLocalisationOptions_Impl()\nI miss some values of configuration keys!\n" ); 197cdf0e10cSrcweir 198cdf0e10cSrcweir // Copy values from list in right order to ouer internal member. 199cdf0e10cSrcweir sal_Int32 nPropertyCount = seqValues.getLength(); 200cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty ) 201cdf0e10cSrcweir { 202cdf0e10cSrcweir // Safe impossible cases. 203cdf0e10cSrcweir // Check any for valid value. 204cdf0e10cSrcweir DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtLocalisationOptions_Impl::SvtLocalisationOptions_Impl()\nInvalid property value detected!\n" ); 205cdf0e10cSrcweir switch( nProperty ) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir case PROPERTYHANDLE_AUTOMNEMONIC : { 208cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtLocalisationOptions_Impl::SvtLocalisationOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Localisation\\AutoMnemonic\"?" ); 209cdf0e10cSrcweir seqValues[nProperty] >>= m_bAutoMnemonic; 210cdf0e10cSrcweir } 211cdf0e10cSrcweir break; 212cdf0e10cSrcweir 213cdf0e10cSrcweir case PROPERTYHANDLE_DIALOGSCALE : { 214cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtLocalisationOptions_Impl::SvtLocalisationOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Localisation\\DialogScale\"?" ); 215cdf0e10cSrcweir seqValues[nProperty] >>= m_nDialogScale; 216cdf0e10cSrcweir } 217cdf0e10cSrcweir break; 218cdf0e10cSrcweir } 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir // Enable notification mechanism of ouer baseclass. 222cdf0e10cSrcweir // We need it to get information about changes outside these class on ouer used configuration keys! 223cdf0e10cSrcweir EnableNotification( seqNames ); 224cdf0e10cSrcweir } 225cdf0e10cSrcweir 226cdf0e10cSrcweir //***************************************************************************************************************** 227cdf0e10cSrcweir // destructor 228cdf0e10cSrcweir //***************************************************************************************************************** 229cdf0e10cSrcweir SvtLocalisationOptions_Impl::~SvtLocalisationOptions_Impl() 230cdf0e10cSrcweir { 231cdf0e10cSrcweir // We must save our current values .. if user forget it! 232cdf0e10cSrcweir if( IsModified() == sal_True ) 233cdf0e10cSrcweir { 234cdf0e10cSrcweir Commit(); 235cdf0e10cSrcweir } 236cdf0e10cSrcweir } 237cdf0e10cSrcweir 238cdf0e10cSrcweir //***************************************************************************************************************** 239cdf0e10cSrcweir // public method 240cdf0e10cSrcweir //***************************************************************************************************************** 241cdf0e10cSrcweir void SvtLocalisationOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames ) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir // Use given list of updated properties to get his values from configuration directly! 244cdf0e10cSrcweir Sequence< Any > seqValues = GetProperties( seqPropertyNames ); 245cdf0e10cSrcweir // Safe impossible cases. 246cdf0e10cSrcweir // We need values from ALL notified configuration keys. 247cdf0e10cSrcweir DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtLocalisationOptions_Impl::Notify()\nI miss some values of configuration keys!\n" ); 248cdf0e10cSrcweir // Step over list of property names and get right value from coreesponding value list to set it on internal members! 249cdf0e10cSrcweir sal_Int32 nCount = seqPropertyNames.getLength(); 250cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) 251cdf0e10cSrcweir { 252cdf0e10cSrcweir if( seqPropertyNames[nProperty] == PROPERTYNAME_AUTOMNEMONIC ) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtLocalisationOptions_Impl::SvtLocalisationOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Localisation\\AutoMnemonic\"?" ); 255cdf0e10cSrcweir seqValues[nProperty] >>= m_bAutoMnemonic; 256cdf0e10cSrcweir } 257cdf0e10cSrcweir else 258cdf0e10cSrcweir if( seqPropertyNames[nProperty] == PROPERTYNAME_DIALOGSCALE ) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtLocalisationOptions_Impl::SvtLocalisationOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Localisation\\DialogScale\"?" ); 261cdf0e10cSrcweir seqValues[nProperty] >>= m_nDialogScale; 262cdf0e10cSrcweir } 263cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 264cdf0e10cSrcweir else DBG_ASSERT( sal_False, "SvtLocalisationOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" ); 265cdf0e10cSrcweir #endif 266cdf0e10cSrcweir } 267cdf0e10cSrcweir 268cdf0e10cSrcweir NotifyListeners(0); 269cdf0e10cSrcweir } 270cdf0e10cSrcweir 271cdf0e10cSrcweir //***************************************************************************************************************** 272cdf0e10cSrcweir // public method 273cdf0e10cSrcweir //***************************************************************************************************************** 274cdf0e10cSrcweir void SvtLocalisationOptions_Impl::Commit() 275cdf0e10cSrcweir { 276cdf0e10cSrcweir // Get names of supported properties, create a list for values and copy current values to it. 277cdf0e10cSrcweir Sequence< OUString > seqNames = GetPropertyNames (); 278cdf0e10cSrcweir sal_Int32 nCount = seqNames.getLength(); 279cdf0e10cSrcweir Sequence< Any > seqValues ( nCount ); 280cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir switch( nProperty ) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir case PROPERTYHANDLE_AUTOMNEMONIC : { 285cdf0e10cSrcweir seqValues[nProperty] <<= m_bAutoMnemonic; 286cdf0e10cSrcweir } 287cdf0e10cSrcweir break; 288cdf0e10cSrcweir 289cdf0e10cSrcweir case PROPERTYHANDLE_DIALOGSCALE : { 290cdf0e10cSrcweir seqValues[nProperty] <<= m_nDialogScale; 291cdf0e10cSrcweir } 292cdf0e10cSrcweir break; 293cdf0e10cSrcweir } 294cdf0e10cSrcweir } 295cdf0e10cSrcweir // Set properties in configuration. 296cdf0e10cSrcweir PutProperties( seqNames, seqValues ); 297cdf0e10cSrcweir } 298cdf0e10cSrcweir 299cdf0e10cSrcweir //***************************************************************************************************************** 300cdf0e10cSrcweir // public method 301cdf0e10cSrcweir //***************************************************************************************************************** 302cdf0e10cSrcweir sal_Bool SvtLocalisationOptions_Impl::IsAutoMnemonic() const 303cdf0e10cSrcweir { 304cdf0e10cSrcweir return m_bAutoMnemonic; 305cdf0e10cSrcweir } 306cdf0e10cSrcweir 307cdf0e10cSrcweir //***************************************************************************************************************** 308cdf0e10cSrcweir // public method 309cdf0e10cSrcweir //***************************************************************************************************************** 310cdf0e10cSrcweir void SvtLocalisationOptions_Impl::SetAutoMnemonic( sal_Bool bState ) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir m_bAutoMnemonic = bState; 313cdf0e10cSrcweir SetModified(); 314cdf0e10cSrcweir } 315cdf0e10cSrcweir 316cdf0e10cSrcweir //***************************************************************************************************************** 317cdf0e10cSrcweir // public method 318cdf0e10cSrcweir //***************************************************************************************************************** 319cdf0e10cSrcweir sal_Int32 SvtLocalisationOptions_Impl::GetDialogScale() const 320cdf0e10cSrcweir { 321cdf0e10cSrcweir return m_nDialogScale; 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir //***************************************************************************************************************** 325cdf0e10cSrcweir // public method 326cdf0e10cSrcweir //***************************************************************************************************************** 327cdf0e10cSrcweir void SvtLocalisationOptions_Impl::SetDialogScale( sal_Int32 nScale ) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir m_nDialogScale = nScale; 330cdf0e10cSrcweir SetModified(); 331cdf0e10cSrcweir } 332cdf0e10cSrcweir 333cdf0e10cSrcweir //***************************************************************************************************************** 334cdf0e10cSrcweir // private method 335cdf0e10cSrcweir //***************************************************************************************************************** 336cdf0e10cSrcweir Sequence< OUString > SvtLocalisationOptions_Impl::GetPropertyNames() 337cdf0e10cSrcweir { 338cdf0e10cSrcweir // Build static list of configuration key names. 339cdf0e10cSrcweir static const OUString pProperties[] = 340cdf0e10cSrcweir { 341cdf0e10cSrcweir PROPERTYNAME_AUTOMNEMONIC , 342cdf0e10cSrcweir PROPERTYNAME_DIALOGSCALE , 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 SvtLocalisationOptions_Impl* SvtLocalisationOptions::m_pDataContainer = NULL ; 356cdf0e10cSrcweir sal_Int32 SvtLocalisationOptions::m_nRefCount = 0 ; 357cdf0e10cSrcweir 358cdf0e10cSrcweir //***************************************************************************************************************** 359cdf0e10cSrcweir // constructor 360cdf0e10cSrcweir //***************************************************************************************************************** 361cdf0e10cSrcweir SvtLocalisationOptions::SvtLocalisationOptions() 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 exist! 368cdf0e10cSrcweir if( m_pDataContainer == NULL ) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtLocalisationOptions_Impl::ctor()"); 371cdf0e10cSrcweir m_pDataContainer = new SvtLocalisationOptions_Impl; 372cdf0e10cSrcweir 373cdf0e10cSrcweir ItemHolder1::holdConfigItem(E_LOCALISATIONOPTIONS); 374cdf0e10cSrcweir } 375cdf0e10cSrcweir } 376cdf0e10cSrcweir 377cdf0e10cSrcweir //***************************************************************************************************************** 378cdf0e10cSrcweir // destructor 379cdf0e10cSrcweir //***************************************************************************************************************** 380cdf0e10cSrcweir SvtLocalisationOptions::~SvtLocalisationOptions() 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 SvtLocalisationOptions::IsAutoMnemonic() const 399cdf0e10cSrcweir { 400cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 401cdf0e10cSrcweir return m_pDataContainer->IsAutoMnemonic(); 402cdf0e10cSrcweir } 403cdf0e10cSrcweir 404cdf0e10cSrcweir //***************************************************************************************************************** 405cdf0e10cSrcweir // public method 406cdf0e10cSrcweir //***************************************************************************************************************** 407cdf0e10cSrcweir void SvtLocalisationOptions::SetAutoMnemonic( sal_Bool bState ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 410cdf0e10cSrcweir m_pDataContainer->SetAutoMnemonic( bState ); 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 413cdf0e10cSrcweir //***************************************************************************************************************** 414cdf0e10cSrcweir // public method 415cdf0e10cSrcweir //***************************************************************************************************************** 416cdf0e10cSrcweir sal_Int32 SvtLocalisationOptions::GetDialogScale() const 417cdf0e10cSrcweir { 418cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 419cdf0e10cSrcweir return m_pDataContainer->GetDialogScale(); 420cdf0e10cSrcweir } 421cdf0e10cSrcweir 422cdf0e10cSrcweir //***************************************************************************************************************** 423cdf0e10cSrcweir // public method 424cdf0e10cSrcweir //***************************************************************************************************************** 425cdf0e10cSrcweir void SvtLocalisationOptions::SetDialogScale( sal_Int32 nScale ) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir MutexGuard aGuard( GetOwnStaticMutex() ); 428cdf0e10cSrcweir m_pDataContainer->SetDialogScale( nScale ); 429cdf0e10cSrcweir } 430cdf0e10cSrcweir 431cdf0e10cSrcweir //***************************************************************************************************************** 432cdf0e10cSrcweir // private method 433cdf0e10cSrcweir //***************************************************************************************************************** 434cdf0e10cSrcweir Mutex& SvtLocalisationOptions::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