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 #include "unotools/configmgr.hxx"
31*cdf0e10cSrcweir #include "unotools/configitem.hxx"
32*cdf0e10cSrcweir #include "unotools/configpathes.hxx"
33*cdf0e10cSrcweir #include <unotools/processfactory.hxx>
34*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
39*cdf0e10cSrcweir #include <osl/diagnose.h>
40*cdf0e10cSrcweir #include <rtl/bootstrap.hxx>
41*cdf0e10cSrcweir #include <rtl/instance.hxx>
42*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
43*cdf0e10cSrcweir #include <rtl/strbuf.hxx>
44*cdf0e10cSrcweir #endif
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include <list>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir //-----------------------------------------------------------------------------
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir using namespace utl;
51*cdf0e10cSrcweir using namespace rtl;
52*cdf0e10cSrcweir using namespace com::sun::star::uno;
53*cdf0e10cSrcweir using namespace com::sun::star::lang;
54*cdf0e10cSrcweir using namespace com::sun::star::beans;
55*cdf0e10cSrcweir using namespace com::sun::star::container;
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir #define C2U(cChar) OUString::createFromAscii(cChar)
58*cdf0e10cSrcweir #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir //-----------------------------------------------------------------------------
61*cdf0e10cSrcweir const char* cConfigBaseURL = "/org.openoffice.";
62*cdf0e10cSrcweir //const char* cConfigBaseURL = "/com.sun.star.";
63*cdf0e10cSrcweir const char* cAccessSrvc = "com.sun.star.configuration.ConfigurationUpdateAccess";
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir namespace
66*cdf0e10cSrcweir {
67*cdf0e10cSrcweir     struct BrandName
68*cdf0e10cSrcweir         : public rtl::Static< ::rtl::OUString, BrandName > {};
69*cdf0e10cSrcweir     struct ProductVersion
70*cdf0e10cSrcweir         : public rtl::Static< ::rtl::OUString, ProductVersion > {};
71*cdf0e10cSrcweir     struct AboutBoxProductVersion
72*cdf0e10cSrcweir         : public rtl::Static< ::rtl::OUString, AboutBoxProductVersion > {};
73*cdf0e10cSrcweir     struct OOOVendor
74*cdf0e10cSrcweir         : public rtl::Static< ::rtl::OUString, OOOVendor > {};
75*cdf0e10cSrcweir     struct ProductExtension
76*cdf0e10cSrcweir         : public rtl::Static< ::rtl::OUString, ProductExtension > {};
77*cdf0e10cSrcweir     struct XMLFileFormatName
78*cdf0e10cSrcweir         : public rtl::Static< ::rtl::OUString, XMLFileFormatName > {};
79*cdf0e10cSrcweir     struct XMLFileFormatVersion
80*cdf0e10cSrcweir         : public rtl::Static< ::rtl::OUString, XMLFileFormatVersion > {};
81*cdf0e10cSrcweir     struct WriterCompatibilityVersionOOo11
82*cdf0e10cSrcweir         : public rtl::Static< ::rtl::OUString, WriterCompatibilityVersionOOo11 > {};
83*cdf0e10cSrcweir     struct OpenSourceContext : public rtl::StaticWithInit< sal_Int32, OpenSourceContext >
84*cdf0e10cSrcweir     {
85*cdf0e10cSrcweir         sal_Int32 operator() () { return sal_Int32( -1 ); }
86*cdf0e10cSrcweir     };
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir }
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir //-----------------------------------------------------------------------------
91*cdf0e10cSrcweir struct ConfigItemListEntry_Impl
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir 	ConfigItem* 				pConfigItem;
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 	ConfigItemListEntry_Impl(ConfigItem* 	pItem ) :
96*cdf0e10cSrcweir 		pConfigItem(pItem){}
97*cdf0e10cSrcweir };
98*cdf0e10cSrcweir typedef std::list<ConfigItemListEntry_Impl> ConfigItemList;
99*cdf0e10cSrcweir struct utl::ConfigMgr_Impl
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir 	ConfigItemList 							aItemList;
102*cdf0e10cSrcweir };
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir /* -----------------------------28.08.00 15:35--------------------------------
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
107*cdf0e10cSrcweir ConfigManager::ConfigManager() :
108*cdf0e10cSrcweir 	pMgrImpl(new utl::ConfigMgr_Impl)
109*cdf0e10cSrcweir {
110*cdf0e10cSrcweir 	GetConfigurationProvider(); // attempt to create the provider early
111*cdf0e10cSrcweir }
112*cdf0e10cSrcweir /* -----------------------------17.11.00 13:51--------------------------------
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
115*cdf0e10cSrcweir ConfigManager::ConfigManager(Reference< XMultiServiceFactory > xConfigProv) :
116*cdf0e10cSrcweir 	xConfigurationProvider(xConfigProv),
117*cdf0e10cSrcweir 	pMgrImpl(new utl::ConfigMgr_Impl)
118*cdf0e10cSrcweir {
119*cdf0e10cSrcweir }
120*cdf0e10cSrcweir /* -----------------------------28.08.00 15:35--------------------------------
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
123*cdf0e10cSrcweir ConfigManager::~ConfigManager()
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir 	//check list content -> should be empty!
126*cdf0e10cSrcweir 	OSL_ENSURE(pMgrImpl->aItemList.empty(), "some ConfigItems are still alive");
127*cdf0e10cSrcweir 	if(!pMgrImpl->aItemList.empty())
128*cdf0e10cSrcweir 	{
129*cdf0e10cSrcweir 		ConfigItemList::iterator aListIter;
130*cdf0e10cSrcweir 		for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
131*cdf0e10cSrcweir 		{
132*cdf0e10cSrcweir 			ConfigItemListEntry_Impl& rEntry = *aListIter;
133*cdf0e10cSrcweir 			rEntry.pConfigItem->ReleaseConfigMgr();
134*cdf0e10cSrcweir 		}
135*cdf0e10cSrcweir 		pMgrImpl->aItemList.erase(pMgrImpl->aItemList.begin(), pMgrImpl->aItemList.end());
136*cdf0e10cSrcweir 	}
137*cdf0e10cSrcweir 	delete pMgrImpl;
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir }
140*cdf0e10cSrcweir /* -----------------------------28.08.00 16:17--------------------------------
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
143*cdf0e10cSrcweir Reference< XMultiServiceFactory > ConfigManager::GetConfigurationProvider()
144*cdf0e10cSrcweir {
145*cdf0e10cSrcweir 	if(!xConfigurationProvider.is())
146*cdf0e10cSrcweir 	{
147*cdf0e10cSrcweir 		Reference< XMultiServiceFactory > xMSF = ::utl::getProcessServiceFactory();
148*cdf0e10cSrcweir 		if ( xMSF.is() )
149*cdf0e10cSrcweir 		{
150*cdf0e10cSrcweir 			try
151*cdf0e10cSrcweir 			{
152*cdf0e10cSrcweir 				xConfigurationProvider = Reference< XMultiServiceFactory >
153*cdf0e10cSrcweir 					(xMSF->createInstance(
154*cdf0e10cSrcweir 						C2U("com.sun.star.configuration.ConfigurationProvider")),
155*cdf0e10cSrcweir 					 UNO_QUERY);
156*cdf0e10cSrcweir 			}
157*cdf0e10cSrcweir #ifdef DBG_UTIL
158*cdf0e10cSrcweir 	catch(Exception& rEx)
159*cdf0e10cSrcweir 	{
160*cdf0e10cSrcweir         static sal_Bool bMessage = sal_True;
161*cdf0e10cSrcweir         if(bMessage)
162*cdf0e10cSrcweir         {
163*cdf0e10cSrcweir             bMessage = sal_False;
164*cdf0e10cSrcweir             OString sMsg("CreateInstance with arguments exception: ");
165*cdf0e10cSrcweir             sMsg += OString(rEx.Message.getStr(),
166*cdf0e10cSrcweir                         rEx.Message.getLength(),
167*cdf0e10cSrcweir                         RTL_TEXTENCODING_ASCII_US);
168*cdf0e10cSrcweir             OSL_ENSURE(sal_False, sMsg.getStr());
169*cdf0e10cSrcweir         }
170*cdf0e10cSrcweir 	}
171*cdf0e10cSrcweir #else
172*cdf0e10cSrcweir 	catch(Exception&){}
173*cdf0e10cSrcweir #endif
174*cdf0e10cSrcweir 		}
175*cdf0e10cSrcweir 	}
176*cdf0e10cSrcweir 	return xConfigurationProvider;
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir /* -----------------------------03.12.02 -------------------------------------
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
181*cdf0e10cSrcweir namespace
182*cdf0e10cSrcweir {
183*cdf0e10cSrcweir     // helper to achieve exception - safe registration of a ConfigItem under construction
184*cdf0e10cSrcweir     class RegisterConfigItemHelper // : Noncopyable
185*cdf0e10cSrcweir     {
186*cdf0e10cSrcweir         utl::ConfigManager & rCfgMgr;
187*cdf0e10cSrcweir         utl::ConfigItem* pCfgItem;
188*cdf0e10cSrcweir     public:
189*cdf0e10cSrcweir         RegisterConfigItemHelper(utl::ConfigManager & rMgr, utl::ConfigItem& rCfgItem)
190*cdf0e10cSrcweir         : rCfgMgr(rMgr)
191*cdf0e10cSrcweir         , pCfgItem(&rCfgItem)
192*cdf0e10cSrcweir         {
193*cdf0e10cSrcweir             rCfgMgr.RegisterConfigItem(rCfgItem);
194*cdf0e10cSrcweir         }
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir         ~RegisterConfigItemHelper()
197*cdf0e10cSrcweir         {
198*cdf0e10cSrcweir             if (pCfgItem) rCfgMgr.RemoveConfigItem(*pCfgItem);
199*cdf0e10cSrcweir         }
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir         void keep() { pCfgItem = 0; }
202*cdf0e10cSrcweir     };
203*cdf0e10cSrcweir }
204*cdf0e10cSrcweir /* -----------------------------12.12.00 17:19--------------------------------
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
207*cdf0e10cSrcweir Reference< XMultiServiceFactory > ConfigManager::GetLocalConfigurationProvider()
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir 	return GetConfigurationProvider();
210*cdf0e10cSrcweir }
211*cdf0e10cSrcweir /* -----------------------------29.08.00 12:35--------------------------------
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
214*cdf0e10cSrcweir Reference< XHierarchicalNameAccess > ConfigManager::AddConfigItem(utl::ConfigItem& rCfgItem)
215*cdf0e10cSrcweir {
216*cdf0e10cSrcweir     RegisterConfigItemHelper registeredItem(*this,rCfgItem);
217*cdf0e10cSrcweir     Reference< XHierarchicalNameAccess > xTree = AcquireTree(rCfgItem);
218*cdf0e10cSrcweir     registeredItem.keep();
219*cdf0e10cSrcweir     return xTree;
220*cdf0e10cSrcweir }
221*cdf0e10cSrcweir /* -----------------------------21.06.01 12:20--------------------------------
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
224*cdf0e10cSrcweir void    ConfigManager::RegisterConfigItem(utl::ConfigItem& rCfgItem)
225*cdf0e10cSrcweir {
226*cdf0e10cSrcweir     ConfigItemList::iterator aListIter = pMgrImpl->aItemList.begin();
227*cdf0e10cSrcweir #ifdef DBG_UTIL
228*cdf0e10cSrcweir 	for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
229*cdf0e10cSrcweir 	{
230*cdf0e10cSrcweir 		ConfigItemListEntry_Impl& rEntry = *aListIter;
231*cdf0e10cSrcweir 		if(rEntry.pConfigItem == &rCfgItem)
232*cdf0e10cSrcweir             OSL_ENSURE(sal_False, "RegisterConfigItem: already inserted!");
233*cdf0e10cSrcweir 	}
234*cdf0e10cSrcweir #endif
235*cdf0e10cSrcweir     pMgrImpl->aItemList.insert(aListIter, ConfigItemListEntry_Impl(&rCfgItem));
236*cdf0e10cSrcweir }
237*cdf0e10cSrcweir /* -----------------------------21.06.01 12:20--------------------------------
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
240*cdf0e10cSrcweir Reference< XHierarchicalNameAccess> ConfigManager::AcquireTree(utl::ConfigItem& rCfgItem)
241*cdf0e10cSrcweir {
242*cdf0e10cSrcweir     ConfigItemList::iterator aListIter = pMgrImpl->aItemList.begin();
243*cdf0e10cSrcweir #ifdef DBG_UTIL
244*cdf0e10cSrcweir     sal_Bool bFound = sal_False;
245*cdf0e10cSrcweir     for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
246*cdf0e10cSrcweir 	{
247*cdf0e10cSrcweir 		ConfigItemListEntry_Impl& rEntry = *aListIter;
248*cdf0e10cSrcweir 		if(rEntry.pConfigItem == &rCfgItem)
249*cdf0e10cSrcweir         {
250*cdf0e10cSrcweir             bFound = sal_True;
251*cdf0e10cSrcweir             break;
252*cdf0e10cSrcweir         }
253*cdf0e10cSrcweir     }
254*cdf0e10cSrcweir     OSL_ENSURE(bFound, "AcquireTree: ConfigItem unknown!");
255*cdf0e10cSrcweir #endif
256*cdf0e10cSrcweir 	OUString sPath = C2U(cConfigBaseURL);
257*cdf0e10cSrcweir 	sPath += rCfgItem.GetSubTreeName();
258*cdf0e10cSrcweir     Sequence< Any > aArgs(2);
259*cdf0e10cSrcweir     Any* pArgs = aArgs.getArray();
260*cdf0e10cSrcweir 	PropertyValue aPath;
261*cdf0e10cSrcweir 	aPath.Name = C2U("nodepath");
262*cdf0e10cSrcweir 	aPath.Value <<= sPath;
263*cdf0e10cSrcweir     pArgs[0] <<= aPath;
264*cdf0e10cSrcweir     sal_Bool bLazy = 0 != (rCfgItem.GetMode()&CONFIG_MODE_DELAYED_UPDATE);
265*cdf0e10cSrcweir     PropertyValue aUpdate;
266*cdf0e10cSrcweir     aUpdate.Name = C2U("lazywrite");
267*cdf0e10cSrcweir     aUpdate.Value.setValue(&bLazy, ::getBooleanCppuType());
268*cdf0e10cSrcweir     pArgs[1] <<= aUpdate;
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir     // Initialize item with support for reading/writing more then one locales at same time!
271*cdf0e10cSrcweir 	// It's neccessary for creation of a complete configuration entry without changing office locale
272*cdf0e10cSrcweir 	// at runtime.
273*cdf0e10cSrcweir     if((rCfgItem.GetMode() & CONFIG_MODE_ALL_LOCALES) == CONFIG_MODE_ALL_LOCALES)
274*cdf0e10cSrcweir 	{
275*cdf0e10cSrcweir         sal_Int32 nCount = aArgs.getLength();
276*cdf0e10cSrcweir         aArgs.realloc(nCount+1);
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir         PropertyValue aAllLocale;
279*cdf0e10cSrcweir         aAllLocale.Name  =   C2U("locale");
280*cdf0e10cSrcweir         aAllLocale.Value <<= C2U("*"     );
281*cdf0e10cSrcweir         aArgs[nCount]    <<= aAllLocale;
282*cdf0e10cSrcweir 	}
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir 	Reference< XMultiServiceFactory > xCfgProvider = GetConfigurationProvider();
285*cdf0e10cSrcweir 	Reference< XInterface > xIFace;
286*cdf0e10cSrcweir 	if(xCfgProvider.is())
287*cdf0e10cSrcweir 	{
288*cdf0e10cSrcweir 		try
289*cdf0e10cSrcweir 		{
290*cdf0e10cSrcweir 			xIFace = xCfgProvider->createInstanceWithArguments(
291*cdf0e10cSrcweir 					C2U(cAccessSrvc),
292*cdf0e10cSrcweir 					aArgs);
293*cdf0e10cSrcweir 		}
294*cdf0e10cSrcweir 		catch(Exception& rEx)
295*cdf0e10cSrcweir 		{
296*cdf0e10cSrcweir             if (CONFIG_MODE_PROPAGATE_ERRORS & rCfgItem.GetMode())
297*cdf0e10cSrcweir             {
298*cdf0e10cSrcweir                 OSL_TRACE("ConfigItem: Propagating creation error: %s\n",
299*cdf0e10cSrcweir                             OUStringToOString(rEx.Message,RTL_TEXTENCODING_ASCII_US).getStr());
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir                 throw;
302*cdf0e10cSrcweir             }
303*cdf0e10cSrcweir #ifdef DBG_UTIL
304*cdf0e10cSrcweir             if(0 == (CONFIG_MODE_IGNORE_ERRORS & rCfgItem.GetMode()))
305*cdf0e10cSrcweir             {
306*cdf0e10cSrcweir                 OString sMsg("CreateInstance exception: ");
307*cdf0e10cSrcweir                 sMsg += OString(rEx.Message.getStr(),
308*cdf0e10cSrcweir                             rEx.Message.getLength(),
309*cdf0e10cSrcweir                             RTL_TEXTENCODING_ASCII_US);
310*cdf0e10cSrcweir                 OSL_ENSURE(sal_False, sMsg.getStr());
311*cdf0e10cSrcweir             }
312*cdf0e10cSrcweir #endif
313*cdf0e10cSrcweir 		}
314*cdf0e10cSrcweir     }
315*cdf0e10cSrcweir 	return Reference<XHierarchicalNameAccess>(xIFace, UNO_QUERY);
316*cdf0e10cSrcweir }
317*cdf0e10cSrcweir /* -----------------------------29.08.00 12:35--------------------------------
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
320*cdf0e10cSrcweir void ConfigManager::RemoveConfigItem(utl::ConfigItem& rCfgItem)
321*cdf0e10cSrcweir {
322*cdf0e10cSrcweir 	if( !pMgrImpl->aItemList.empty() )
323*cdf0e10cSrcweir 	{
324*cdf0e10cSrcweir 		ConfigItemList::iterator aListIter = pMgrImpl->aItemList.begin();
325*cdf0e10cSrcweir 		for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
326*cdf0e10cSrcweir 		{
327*cdf0e10cSrcweir 			ConfigItemListEntry_Impl& rEntry = *aListIter;
328*cdf0e10cSrcweir 			if(rEntry.pConfigItem == &rCfgItem)
329*cdf0e10cSrcweir 			{
330*cdf0e10cSrcweir 				pMgrImpl->aItemList.erase(aListIter);
331*cdf0e10cSrcweir 				break;
332*cdf0e10cSrcweir 			}
333*cdf0e10cSrcweir 		}
334*cdf0e10cSrcweir 	}
335*cdf0e10cSrcweir }
336*cdf0e10cSrcweir /* -----------------------------30.08.00 15:04--------------------------------
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
339*cdf0e10cSrcweir void ConfigManager::StoreConfigItems()
340*cdf0e10cSrcweir {
341*cdf0e10cSrcweir 	if(!pMgrImpl->aItemList.empty())
342*cdf0e10cSrcweir 	{
343*cdf0e10cSrcweir 		ConfigItemList::iterator aListIter = pMgrImpl->aItemList.begin();
344*cdf0e10cSrcweir 		for(aListIter = pMgrImpl->aItemList.begin(); aListIter != pMgrImpl->aItemList.end(); ++aListIter)
345*cdf0e10cSrcweir 		{
346*cdf0e10cSrcweir 			ConfigItemListEntry_Impl& rEntry = *aListIter;
347*cdf0e10cSrcweir 			if(rEntry.pConfigItem->IsModified())
348*cdf0e10cSrcweir             {
349*cdf0e10cSrcweir 				rEntry.pConfigItem->Commit();
350*cdf0e10cSrcweir                 rEntry.pConfigItem->ClearModified();
351*cdf0e10cSrcweir             }
352*cdf0e10cSrcweir 		}
353*cdf0e10cSrcweir 	}
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir ConfigManager*	 ConfigManager::pConfigManager = 0;
356*cdf0e10cSrcweir /* -----------------------------07.09.00 11:06--------------------------------
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
359*cdf0e10cSrcweir ConfigManager*	ConfigManager::GetConfigManager()
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir 	if(!pConfigManager)
362*cdf0e10cSrcweir 	{
363*cdf0e10cSrcweir 		pConfigManager = new ConfigManager();
364*cdf0e10cSrcweir 	}
365*cdf0e10cSrcweir 	return pConfigManager;
366*cdf0e10cSrcweir }
367*cdf0e10cSrcweir /* -----------------------------07.09.00 11:06--------------------------------
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
370*cdf0e10cSrcweir void	ConfigManager::RemoveConfigManager()
371*cdf0e10cSrcweir {
372*cdf0e10cSrcweir 	if(pConfigManager)
373*cdf0e10cSrcweir 	{
374*cdf0e10cSrcweir 		delete pConfigManager;
375*cdf0e10cSrcweir 		pConfigManager = 0;
376*cdf0e10cSrcweir 	}
377*cdf0e10cSrcweir }
378*cdf0e10cSrcweir /* -----------------------------08.09.00 13:22--------------------------------
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
381*cdf0e10cSrcweir rtl::OUString ConfigManager::GetConfigBaseURL()
382*cdf0e10cSrcweir {
383*cdf0e10cSrcweir 	return C2U(cConfigBaseURL);
384*cdf0e10cSrcweir }
385*cdf0e10cSrcweir /* -----------------------------25.09.00 16:34--------------------------------
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
388*cdf0e10cSrcweir Any ConfigManager::GetDirectConfigProperty(ConfigProperty eProp)
389*cdf0e10cSrcweir {
390*cdf0e10cSrcweir     switch(eProp)
391*cdf0e10cSrcweir     {
392*cdf0e10cSrcweir         case INSTALLPATH:
393*cdf0e10cSrcweir             OSL_ENSURE( false,
394*cdf0e10cSrcweir                         "ConfigManager::GetDirectConfigProperty: "
395*cdf0e10cSrcweir                         "INSTALLPATH no longer supported." );
396*cdf0e10cSrcweir             return Any();
397*cdf0e10cSrcweir         case USERINSTALLURL:
398*cdf0e10cSrcweir             OSL_ENSURE( false,
399*cdf0e10cSrcweir                         "ConfigManager::GetDirectConfigProperty: "
400*cdf0e10cSrcweir                         "USERINSTALLURL no longer supported." );
401*cdf0e10cSrcweir             return Any();
402*cdf0e10cSrcweir         case OFFICEINSTALL:
403*cdf0e10cSrcweir             OSL_ENSURE( false,
404*cdf0e10cSrcweir                         "ConfigManager::GetDirectConfigProperty: "
405*cdf0e10cSrcweir                         "OFFICEINSTALL no longer supported." );
406*cdf0e10cSrcweir             return Any();
407*cdf0e10cSrcweir         case OFFICEINSTALLURL:
408*cdf0e10cSrcweir             OSL_ENSURE( false,
409*cdf0e10cSrcweir                         "ConfigManager::GetDirectConfigProperty: "
410*cdf0e10cSrcweir                         "OFFICEINSTALLURL no longer supported." );
411*cdf0e10cSrcweir             return Any();
412*cdf0e10cSrcweir         default:
413*cdf0e10cSrcweir             break;
414*cdf0e10cSrcweir     }
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir     Any aRet;
417*cdf0e10cSrcweir     ::rtl::OUString &rBrandName = BrandName::get();
418*cdf0e10cSrcweir     if ( eProp == PRODUCTNAME && rBrandName.getLength() )
419*cdf0e10cSrcweir     {
420*cdf0e10cSrcweir         aRet <<= rBrandName;
421*cdf0e10cSrcweir         return aRet;
422*cdf0e10cSrcweir     }
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir     rtl::OUString &rProductVersion = ProductVersion::get();
425*cdf0e10cSrcweir     if ( eProp == PRODUCTVERSION && rProductVersion.getLength() )
426*cdf0e10cSrcweir     {
427*cdf0e10cSrcweir         aRet <<= rProductVersion;
428*cdf0e10cSrcweir         return aRet;
429*cdf0e10cSrcweir     }
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir     rtl::OUString &rAboutBoxProductVersion = AboutBoxProductVersion::get();
432*cdf0e10cSrcweir     if ( eProp == ABOUTBOXPRODUCTVERSION && rAboutBoxProductVersion.getLength() )
433*cdf0e10cSrcweir     {
434*cdf0e10cSrcweir         aRet <<= rAboutBoxProductVersion;
435*cdf0e10cSrcweir         return aRet;
436*cdf0e10cSrcweir     }
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir     rtl::OUString &rOOOVendor = OOOVendor::get();
439*cdf0e10cSrcweir     if ( eProp == OOOVENDOR && rOOOVendor.getLength() )
440*cdf0e10cSrcweir     {
441*cdf0e10cSrcweir         aRet <<= rOOOVendor;
442*cdf0e10cSrcweir         return aRet;
443*cdf0e10cSrcweir     }
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir     rtl::OUString &rProductExtension = ProductExtension::get();
447*cdf0e10cSrcweir     if ( eProp == PRODUCTEXTENSION && rProductExtension.getLength() )
448*cdf0e10cSrcweir     {
449*cdf0e10cSrcweir         aRet <<= rProductExtension;
450*cdf0e10cSrcweir         return aRet;
451*cdf0e10cSrcweir     }
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir     rtl::OUString &rXMLFileFormatName = XMLFileFormatName::get();
454*cdf0e10cSrcweir     if ( eProp == PRODUCTXMLFILEFORMATNAME && rXMLFileFormatName.getLength() )
455*cdf0e10cSrcweir     {
456*cdf0e10cSrcweir         aRet <<= rXMLFileFormatName;
457*cdf0e10cSrcweir         return aRet;
458*cdf0e10cSrcweir     }
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir     rtl::OUString &rXMLFileFormatVersion = XMLFileFormatVersion::get();
461*cdf0e10cSrcweir     if ( eProp == PRODUCTXMLFILEFORMATVERSION && rXMLFileFormatVersion.getLength() )
462*cdf0e10cSrcweir     {
463*cdf0e10cSrcweir         aRet <<= rXMLFileFormatVersion;
464*cdf0e10cSrcweir         return aRet;
465*cdf0e10cSrcweir     }
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir     sal_Int32 &rOpenSourceContext = OpenSourceContext::get();
468*cdf0e10cSrcweir     if ( eProp == OPENSOURCECONTEXT && ( rOpenSourceContext >= 0 ) )
469*cdf0e10cSrcweir     {
470*cdf0e10cSrcweir         aRet <<= rOpenSourceContext;
471*cdf0e10cSrcweir         return aRet;
472*cdf0e10cSrcweir     }
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir     rtl::OUString &rWriterCompatibilityVersionOOo11 = WriterCompatibilityVersionOOo11::get();
475*cdf0e10cSrcweir     if ( eProp == WRITERCOMPATIBILITYVERSIONOOO11 && rWriterCompatibilityVersionOOo11.getLength() )
476*cdf0e10cSrcweir     {
477*cdf0e10cSrcweir         aRet <<= rWriterCompatibilityVersionOOo11;
478*cdf0e10cSrcweir         return aRet;
479*cdf0e10cSrcweir     }
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir     if (eProp == PRODUCTEXTENSION) {
482*cdf0e10cSrcweir         rtl::OUString name(
483*cdf0e10cSrcweir             rtl::OUString(
484*cdf0e10cSrcweir                 RTL_CONSTASCII_USTRINGPARAM(
485*cdf0e10cSrcweir                     "${BRAND_BASE_DIR}/program/edition/edition.ini")));
486*cdf0e10cSrcweir         rtl::Bootstrap::expandMacros(name);
487*cdf0e10cSrcweir         if (rtl::Bootstrap(name).getFrom(
488*cdf0e10cSrcweir                 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EDITIONNAME")),
489*cdf0e10cSrcweir                 rProductExtension))
490*cdf0e10cSrcweir         {
491*cdf0e10cSrcweir             return com::sun::star::uno::Any(rProductExtension);
492*cdf0e10cSrcweir         }
493*cdf0e10cSrcweir     }
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir 	OUString sPath = C2U(cConfigBaseURL);
496*cdf0e10cSrcweir 	switch(eProp)
497*cdf0e10cSrcweir 	{
498*cdf0e10cSrcweir 		case LOCALE:						sPath += C2U("Setup/L10N"); break;
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir         case PRODUCTNAME:
501*cdf0e10cSrcweir         case PRODUCTVERSION:
502*cdf0e10cSrcweir         case PRODUCTEXTENSION:
503*cdf0e10cSrcweir         case PRODUCTXMLFILEFORMATNAME :
504*cdf0e10cSrcweir 		case PRODUCTXMLFILEFORMATVERSION:
505*cdf0e10cSrcweir         case OPENSOURCECONTEXT:
506*cdf0e10cSrcweir         case OOOVENDOR:
507*cdf0e10cSrcweir         case ABOUTBOXPRODUCTVERSION:        sPath += C2U("Setup/Product"); break;
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir 		case DEFAULTCURRENCY:				sPath += C2U("Setup/L10N"); break;
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir 		case WRITERCOMPATIBILITYVERSIONOOO11:
512*cdf0e10cSrcweir 			sPath += C2U("Office.Compatibility/WriterCompatibilityVersion"); break;
513*cdf0e10cSrcweir         default:
514*cdf0e10cSrcweir             break;
515*cdf0e10cSrcweir 	}
516*cdf0e10cSrcweir 	Sequence< Any > aArgs(1);
517*cdf0e10cSrcweir 	aArgs[0] <<= sPath;
518*cdf0e10cSrcweir 	Reference< XMultiServiceFactory > xCfgProvider = GetConfigManager()->GetConfigurationProvider();
519*cdf0e10cSrcweir 	if(!xCfgProvider.is())
520*cdf0e10cSrcweir 		return aRet;
521*cdf0e10cSrcweir 	Reference< XInterface > xIFace;
522*cdf0e10cSrcweir 	try
523*cdf0e10cSrcweir 	{
524*cdf0e10cSrcweir 		xIFace = xCfgProvider->createInstanceWithArguments(
525*cdf0e10cSrcweir 				C2U(cAccessSrvc),
526*cdf0e10cSrcweir 				aArgs);
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir 	}
529*cdf0e10cSrcweir 	catch(Exception&){}
530*cdf0e10cSrcweir 	Reference<XNameAccess> xDirectAccess(xIFace, UNO_QUERY);
531*cdf0e10cSrcweir 	if(xDirectAccess.is())
532*cdf0e10cSrcweir 	{
533*cdf0e10cSrcweir 		OUString sProperty;
534*cdf0e10cSrcweir 		switch(eProp)
535*cdf0e10cSrcweir 		{
536*cdf0e10cSrcweir 			case LOCALE:							sProperty = C2U("ooLocale"); break;
537*cdf0e10cSrcweir             case PRODUCTNAME:						sProperty = C2U("ooName"); break;
538*cdf0e10cSrcweir             case PRODUCTVERSION:					sProperty = C2U("ooSetupVersion"); break;
539*cdf0e10cSrcweir             case ABOUTBOXPRODUCTVERSION: 			sProperty = C2U("ooSetupVersionAboutBox"); break;
540*cdf0e10cSrcweir             case OOOVENDOR:                         sProperty = C2U("ooVendor"); break;
541*cdf0e10cSrcweir             case PRODUCTEXTENSION:					sProperty = C2U("ooSetupExtension"); break;
542*cdf0e10cSrcweir             case PRODUCTXMLFILEFORMATNAME:          sProperty = C2U("ooXMLFileFormatName"); break;
543*cdf0e10cSrcweir             case PRODUCTXMLFILEFORMATVERSION:       sProperty = C2U("ooXMLFileFormatVersion"); break;
544*cdf0e10cSrcweir             case OPENSOURCECONTEXT:                 sProperty = C2U("ooOpenSourceContext"); break;
545*cdf0e10cSrcweir             case DEFAULTCURRENCY:                   sProperty = C2U("ooSetupCurrency"); break;
546*cdf0e10cSrcweir 			case WRITERCOMPATIBILITYVERSIONOOO11:	sProperty = C2U("OOo11"); break;
547*cdf0e10cSrcweir             default:
548*cdf0e10cSrcweir                 break;
549*cdf0e10cSrcweir 		}
550*cdf0e10cSrcweir 		try
551*cdf0e10cSrcweir 		{
552*cdf0e10cSrcweir 			aRet = xDirectAccess->getByName(sProperty);
553*cdf0e10cSrcweir 		}
554*cdf0e10cSrcweir 		catch(Exception&)
555*cdf0e10cSrcweir 		{
556*cdf0e10cSrcweir             #if OSL_DEBUG_LEVEL > 0
557*cdf0e10cSrcweir             rtl::OStringBuffer aBuf(256);
558*cdf0e10cSrcweir             aBuf.append( "ConfigManager::GetDirectConfigProperty: could not retrieve the property \"" );
559*cdf0e10cSrcweir             aBuf.append( rtl::OUStringToOString( sProperty, RTL_TEXTENCODING_ASCII_US ) );
560*cdf0e10cSrcweir             aBuf.append( "\" under \"" );
561*cdf0e10cSrcweir             aBuf.append( rtl::OUStringToOString( sPath, RTL_TEXTENCODING_ASCII_US ) );
562*cdf0e10cSrcweir             aBuf.append( "\" (caught an exception)!" );
563*cdf0e10cSrcweir 			OSL_ENSURE( sal_False, aBuf.getStr() );
564*cdf0e10cSrcweir             #endif
565*cdf0e10cSrcweir 		}
566*cdf0e10cSrcweir 	}
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir     if ( eProp == PRODUCTNAME )
569*cdf0e10cSrcweir         aRet >>= rBrandName;
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir     if ( eProp == PRODUCTXMLFILEFORMATNAME )
572*cdf0e10cSrcweir         aRet >>= rXMLFileFormatName;
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir     if ( eProp == PRODUCTXMLFILEFORMATVERSION )
575*cdf0e10cSrcweir         aRet >>= rXMLFileFormatVersion;
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir     if ( eProp == PRODUCTVERSION )
578*cdf0e10cSrcweir         aRet >>= rProductVersion;
579*cdf0e10cSrcweir 
580*cdf0e10cSrcweir     if( eProp == OOOVENDOR )
581*cdf0e10cSrcweir         aRet >>= rOOOVendor;
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir     if ( eProp == ABOUTBOXPRODUCTVERSION )
584*cdf0e10cSrcweir     {
585*cdf0e10cSrcweir         aRet >>= rAboutBoxProductVersion;
586*cdf0e10cSrcweir         getBasisAboutBoxProductVersion( rAboutBoxProductVersion );
587*cdf0e10cSrcweir         aRet <<= rAboutBoxProductVersion;
588*cdf0e10cSrcweir     }
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir     if ( eProp == PRODUCTEXTENSION )
591*cdf0e10cSrcweir         aRet >>= rProductExtension;
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir     if ( eProp == WRITERCOMPATIBILITYVERSIONOOO11 )
594*cdf0e10cSrcweir         aRet >>= rWriterCompatibilityVersionOOo11;
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir     if ( eProp == OPENSOURCECONTEXT )
597*cdf0e10cSrcweir         aRet >>= rOpenSourceContext;
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir 	return aRet;
600*cdf0e10cSrcweir }
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir /*---------------------------------------------------------------------------*/
603*cdf0e10cSrcweir void ConfigManager::getBasisAboutBoxProductVersion( OUString& rVersion )
604*cdf0e10cSrcweir {
605*cdf0e10cSrcweir     rtl::OUString aPackageVersion = UNISTRING( "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("version") ":OOOPackageVersion}" );
606*cdf0e10cSrcweir     rtl::Bootstrap::expandMacros( aPackageVersion );
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir     if ( aPackageVersion.getLength() )
609*cdf0e10cSrcweir     {
610*cdf0e10cSrcweir         sal_Int32 nTokIndex = 0;
611*cdf0e10cSrcweir         rtl::OUString aVersionMinor = aPackageVersion.getToken( 1, '.', nTokIndex );
612*cdf0e10cSrcweir         rtl::OUString aVersionMicro;
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir         if ( nTokIndex > 0 )
615*cdf0e10cSrcweir             aVersionMicro = aPackageVersion.getToken( 0, '.', nTokIndex );
616*cdf0e10cSrcweir 
617*cdf0e10cSrcweir         if ( aVersionMinor.getLength() == 0 )
618*cdf0e10cSrcweir             aVersionMinor = UNISTRING( "0" );
619*cdf0e10cSrcweir         if ( aVersionMicro.getLength() == 0 )
620*cdf0e10cSrcweir             aVersionMicro = UNISTRING( "0" );
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir         sal_Int32 nIndex = rVersion.indexOf( '.' );
623*cdf0e10cSrcweir         if ( nIndex == -1 )
624*cdf0e10cSrcweir         {
625*cdf0e10cSrcweir             rVersion += UNISTRING( "." );
626*cdf0e10cSrcweir             rVersion += aVersionMinor;
627*cdf0e10cSrcweir         }
628*cdf0e10cSrcweir         else
629*cdf0e10cSrcweir         {
630*cdf0e10cSrcweir             nIndex = rVersion.indexOf( '.', nIndex+1 );
631*cdf0e10cSrcweir         }
632*cdf0e10cSrcweir         if ( nIndex == -1 )
633*cdf0e10cSrcweir         {
634*cdf0e10cSrcweir             rVersion += UNISTRING( "." );
635*cdf0e10cSrcweir             rVersion += aVersionMicro;
636*cdf0e10cSrcweir         }
637*cdf0e10cSrcweir         else
638*cdf0e10cSrcweir         {
639*cdf0e10cSrcweir             rVersion = rVersion.replaceAt( nIndex+1, rVersion.getLength()-nIndex-1, aVersionMicro );
640*cdf0e10cSrcweir         }
641*cdf0e10cSrcweir     }
642*cdf0e10cSrcweir }
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir /* -----------------------------12.12.00 17:22--------------------------------
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
647*cdf0e10cSrcweir Reference< XHierarchicalNameAccess> ConfigManager::GetHierarchyAccess(const OUString& rFullPath)
648*cdf0e10cSrcweir {
649*cdf0e10cSrcweir 	Sequence< Any > aArgs(1);
650*cdf0e10cSrcweir 	aArgs[0] <<= rFullPath;
651*cdf0e10cSrcweir 	Reference< XMultiServiceFactory > xCfgProvider = GetLocalConfigurationProvider();
652*cdf0e10cSrcweir 	Reference< XInterface > xIFace;
653*cdf0e10cSrcweir 	if(xCfgProvider.is())
654*cdf0e10cSrcweir 	{
655*cdf0e10cSrcweir 		try
656*cdf0e10cSrcweir 		{
657*cdf0e10cSrcweir 			xIFace = xCfgProvider->createInstanceWithArguments(
658*cdf0e10cSrcweir 					C2U(cAccessSrvc),
659*cdf0e10cSrcweir 					aArgs);
660*cdf0e10cSrcweir 		}
661*cdf0e10cSrcweir #ifdef DBG_UTIL
662*cdf0e10cSrcweir 		catch(Exception& rEx)
663*cdf0e10cSrcweir 		{
664*cdf0e10cSrcweir 			OString sMsg("CreateInstance exception: ");
665*cdf0e10cSrcweir 			sMsg += OString(rEx.Message.getStr(),
666*cdf0e10cSrcweir 						rEx.Message.getLength(),
667*cdf0e10cSrcweir 				 		RTL_TEXTENCODING_ASCII_US);
668*cdf0e10cSrcweir 			OSL_ENSURE(sal_False, sMsg.getStr());
669*cdf0e10cSrcweir 		}
670*cdf0e10cSrcweir #else
671*cdf0e10cSrcweir 		catch(Exception&){}
672*cdf0e10cSrcweir #endif
673*cdf0e10cSrcweir 	}
674*cdf0e10cSrcweir 	return Reference<XHierarchicalNameAccess>(xIFace, UNO_QUERY);
675*cdf0e10cSrcweir }
676*cdf0e10cSrcweir /* -----------------------------12.12.00 17:17--------------------------------
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
679*cdf0e10cSrcweir Any ConfigManager::GetLocalProperty(const OUString& rProperty)
680*cdf0e10cSrcweir {
681*cdf0e10cSrcweir 	OUString sPath = C2U(cConfigBaseURL);
682*cdf0e10cSrcweir 	sPath += rProperty;
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir 	OUString sNode, sProperty;
685*cdf0e10cSrcweir     OSL_VERIFY( splitLastFromConfigurationPath(sPath, sNode, sProperty) );
686*cdf0e10cSrcweir 
687*cdf0e10cSrcweir 	Reference< XNameAccess> xAccess( GetHierarchyAccess(sNode), UNO_QUERY );
688*cdf0e10cSrcweir 	Any aRet;
689*cdf0e10cSrcweir 	try
690*cdf0e10cSrcweir 	{
691*cdf0e10cSrcweir 		if(xAccess.is())
692*cdf0e10cSrcweir 			aRet = xAccess->getByName(sProperty);
693*cdf0e10cSrcweir 	}
694*cdf0e10cSrcweir #ifdef DBG_UTIL
695*cdf0e10cSrcweir 	catch(Exception& rEx)
696*cdf0e10cSrcweir 	{
697*cdf0e10cSrcweir 		OString sMsg("GetLocalProperty: ");
698*cdf0e10cSrcweir 		sMsg += OString(rEx.Message.getStr(),
699*cdf0e10cSrcweir 					rEx.Message.getLength(),
700*cdf0e10cSrcweir 				 	RTL_TEXTENCODING_ASCII_US);
701*cdf0e10cSrcweir 		OSL_ENSURE(sal_False, sMsg.getStr());
702*cdf0e10cSrcweir 	}
703*cdf0e10cSrcweir #else
704*cdf0e10cSrcweir 	catch(Exception&){}
705*cdf0e10cSrcweir #endif
706*cdf0e10cSrcweir 	return aRet;
707*cdf0e10cSrcweir }
708*cdf0e10cSrcweir /* -----------------------------12.12.00 17:17--------------------------------
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
711*cdf0e10cSrcweir void ConfigManager::PutLocalProperty(const OUString& rProperty, const Any& rValue)
712*cdf0e10cSrcweir {
713*cdf0e10cSrcweir 	OUString sPath = C2U(cConfigBaseURL);
714*cdf0e10cSrcweir 	sPath += rProperty;
715*cdf0e10cSrcweir 
716*cdf0e10cSrcweir 	OUString sNode, sProperty;
717*cdf0e10cSrcweir     OSL_VERIFY( splitLastFromConfigurationPath(sPath, sNode, sProperty) );
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir 	Reference<XNameReplace> xNodeReplace(GetHierarchyAccess(sNode), UNO_QUERY);
720*cdf0e10cSrcweir 	if(xNodeReplace.is())
721*cdf0e10cSrcweir 	{
722*cdf0e10cSrcweir 		try
723*cdf0e10cSrcweir 		{
724*cdf0e10cSrcweir 			xNodeReplace->replaceByName(sProperty, rValue);
725*cdf0e10cSrcweir 		}
726*cdf0e10cSrcweir #ifdef DBG_UTIL
727*cdf0e10cSrcweir 		catch(Exception& rEx)
728*cdf0e10cSrcweir 		{
729*cdf0e10cSrcweir 			OString sMsg("PutLocalProperty: ");
730*cdf0e10cSrcweir 			sMsg += OString(rEx.Message.getStr(),
731*cdf0e10cSrcweir 						rEx.Message.getLength(),
732*cdf0e10cSrcweir 				 		RTL_TEXTENCODING_ASCII_US);
733*cdf0e10cSrcweir 			OSL_ENSURE(sal_False, sMsg.getStr());
734*cdf0e10cSrcweir 		}
735*cdf0e10cSrcweir #else
736*cdf0e10cSrcweir 		catch(Exception& ){}
737*cdf0e10cSrcweir #endif
738*cdf0e10cSrcweir 	}
739*cdf0e10cSrcweir }
740*cdf0e10cSrcweir /* -----------------------------13.12.00 08:47--------------------------------
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
743*cdf0e10cSrcweir sal_Bool	ConfigManager::IsLocalConfigProvider()
744*cdf0e10cSrcweir {
745*cdf0e10cSrcweir 	return false;
746*cdf0e10cSrcweir }
747*cdf0e10cSrcweir 
748