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 31*cdf0e10cSrcweir #include <unotools/defaultoptions.hxx> 32*cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 33*cdf0e10cSrcweir #include <unotools/configitem.hxx> 34*cdf0e10cSrcweir #include <unotools/configmgr.hxx> 35*cdf0e10cSrcweir #include <tools/debug.hxx> 36*cdf0e10cSrcweir #include <tools/resmgr.hxx> 37*cdf0e10cSrcweir #include <tools/urlobj.hxx> 38*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 39*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 40*cdf0e10cSrcweir #include <osl/mutex.hxx> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include <vos/process.hxx> 43*cdf0e10cSrcweir #include <unotools/localfilehelper.hxx> 44*cdf0e10cSrcweir #include <rtl/instance.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include <itemholder1.hxx> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir using namespace osl; 49*cdf0e10cSrcweir using namespace utl; 50*cdf0e10cSrcweir using namespace rtl; 51*cdf0e10cSrcweir using namespace com::sun::star::uno; 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir // define ---------------------------------------------------------------- 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir #define ASCII_STR(s) OUString( RTL_CONSTASCII_USTRINGPARAM(s) ) 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir #define DEFAULTPATH__ADDIN 0 58*cdf0e10cSrcweir #define DEFAULTPATH__AUTOCORRECT 1 59*cdf0e10cSrcweir #define DEFAULTPATH__AUTOTEXT 2 60*cdf0e10cSrcweir #define DEFAULTPATH__BACKUP 3 61*cdf0e10cSrcweir #define DEFAULTPATH__BASIC 4 62*cdf0e10cSrcweir #define DEFAULTPATH__BITMAP 5 63*cdf0e10cSrcweir #define DEFAULTPATH__CONFIG 6 64*cdf0e10cSrcweir #define DEFAULTPATH__DICTIONARY 7 65*cdf0e10cSrcweir #define DEFAULTPATH__FAVORITES 8 66*cdf0e10cSrcweir #define DEFAULTPATH__FILTER 9 67*cdf0e10cSrcweir #define DEFAULTPATH__GALLERY 10 68*cdf0e10cSrcweir #define DEFAULTPATH__GRAPHIC 11 69*cdf0e10cSrcweir #define DEFAULTPATH__HELP 12 70*cdf0e10cSrcweir #define DEFAULTPATH__LINGUISTIC 13 71*cdf0e10cSrcweir #define DEFAULTPATH__MODULE 14 72*cdf0e10cSrcweir #define DEFAULTPATH__PALETTE 15 73*cdf0e10cSrcweir #define DEFAULTPATH__PLUGIN 16 74*cdf0e10cSrcweir #define DEFAULTPATH__TEMP 17 75*cdf0e10cSrcweir #define DEFAULTPATH__TEMPLATE 18 76*cdf0e10cSrcweir #define DEFAULTPATH__USERCONFIG 19 77*cdf0e10cSrcweir #define DEFAULTPATH__WORK 20 78*cdf0e10cSrcweir #define DEFAULTPATH__USERDICTIONARY 21 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir // class SvtDefaultOptions_Impl ------------------------------------------ 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir class SvtDefaultOptions_Impl : public utl::ConfigItem 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir public: 85*cdf0e10cSrcweir String m_aAddinPath; 86*cdf0e10cSrcweir String m_aAutoCorrectPath; 87*cdf0e10cSrcweir String m_aAutoTextPath; 88*cdf0e10cSrcweir String m_aBackupPath; 89*cdf0e10cSrcweir String m_aBasicPath; 90*cdf0e10cSrcweir String m_aBitmapPath; 91*cdf0e10cSrcweir String m_aConfigPath; 92*cdf0e10cSrcweir String m_aDictionaryPath; 93*cdf0e10cSrcweir String m_aFavoritesPath; 94*cdf0e10cSrcweir String m_aFilterPath; 95*cdf0e10cSrcweir String m_aGalleryPath; 96*cdf0e10cSrcweir String m_aGraphicPath; 97*cdf0e10cSrcweir String m_aHelpPath; 98*cdf0e10cSrcweir String m_aLinguisticPath; 99*cdf0e10cSrcweir String m_aModulePath; 100*cdf0e10cSrcweir String m_aPalettePath; 101*cdf0e10cSrcweir String m_aPluginPath; 102*cdf0e10cSrcweir String m_aTempPath; 103*cdf0e10cSrcweir String m_aTemplatePath; 104*cdf0e10cSrcweir String m_aUserConfigPath; 105*cdf0e10cSrcweir String m_aWorkPath; 106*cdf0e10cSrcweir String m_aUserDictionaryPath; 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir SvtDefaultOptions_Impl(); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir String GetDefaultPath( sal_uInt16 nId ) const; 111*cdf0e10cSrcweir virtual void Commit(); 112*cdf0e10cSrcweir virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames); 113*cdf0e10cSrcweir }; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir // global ---------------------------------------------------------------- 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir static SvtDefaultOptions_Impl* pOptions = NULL; 118*cdf0e10cSrcweir static sal_Int32 nRefCount = 0; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir typedef String SvtDefaultOptions_Impl:: *PathStrPtr; 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir struct PathToDefaultMapping_Impl 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir SvtPathOptions::Pathes _ePath; 125*cdf0e10cSrcweir PathStrPtr _pDefaultPath; 126*cdf0e10cSrcweir }; 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir static PathToDefaultMapping_Impl __READONLY_DATA PathMap_Impl[] = 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir { SvtPathOptions::PATH_ADDIN, &SvtDefaultOptions_Impl::m_aAddinPath }, 131*cdf0e10cSrcweir { SvtPathOptions::PATH_AUTOCORRECT, &SvtDefaultOptions_Impl::m_aAutoCorrectPath }, 132*cdf0e10cSrcweir { SvtPathOptions::PATH_AUTOTEXT, &SvtDefaultOptions_Impl::m_aAutoTextPath }, 133*cdf0e10cSrcweir { SvtPathOptions::PATH_BACKUP, &SvtDefaultOptions_Impl::m_aBackupPath }, 134*cdf0e10cSrcweir { SvtPathOptions::PATH_BASIC, &SvtDefaultOptions_Impl::m_aBasicPath }, 135*cdf0e10cSrcweir { SvtPathOptions::PATH_BITMAP, &SvtDefaultOptions_Impl::m_aBitmapPath }, 136*cdf0e10cSrcweir { SvtPathOptions::PATH_CONFIG, &SvtDefaultOptions_Impl::m_aConfigPath }, 137*cdf0e10cSrcweir { SvtPathOptions::PATH_DICTIONARY, &SvtDefaultOptions_Impl::m_aDictionaryPath }, 138*cdf0e10cSrcweir { SvtPathOptions::PATH_FAVORITES, &SvtDefaultOptions_Impl::m_aFavoritesPath }, 139*cdf0e10cSrcweir { SvtPathOptions::PATH_FILTER, &SvtDefaultOptions_Impl::m_aFilterPath }, 140*cdf0e10cSrcweir { SvtPathOptions::PATH_GALLERY, &SvtDefaultOptions_Impl::m_aGalleryPath }, 141*cdf0e10cSrcweir { SvtPathOptions::PATH_GRAPHIC, &SvtDefaultOptions_Impl::m_aGraphicPath }, 142*cdf0e10cSrcweir { SvtPathOptions::PATH_HELP, &SvtDefaultOptions_Impl::m_aHelpPath }, 143*cdf0e10cSrcweir { SvtPathOptions::PATH_LINGUISTIC, &SvtDefaultOptions_Impl::m_aLinguisticPath }, 144*cdf0e10cSrcweir { SvtPathOptions::PATH_MODULE, &SvtDefaultOptions_Impl::m_aModulePath }, 145*cdf0e10cSrcweir { SvtPathOptions::PATH_PALETTE, &SvtDefaultOptions_Impl::m_aPalettePath }, 146*cdf0e10cSrcweir { SvtPathOptions::PATH_PLUGIN, &SvtDefaultOptions_Impl::m_aPluginPath }, 147*cdf0e10cSrcweir { SvtPathOptions::PATH_TEMP, &SvtDefaultOptions_Impl::m_aTempPath }, 148*cdf0e10cSrcweir { SvtPathOptions::PATH_TEMPLATE, &SvtDefaultOptions_Impl::m_aTemplatePath }, 149*cdf0e10cSrcweir { SvtPathOptions::PATH_USERCONFIG, &SvtDefaultOptions_Impl::m_aUserConfigPath }, 150*cdf0e10cSrcweir { SvtPathOptions::PATH_WORK, &SvtDefaultOptions_Impl::m_aWorkPath } 151*cdf0e10cSrcweir }; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir // functions ------------------------------------------------------------- 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir Sequence< OUString > GetDefaultPropertyNames() 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir static const char* aPropNames[] = 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir "Addin", // PATH_ADDIN 160*cdf0e10cSrcweir "AutoCorrect", // PATH_AUTOCORRECT 161*cdf0e10cSrcweir "AutoText", // PATH_AUTOTEXT 162*cdf0e10cSrcweir "Backup", // PATH_BACKUP 163*cdf0e10cSrcweir "Basic", // PATH_BASIC 164*cdf0e10cSrcweir "Bitmap", // PATH_BITMAP 165*cdf0e10cSrcweir "Config", // PATH_CONFIG 166*cdf0e10cSrcweir "Dictionary", // PATH_DICTIONARY 167*cdf0e10cSrcweir "Favorite", // PATH_FAVORITES 168*cdf0e10cSrcweir "Filter", // PATH_FILTER 169*cdf0e10cSrcweir "Gallery", // PATH_GALLERY 170*cdf0e10cSrcweir "Graphic", // PATH_GRAPHIC 171*cdf0e10cSrcweir "Help", // PATH_HELP 172*cdf0e10cSrcweir "Linguistic", // PATH_LINGUISTIC 173*cdf0e10cSrcweir "Module", // PATH_MODULE 174*cdf0e10cSrcweir "Palette", // PATH_PALETTE 175*cdf0e10cSrcweir "Plugin", // PATH_PLUGIN 176*cdf0e10cSrcweir "Temp", // PATH_TEMP 177*cdf0e10cSrcweir "Template", // PATH_TEMPLATE 178*cdf0e10cSrcweir "UserConfig", // PATH_USERCONFIG 179*cdf0e10cSrcweir "Work" // PATH_WORK 180*cdf0e10cSrcweir }; 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir const int nCount = sizeof( aPropNames ) / sizeof( const char* ); 183*cdf0e10cSrcweir Sequence< OUString > aNames( nCount ); 184*cdf0e10cSrcweir OUString* pNames = aNames.getArray(); 185*cdf0e10cSrcweir for ( int i = 0; i < nCount; i++ ) 186*cdf0e10cSrcweir pNames[i] = OUString::createFromAscii( aPropNames[i] ); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir return aNames; 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir void SvtDefaultOptions_Impl::Notify( const Sequence< rtl::OUString >& ) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir // no notification, will never be changed 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir void SvtDefaultOptions_Impl::Commit() 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir // will never be changed 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir // class SvtDefaultOptions_Impl ------------------------------------------ 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir String SvtDefaultOptions_Impl::GetDefaultPath( sal_uInt16 nId ) const 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir String aRet; 206*cdf0e10cSrcweir sal_uInt16 nIdx = 0; 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir while ( PathMap_Impl[nIdx]._ePath <= SvtPathOptions::PATH_WORK ) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir if ( nId == PathMap_Impl[nIdx]._ePath && PathMap_Impl[nIdx]._pDefaultPath ) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir aRet = this->*(PathMap_Impl[nIdx]._pDefaultPath); 213*cdf0e10cSrcweir if ( nId == SvtPathOptions::PATH_ADDIN || 214*cdf0e10cSrcweir nId == SvtPathOptions::PATH_FILTER || 215*cdf0e10cSrcweir nId == SvtPathOptions::PATH_HELP || 216*cdf0e10cSrcweir nId == SvtPathOptions::PATH_MODULE || 217*cdf0e10cSrcweir nId == SvtPathOptions::PATH_PLUGIN ) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir String aTmp; 220*cdf0e10cSrcweir ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aRet, aTmp ); 221*cdf0e10cSrcweir aRet = aTmp; 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir break; 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir ++nIdx; 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir return aRet; 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir // ----------------------------------------------------------------------- 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir SvtDefaultOptions_Impl::SvtDefaultOptions_Impl() : ConfigItem( ASCII_STR("Office.Common/Path/Default") ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir /*ConfigManager* pCfgMgr =*/ ConfigManager::GetConfigManager(); 237*cdf0e10cSrcweir Sequence< OUString > aNames = GetDefaultPropertyNames(); 238*cdf0e10cSrcweir Sequence< Any > aValues = GetProperties( aNames ); 239*cdf0e10cSrcweir EnableNotification( aNames ); 240*cdf0e10cSrcweir const Any* pValues = aValues.getConstArray(); 241*cdf0e10cSrcweir DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" ); 242*cdf0e10cSrcweir if ( aValues.getLength() == aNames.getLength() ) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir SvtPathOptions aPathOpt; 245*cdf0e10cSrcweir OUString aTempStr, aFullPath; 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir for ( int nProp = 0; nProp < aNames.getLength(); nProp++ ) 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir if ( pValues[nProp].hasValue() ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir switch ( pValues[nProp].getValueTypeClass() ) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir case ::com::sun::star::uno::TypeClass_STRING : 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir // multi pathes 256*cdf0e10cSrcweir if ( pValues[nProp] >>= aTempStr ) 257*cdf0e10cSrcweir aFullPath = aPathOpt.SubstituteVariable( aTempStr ); 258*cdf0e10cSrcweir else 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir DBG_ERRORFILE( "any operator >>= failed" ); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir break; 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir case ::com::sun::star::uno::TypeClass_SEQUENCE : 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir // single pathes 268*cdf0e10cSrcweir aFullPath = OUString(); 269*cdf0e10cSrcweir Sequence < OUString > aList; 270*cdf0e10cSrcweir if ( pValues[nProp] >>= aList ) 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir sal_Int32 nCount = aList.getLength(); 273*cdf0e10cSrcweir for ( sal_Int32 nPosition = 0; nPosition < nCount; ++nPosition ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir aTempStr = aPathOpt.SubstituteVariable( aList[ nPosition ] ); 276*cdf0e10cSrcweir aFullPath += aTempStr; 277*cdf0e10cSrcweir if ( nPosition < nCount-1 ) 278*cdf0e10cSrcweir aFullPath += OUString( RTL_CONSTASCII_USTRINGPARAM(";") ); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir else 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir DBG_ERRORFILE( "any operator >>= failed" ); 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir break; 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir default: 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir DBG_ERRORFILE( "Wrong any type" ); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir switch ( nProp ) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir case DEFAULTPATH__ADDIN: m_aAddinPath = String( aFullPath ); break; 297*cdf0e10cSrcweir case DEFAULTPATH__AUTOCORRECT: m_aAutoCorrectPath = String( aFullPath ); break; 298*cdf0e10cSrcweir case DEFAULTPATH__AUTOTEXT: m_aAutoTextPath = String( aFullPath ); break; 299*cdf0e10cSrcweir case DEFAULTPATH__BACKUP: m_aBackupPath = String( aFullPath ); break; 300*cdf0e10cSrcweir case DEFAULTPATH__BASIC: m_aBasicPath = String( aFullPath ); break; 301*cdf0e10cSrcweir case DEFAULTPATH__BITMAP: m_aBitmapPath = String( aFullPath ); break; 302*cdf0e10cSrcweir case DEFAULTPATH__CONFIG: m_aConfigPath = String( aFullPath ); break; 303*cdf0e10cSrcweir case DEFAULTPATH__DICTIONARY: m_aDictionaryPath = String( aFullPath ); break; 304*cdf0e10cSrcweir case DEFAULTPATH__FAVORITES: m_aFavoritesPath = String( aFullPath ); break; 305*cdf0e10cSrcweir case DEFAULTPATH__FILTER: m_aFilterPath = String( aFullPath ); break; 306*cdf0e10cSrcweir case DEFAULTPATH__GALLERY: m_aGalleryPath = String( aFullPath ); break; 307*cdf0e10cSrcweir case DEFAULTPATH__GRAPHIC: m_aGraphicPath = String( aFullPath ); break; 308*cdf0e10cSrcweir case DEFAULTPATH__HELP: m_aHelpPath = String( aFullPath ); break; 309*cdf0e10cSrcweir case DEFAULTPATH__LINGUISTIC: m_aLinguisticPath = String( aFullPath ); break; 310*cdf0e10cSrcweir case DEFAULTPATH__MODULE: m_aModulePath = String( aFullPath ); break; 311*cdf0e10cSrcweir case DEFAULTPATH__PALETTE: m_aPalettePath = String( aFullPath ); break; 312*cdf0e10cSrcweir case DEFAULTPATH__PLUGIN: m_aPluginPath = String( aFullPath ); break; 313*cdf0e10cSrcweir case DEFAULTPATH__TEMP: m_aTempPath = String( aFullPath ); break; 314*cdf0e10cSrcweir case DEFAULTPATH__TEMPLATE: m_aTemplatePath = String( aFullPath ); break; 315*cdf0e10cSrcweir case DEFAULTPATH__USERCONFIG: m_aUserConfigPath = String( aFullPath ); break; 316*cdf0e10cSrcweir case DEFAULTPATH__WORK: m_aWorkPath = String( aFullPath ); break; 317*cdf0e10cSrcweir case DEFAULTPATH__USERDICTIONARY: m_aUserDictionaryPath = String( aFullPath );break; 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir default: 320*cdf0e10cSrcweir DBG_ERRORFILE( "invalid index to load a default path" ); 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir // class SvtDefaultOptions ----------------------------------------------- 328*cdf0e10cSrcweir namespace { struct lclMutex : public rtl::Static< ::osl::Mutex, lclMutex > {}; } 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir SvtDefaultOptions::SvtDefaultOptions() 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir // Global access, must be guarded (multithreading) 333*cdf0e10cSrcweir ::osl::MutexGuard aGuard( lclMutex::get() ); 334*cdf0e10cSrcweir if ( !pOptions ) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir pOptions = new SvtDefaultOptions_Impl; 337*cdf0e10cSrcweir ItemHolder1::holdConfigItem(E_DEFAULTOPTIONS); 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir ++nRefCount; 340*cdf0e10cSrcweir pImp = pOptions; 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir // ----------------------------------------------------------------------- 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir SvtDefaultOptions::~SvtDefaultOptions() 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir // Global access, must be guarded (multithreading) 348*cdf0e10cSrcweir ::osl::MutexGuard aGuard( lclMutex::get() ); 349*cdf0e10cSrcweir if ( !--nRefCount ) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir if ( pOptions->IsModified() ) 352*cdf0e10cSrcweir pOptions->Commit(); 353*cdf0e10cSrcweir DELETEZ( pOptions ); 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir // ----------------------------------------------------------------------- 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir String SvtDefaultOptions::GetDefaultPath( sal_uInt16 nId ) const 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir return pImp->GetDefaultPath( nId ); 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir 364