update dev300-m58
[ooovba.git] / unotools / source / config / configmgr.cxx
blob6c34be48a0d26f78fc7705139325437ec0cc79fc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: configmgr.cxx,v $
10 * $Revision: 1.47.14.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_unotools.hxx"
33 #include "unotools/configmgr.hxx"
34 #include "unotools/configitem.hxx"
35 #include "unotools/configpathes.hxx"
36 #include <unotools/processfactory.hxx>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <com/sun/star/container/XNameAccess.hpp>
39 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
40 #include <com/sun/star/container/XNameContainer.hpp>
41 #include <com/sun/star/beans/PropertyValue.hpp>
42 #include <osl/diagnose.h>
43 #include <rtl/bootstrap.hxx>
44 #include <rtl/instance.hxx>
45 #if OSL_DEBUG_LEVEL > 0
46 #include <rtl/strbuf.hxx>
47 #endif
49 #include <list>
51 //-----------------------------------------------------------------------------
53 using namespace utl;
54 using namespace rtl;
55 using namespace com::sun::star::uno;
56 using namespace com::sun::star::lang;
57 using namespace com::sun::star::beans;
58 using namespace com::sun::star::container;
60 #define C2U(cChar) OUString::createFromAscii(cChar)
61 #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
63 //-----------------------------------------------------------------------------
64 const char* cConfigBaseURL = "/org.openoffice.";
65 //const char* cConfigBaseURL = "/com.sun.star.";
66 const char* cAccessSrvc = "com.sun.star.configuration.ConfigurationUpdateAccess";
68 namespace
70 struct BrandName
71 : public rtl::Static< ::rtl::OUString, BrandName > {};
72 struct ProductVersion
73 : public rtl::Static< ::rtl::OUString, ProductVersion > {};
74 struct AboutBoxProductVersion
75 : public rtl::Static< ::rtl::OUString, AboutBoxProductVersion > {};
76 struct ProductExtension
77 : public rtl::Static< ::rtl::OUString, ProductExtension > {};
78 struct XMLFileFormatName
79 : public rtl::Static< ::rtl::OUString, XMLFileFormatName > {};
80 struct XMLFileFormatVersion
81 : public rtl::Static< ::rtl::OUString, XMLFileFormatVersion > {};
82 struct WriterCompatibilityVersionOOo11
83 : public rtl::Static< ::rtl::OUString, WriterCompatibilityVersionOOo11 > {};
84 struct OpenSourceContext : public rtl::StaticWithInit< sal_Int32, OpenSourceContext >
86 sal_Int32 operator() () { return sal_Int32( -1 ); }
91 //-----------------------------------------------------------------------------
92 struct ConfigItemListEntry_Impl
94 ConfigItem* pConfigItem;
96 ConfigItemListEntry_Impl(ConfigItem* pItem ) :
97 pConfigItem(pItem){}
99 typedef std::list<ConfigItemListEntry_Impl> ConfigItemList;
100 struct utl::ConfigMgr_Impl
102 ConfigItemList aItemList;
105 /* -----------------------------28.08.00 15:35--------------------------------
107 ---------------------------------------------------------------------------*/
108 ConfigManager::ConfigManager() :
109 pMgrImpl(new utl::ConfigMgr_Impl)
111 GetConfigurationProvider(); // attempt to create the provider early
113 /* -----------------------------17.11.00 13:51--------------------------------
115 ---------------------------------------------------------------------------*/
116 ConfigManager::ConfigManager(Reference< XMultiServiceFactory > xConfigProv) :
117 xConfigurationProvider(xConfigProv),
118 pMgrImpl(new utl::ConfigMgr_Impl)
121 /* -----------------------------28.08.00 15:35--------------------------------
123 ---------------------------------------------------------------------------*/
124 ConfigManager::~ConfigManager()
126 //check list content -> should be empty!
127 OSL_ENSURE(pMgrImpl->aItemList.empty(), "some ConfigItems are still alive");
128 if(!pMgrImpl->aItemList.empty())
130 ConfigItemList::iterator aListIter;
131 for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
133 ConfigItemListEntry_Impl& rEntry = *aListIter;
134 rEntry.pConfigItem->ReleaseConfigMgr();
136 pMgrImpl->aItemList.erase(pMgrImpl->aItemList.begin(), pMgrImpl->aItemList.end());
138 delete pMgrImpl;
141 /* -----------------------------28.08.00 16:17--------------------------------
143 ---------------------------------------------------------------------------*/
144 Reference< XMultiServiceFactory > ConfigManager::GetConfigurationProvider()
146 if(!xConfigurationProvider.is())
148 Reference< XMultiServiceFactory > xMSF = ::utl::getProcessServiceFactory();
149 if ( xMSF.is() )
153 xConfigurationProvider = Reference< XMultiServiceFactory >
154 (xMSF->createInstance(
155 C2U("com.sun.star.configuration.ConfigurationProvider")),
156 UNO_QUERY);
158 #ifdef DBG_UTIL
159 catch(Exception& rEx)
161 static sal_Bool bMessage = sal_True;
162 if(bMessage)
164 bMessage = sal_False;
165 OString sMsg("CreateInstance with arguments exception: ");
166 sMsg += OString(rEx.Message.getStr(),
167 rEx.Message.getLength(),
168 RTL_TEXTENCODING_ASCII_US);
169 OSL_ENSURE(sal_False, sMsg.getStr());
172 #else
173 catch(Exception&){}
174 #endif
177 return xConfigurationProvider;
179 /* -----------------------------03.12.02 -------------------------------------
181 ---------------------------------------------------------------------------*/
182 namespace
184 // helper to achieve exception - safe registration of a ConfigItem under construction
185 class RegisterConfigItemHelper // : Noncopyable
187 utl::ConfigManager & rCfgMgr;
188 utl::ConfigItem* pCfgItem;
189 public:
190 RegisterConfigItemHelper(utl::ConfigManager & rMgr, utl::ConfigItem& rCfgItem)
191 : rCfgMgr(rMgr)
192 , pCfgItem(&rCfgItem)
194 rCfgMgr.RegisterConfigItem(rCfgItem);
197 ~RegisterConfigItemHelper()
199 if (pCfgItem) rCfgMgr.RemoveConfigItem(*pCfgItem);
202 void keep() { pCfgItem = 0; }
205 /* -----------------------------12.12.00 17:19--------------------------------
207 ---------------------------------------------------------------------------*/
208 Reference< XMultiServiceFactory > ConfigManager::GetLocalConfigurationProvider()
210 return GetConfigurationProvider();
212 /* -----------------------------29.08.00 12:35--------------------------------
214 ---------------------------------------------------------------------------*/
215 Reference< XHierarchicalNameAccess > ConfigManager::AddConfigItem(utl::ConfigItem& rCfgItem)
217 RegisterConfigItemHelper registeredItem(*this,rCfgItem);
218 Reference< XHierarchicalNameAccess > xTree = AcquireTree(rCfgItem);
219 registeredItem.keep();
220 return xTree;
222 /* -----------------------------21.06.01 12:20--------------------------------
224 ---------------------------------------------------------------------------*/
225 void ConfigManager::RegisterConfigItem(utl::ConfigItem& rCfgItem)
227 ConfigItemList::iterator aListIter = pMgrImpl->aItemList.begin();
228 #ifdef DBG_UTIL
229 for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
231 ConfigItemListEntry_Impl& rEntry = *aListIter;
232 if(rEntry.pConfigItem == &rCfgItem)
233 OSL_ENSURE(sal_False, "RegisterConfigItem: already inserted!");
235 #endif
236 pMgrImpl->aItemList.insert(aListIter, ConfigItemListEntry_Impl(&rCfgItem));
238 /* -----------------------------21.06.01 12:20--------------------------------
240 ---------------------------------------------------------------------------*/
241 Reference< XHierarchicalNameAccess> ConfigManager::AcquireTree(utl::ConfigItem& rCfgItem)
243 ConfigItemList::iterator aListIter = pMgrImpl->aItemList.begin();
244 #ifdef DBG_UTIL
245 sal_Bool bFound = sal_False;
246 for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
248 ConfigItemListEntry_Impl& rEntry = *aListIter;
249 if(rEntry.pConfigItem == &rCfgItem)
251 bFound = sal_True;
252 break;
255 OSL_ENSURE(bFound, "AcquireTree: ConfigItem unknown!");
256 #endif
257 OUString sPath = C2U(cConfigBaseURL);
258 sPath += rCfgItem.GetSubTreeName();
259 Sequence< Any > aArgs(2);
260 Any* pArgs = aArgs.getArray();
261 PropertyValue aPath;
262 aPath.Name = C2U("nodepath");
263 aPath.Value <<= sPath;
264 pArgs[0] <<= aPath;
265 sal_Bool bLazy = 0 != (rCfgItem.GetMode()&CONFIG_MODE_DELAYED_UPDATE);
266 PropertyValue aUpdate;
267 aUpdate.Name = C2U("lazywrite");
268 aUpdate.Value.setValue(&bLazy, ::getBooleanCppuType());
269 pArgs[1] <<= aUpdate;
271 // Initialize item with support for reading/writing more then one locales at same time!
272 // It's neccessary for creation of a complete configuration entry without changing office locale
273 // at runtime.
274 if((rCfgItem.GetMode() & CONFIG_MODE_ALL_LOCALES) == CONFIG_MODE_ALL_LOCALES)
276 sal_Int32 nCount = aArgs.getLength();
277 aArgs.realloc(nCount+1);
279 PropertyValue aAllLocale;
280 aAllLocale.Name = C2U("locale");
281 aAllLocale.Value <<= C2U("*" );
282 aArgs[nCount] <<= aAllLocale;
285 Reference< XMultiServiceFactory > xCfgProvider = GetConfigurationProvider();
286 Reference< XInterface > xIFace;
287 if(xCfgProvider.is())
291 xIFace = xCfgProvider->createInstanceWithArguments(
292 C2U(cAccessSrvc),
293 aArgs);
295 catch(Exception& rEx)
297 if (CONFIG_MODE_PROPAGATE_ERRORS & rCfgItem.GetMode())
299 OSL_TRACE("ConfigItem: Propagating creation error: %s\n",
300 OUStringToOString(rEx.Message,RTL_TEXTENCODING_ASCII_US).getStr());
302 throw;
304 #ifdef DBG_UTIL
305 if(0 == (CONFIG_MODE_IGNORE_ERRORS & rCfgItem.GetMode()))
307 OString sMsg("CreateInstance exception: ");
308 sMsg += OString(rEx.Message.getStr(),
309 rEx.Message.getLength(),
310 RTL_TEXTENCODING_ASCII_US);
311 OSL_ENSURE(sal_False, sMsg.getStr());
313 #endif
316 return Reference<XHierarchicalNameAccess>(xIFace, UNO_QUERY);
318 /* -----------------------------29.08.00 12:35--------------------------------
320 ---------------------------------------------------------------------------*/
321 void ConfigManager::RemoveConfigItem(utl::ConfigItem& rCfgItem)
323 if( !pMgrImpl->aItemList.empty() )
325 ConfigItemList::iterator aListIter = pMgrImpl->aItemList.begin();
326 for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
328 ConfigItemListEntry_Impl& rEntry = *aListIter;
329 if(rEntry.pConfigItem == &rCfgItem)
331 pMgrImpl->aItemList.erase(aListIter);
332 break;
337 /* -----------------------------30.08.00 15:04--------------------------------
339 ---------------------------------------------------------------------------*/
340 void ConfigManager::StoreConfigItems()
342 if(!pMgrImpl->aItemList.empty())
344 ConfigItemList::iterator aListIter = pMgrImpl->aItemList.begin();
345 for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
347 ConfigItemListEntry_Impl& rEntry = *aListIter;
348 if(rEntry.pConfigItem->IsModified())
350 rEntry.pConfigItem->Commit();
351 rEntry.pConfigItem->ClearModified();
356 ConfigManager* ConfigManager::pConfigManager = 0;
357 /* -----------------------------07.09.00 11:06--------------------------------
359 ---------------------------------------------------------------------------*/
360 ConfigManager* ConfigManager::GetConfigManager()
362 if(!pConfigManager)
364 pConfigManager = new ConfigManager();
366 return pConfigManager;
368 /* -----------------------------07.09.00 11:06--------------------------------
370 ---------------------------------------------------------------------------*/
371 void ConfigManager::RemoveConfigManager()
373 if(pConfigManager)
375 delete pConfigManager;
376 pConfigManager = 0;
379 /* -----------------------------08.09.00 13:22--------------------------------
381 ---------------------------------------------------------------------------*/
382 rtl::OUString ConfigManager::GetConfigBaseURL()
384 return C2U(cConfigBaseURL);
386 /* -----------------------------25.09.00 16:34--------------------------------
388 ---------------------------------------------------------------------------*/
389 Any ConfigManager::GetDirectConfigProperty(ConfigProperty eProp)
391 switch(eProp)
393 case INSTALLPATH:
394 OSL_ENSURE( false,
395 "ConfigManager::GetDirectConfigProperty: "
396 "INSTALLPATH no longer supported." );
397 return Any();
398 case USERINSTALLURL:
399 OSL_ENSURE( false,
400 "ConfigManager::GetDirectConfigProperty: "
401 "USERINSTALLURL no longer supported." );
402 return Any();
403 case OFFICEINSTALL:
404 OSL_ENSURE( false,
405 "ConfigManager::GetDirectConfigProperty: "
406 "OFFICEINSTALL no longer supported." );
407 return Any();
408 case OFFICEINSTALLURL:
409 OSL_ENSURE( false,
410 "ConfigManager::GetDirectConfigProperty: "
411 "OFFICEINSTALLURL no longer supported." );
412 return Any();
413 default:
414 break;
417 Any aRet;
418 ::rtl::OUString &rBrandName = BrandName::get();
419 if ( eProp == PRODUCTNAME && rBrandName.getLength() )
421 aRet <<= rBrandName;
422 return aRet;
425 rtl::OUString &rProductVersion = ProductVersion::get();
426 if ( eProp == PRODUCTVERSION && rProductVersion.getLength() )
428 aRet <<= rProductVersion;
429 return aRet;
432 rtl::OUString &rAboutBoxProductVersion = AboutBoxProductVersion::get();
433 if ( eProp == ABOUTBOXPRODUCTVERSION && rAboutBoxProductVersion.getLength() )
435 aRet <<= rAboutBoxProductVersion;
436 return aRet;
439 rtl::OUString &rProductExtension = ProductExtension::get();
440 if ( eProp == PRODUCTEXTENSION && rProductExtension.getLength() )
442 aRet <<= rProductExtension;
443 return aRet;
446 rtl::OUString &rXMLFileFormatName = XMLFileFormatName::get();
447 if ( eProp == PRODUCTXMLFILEFORMATNAME && rXMLFileFormatName.getLength() )
449 aRet <<= rXMLFileFormatName;
450 return aRet;
453 rtl::OUString &rXMLFileFormatVersion = XMLFileFormatVersion::get();
454 if ( eProp == PRODUCTXMLFILEFORMATVERSION && rXMLFileFormatVersion.getLength() )
456 aRet <<= rXMLFileFormatVersion;
457 return aRet;
460 sal_Int32 &rOpenSourceContext = OpenSourceContext::get();
461 if ( eProp == OPENSOURCECONTEXT && ( rOpenSourceContext >= 0 ) )
463 aRet <<= rOpenSourceContext;
464 return aRet;
467 rtl::OUString &rWriterCompatibilityVersionOOo11 = WriterCompatibilityVersionOOo11::get();
468 if ( eProp == WRITERCOMPATIBILITYVERSIONOOO11 && rWriterCompatibilityVersionOOo11.getLength() )
470 aRet <<= rWriterCompatibilityVersionOOo11;
471 return aRet;
474 if (eProp == PRODUCTEXTENSION) {
475 rtl::OUString name(
476 rtl::OUString(
477 RTL_CONSTASCII_USTRINGPARAM(
478 "${BRAND_BASE_DIR}/program/edition/edition.ini")));
479 rtl::Bootstrap::expandMacros(name);
480 if (rtl::Bootstrap(name).getFrom(
481 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EDITIONNAME")),
482 rProductExtension))
484 return com::sun::star::uno::Any(rProductExtension);
488 OUString sPath = C2U(cConfigBaseURL);
489 switch(eProp)
491 case LOCALE: sPath += C2U("Setup/L10N"); break;
493 case PRODUCTNAME:
494 case PRODUCTVERSION:
495 case PRODUCTEXTENSION:
496 case PRODUCTXMLFILEFORMATNAME :
497 case PRODUCTXMLFILEFORMATVERSION:
498 case OPENSOURCECONTEXT:
499 case ABOUTBOXPRODUCTVERSION: sPath += C2U("Setup/Product"); break;
501 case DEFAULTCURRENCY: sPath += C2U("Setup/L10N"); break;
503 case WRITERCOMPATIBILITYVERSIONOOO11:
504 sPath += C2U("Office.Compatibility/WriterCompatibilityVersion"); break;
505 default:
506 break;
508 Sequence< Any > aArgs(1);
509 aArgs[0] <<= sPath;
510 Reference< XMultiServiceFactory > xCfgProvider = GetConfigManager()->GetConfigurationProvider();
511 if(!xCfgProvider.is())
512 return aRet;
513 Reference< XInterface > xIFace;
516 xIFace = xCfgProvider->createInstanceWithArguments(
517 C2U(cAccessSrvc),
518 aArgs);
521 catch(Exception&){}
522 Reference<XNameAccess> xDirectAccess(xIFace, UNO_QUERY);
523 if(xDirectAccess.is())
525 OUString sProperty;
526 switch(eProp)
528 case LOCALE: sProperty = C2U("ooLocale"); break;
529 case PRODUCTNAME: sProperty = C2U("ooName"); break;
530 case PRODUCTVERSION: sProperty = C2U("ooSetupVersion"); break;
531 case ABOUTBOXPRODUCTVERSION: sProperty = C2U("ooSetupVersionAboutBox"); break;
532 case PRODUCTEXTENSION: sProperty = C2U("ooSetupExtension"); break;
533 case PRODUCTXMLFILEFORMATNAME: sProperty = C2U("ooXMLFileFormatName"); break;
534 case PRODUCTXMLFILEFORMATVERSION: sProperty = C2U("ooXMLFileFormatVersion"); break;
535 case OPENSOURCECONTEXT: sProperty = C2U("ooOpenSourceContext"); break;
536 case DEFAULTCURRENCY: sProperty = C2U("ooSetupCurrency"); break;
537 case WRITERCOMPATIBILITYVERSIONOOO11: sProperty = C2U("OOo11"); break;
538 default:
539 break;
543 aRet = xDirectAccess->getByName(sProperty);
545 catch(Exception&)
547 #if OSL_DEBUG_LEVEL > 0
548 rtl::OStringBuffer aBuf(256);
549 aBuf.append( "ConfigManager::GetDirectConfigProperty: could not retrieve the property \"" );
550 aBuf.append( rtl::OUStringToOString( sProperty, RTL_TEXTENCODING_ASCII_US ) );
551 aBuf.append( "\" under \"" );
552 aBuf.append( rtl::OUStringToOString( sPath, RTL_TEXTENCODING_ASCII_US ) );
553 aBuf.append( "\" (caught an exception)!" );
554 OSL_ENSURE( sal_False, aBuf.getStr() );
555 #endif
559 if ( eProp == PRODUCTNAME )
560 aRet >>= rBrandName;
562 if ( eProp == PRODUCTXMLFILEFORMATNAME )
563 aRet >>= rXMLFileFormatName;
565 if ( eProp == PRODUCTXMLFILEFORMATVERSION )
566 aRet >>= rXMLFileFormatVersion;
568 if ( eProp == PRODUCTVERSION )
569 aRet >>= rProductVersion;
571 if ( eProp == ABOUTBOXPRODUCTVERSION )
573 aRet >>= rAboutBoxProductVersion;
574 getBasisAboutBoxProductVersion( rAboutBoxProductVersion );
575 aRet <<= rAboutBoxProductVersion;
578 if ( eProp == PRODUCTEXTENSION )
579 aRet >>= rProductExtension;
581 if ( eProp == WRITERCOMPATIBILITYVERSIONOOO11 )
582 aRet >>= rWriterCompatibilityVersionOOo11;
584 if ( eProp == OPENSOURCECONTEXT )
585 aRet >>= rOpenSourceContext;
587 return aRet;
590 /*---------------------------------------------------------------------------*/
591 void ConfigManager::getBasisAboutBoxProductVersion( OUString& rVersion )
593 rtl::OUString aPackageVersion = UNISTRING( "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("version") ":OOOPackageVersion}" );
594 rtl::Bootstrap::expandMacros( aPackageVersion );
596 if ( aPackageVersion.getLength() )
598 sal_Int32 nTokIndex = 0;
599 rtl::OUString aVersionMinor = aPackageVersion.getToken( 1, '.', nTokIndex );
600 rtl::OUString aVersionMicro;
602 if ( nTokIndex > 0 )
603 aVersionMicro = aPackageVersion.getToken( 0, '.', nTokIndex );
605 if ( aVersionMinor.getLength() == 0 )
606 aVersionMinor = UNISTRING( "0" );
607 if ( aVersionMicro.getLength() == 0 )
608 aVersionMicro = UNISTRING( "0" );
610 sal_Int32 nIndex = rVersion.indexOf( '.' );
611 if ( nIndex == -1 )
613 rVersion += UNISTRING( "." );
614 rVersion += aVersionMinor;
616 else
618 nIndex = rVersion.indexOf( '.', nIndex+1 );
620 if ( nIndex == -1 )
622 rVersion += UNISTRING( "." );
623 rVersion += aVersionMicro;
625 else
627 rVersion = rVersion.replaceAt( nIndex+1, rVersion.getLength()-nIndex-1, aVersionMicro );
632 /* -----------------------------12.12.00 17:22--------------------------------
634 ---------------------------------------------------------------------------*/
635 Reference< XHierarchicalNameAccess> ConfigManager::GetHierarchyAccess(const OUString& rFullPath)
637 Sequence< Any > aArgs(1);
638 aArgs[0] <<= rFullPath;
639 Reference< XMultiServiceFactory > xCfgProvider = GetLocalConfigurationProvider();
640 Reference< XInterface > xIFace;
641 if(xCfgProvider.is())
645 xIFace = xCfgProvider->createInstanceWithArguments(
646 C2U(cAccessSrvc),
647 aArgs);
649 #ifdef DBG_UTIL
650 catch(Exception& rEx)
652 OString sMsg("CreateInstance exception: ");
653 sMsg += OString(rEx.Message.getStr(),
654 rEx.Message.getLength(),
655 RTL_TEXTENCODING_ASCII_US);
656 OSL_ENSURE(sal_False, sMsg.getStr());
658 #else
659 catch(Exception&){}
660 #endif
662 return Reference<XHierarchicalNameAccess>(xIFace, UNO_QUERY);
664 /* -----------------------------12.12.00 17:17--------------------------------
666 ---------------------------------------------------------------------------*/
667 Any ConfigManager::GetLocalProperty(const OUString& rProperty)
669 OUString sPath = C2U(cConfigBaseURL);
670 sPath += rProperty;
672 OUString sNode, sProperty;
673 OSL_VERIFY( splitLastFromConfigurationPath(sPath, sNode, sProperty) );
675 Reference< XNameAccess> xAccess( GetHierarchyAccess(sNode), UNO_QUERY );
676 Any aRet;
679 if(xAccess.is())
680 aRet = xAccess->getByName(sProperty);
682 #ifdef DBG_UTIL
683 catch(Exception& rEx)
685 OString sMsg("GetLocalProperty: ");
686 sMsg += OString(rEx.Message.getStr(),
687 rEx.Message.getLength(),
688 RTL_TEXTENCODING_ASCII_US);
689 OSL_ENSURE(sal_False, sMsg.getStr());
691 #else
692 catch(Exception&){}
693 #endif
694 return aRet;
696 /* -----------------------------12.12.00 17:17--------------------------------
698 ---------------------------------------------------------------------------*/
699 void ConfigManager::PutLocalProperty(const OUString& rProperty, const Any& rValue)
701 OUString sPath = C2U(cConfigBaseURL);
702 sPath += rProperty;
704 OUString sNode, sProperty;
705 OSL_VERIFY( splitLastFromConfigurationPath(sPath, sNode, sProperty) );
707 Reference<XNameReplace> xNodeReplace(GetHierarchyAccess(sNode), UNO_QUERY);
708 if(xNodeReplace.is())
712 xNodeReplace->replaceByName(sProperty, rValue);
714 #ifdef DBG_UTIL
715 catch(Exception& rEx)
717 OString sMsg("PutLocalProperty: ");
718 sMsg += OString(rEx.Message.getStr(),
719 rEx.Message.getLength(),
720 RTL_TEXTENCODING_ASCII_US);
721 OSL_ENSURE(sal_False, sMsg.getStr());
723 #else
724 catch(Exception& ){}
725 #endif
728 /* -----------------------------13.12.00 08:47--------------------------------
730 ---------------------------------------------------------------------------*/
731 sal_Bool ConfigManager::IsLocalConfigProvider()
733 return false;