16d739b60SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 36d739b60SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 46d739b60SAndrew Rist * or more contributor license agreements. See the NOTICE file 56d739b60SAndrew Rist * distributed with this work for additional information 66d739b60SAndrew Rist * regarding copyright ownership. The ASF licenses this file 76d739b60SAndrew Rist * to you under the Apache License, Version 2.0 (the 86d739b60SAndrew Rist * "License"); you may not use this file except in compliance 96d739b60SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 116d739b60SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 136d739b60SAndrew Rist * Unless required by applicable law or agreed to in writing, 146d739b60SAndrew Rist * software distributed under the License is distributed on an 156d739b60SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 166d739b60SAndrew Rist * KIND, either express or implied. See the License for the 176d739b60SAndrew Rist * specific language governing permissions and limitations 186d739b60SAndrew Rist * under the License. 19cdf0e10cSrcweir * 206d739b60SAndrew Rist *************************************************************/ 216d739b60SAndrew Rist 226d739b60SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_framework.hxx" 26cdf0e10cSrcweir // ______________________________________________ 27cdf0e10cSrcweir // my own includes 28cdf0e10cSrcweir 2915289133Smseidel /** Attention: stl headers must(!) be included at first. Otherwise it can make trouble 30cdf0e10cSrcweir with solaris headers ... 31cdf0e10cSrcweir */ 32cdf0e10cSrcweir #include <vector> 33cdf0e10cSrcweir #include <services/pathsettings.hxx> 34cdf0e10cSrcweir #include <threadhelp/readguard.hxx> 35cdf0e10cSrcweir #include <threadhelp/writeguard.hxx> 36cdf0e10cSrcweir #include <services.h> 37cdf0e10cSrcweir 38cdf0e10cSrcweir // ______________________________________________ 39cdf0e10cSrcweir // interface includes 40cdf0e10cSrcweir #include <com/sun/star/beans/Property.hpp> 41cdf0e10cSrcweir #include <com/sun/star/beans/XProperty.hpp> 42cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp> 43cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp> 44cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 45cdf0e10cSrcweir #include <com/sun/star/util/XChangesNotifier.hpp> 46cdf0e10cSrcweir 47cdf0e10cSrcweir // ______________________________________________ 48cdf0e10cSrcweir // includes of other projects 49cdf0e10cSrcweir #include <tools/urlobj.hxx> 50cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 51cdf0e10cSrcweir #include <rtl/logfile.hxx> 52cdf0e10cSrcweir 53cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx> 54cdf0e10cSrcweir #include <unotools/configpathes.hxx> 55cdf0e10cSrcweir 56cdf0e10cSrcweir #include <fwkdllapi.h> 57cdf0e10cSrcweir 58cdf0e10cSrcweir // ______________________________________________ 59cdf0e10cSrcweir // non exported const 60cdf0e10cSrcweir 61cdf0e10cSrcweir #define CFG_READONLY_DEFAULT sal_False 62cdf0e10cSrcweir 63cdf0e10cSrcweir const ::rtl::OUString CFGPROP_INTERNALPATHES = ::rtl::OUString::createFromAscii("InternalPaths"); 64cdf0e10cSrcweir const ::rtl::OUString CFGPROP_USERPATHES = ::rtl::OUString::createFromAscii("UserPaths" ); 65cdf0e10cSrcweir const ::rtl::OUString CFGPROP_WRITEPATH = ::rtl::OUString::createFromAscii("WritePath" ); 66cdf0e10cSrcweir const ::rtl::OUString CFGPROP_ISSINGLEPATH = ::rtl::OUString::createFromAscii("IsSinglePath" ); 67cdf0e10cSrcweir 68cdf0e10cSrcweir /* 69cdf0e10cSrcweir 0 : old style "Template" string using ";" as seperator 70cdf0e10cSrcweir 1 : internal paths "Template_internal" string list 71cdf0e10cSrcweir 2 : user paths "Template_user" string list 72cdf0e10cSrcweir 3 : write path "Template_write" string 73cdf0e10cSrcweir */ 74cdf0e10cSrcweir 75cdf0e10cSrcweir const ::rtl::OUString POSTFIX_INTERNAL_PATHES = ::rtl::OUString::createFromAscii("_internal"); 76cdf0e10cSrcweir const ::rtl::OUString POSTFIX_USER_PATHES = ::rtl::OUString::createFromAscii("_user" ); 77cdf0e10cSrcweir const ::rtl::OUString POSTFIX_WRITE_PATH = ::rtl::OUString::createFromAscii("_writable"); 78cdf0e10cSrcweir 79cdf0e10cSrcweir const sal_Int32 IDGROUP_OLDSTYLE = 0; 80cdf0e10cSrcweir const sal_Int32 IDGROUP_INTERNAL_PATHES = 1; 81cdf0e10cSrcweir const sal_Int32 IDGROUP_USER_PATHES = 2; 82cdf0e10cSrcweir const sal_Int32 IDGROUP_WRITE_PATH = 3; 83cdf0e10cSrcweir 84cdf0e10cSrcweir const sal_Int32 IDGROUP_COUNT = 4; 85cdf0e10cSrcweir 86cdf0e10cSrcweir sal_Int32 impl_getPropGroup(sal_Int32 nID) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir return (nID % IDGROUP_COUNT); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir // ______________________________________________ 92cdf0e10cSrcweir // namespace 93cdf0e10cSrcweir 94cdf0e10cSrcweir namespace framework 95cdf0e10cSrcweir { 96cdf0e10cSrcweir 97cdf0e10cSrcweir //----------------------------------------------------------------------------- 98cdf0e10cSrcweir // XInterface, XTypeProvider, XServiceInfo 99cdf0e10cSrcweir 100cdf0e10cSrcweir DEFINE_XINTERFACE_7 ( PathSettings , 101cdf0e10cSrcweir OWeakObject , 102cdf0e10cSrcweir DIRECT_INTERFACE ( css::lang::XTypeProvider ), 103cdf0e10cSrcweir DIRECT_INTERFACE ( css::lang::XServiceInfo ), 104cdf0e10cSrcweir DERIVED_INTERFACE( css::lang::XEventListener, css::util::XChangesListener), 105cdf0e10cSrcweir DIRECT_INTERFACE ( css::util::XChangesListener ), 106cdf0e10cSrcweir DIRECT_INTERFACE ( css::beans::XPropertySet ), 107cdf0e10cSrcweir DIRECT_INTERFACE ( css::beans::XFastPropertySet ), 108cdf0e10cSrcweir DIRECT_INTERFACE ( css::beans::XMultiPropertySet ) 109cdf0e10cSrcweir ) 110cdf0e10cSrcweir 111cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_7 ( PathSettings , 112cdf0e10cSrcweir css::lang::XTypeProvider , 113cdf0e10cSrcweir css::lang::XServiceInfo , 114cdf0e10cSrcweir css::lang::XEventListener , 115cdf0e10cSrcweir css::util::XChangesListener , 116cdf0e10cSrcweir css::beans::XPropertySet , 117cdf0e10cSrcweir css::beans::XFastPropertySet , 118cdf0e10cSrcweir css::beans::XMultiPropertySet 119cdf0e10cSrcweir ) 120cdf0e10cSrcweir 121cdf0e10cSrcweir DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( PathSettings , 122cdf0e10cSrcweir ::cppu::OWeakObject , 123cdf0e10cSrcweir SERVICENAME_PATHSETTINGS , 124cdf0e10cSrcweir IMPLEMENTATIONNAME_PATHSETTINGS 125cdf0e10cSrcweir ) 126cdf0e10cSrcweir 127cdf0e10cSrcweir DEFINE_INIT_SERVICE ( PathSettings, 128cdf0e10cSrcweir { 129cdf0e10cSrcweir /*Attention 130cdf0e10cSrcweir I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance() 131cdf0e10cSrcweir to create a new instance of this class by our own supported service factory. 132cdf0e10cSrcweir see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations! 133cdf0e10cSrcweir */ 134cdf0e10cSrcweir 135cdf0e10cSrcweir // fill cache 136cdf0e10cSrcweir impl_readAll(); 137cdf0e10cSrcweir } 138cdf0e10cSrcweir ) 139cdf0e10cSrcweir 140cdf0e10cSrcweir //----------------------------------------------------------------------------- 141cdf0e10cSrcweir PathSettings::PathSettings( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ) 142cdf0e10cSrcweir // Init baseclasses first 143cdf0e10cSrcweir // Attention: Don't change order of initialization! 144cdf0e10cSrcweir // ThreadHelpBase is a struct with a lock as member. We can't use a lock as direct member! 145cdf0e10cSrcweir // We must garant right initialization and a valid value of this to initialize other baseclasses! 146cdf0e10cSrcweir : ThreadHelpBase() 147cdf0e10cSrcweir , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >(m_aLock.getShareableOslMutex()) 148cdf0e10cSrcweir , ::cppu::OPropertySetHelper(*(static_cast< ::cppu::OBroadcastHelper* >(this))) 149cdf0e10cSrcweir , ::cppu::OWeakObject() 150cdf0e10cSrcweir // Init member 151cdf0e10cSrcweir , m_xSMGR (xSMGR) 152cdf0e10cSrcweir , m_pPropHelp(0 ) 153cdf0e10cSrcweir , m_bIgnoreEvents(sal_False) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "PathSettings::PathSettings" ); 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir //----------------------------------------------------------------------------- 159cdf0e10cSrcweir PathSettings::~PathSettings() 160cdf0e10cSrcweir { 161cdf0e10cSrcweir if (m_pPropHelp) 162cdf0e10cSrcweir delete m_pPropHelp; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir //----------------------------------------------------------------------------- 166cdf0e10cSrcweir void SAL_CALL PathSettings::changesOccurred(const css::util::ChangesEvent& aEvent) 167cdf0e10cSrcweir throw (css::uno::RuntimeException) 168cdf0e10cSrcweir { 169cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "PathSettings::changesOccurred" ); 170cdf0e10cSrcweir /* 171cdf0e10cSrcweir if (m_bIgnoreEvents) 172cdf0e10cSrcweir return; 173cdf0e10cSrcweir */ 174cdf0e10cSrcweir 175cdf0e10cSrcweir sal_Int32 c = aEvent.Changes.getLength(); 176cdf0e10cSrcweir sal_Int32 i = 0; 177cdf0e10cSrcweir sal_Bool bUpdateDescriptor = sal_False; 178cdf0e10cSrcweir 179cdf0e10cSrcweir for (i=0; i<c; ++i) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir const css::util::ElementChange& aChange = aEvent.Changes[i]; 182cdf0e10cSrcweir 183cdf0e10cSrcweir ::rtl::OUString sChanged; 184cdf0e10cSrcweir aChange.Accessor >>= sChanged; 185cdf0e10cSrcweir 186cdf0e10cSrcweir ::rtl::OUString sPath = ::utl::extractFirstFromConfigurationPath(sChanged); 187cdf0e10cSrcweir if (sPath.getLength()) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir PathSettings::EChangeOp eOp = impl_updatePath(sPath, sal_True); 190cdf0e10cSrcweir if ( 191cdf0e10cSrcweir (eOp == PathSettings::E_ADDED ) || 192cdf0e10cSrcweir (eOp == PathSettings::E_REMOVED) 193cdf0e10cSrcweir ) 194cdf0e10cSrcweir bUpdateDescriptor = sal_True; 195cdf0e10cSrcweir } 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir if (bUpdateDescriptor) 199cdf0e10cSrcweir impl_rebuildPropertyDescriptor(); 200cdf0e10cSrcweir } 201cdf0e10cSrcweir 202cdf0e10cSrcweir //----------------------------------------------------------------------------- 203cdf0e10cSrcweir void SAL_CALL PathSettings::disposing(const css::lang::EventObject& aSource) 204cdf0e10cSrcweir throw(css::uno::RuntimeException) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "PathSettings::disposing" ); 207cdf0e10cSrcweir // SAFE -> 208cdf0e10cSrcweir WriteGuard aWriteLock(m_aLock); 209cdf0e10cSrcweir 210cdf0e10cSrcweir if (aSource.Source == m_xCfgNew) 211cdf0e10cSrcweir m_xCfgNew.clear(); 212cdf0e10cSrcweir 213cdf0e10cSrcweir aWriteLock.unlock(); 214cdf0e10cSrcweir // <- SAFE 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir //----------------------------------------------------------------------------- 218cdf0e10cSrcweir void PathSettings::impl_readAll() 219cdf0e10cSrcweir { 220cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "PathSettings::impl_readAll" ); 221cdf0e10cSrcweir RTL_LOGFILE_CONTEXT(aLog, "framework (as96863) ::PathSettings::load config (all)"); 222cdf0e10cSrcweir 223cdf0e10cSrcweir // TODO think about me 224cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xCfg = fa_getCfgNew(); 225cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > lPaths = xCfg->getElementNames(); 226cdf0e10cSrcweir 227cdf0e10cSrcweir sal_Int32 c = lPaths.getLength(); 228cdf0e10cSrcweir sal_Int32 i = 0; 229cdf0e10cSrcweir 230cdf0e10cSrcweir for (i=0; i<c; ++i) 231cdf0e10cSrcweir { 232cdf0e10cSrcweir const ::rtl::OUString& sPath = lPaths[i]; 233cdf0e10cSrcweir impl_updatePath(sPath, sal_False); 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir impl_rebuildPropertyDescriptor(); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir 239cdf0e10cSrcweir //----------------------------------------------------------------------------- 240cdf0e10cSrcweir // NO substitution here ! It's done outside ... 241cdf0e10cSrcweir OUStringList PathSettings::impl_readOldFormat(const ::rtl::OUString& sPath) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "PathSettings::impl_readOldFormat" ); 244cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xCfg( fa_getCfgOld() ); 245cdf0e10cSrcweir OUStringList aPathVal; 246cdf0e10cSrcweir 247cdf0e10cSrcweir if( xCfg->hasByName(sPath) ) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir css::uno::Any aVal( xCfg->getByName(sPath) ); 250cdf0e10cSrcweir 251cdf0e10cSrcweir ::rtl::OUString sStringVal; 252cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > lStringListVal; 253cdf0e10cSrcweir 254cdf0e10cSrcweir if (aVal >>= sStringVal) 255cdf0e10cSrcweir { 256cdf0e10cSrcweir aPathVal.push_back(sStringVal); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir else if (aVal >>= lStringListVal) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir aPathVal << lStringListVal; 261cdf0e10cSrcweir } 262cdf0e10cSrcweir } 263cdf0e10cSrcweir 264cdf0e10cSrcweir return aPathVal; 265cdf0e10cSrcweir } 266cdf0e10cSrcweir 267cdf0e10cSrcweir //----------------------------------------------------------------------------- 268cdf0e10cSrcweir // NO substitution here ! It's done outside ... 269cdf0e10cSrcweir PathSettings::PathInfo PathSettings::impl_readNewFormat(const ::rtl::OUString& sPath) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xCfg = fa_getCfgNew(); 272cdf0e10cSrcweir 273cdf0e10cSrcweir // get access to the "queried" path 274cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xPath; 275cdf0e10cSrcweir xCfg->getByName(sPath) >>= xPath; 276cdf0e10cSrcweir 277cdf0e10cSrcweir PathSettings::PathInfo aPathVal; 278cdf0e10cSrcweir 279cdf0e10cSrcweir // read internal path list 280cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xIPath; 281cdf0e10cSrcweir xPath->getByName(CFGPROP_INTERNALPATHES) >>= xIPath; 282cdf0e10cSrcweir aPathVal.lInternalPaths << xIPath->getElementNames(); 283cdf0e10cSrcweir 284cdf0e10cSrcweir // read user defined path list 285cdf0e10cSrcweir aPathVal.lUserPaths << xPath->getByName(CFGPROP_USERPATHES); 286cdf0e10cSrcweir 287cdf0e10cSrcweir // read the writeable path 288cdf0e10cSrcweir xPath->getByName(CFGPROP_WRITEPATH) >>= aPathVal.sWritePath; 289cdf0e10cSrcweir 290cdf0e10cSrcweir // read state props 291cdf0e10cSrcweir xPath->getByName(CFGPROP_ISSINGLEPATH) >>= aPathVal.bIsSinglePath; 292cdf0e10cSrcweir 293cdf0e10cSrcweir // analyze finalized/mandatory states 294cdf0e10cSrcweir aPathVal.bIsReadonly = sal_False; 295cdf0e10cSrcweir css::uno::Reference< css::beans::XProperty > xInfo(xPath, css::uno::UNO_QUERY); 296cdf0e10cSrcweir if (xInfo.is()) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir css::beans::Property aInfo = xInfo->getAsProperty(); 299cdf0e10cSrcweir sal_Bool bFinalized = ((aInfo.Attributes & css::beans::PropertyAttribute::READONLY ) == css::beans::PropertyAttribute::READONLY ); 300cdf0e10cSrcweir //sal_Bool bMandatory = ((aInfo.Attributes & css::beans::PropertyAttribute::REMOVEABLE) != css::beans::PropertyAttribute::REMOVEABLE); 301cdf0e10cSrcweir 302cdf0e10cSrcweir // Note: Till we support finalized / mandatory on our API more in detail we handle 30307a3d7f1SPedro Giffuni // all states simple as READONLY ! But because all really needed paths are "mandatory" by default 304cdf0e10cSrcweir // we have to handle "finalized" as the real "readonly" indicator . 305cdf0e10cSrcweir aPathVal.bIsReadonly = bFinalized; 306cdf0e10cSrcweir } 307cdf0e10cSrcweir 308cdf0e10cSrcweir return aPathVal; 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir //----------------------------------------------------------------------------- 312cdf0e10cSrcweir void PathSettings::impl_storePath(const PathSettings::PathInfo& aPath) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "PathSettings::impl_storePath" ); 315cdf0e10cSrcweir m_bIgnoreEvents = sal_True; 316cdf0e10cSrcweir 317cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xCfgNew = fa_getCfgNew(); 318cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xCfgOld = fa_getCfgOld(); 319cdf0e10cSrcweir 320cdf0e10cSrcweir // try to replace path-parts with well known and uspported variables. 32107a3d7f1SPedro Giffuni // So an office can be moved easialy to another location without losing 32207a3d7f1SPedro Giffuni // it's related paths. 323cdf0e10cSrcweir PathInfo aResubstPath(aPath); 324cdf0e10cSrcweir impl_subst(aResubstPath, sal_True); 325cdf0e10cSrcweir 326cdf0e10cSrcweir // update new configuration 327cdf0e10cSrcweir if (! aResubstPath.bIsSinglePath) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir ::comphelper::ConfigurationHelper::writeRelativeKey(xCfgNew, 330cdf0e10cSrcweir aResubstPath.sPathName, 331cdf0e10cSrcweir CFGPROP_USERPATHES, 332cdf0e10cSrcweir css::uno::makeAny(aResubstPath.lUserPaths.getAsConstList())); 333cdf0e10cSrcweir } 334cdf0e10cSrcweir 335cdf0e10cSrcweir ::comphelper::ConfigurationHelper::writeRelativeKey(xCfgNew, 336cdf0e10cSrcweir aResubstPath.sPathName, 337cdf0e10cSrcweir CFGPROP_WRITEPATH, 338cdf0e10cSrcweir css::uno::makeAny(aResubstPath.sWritePath)); 339cdf0e10cSrcweir 340cdf0e10cSrcweir ::comphelper::ConfigurationHelper::flush(xCfgNew); 341cdf0e10cSrcweir 342cdf0e10cSrcweir // remove the whole path from the old configuration ! 34307a3d7f1SPedro Giffuni // Otherwise we can't make sure that the diff between new and old configuration 34407a3d7f1SPedro Giffuni // on loading time really represent an user setting !!! 345cdf0e10cSrcweir 346cdf0e10cSrcweir // Check if the given path exists inside the old configuration. 34707a3d7f1SPedro Giffuni // Because our new configuration knows more then the list of old paths ... ! 348cdf0e10cSrcweir if (xCfgOld->hasByName(aResubstPath.sPathName)) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertySet > xProps(xCfgOld, css::uno::UNO_QUERY_THROW); 351cdf0e10cSrcweir xProps->setPropertyValue(aResubstPath.sPathName, css::uno::Any()); 352cdf0e10cSrcweir ::comphelper::ConfigurationHelper::flush(xCfgOld); 353cdf0e10cSrcweir } 354cdf0e10cSrcweir 355cdf0e10cSrcweir m_bIgnoreEvents = sal_False; 356cdf0e10cSrcweir } 357cdf0e10cSrcweir 358cdf0e10cSrcweir //----------------------------------------------------------------------------- 359cdf0e10cSrcweir #ifdef MIGRATE_OLD_USER_PATHES 360cdf0e10cSrcweir void PathSettings::impl_mergeOldUserPaths( PathSettings::PathInfo& rPath, 361cdf0e10cSrcweir const OUStringList& lOld ) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "PathSettings::impl_mergeOldUserPaths" ); 364cdf0e10cSrcweir OUStringList::const_iterator pIt; 365cdf0e10cSrcweir for ( pIt = lOld.begin(); 366cdf0e10cSrcweir pIt != lOld.end() ; 367cdf0e10cSrcweir ++pIt ) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir const ::rtl::OUString& sOld = *pIt; 370cdf0e10cSrcweir 371cdf0e10cSrcweir if (rPath.bIsSinglePath) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir LOG_ASSERT2(lOld.size()>1, "PathSettings::impl_mergeOldUserPaths()", "Single path has more then one path value inside old configuration (Common.xcu)!") 374cdf0e10cSrcweir if (! rPath.sWritePath.equals(sOld)) 375cdf0e10cSrcweir rPath.sWritePath = sOld; 376cdf0e10cSrcweir } 377cdf0e10cSrcweir else 378cdf0e10cSrcweir { 379cdf0e10cSrcweir if ( 380cdf0e10cSrcweir ( rPath.lInternalPaths.findConst(sOld) == rPath.lInternalPaths.end()) && 381cdf0e10cSrcweir ( rPath.lUserPaths.findConst(sOld) == rPath.lUserPaths.end() ) && 382cdf0e10cSrcweir (! rPath.sWritePath.equals(sOld) ) 383cdf0e10cSrcweir ) 384cdf0e10cSrcweir rPath.lUserPaths.push_back(sOld); 385cdf0e10cSrcweir } 386cdf0e10cSrcweir } 387cdf0e10cSrcweir } 388cdf0e10cSrcweir #endif // MIGRATE_OLD_USER_PATHES 389cdf0e10cSrcweir 390cdf0e10cSrcweir //----------------------------------------------------------------------------- 391cdf0e10cSrcweir PathSettings::EChangeOp PathSettings::impl_updatePath(const ::rtl::OUString& sPath , 392cdf0e10cSrcweir sal_Bool bNotifyListener) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir // SAFE -> 395cdf0e10cSrcweir WriteGuard aWriteLock(m_aLock); 396cdf0e10cSrcweir 397cdf0e10cSrcweir PathSettings::PathInfo* pPathOld = 0; 398cdf0e10cSrcweir PathSettings::PathInfo* pPathNew = 0; 399cdf0e10cSrcweir PathSettings::EChangeOp eOp = PathSettings::E_UNDEFINED; 400cdf0e10cSrcweir PathSettings::PathInfo aPath; 401cdf0e10cSrcweir 402cdf0e10cSrcweir try 403cdf0e10cSrcweir { 404cdf0e10cSrcweir aPath = impl_readNewFormat(sPath); 405cdf0e10cSrcweir aPath.sPathName = sPath; 406cdf0e10cSrcweir // replace all might existing variables with real values 40707a3d7f1SPedro Giffuni // Do it before these old paths will be compared against the 408cdf0e10cSrcweir // new path configuration. Otherwise some striungs uses different variables ... but substitution 409cdf0e10cSrcweir // will produce strings with same content (because some variables are redundant!) 410cdf0e10cSrcweir impl_subst(aPath, sal_False); 411cdf0e10cSrcweir } 412cdf0e10cSrcweir catch(const css::uno::RuntimeException& exRun) 413cdf0e10cSrcweir { throw exRun; } 414cdf0e10cSrcweir catch(const css::container::NoSuchElementException&) 415cdf0e10cSrcweir { eOp = PathSettings::E_REMOVED; } 416cdf0e10cSrcweir catch(const css::uno::Exception& exAny) 417cdf0e10cSrcweir { throw exAny; } 418cdf0e10cSrcweir 419cdf0e10cSrcweir #ifdef MIGRATE_OLD_USER_PATHES 420cdf0e10cSrcweir try 421cdf0e10cSrcweir { 422cdf0e10cSrcweir // migration of old user defined values on demand 423cdf0e10cSrcweir // can be disabled for a new major 424cdf0e10cSrcweir OUStringList lOldVals = impl_readOldFormat(sPath); 425cdf0e10cSrcweir // replace all might existing variables with real values 42607a3d7f1SPedro Giffuni // Do it before these old paths will be compared against the 427cdf0e10cSrcweir // new path configuration. Otherwise some striungs uses different variables ... but substitution 428cdf0e10cSrcweir // will produce strings with same content (because some variables are redundant!) 429cdf0e10cSrcweir impl_subst(lOldVals, fa_getSubstitution(), sal_False); 430cdf0e10cSrcweir impl_mergeOldUserPaths(aPath, lOldVals); 431cdf0e10cSrcweir } 432cdf0e10cSrcweir catch(const css::uno::RuntimeException& exRun) 433cdf0e10cSrcweir { throw exRun; } 434cdf0e10cSrcweir // Normal(!) exceptions can be ignored! 435cdf0e10cSrcweir // E.g. in case an addon installs a new path, which was not well known for an OOo 1.x installation 43607a3d7f1SPedro Giffuni // we can't find a value for it inside the "old" configuration. So a NoSuchElementException 437cdf0e10cSrcweir // will be normal .-) 438cdf0e10cSrcweir catch(const css::uno::Exception&) 439cdf0e10cSrcweir {} 440cdf0e10cSrcweir #endif // MIGRATE_OLD_USER_PATHES 441cdf0e10cSrcweir 442cdf0e10cSrcweir PathSettings::PathHash::iterator pPath = m_lPaths.find(sPath); 443cdf0e10cSrcweir if (eOp == PathSettings::E_UNDEFINED) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir if (pPath != m_lPaths.end()) 446cdf0e10cSrcweir eOp = PathSettings::E_CHANGED; 447cdf0e10cSrcweir else 448cdf0e10cSrcweir eOp = PathSettings::E_ADDED; 449cdf0e10cSrcweir } 450cdf0e10cSrcweir 451cdf0e10cSrcweir switch(eOp) 452cdf0e10cSrcweir { 453cdf0e10cSrcweir case PathSettings::E_ADDED : 454cdf0e10cSrcweir { 455cdf0e10cSrcweir if (bNotifyListener) 456cdf0e10cSrcweir { 457cdf0e10cSrcweir pPathOld = 0; 458cdf0e10cSrcweir pPathNew = &aPath; 459cdf0e10cSrcweir impl_notifyPropListener(eOp, sPath, pPathOld, pPathNew); 460cdf0e10cSrcweir } 461cdf0e10cSrcweir m_lPaths[sPath] = aPath; 462cdf0e10cSrcweir } 463cdf0e10cSrcweir break; 464cdf0e10cSrcweir 465cdf0e10cSrcweir case PathSettings::E_CHANGED : 466cdf0e10cSrcweir { 467cdf0e10cSrcweir if (bNotifyListener) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir pPathOld = &(pPath->second); 470cdf0e10cSrcweir pPathNew = &aPath; 471cdf0e10cSrcweir impl_notifyPropListener(eOp, sPath, pPathOld, pPathNew); 472cdf0e10cSrcweir } 473cdf0e10cSrcweir m_lPaths[sPath] = aPath; 474cdf0e10cSrcweir } 475cdf0e10cSrcweir break; 476cdf0e10cSrcweir 477cdf0e10cSrcweir case PathSettings::E_REMOVED : 478cdf0e10cSrcweir { 479cdf0e10cSrcweir if (pPath != m_lPaths.end()) 480cdf0e10cSrcweir { 481cdf0e10cSrcweir if (bNotifyListener) 482cdf0e10cSrcweir { 483cdf0e10cSrcweir pPathOld = &(pPath->second); 484cdf0e10cSrcweir pPathNew = 0; 485cdf0e10cSrcweir impl_notifyPropListener(eOp, sPath, pPathOld, pPathNew); 486cdf0e10cSrcweir } 487cdf0e10cSrcweir m_lPaths.erase(pPath); 488cdf0e10cSrcweir } 489cdf0e10cSrcweir } 490cdf0e10cSrcweir break; 491cdf0e10cSrcweir 492cdf0e10cSrcweir default: // to let compiler be happy 493cdf0e10cSrcweir break; 494cdf0e10cSrcweir } 495cdf0e10cSrcweir 496cdf0e10cSrcweir return eOp; 497cdf0e10cSrcweir } 498cdf0e10cSrcweir 499cdf0e10cSrcweir //----------------------------------------------------------------------------- 500cdf0e10cSrcweir css::uno::Sequence< sal_Int32 > PathSettings::impl_mapPathName2IDList(const ::rtl::OUString& sPath) 501cdf0e10cSrcweir { 502cdf0e10cSrcweir ::rtl::OUString sOldStyleProp = sPath; 503cdf0e10cSrcweir ::rtl::OUString sInternalProp = sPath+POSTFIX_INTERNAL_PATHES; 504cdf0e10cSrcweir ::rtl::OUString sUserProp = sPath+POSTFIX_USER_PATHES; 505cdf0e10cSrcweir ::rtl::OUString sWriteProp = sPath+POSTFIX_WRITE_PATH; 506cdf0e10cSrcweir 507cdf0e10cSrcweir // Attention: The default set of IDs is fix and must follow these schema. 50815289133Smseidel // Otherwise the outside code ant work for new added properties. 509cdf0e10cSrcweir // Why ? 510cdf0e10cSrcweir // The outside code must fire N events for every changed property. 511cdf0e10cSrcweir // And the knowing about packaging of variables of the structure PathInfo 51207a3d7f1SPedro Giffuni // follow these group IDs ! But if such ID isn't in the range of [0..IDGROUP_COUNT] 51307a3d7f1SPedro Giffuni // the outside can't determine the right group ... and can't fire the right events .-) 514cdf0e10cSrcweir 515cdf0e10cSrcweir css::uno::Sequence< sal_Int32 > lIDs(IDGROUP_COUNT); 516cdf0e10cSrcweir lIDs[0] = IDGROUP_OLDSTYLE ; 517cdf0e10cSrcweir lIDs[1] = IDGROUP_INTERNAL_PATHES; 518cdf0e10cSrcweir lIDs[2] = IDGROUP_USER_PATHES ; 519cdf0e10cSrcweir lIDs[3] = IDGROUP_WRITE_PATH ; 520cdf0e10cSrcweir 521cdf0e10cSrcweir sal_Int32 c = m_lPropDesc.getLength(); 522cdf0e10cSrcweir sal_Int32 i = 0; 523cdf0e10cSrcweir for (i=0; i<c; ++i) 524cdf0e10cSrcweir { 525cdf0e10cSrcweir const css::beans::Property& rProp = m_lPropDesc[i]; 526cdf0e10cSrcweir 527cdf0e10cSrcweir if (rProp.Name.equals(sOldStyleProp)) 528cdf0e10cSrcweir lIDs[IDGROUP_OLDSTYLE] = rProp.Handle; 529cdf0e10cSrcweir else 530cdf0e10cSrcweir if (rProp.Name.equals(sInternalProp)) 531cdf0e10cSrcweir lIDs[IDGROUP_INTERNAL_PATHES] = rProp.Handle; 532cdf0e10cSrcweir else 533cdf0e10cSrcweir if (rProp.Name.equals(sUserProp)) 534cdf0e10cSrcweir lIDs[IDGROUP_USER_PATHES] = rProp.Handle; 535cdf0e10cSrcweir else 536cdf0e10cSrcweir if (rProp.Name.equals(sWriteProp)) 537cdf0e10cSrcweir lIDs[IDGROUP_WRITE_PATH] = rProp.Handle; 538cdf0e10cSrcweir } 539cdf0e10cSrcweir 540cdf0e10cSrcweir return lIDs; 541cdf0e10cSrcweir } 542cdf0e10cSrcweir 543cdf0e10cSrcweir //----------------------------------------------------------------------------- 544cdf0e10cSrcweir void PathSettings::impl_notifyPropListener( PathSettings::EChangeOp /*eOp*/ , 545cdf0e10cSrcweir const ::rtl::OUString& sPath , 546cdf0e10cSrcweir const PathSettings::PathInfo* pPathOld, 547cdf0e10cSrcweir const PathSettings::PathInfo* pPathNew) 548cdf0e10cSrcweir { 549cdf0e10cSrcweir css::uno::Sequence< sal_Int32 > lHandles(1); 550cdf0e10cSrcweir css::uno::Sequence< css::uno::Any > lOldVals(1); 551cdf0e10cSrcweir css::uno::Sequence< css::uno::Any > lNewVals(1); 552cdf0e10cSrcweir 553cdf0e10cSrcweir css::uno::Sequence< sal_Int32 > lIDs = impl_mapPathName2IDList(sPath); 554cdf0e10cSrcweir sal_Int32 c = lIDs.getLength(); 555cdf0e10cSrcweir sal_Int32 i = 0; 556cdf0e10cSrcweir sal_Int32 nMaxID = m_lPropDesc.getLength()-1; 557cdf0e10cSrcweir for (i=0; i<c; ++i) 558cdf0e10cSrcweir { 559cdf0e10cSrcweir sal_Int32 nID = lIDs[i]; 560cdf0e10cSrcweir 561cdf0e10cSrcweir if ( 562cdf0e10cSrcweir (nID < 0 ) || 563cdf0e10cSrcweir (nID > nMaxID) 564cdf0e10cSrcweir ) 565cdf0e10cSrcweir continue; 566cdf0e10cSrcweir 567cdf0e10cSrcweir lHandles[0] = nID; 568cdf0e10cSrcweir switch(impl_getPropGroup(nID)) 569cdf0e10cSrcweir { 570cdf0e10cSrcweir case IDGROUP_OLDSTYLE : 571cdf0e10cSrcweir { 572cdf0e10cSrcweir if (pPathOld) 573cdf0e10cSrcweir { 574cdf0e10cSrcweir ::rtl::OUString sVal = impl_convertPath2OldStyle(*pPathOld); 575cdf0e10cSrcweir lOldVals[0] <<= sVal; 576cdf0e10cSrcweir } 577cdf0e10cSrcweir if (pPathNew) 578cdf0e10cSrcweir { 579cdf0e10cSrcweir ::rtl::OUString sVal = impl_convertPath2OldStyle(*pPathNew); 580cdf0e10cSrcweir lNewVals[0] <<= sVal; 581cdf0e10cSrcweir } 582cdf0e10cSrcweir } 583cdf0e10cSrcweir break; 584cdf0e10cSrcweir 585cdf0e10cSrcweir case IDGROUP_INTERNAL_PATHES : 586cdf0e10cSrcweir { 587cdf0e10cSrcweir if (pPathOld) 588cdf0e10cSrcweir lOldVals[0] <<= pPathOld->lInternalPaths.getAsConstList(); 589cdf0e10cSrcweir if (pPathNew) 590cdf0e10cSrcweir lNewVals[0] <<= pPathNew->lInternalPaths.getAsConstList(); 591cdf0e10cSrcweir } 592cdf0e10cSrcweir break; 593cdf0e10cSrcweir 594cdf0e10cSrcweir case IDGROUP_USER_PATHES : 595cdf0e10cSrcweir { 596cdf0e10cSrcweir if (pPathOld) 597cdf0e10cSrcweir lOldVals[0] <<= pPathOld->lUserPaths.getAsConstList(); 598cdf0e10cSrcweir if (pPathNew) 599cdf0e10cSrcweir lNewVals[0] <<= pPathNew->lUserPaths.getAsConstList(); 600cdf0e10cSrcweir } 601cdf0e10cSrcweir break; 602cdf0e10cSrcweir 603cdf0e10cSrcweir case IDGROUP_WRITE_PATH : 604cdf0e10cSrcweir { 605cdf0e10cSrcweir if (pPathOld) 606cdf0e10cSrcweir lOldVals[0] <<= pPathOld->sWritePath; 607cdf0e10cSrcweir if (pPathNew) 608cdf0e10cSrcweir lNewVals[0] <<= pPathNew->sWritePath; 609cdf0e10cSrcweir } 610cdf0e10cSrcweir break; 611cdf0e10cSrcweir } 612cdf0e10cSrcweir 613cdf0e10cSrcweir fire(lHandles.getArray(), 614cdf0e10cSrcweir lNewVals.getArray(), 615cdf0e10cSrcweir lOldVals.getArray(), 616cdf0e10cSrcweir 1, 617cdf0e10cSrcweir sal_False); 618cdf0e10cSrcweir } 619cdf0e10cSrcweir } 620cdf0e10cSrcweir 621cdf0e10cSrcweir //----------------------------------------------------------------------------- 622cdf0e10cSrcweir void PathSettings::impl_subst( OUStringList& lVals , 623cdf0e10cSrcweir const css::uno::Reference< css::util::XStringSubstitution >& xSubst , 624cdf0e10cSrcweir sal_Bool bReSubst) 625cdf0e10cSrcweir { 626cdf0e10cSrcweir OUStringList::iterator pIt; 627cdf0e10cSrcweir 628cdf0e10cSrcweir for ( pIt = lVals.begin(); 629cdf0e10cSrcweir pIt != lVals.end() ; 630cdf0e10cSrcweir ++pIt ) 631cdf0e10cSrcweir { 632cdf0e10cSrcweir const ::rtl::OUString& sOld = *pIt; 633cdf0e10cSrcweir ::rtl::OUString sNew ; 634cdf0e10cSrcweir if (bReSubst) 635cdf0e10cSrcweir sNew = xSubst->reSubstituteVariables(sOld); 636cdf0e10cSrcweir else 637cdf0e10cSrcweir sNew = xSubst->substituteVariables(sOld, sal_False); 638cdf0e10cSrcweir 639cdf0e10cSrcweir *pIt = sNew; 640cdf0e10cSrcweir } 641cdf0e10cSrcweir } 642cdf0e10cSrcweir 643cdf0e10cSrcweir //----------------------------------------------------------------------------- 644cdf0e10cSrcweir void PathSettings::impl_subst(PathSettings::PathInfo& aPath , 645cdf0e10cSrcweir sal_Bool bReSubst) 646cdf0e10cSrcweir { 647cdf0e10cSrcweir css::uno::Reference< css::util::XStringSubstitution > xSubst = fa_getSubstitution(); 648cdf0e10cSrcweir 649cdf0e10cSrcweir impl_subst(aPath.lInternalPaths, xSubst, bReSubst); 650cdf0e10cSrcweir impl_subst(aPath.lUserPaths , xSubst, bReSubst); 651cdf0e10cSrcweir if (bReSubst) 652cdf0e10cSrcweir aPath.sWritePath = xSubst->reSubstituteVariables(aPath.sWritePath); 653cdf0e10cSrcweir else 654cdf0e10cSrcweir aPath.sWritePath = xSubst->substituteVariables(aPath.sWritePath, sal_False); 655cdf0e10cSrcweir } 656cdf0e10cSrcweir 657cdf0e10cSrcweir //----------------------------------------------------------------------------- 658cdf0e10cSrcweir ::rtl::OUString PathSettings::impl_convertPath2OldStyle(const PathSettings::PathInfo& rPath) const 659cdf0e10cSrcweir { 660cdf0e10cSrcweir OUStringList::const_iterator pIt; 661cdf0e10cSrcweir OUStringList lTemp; 662cdf0e10cSrcweir lTemp.reserve(rPath.lInternalPaths.size() + rPath.lUserPaths.size() + 1); 663cdf0e10cSrcweir 664cdf0e10cSrcweir for ( pIt = rPath.lInternalPaths.begin(); 665cdf0e10cSrcweir pIt != rPath.lInternalPaths.end() ; 666cdf0e10cSrcweir ++pIt ) 667cdf0e10cSrcweir { 668cdf0e10cSrcweir lTemp.push_back(*pIt); 669cdf0e10cSrcweir } 670cdf0e10cSrcweir for ( pIt = rPath.lUserPaths.begin(); 671cdf0e10cSrcweir pIt != rPath.lUserPaths.end() ; 672cdf0e10cSrcweir ++pIt ) 673cdf0e10cSrcweir { 674cdf0e10cSrcweir lTemp.push_back(*pIt); 675cdf0e10cSrcweir } 676cdf0e10cSrcweir 677cdf0e10cSrcweir if (rPath.sWritePath.getLength() > 0) 678cdf0e10cSrcweir lTemp.push_back(rPath.sWritePath); 679cdf0e10cSrcweir 680cdf0e10cSrcweir ::rtl::OUStringBuffer sPathVal(256); 681cdf0e10cSrcweir for ( pIt = lTemp.begin(); 682cdf0e10cSrcweir pIt != lTemp.end() ; 683cdf0e10cSrcweir ) 684cdf0e10cSrcweir { 685cdf0e10cSrcweir sPathVal.append(*pIt); 686cdf0e10cSrcweir ++pIt; 687cdf0e10cSrcweir if (pIt != lTemp.end()) 688cdf0e10cSrcweir sPathVal.appendAscii(";"); 689cdf0e10cSrcweir } 690cdf0e10cSrcweir 691cdf0e10cSrcweir return sPathVal.makeStringAndClear(); 692cdf0e10cSrcweir } 693cdf0e10cSrcweir 694cdf0e10cSrcweir //----------------------------------------------------------------------------- 695cdf0e10cSrcweir OUStringList PathSettings::impl_convertOldStyle2Path(const ::rtl::OUString& sOldStylePath) const 696cdf0e10cSrcweir { 697cdf0e10cSrcweir OUStringList lList; 698cdf0e10cSrcweir sal_Int32 nToken = 0; 699cdf0e10cSrcweir do 700cdf0e10cSrcweir { 701cdf0e10cSrcweir ::rtl::OUString sToken = sOldStylePath.getToken(0, ';', nToken); 702cdf0e10cSrcweir if (sToken.getLength()) 703cdf0e10cSrcweir lList.push_back(sToken); 704cdf0e10cSrcweir } 705cdf0e10cSrcweir while(nToken >= 0); 706cdf0e10cSrcweir 707cdf0e10cSrcweir return lList; 708cdf0e10cSrcweir } 709cdf0e10cSrcweir 710cdf0e10cSrcweir //----------------------------------------------------------------------------- 711cdf0e10cSrcweir void PathSettings::impl_purgeKnownPaths(const PathSettings::PathInfo& rPath, 712cdf0e10cSrcweir OUStringList& lList) 713cdf0e10cSrcweir { 714cdf0e10cSrcweir OUStringList::const_iterator pIt; 715cdf0e10cSrcweir for ( pIt = rPath.lInternalPaths.begin(); 716cdf0e10cSrcweir pIt != rPath.lInternalPaths.end() ; 717cdf0e10cSrcweir ++pIt ) 718cdf0e10cSrcweir { 719cdf0e10cSrcweir const ::rtl::OUString& rItem = *pIt; 720cdf0e10cSrcweir OUStringList::iterator pItem = lList.find(rItem); 721cdf0e10cSrcweir if (pItem != lList.end()) 722cdf0e10cSrcweir lList.erase(pItem); 723cdf0e10cSrcweir } 724cdf0e10cSrcweir for ( pIt = rPath.lUserPaths.begin(); 725cdf0e10cSrcweir pIt != rPath.lUserPaths.end() ; 726cdf0e10cSrcweir ++pIt ) 727cdf0e10cSrcweir { 728cdf0e10cSrcweir const ::rtl::OUString& rItem = *pIt; 729cdf0e10cSrcweir OUStringList::iterator pItem = lList.find(rItem); 730cdf0e10cSrcweir if (pItem != lList.end()) 731cdf0e10cSrcweir lList.erase(pItem); 732cdf0e10cSrcweir } 733cdf0e10cSrcweir 734cdf0e10cSrcweir OUStringList::iterator pItem = lList.find(rPath.sWritePath); 735cdf0e10cSrcweir if (pItem != lList.end()) 736cdf0e10cSrcweir lList.erase(pItem); 737cdf0e10cSrcweir } 738cdf0e10cSrcweir 739cdf0e10cSrcweir //----------------------------------------------------------------------------- 740cdf0e10cSrcweir void PathSettings::impl_rebuildPropertyDescriptor() 741cdf0e10cSrcweir { 742cdf0e10cSrcweir // SAFE -> 743cdf0e10cSrcweir WriteGuard aWriteLock(m_aLock); 744cdf0e10cSrcweir 745cdf0e10cSrcweir sal_Int32 c = (sal_Int32)m_lPaths.size(); 746cdf0e10cSrcweir sal_Int32 i = 0; 747cdf0e10cSrcweir m_lPropDesc.realloc(c*IDGROUP_COUNT); 748cdf0e10cSrcweir 749cdf0e10cSrcweir PathHash::const_iterator pIt; 750cdf0e10cSrcweir for ( pIt = m_lPaths.begin(); 751cdf0e10cSrcweir pIt != m_lPaths.end() ; 752cdf0e10cSrcweir ++pIt ) 753cdf0e10cSrcweir { 754cdf0e10cSrcweir const PathSettings::PathInfo& rPath = pIt->second; 755cdf0e10cSrcweir css::beans::Property* pProp = 0; 756cdf0e10cSrcweir 757cdf0e10cSrcweir pProp = &(m_lPropDesc[i]); 758cdf0e10cSrcweir pProp->Name = rPath.sPathName; 759cdf0e10cSrcweir pProp->Handle = i; 760cdf0e10cSrcweir pProp->Type = ::getCppuType((::rtl::OUString*)0); 761cdf0e10cSrcweir pProp->Attributes = css::beans::PropertyAttribute::BOUND; 762cdf0e10cSrcweir if (rPath.bIsReadonly) 763cdf0e10cSrcweir pProp->Attributes |= css::beans::PropertyAttribute::READONLY; 764cdf0e10cSrcweir ++i; 765cdf0e10cSrcweir 766cdf0e10cSrcweir pProp = &(m_lPropDesc[i]); 767cdf0e10cSrcweir pProp->Name = rPath.sPathName+POSTFIX_INTERNAL_PATHES; 768cdf0e10cSrcweir pProp->Handle = i; 769cdf0e10cSrcweir pProp->Type = ::getCppuType((css::uno::Sequence< ::rtl::OUString >*)0); 770cdf0e10cSrcweir pProp->Attributes = css::beans::PropertyAttribute::BOUND | 771cdf0e10cSrcweir css::beans::PropertyAttribute::READONLY; 772cdf0e10cSrcweir ++i; 773cdf0e10cSrcweir 774cdf0e10cSrcweir pProp = &(m_lPropDesc[i]); 775cdf0e10cSrcweir pProp->Name = rPath.sPathName+POSTFIX_USER_PATHES; 776cdf0e10cSrcweir pProp->Handle = i; 777cdf0e10cSrcweir pProp->Type = ::getCppuType((css::uno::Sequence< ::rtl::OUString >*)0); 778cdf0e10cSrcweir pProp->Attributes = css::beans::PropertyAttribute::BOUND; 779cdf0e10cSrcweir if (rPath.bIsReadonly) 780cdf0e10cSrcweir pProp->Attributes |= css::beans::PropertyAttribute::READONLY; 781cdf0e10cSrcweir ++i; 782cdf0e10cSrcweir 783cdf0e10cSrcweir pProp = &(m_lPropDesc[i]); 784cdf0e10cSrcweir pProp->Name = rPath.sPathName+POSTFIX_WRITE_PATH; 785cdf0e10cSrcweir pProp->Handle = i; 786cdf0e10cSrcweir pProp->Type = ::getCppuType((::rtl::OUString*)0); 787cdf0e10cSrcweir pProp->Attributes = css::beans::PropertyAttribute::BOUND; 788cdf0e10cSrcweir if (rPath.bIsReadonly) 789cdf0e10cSrcweir pProp->Attributes |= css::beans::PropertyAttribute::READONLY; 790cdf0e10cSrcweir ++i; 791cdf0e10cSrcweir } 792cdf0e10cSrcweir 793cdf0e10cSrcweir if (m_pPropHelp) 794cdf0e10cSrcweir delete m_pPropHelp; 795cdf0e10cSrcweir m_pPropHelp = new ::cppu::OPropertyArrayHelper(m_lPropDesc, sal_False); // false => not sorted ... must be done inside helper 796cdf0e10cSrcweir 797cdf0e10cSrcweir aWriteLock.unlock(); 798cdf0e10cSrcweir // <- SAFE 799cdf0e10cSrcweir } 800cdf0e10cSrcweir 801cdf0e10cSrcweir //----------------------------------------------------------------------------- 802cdf0e10cSrcweir css::uno::Any PathSettings::impl_getPathValue(sal_Int32 nID) const 803cdf0e10cSrcweir { 804cdf0e10cSrcweir const PathSettings::PathInfo* pPath = impl_getPathAccessConst(nID); 805cdf0e10cSrcweir if (! pPath) 806cdf0e10cSrcweir throw css::container::NoSuchElementException(); 807cdf0e10cSrcweir 808cdf0e10cSrcweir css::uno::Any aVal; 809cdf0e10cSrcweir switch(impl_getPropGroup(nID)) 810cdf0e10cSrcweir { 811cdf0e10cSrcweir case IDGROUP_OLDSTYLE : 812cdf0e10cSrcweir { 813cdf0e10cSrcweir ::rtl::OUString sVal = impl_convertPath2OldStyle(*pPath); 814cdf0e10cSrcweir aVal <<= sVal; 815cdf0e10cSrcweir } 816cdf0e10cSrcweir break; 817cdf0e10cSrcweir 818cdf0e10cSrcweir case IDGROUP_INTERNAL_PATHES : 819cdf0e10cSrcweir { 820cdf0e10cSrcweir aVal <<= pPath->lInternalPaths.getAsConstList(); 821cdf0e10cSrcweir } 822cdf0e10cSrcweir break; 823cdf0e10cSrcweir 824cdf0e10cSrcweir case IDGROUP_USER_PATHES : 825cdf0e10cSrcweir { 826cdf0e10cSrcweir aVal <<= pPath->lUserPaths.getAsConstList(); 827cdf0e10cSrcweir } 828cdf0e10cSrcweir break; 829cdf0e10cSrcweir 830cdf0e10cSrcweir case IDGROUP_WRITE_PATH : 831cdf0e10cSrcweir { 832cdf0e10cSrcweir aVal <<= pPath->sWritePath; 833cdf0e10cSrcweir } 834cdf0e10cSrcweir break; 835cdf0e10cSrcweir } 836cdf0e10cSrcweir 837cdf0e10cSrcweir return aVal; 838cdf0e10cSrcweir } 839cdf0e10cSrcweir 840cdf0e10cSrcweir //----------------------------------------------------------------------------- 841cdf0e10cSrcweir void PathSettings::impl_setPathValue( sal_Int32 nID , 842cdf0e10cSrcweir const css::uno::Any& aVal) 843cdf0e10cSrcweir { 844cdf0e10cSrcweir PathSettings::PathInfo* pOrgPath = impl_getPathAccess(nID); 845cdf0e10cSrcweir if (! pOrgPath) 846cdf0e10cSrcweir throw css::container::NoSuchElementException(); 847cdf0e10cSrcweir 848cdf0e10cSrcweir // We work on a copied path ... so we can be sure that errors during this operation 849cdf0e10cSrcweir // does not make our internal cache invalid .-) 850cdf0e10cSrcweir PathSettings::PathInfo aChangePath(*pOrgPath); 851cdf0e10cSrcweir 852cdf0e10cSrcweir switch(impl_getPropGroup(nID)) 853cdf0e10cSrcweir { 854cdf0e10cSrcweir case IDGROUP_OLDSTYLE : 855cdf0e10cSrcweir { 856cdf0e10cSrcweir ::rtl::OUString sVal; 857cdf0e10cSrcweir aVal >>= sVal; 858cdf0e10cSrcweir OUStringList lList = impl_convertOldStyle2Path(sVal); 859cdf0e10cSrcweir impl_subst(lList, fa_getSubstitution(), sal_False); 860cdf0e10cSrcweir impl_purgeKnownPaths(aChangePath, lList); 861cdf0e10cSrcweir if (! impl_isValidPath(lList)) 862cdf0e10cSrcweir throw css::lang::IllegalArgumentException(); 863cdf0e10cSrcweir 864cdf0e10cSrcweir if (aChangePath.bIsSinglePath) 865cdf0e10cSrcweir { 866cdf0e10cSrcweir LOG_ASSERT2(lList.size()>1, "PathSettings::impl_setPathValue()", "You try to set more then path value for a defined SINGLE_PATH!") 867cdf0e10cSrcweir if ( !lList.empty() ) 868cdf0e10cSrcweir aChangePath.sWritePath = *(lList.begin()); 869cdf0e10cSrcweir else 870cdf0e10cSrcweir aChangePath.sWritePath = ::rtl::OUString(); 871cdf0e10cSrcweir } 872cdf0e10cSrcweir else 873cdf0e10cSrcweir { 874cdf0e10cSrcweir OUStringList::const_iterator pIt; 875cdf0e10cSrcweir for ( pIt = lList.begin(); 876cdf0e10cSrcweir pIt != lList.end() ; 877cdf0e10cSrcweir ++pIt ) 878cdf0e10cSrcweir { 879cdf0e10cSrcweir aChangePath.lUserPaths.push_back(*pIt); 880cdf0e10cSrcweir } 881cdf0e10cSrcweir } 882cdf0e10cSrcweir } 883cdf0e10cSrcweir break; 884cdf0e10cSrcweir 885cdf0e10cSrcweir case IDGROUP_INTERNAL_PATHES : 886cdf0e10cSrcweir { 887cdf0e10cSrcweir if (aChangePath.bIsSinglePath) 888cdf0e10cSrcweir { 889cdf0e10cSrcweir ::rtl::OUStringBuffer sMsg(256); 890cdf0e10cSrcweir sMsg.appendAscii("The path '" ); 891cdf0e10cSrcweir sMsg.append (aChangePath.sPathName); 89207a3d7f1SPedro Giffuni sMsg.appendAscii("' is defined as SINGLE_PATH. It's sub set of internal paths can't be set."); 893cdf0e10cSrcweir throw css::uno::Exception(sMsg.makeStringAndClear(), 894cdf0e10cSrcweir static_cast< ::cppu::OWeakObject* >(this)); 895cdf0e10cSrcweir } 896cdf0e10cSrcweir 897cdf0e10cSrcweir OUStringList lList; 898cdf0e10cSrcweir lList << aVal; 899cdf0e10cSrcweir if (! impl_isValidPath(lList)) 900cdf0e10cSrcweir throw css::lang::IllegalArgumentException(); 901cdf0e10cSrcweir aChangePath.lInternalPaths = lList; 902cdf0e10cSrcweir } 903cdf0e10cSrcweir break; 904cdf0e10cSrcweir 905cdf0e10cSrcweir case IDGROUP_USER_PATHES : 906cdf0e10cSrcweir { 907cdf0e10cSrcweir if (aChangePath.bIsSinglePath) 908cdf0e10cSrcweir { 909cdf0e10cSrcweir ::rtl::OUStringBuffer sMsg(256); 910cdf0e10cSrcweir sMsg.appendAscii("The path '" ); 911cdf0e10cSrcweir sMsg.append (aChangePath.sPathName); 91207a3d7f1SPedro Giffuni sMsg.appendAscii("' is defined as SINGLE_PATH. It's sub set of internal paths can't be set."); 913cdf0e10cSrcweir throw css::uno::Exception(sMsg.makeStringAndClear(), 914cdf0e10cSrcweir static_cast< ::cppu::OWeakObject* >(this)); 915cdf0e10cSrcweir } 916cdf0e10cSrcweir 917cdf0e10cSrcweir OUStringList lList; 918cdf0e10cSrcweir lList << aVal; 919cdf0e10cSrcweir if (! impl_isValidPath(lList)) 920cdf0e10cSrcweir throw css::lang::IllegalArgumentException(); 921cdf0e10cSrcweir aChangePath.lUserPaths = lList; 922cdf0e10cSrcweir } 923cdf0e10cSrcweir break; 924cdf0e10cSrcweir 925cdf0e10cSrcweir case IDGROUP_WRITE_PATH : 926cdf0e10cSrcweir { 927cdf0e10cSrcweir ::rtl::OUString sVal; 928cdf0e10cSrcweir aVal >>= sVal; 929cdf0e10cSrcweir if (! impl_isValidPath(sVal)) 930cdf0e10cSrcweir throw css::lang::IllegalArgumentException(); 931cdf0e10cSrcweir aChangePath.sWritePath = sVal; 932cdf0e10cSrcweir } 933cdf0e10cSrcweir break; 934cdf0e10cSrcweir } 935cdf0e10cSrcweir 936cdf0e10cSrcweir // TODO check if path has at least one path value set 937cdf0e10cSrcweir // At least it depends from the feature using this path, if an empty path list is allowed. 938cdf0e10cSrcweir /* 939cdf0e10cSrcweir if (impl_isPathEmpty(aChangePath)) 940cdf0e10cSrcweir { 941cdf0e10cSrcweir ::rtl::OUStringBuffer sMsg(256); 942cdf0e10cSrcweir sMsg.appendAscii("The path '" ); 943cdf0e10cSrcweir sMsg.append (aChangePath.sPathName); 944cdf0e10cSrcweir sMsg.appendAscii("' is empty now ... Not a real good idea."); 945cdf0e10cSrcweir throw css::uno::Exception(sMsg.makeStringAndClear(), 946cdf0e10cSrcweir static_cast< ::cppu::OWeakObject* >(this)); 947cdf0e10cSrcweir } 948cdf0e10cSrcweir */ 949cdf0e10cSrcweir 950cdf0e10cSrcweir // first we should try to store the changed (copied!) path ... 951cdf0e10cSrcweir // In case an error occure on saving time an exception is thrown ... 95230acf5e8Spfg // If no exception occurs we can update our internal cache (means 953cdf0e10cSrcweir // we can overwrite pOrgPath ! 954cdf0e10cSrcweir impl_storePath(aChangePath); 955cdf0e10cSrcweir pOrgPath->takeOver(aChangePath); 956cdf0e10cSrcweir } 957cdf0e10cSrcweir 958cdf0e10cSrcweir //----------------------------------------------------------------------------- 959cdf0e10cSrcweir sal_Bool PathSettings::impl_isValidPath(const OUStringList& lPath) const 960cdf0e10cSrcweir { 961cdf0e10cSrcweir OUStringList::const_iterator pIt; 962cdf0e10cSrcweir for ( pIt = lPath.begin(); 963cdf0e10cSrcweir pIt != lPath.end() ; 964cdf0e10cSrcweir ++pIt ) 965cdf0e10cSrcweir { 966cdf0e10cSrcweir const ::rtl::OUString& rVal = *pIt; 967cdf0e10cSrcweir if (! impl_isValidPath(rVal)) 968cdf0e10cSrcweir return sal_False; 969cdf0e10cSrcweir } 970cdf0e10cSrcweir 971cdf0e10cSrcweir return sal_True; 972cdf0e10cSrcweir } 973cdf0e10cSrcweir 974cdf0e10cSrcweir //----------------------------------------------------------------------------- 975cdf0e10cSrcweir sal_Bool PathSettings::impl_isValidPath(const ::rtl::OUString& sPath) const 976cdf0e10cSrcweir { 977cdf0e10cSrcweir // allow empty path to reset a path. 97807a3d7f1SPedro Giffuni // idea by LLA to support empty paths 979cdf0e10cSrcweir // if (sPath.getLength() == 0) 980cdf0e10cSrcweir // { 981cdf0e10cSrcweir // return sal_True; 982cdf0e10cSrcweir // } 983cdf0e10cSrcweir 984cdf0e10cSrcweir return (! INetURLObject(sPath).HasError()); 985cdf0e10cSrcweir } 986cdf0e10cSrcweir 987cdf0e10cSrcweir //----------------------------------------------------------------------------- 988cdf0e10cSrcweir ::rtl::OUString impl_extractBaseFromPropName(const ::rtl::OUString& sPropName) 989cdf0e10cSrcweir { 990cdf0e10cSrcweir sal_Int32 i = -1; 991cdf0e10cSrcweir 992cdf0e10cSrcweir i = sPropName.indexOf(POSTFIX_INTERNAL_PATHES); 993cdf0e10cSrcweir if (i > -1) 994cdf0e10cSrcweir return sPropName.copy(0, i); 995cdf0e10cSrcweir i = sPropName.indexOf(POSTFIX_USER_PATHES); 996cdf0e10cSrcweir if (i > -1) 997cdf0e10cSrcweir return sPropName.copy(0, i); 998cdf0e10cSrcweir i = sPropName.indexOf(POSTFIX_WRITE_PATH); 999cdf0e10cSrcweir if (i > -1) 1000cdf0e10cSrcweir return sPropName.copy(0, i); 1001cdf0e10cSrcweir 1002cdf0e10cSrcweir return sPropName; 1003cdf0e10cSrcweir } 1004cdf0e10cSrcweir 1005cdf0e10cSrcweir //----------------------------------------------------------------------------- 1006cdf0e10cSrcweir PathSettings::PathInfo* PathSettings::impl_getPathAccess(sal_Int32 nHandle) 1007cdf0e10cSrcweir { 1008cdf0e10cSrcweir // SAFE -> 1009cdf0e10cSrcweir ReadGuard aReadLock(m_aLock); 1010cdf0e10cSrcweir 1011cdf0e10cSrcweir if (nHandle > (m_lPropDesc.getLength()-1)) 1012cdf0e10cSrcweir return 0; 1013cdf0e10cSrcweir 1014cdf0e10cSrcweir const css::beans::Property& rProp = m_lPropDesc[nHandle]; 1015cdf0e10cSrcweir ::rtl::OUString sProp = impl_extractBaseFromPropName(rProp.Name); 1016cdf0e10cSrcweir PathSettings::PathHash::iterator rPath = m_lPaths.find(sProp); 1017cdf0e10cSrcweir 1018cdf0e10cSrcweir if (rPath != m_lPaths.end()) 1019cdf0e10cSrcweir return &(rPath->second); 1020cdf0e10cSrcweir 1021cdf0e10cSrcweir return 0; 1022cdf0e10cSrcweir // <- SAFE 1023cdf0e10cSrcweir } 1024cdf0e10cSrcweir 1025cdf0e10cSrcweir //----------------------------------------------------------------------------- 1026cdf0e10cSrcweir const PathSettings::PathInfo* PathSettings::impl_getPathAccessConst(sal_Int32 nHandle) const 1027cdf0e10cSrcweir { 1028cdf0e10cSrcweir // SAFE -> 1029cdf0e10cSrcweir ReadGuard aReadLock(m_aLock); 1030cdf0e10cSrcweir 1031cdf0e10cSrcweir if (nHandle > (m_lPropDesc.getLength()-1)) 1032cdf0e10cSrcweir return 0; 1033cdf0e10cSrcweir 1034cdf0e10cSrcweir const css::beans::Property& rProp = m_lPropDesc[nHandle]; 1035cdf0e10cSrcweir ::rtl::OUString sProp = impl_extractBaseFromPropName(rProp.Name); 1036cdf0e10cSrcweir PathSettings::PathHash::const_iterator rPath = m_lPaths.find(sProp); 1037cdf0e10cSrcweir 1038cdf0e10cSrcweir if (rPath != m_lPaths.end()) 1039cdf0e10cSrcweir return &(rPath->second); 1040cdf0e10cSrcweir 1041cdf0e10cSrcweir return 0; 1042cdf0e10cSrcweir // <- SAFE 1043cdf0e10cSrcweir } 1044cdf0e10cSrcweir 1045cdf0e10cSrcweir //----------------------------------------------------------------------------- 1046cdf0e10cSrcweir sal_Bool SAL_CALL PathSettings::convertFastPropertyValue( css::uno::Any& aConvertedValue, 1047cdf0e10cSrcweir css::uno::Any& aOldValue , 1048cdf0e10cSrcweir sal_Int32 nHandle , 1049cdf0e10cSrcweir const css::uno::Any& aValue ) 1050cdf0e10cSrcweir throw(css::lang::IllegalArgumentException) 1051cdf0e10cSrcweir { 1052cdf0e10cSrcweir // throws NoSuchElementException ! 1053cdf0e10cSrcweir css::uno::Any aCurrentVal = impl_getPathValue(nHandle); 1054cdf0e10cSrcweir 1055cdf0e10cSrcweir return PropHelper::willPropertyBeChanged( 1056cdf0e10cSrcweir aCurrentVal, 1057cdf0e10cSrcweir aValue, 1058cdf0e10cSrcweir aOldValue, 1059cdf0e10cSrcweir aConvertedValue); 1060cdf0e10cSrcweir } 1061cdf0e10cSrcweir 1062cdf0e10cSrcweir //----------------------------------------------------------------------------- 1063cdf0e10cSrcweir void SAL_CALL PathSettings::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, 1064cdf0e10cSrcweir const css::uno::Any& aValue ) 1065cdf0e10cSrcweir throw(css::uno::Exception) 1066cdf0e10cSrcweir { 1067cdf0e10cSrcweir // throws NoSuchElement- and IllegalArgumentException ! 1068cdf0e10cSrcweir impl_setPathValue(nHandle, aValue); 1069cdf0e10cSrcweir } 1070cdf0e10cSrcweir 1071cdf0e10cSrcweir //----------------------------------------------------------------------------- 1072cdf0e10cSrcweir void SAL_CALL PathSettings::getFastPropertyValue(css::uno::Any& aValue , 1073cdf0e10cSrcweir sal_Int32 nHandle) const 1074cdf0e10cSrcweir { 1075cdf0e10cSrcweir aValue = impl_getPathValue(nHandle); 1076cdf0e10cSrcweir } 1077cdf0e10cSrcweir 1078cdf0e10cSrcweir //----------------------------------------------------------------------------- 1079cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& SAL_CALL PathSettings::getInfoHelper() 1080cdf0e10cSrcweir { 1081cdf0e10cSrcweir return *m_pPropHelp; 1082cdf0e10cSrcweir } 1083cdf0e10cSrcweir 1084cdf0e10cSrcweir //----------------------------------------------------------------------------- 1085cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL PathSettings::getPropertySetInfo() 1086cdf0e10cSrcweir throw(css::uno::RuntimeException) 1087cdf0e10cSrcweir { 1088cdf0e10cSrcweir return css::uno::Reference< css::beans::XPropertySetInfo >(createPropertySetInfo(getInfoHelper())); 1089cdf0e10cSrcweir } 1090cdf0e10cSrcweir 1091cdf0e10cSrcweir //----------------------------------------------------------------------------- 1092cdf0e10cSrcweir css::uno::Reference< css::util::XStringSubstitution > PathSettings::fa_getSubstitution() 1093cdf0e10cSrcweir { 1094cdf0e10cSrcweir // SAFE -> 1095cdf0e10cSrcweir ReadGuard aReadLock(m_aLock); 1096cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR; 1097cdf0e10cSrcweir css::uno::Reference< css::util::XStringSubstitution > xSubst = m_xSubstitution; 1098cdf0e10cSrcweir aReadLock.unlock(); 1099cdf0e10cSrcweir // <- SAFE 1100cdf0e10cSrcweir 1101cdf0e10cSrcweir if (! xSubst.is()) 1102cdf0e10cSrcweir { 1103cdf0e10cSrcweir // create the needed substitution service. 1104cdf0e10cSrcweir // We must replace all used variables inside readed path values. 110507a3d7f1SPedro Giffuni // In case we can't do so ... the whole office can't work really. 1106*cfd52e18Smseidel // That's why it seems to be OK to throw a RuntimeException then. 1107cdf0e10cSrcweir xSubst = css::uno::Reference< css::util::XStringSubstitution >( 1108cdf0e10cSrcweir xSMGR->createInstance(SERVICENAME_SUBSTITUTEPATHVARIABLES), 1109cdf0e10cSrcweir css::uno::UNO_QUERY_THROW); 1110cdf0e10cSrcweir 1111cdf0e10cSrcweir // SAFE -> 1112cdf0e10cSrcweir WriteGuard aWriteLock(m_aLock); 1113cdf0e10cSrcweir m_xSubstitution = xSubst; 1114cdf0e10cSrcweir aWriteLock.unlock(); 1115cdf0e10cSrcweir } 1116cdf0e10cSrcweir 1117cdf0e10cSrcweir return xSubst; 1118cdf0e10cSrcweir } 1119cdf0e10cSrcweir 1120cdf0e10cSrcweir //----------------------------------------------------------------------------- 1121cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > PathSettings::fa_getCfgOld() 1122cdf0e10cSrcweir { 1123cdf0e10cSrcweir const static ::rtl::OUString CFG_NODE_OLD = ::rtl::OUString::createFromAscii("org.openoffice.Office.Common/Path/Current"); 1124cdf0e10cSrcweir 1125cdf0e10cSrcweir // SAFE -> 1126cdf0e10cSrcweir ReadGuard aReadLock(m_aLock); 1127cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR; 1128cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xCfg = m_xCfgOld; 1129cdf0e10cSrcweir aReadLock.unlock(); 1130cdf0e10cSrcweir // <- SAFE 1131cdf0e10cSrcweir 1132cdf0e10cSrcweir if (! xCfg.is()) 1133cdf0e10cSrcweir { 1134cdf0e10cSrcweir xCfg = css::uno::Reference< css::container::XNameAccess >( 1135cdf0e10cSrcweir ::comphelper::ConfigurationHelper::openConfig( 1136cdf0e10cSrcweir xSMGR, 1137cdf0e10cSrcweir CFG_NODE_OLD, 113807a3d7f1SPedro Giffuni ::comphelper::ConfigurationHelper::E_STANDARD), // not readonly! Sometimes we need write access there !!! 1139cdf0e10cSrcweir css::uno::UNO_QUERY_THROW); 1140cdf0e10cSrcweir 1141cdf0e10cSrcweir // SAFE -> 1142cdf0e10cSrcweir WriteGuard aWriteLock(m_aLock); 1143cdf0e10cSrcweir m_xCfgOld = xCfg; 1144cdf0e10cSrcweir aWriteLock.unlock(); 1145cdf0e10cSrcweir } 1146cdf0e10cSrcweir 1147cdf0e10cSrcweir return xCfg; 1148cdf0e10cSrcweir } 1149cdf0e10cSrcweir 1150cdf0e10cSrcweir //----------------------------------------------------------------------------- 1151cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > PathSettings::fa_getCfgNew() 1152cdf0e10cSrcweir { 1153cdf0e10cSrcweir const static ::rtl::OUString CFG_NODE_NEW = ::rtl::OUString::createFromAscii("org.openoffice.Office.Paths/Paths"); 1154cdf0e10cSrcweir 1155cdf0e10cSrcweir // SAFE -> 1156cdf0e10cSrcweir ReadGuard aReadLock(m_aLock); 1157cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR; 1158cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xCfg = m_xCfgNew; 1159cdf0e10cSrcweir aReadLock.unlock(); 1160cdf0e10cSrcweir // <- SAFE 1161cdf0e10cSrcweir 1162cdf0e10cSrcweir if (! xCfg.is()) 1163cdf0e10cSrcweir { 1164cdf0e10cSrcweir xCfg = css::uno::Reference< css::container::XNameAccess >( 1165cdf0e10cSrcweir ::comphelper::ConfigurationHelper::openConfig( 1166cdf0e10cSrcweir xSMGR, 1167cdf0e10cSrcweir CFG_NODE_NEW, 1168cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_STANDARD), 1169cdf0e10cSrcweir css::uno::UNO_QUERY_THROW); 1170cdf0e10cSrcweir 1171cdf0e10cSrcweir // SAFE -> 1172cdf0e10cSrcweir WriteGuard aWriteLock(m_aLock); 1173cdf0e10cSrcweir m_xCfgNew = xCfg; 1174cdf0e10cSrcweir aWriteLock.unlock(); 1175cdf0e10cSrcweir 1176cdf0e10cSrcweir css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(xCfg, css::uno::UNO_QUERY_THROW); 1177cdf0e10cSrcweir xBroadcaster->addChangesListener(static_cast< css::util::XChangesListener* >(this)); 1178cdf0e10cSrcweir } 1179cdf0e10cSrcweir 1180cdf0e10cSrcweir return xCfg; 1181cdf0e10cSrcweir } 1182cdf0e10cSrcweir 1183cdf0e10cSrcweir } // namespace framework 1184