xref: /AOO41X/main/unotools/source/config/pathoptions.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 #ifndef GCC
31*cdf0e10cSrcweir #endif
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
34*cdf0e10cSrcweir #include <unotools/configitem.hxx>
35*cdf0e10cSrcweir #include <unotools/configmgr.hxx>
36*cdf0e10cSrcweir #include <tools/debug.hxx>
37*cdf0e10cSrcweir #include <tools/resmgr.hxx>
38*cdf0e10cSrcweir #include <tools/urlobj.hxx>
39*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
40*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
41*cdf0e10cSrcweir #include <osl/mutex.hxx>
42*cdf0e10cSrcweir #include <osl/file.hxx>
43*cdf0e10cSrcweir #include <unotools/localfilehelper.hxx>
44*cdf0e10cSrcweir #include <unotools/bootstrap.hxx>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include <unotools/ucbhelper.hxx>
47*cdf0e10cSrcweir #include <vos/process.hxx>
48*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
49*cdf0e10cSrcweir #include <comphelper/componentcontext.hxx>
50*cdf0e10cSrcweir #include <com/sun/star/beans/XFastPropertySet.hpp>
51*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
52*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
53*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
54*cdf0e10cSrcweir #include <com/sun/star/util/XStringSubstitution.hpp>
55*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
56*cdf0e10cSrcweir #include <com/sun/star/util/XMacroExpander.hpp>
57*cdf0e10cSrcweir #include <rtl/instance.hxx>
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir #include <itemholder1.hxx>
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir #include <vector>
62*cdf0e10cSrcweir #include <hash_map>
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir using namespace osl;
65*cdf0e10cSrcweir using namespace utl;
66*cdf0e10cSrcweir using namespace rtl;
67*cdf0e10cSrcweir using namespace com::sun::star::uno;
68*cdf0e10cSrcweir using namespace com::sun::star::beans;
69*cdf0e10cSrcweir using namespace com::sun::star::util;
70*cdf0e10cSrcweir using namespace com::sun::star::lang;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir // define ----------------------------------------------------------------
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir #define SEARCHPATH_DELIMITER			';'
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir #define ASCII_STR(s)					OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir #define	SIGN_STARTVARIABLE				ASCII_STR("$(")
79*cdf0e10cSrcweir #define	SIGN_ENDVARIABLE				ASCII_STR(")")
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir // Supported variables by the old SvtPathOptions implementation
82*cdf0e10cSrcweir #define	SUBSTITUTE_INST					"$(inst)"
83*cdf0e10cSrcweir #define	SUBSTITUTE_PROG					"$(prog)"
84*cdf0e10cSrcweir #define	SUBSTITUTE_USER					"$(user)"
85*cdf0e10cSrcweir #define SUBSTITUTE_INSTPATH             "$(instpath)"
86*cdf0e10cSrcweir #define SUBSTITUTE_PROGPATH             "$(progpath)"
87*cdf0e10cSrcweir #define SUBSTITUTE_USERPATH             "$(userpath)"
88*cdf0e10cSrcweir #define	SUBSTITUTE_INSTURL				"$(insturl)"
89*cdf0e10cSrcweir #define	SUBSTITUTE_PROGURL				"$(progurl)"
90*cdf0e10cSrcweir #define	SUBSTITUTE_USERURL				"$(userurl)"
91*cdf0e10cSrcweir #define	SUBSTITUTE_PATH					"$(path)"
92*cdf0e10cSrcweir //#define	SUBSTITUTE_LANG					"$(lang)"
93*cdf0e10cSrcweir #define	SUBSTITUTE_LANGID				"$(langid)"
94*cdf0e10cSrcweir #define	SUBSTITUTE_VLANG				"$(vlang)"
95*cdf0e10cSrcweir #define	SUBSTITUTE_WORKDIRURL			"$(workdirurl)"
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir #define STRPOS_NOTFOUND					-1
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir struct OUStringHashCode
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir     size_t operator()( const ::rtl::OUString& sString ) const
102*cdf0e10cSrcweir 	{
103*cdf0e10cSrcweir 		return sString.hashCode();
104*cdf0e10cSrcweir 	}
105*cdf0e10cSrcweir };
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir enum VarNameProperty
108*cdf0e10cSrcweir {
109*cdf0e10cSrcweir 	VAR_NEEDS_SYSTEM_PATH,
110*cdf0e10cSrcweir 	VAR_NEEDS_FILEURL
111*cdf0e10cSrcweir };
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir class NameToHandleMap : public ::std::hash_map<	::rtl::OUString, sal_Int32, OUStringHashCode, ::std::equal_to< ::rtl::OUString > >
114*cdf0e10cSrcweir {
115*cdf0e10cSrcweir 	public:
116*cdf0e10cSrcweir 		inline void free() { NameToHandleMap().swap( *this ); }
117*cdf0e10cSrcweir };
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir class EnumToHandleMap : public ::std::hash_map< sal_Int32, sal_Int32, std::hash< sal_Int32 >, std::equal_to< sal_Int32 > >
120*cdf0e10cSrcweir {
121*cdf0e10cSrcweir 	public:
122*cdf0e10cSrcweir 		inline void free() { EnumToHandleMap().swap( *this ); }
123*cdf0e10cSrcweir };
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir class VarNameToEnumMap : public ::std::hash_map< OUString, VarNameProperty, OUStringHashCode, ::std::equal_to< OUString > >
126*cdf0e10cSrcweir {
127*cdf0e10cSrcweir 	public:
128*cdf0e10cSrcweir 		inline void free() { VarNameToEnumMap().swap( *this ); }
129*cdf0e10cSrcweir };
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir // class SvtPathOptions_Impl ---------------------------------------------
133*cdf0e10cSrcweir class SvtPathOptions_Impl
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir 	private:
136*cdf0e10cSrcweir 		// Local variables to return const references
137*cdf0e10cSrcweir 		std::vector< String >				m_aPathArray;
138*cdf0e10cSrcweir 		Reference< XFastPropertySet >		m_xPathSettings;
139*cdf0e10cSrcweir 		Reference< XStringSubstitution >	m_xSubstVariables;
140*cdf0e10cSrcweir         Reference< XMacroExpander >         m_xMacroExpander;
141*cdf0e10cSrcweir         mutable EnumToHandleMap             m_aMapEnumToPropHandle;
142*cdf0e10cSrcweir 		VarNameToEnumMap					m_aMapVarNamesToEnum;
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 	    ::com::sun::star::lang::Locale 						m_aLocale;
145*cdf0e10cSrcweir 		String								m_aEmptyString;
146*cdf0e10cSrcweir         mutable ::osl::Mutex                m_aMutex;
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 	public:
149*cdf0e10cSrcweir 						SvtPathOptions_Impl();
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 		// get the pathes, not const because of using a mutex
152*cdf0e10cSrcweir         const String&   GetPath( SvtPathOptions::Pathes );
153*cdf0e10cSrcweir         const String&   GetAddinPath() { return GetPath( SvtPathOptions::PATH_ADDIN ); }
154*cdf0e10cSrcweir 		const String&	GetAutoCorrectPath() { return GetPath( SvtPathOptions::PATH_AUTOCORRECT ); }
155*cdf0e10cSrcweir 		const String&	GetAutoTextPath() { return GetPath( SvtPathOptions::PATH_AUTOTEXT ); }
156*cdf0e10cSrcweir 		const String&	GetBackupPath() { return GetPath( SvtPathOptions::PATH_BACKUP ); }
157*cdf0e10cSrcweir 		const String&	GetBasicPath() { return GetPath( SvtPathOptions::PATH_BASIC ); }
158*cdf0e10cSrcweir 		const String&	GetBitmapPath() { return GetPath( SvtPathOptions::PATH_BITMAP ); }
159*cdf0e10cSrcweir 		const String&	GetConfigPath() { return GetPath( SvtPathOptions::PATH_CONFIG ); }
160*cdf0e10cSrcweir 		const String&	GetDictionaryPath() { return GetPath( SvtPathOptions::PATH_DICTIONARY ); }
161*cdf0e10cSrcweir 		const String&	GetFavoritesPath() { return GetPath( SvtPathOptions::PATH_FAVORITES ); }
162*cdf0e10cSrcweir 		const String&	GetFilterPath() { return GetPath( SvtPathOptions::PATH_FILTER ); }
163*cdf0e10cSrcweir 		const String&	GetGalleryPath() { return GetPath( SvtPathOptions::PATH_GALLERY ); }
164*cdf0e10cSrcweir 		const String&	GetGraphicPath() { return GetPath( SvtPathOptions::PATH_GRAPHIC ); }
165*cdf0e10cSrcweir 		const String&	GetHelpPath() { return GetPath( SvtPathOptions::PATH_HELP ); }
166*cdf0e10cSrcweir 		const String&	GetLinguisticPath() { return GetPath( SvtPathOptions::PATH_LINGUISTIC ); }
167*cdf0e10cSrcweir 		const String&	GetModulePath() { return GetPath( SvtPathOptions::PATH_MODULE ); }
168*cdf0e10cSrcweir 		const String&	GetPalettePath() { return GetPath( SvtPathOptions::PATH_PALETTE ); }
169*cdf0e10cSrcweir 		const String&	GetPluginPath() { return GetPath( SvtPathOptions::PATH_PLUGIN ); }
170*cdf0e10cSrcweir 		const String&	GetStoragePath() { return GetPath( SvtPathOptions::PATH_STORAGE ); }
171*cdf0e10cSrcweir 		const String&	GetTempPath() { return GetPath( SvtPathOptions::PATH_TEMP ); }
172*cdf0e10cSrcweir 		const String&	GetTemplatePath() { return GetPath( SvtPathOptions::PATH_TEMPLATE ); }
173*cdf0e10cSrcweir 		const String&	GetUserConfigPath() { return GetPath( SvtPathOptions::PATH_USERCONFIG ); }
174*cdf0e10cSrcweir 		const String&	GetWorkPath() { return GetPath( SvtPathOptions::PATH_WORK ); }
175*cdf0e10cSrcweir 	    const String&   GetUIConfigPath() { return GetPath( SvtPathOptions::PATH_UICONFIG ); }
176*cdf0e10cSrcweir         const String&   GetFingerprintPath() { return GetPath( SvtPathOptions::PATH_FINGERPRINT ); }
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 		// set the pathes
179*cdf0e10cSrcweir         void            SetPath( SvtPathOptions::Pathes, const String& rNewPath );
180*cdf0e10cSrcweir         void            SetAddinPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_ADDIN, rPath ); }
181*cdf0e10cSrcweir 		void			SetAutoCorrectPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_AUTOCORRECT, rPath ); }
182*cdf0e10cSrcweir 		void			SetAutoTextPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_AUTOTEXT, rPath ); }
183*cdf0e10cSrcweir 		void			SetBackupPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_BACKUP, rPath ); }
184*cdf0e10cSrcweir 		void			SetBasicPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_BASIC, rPath ); }
185*cdf0e10cSrcweir 		void			SetBitmapPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_BITMAP, rPath ); }
186*cdf0e10cSrcweir 		void			SetConfigPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_CONFIG, rPath ); }
187*cdf0e10cSrcweir 		void			SetDictionaryPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_DICTIONARY, rPath ); }
188*cdf0e10cSrcweir 		void			SetFavoritesPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_FAVORITES, rPath ); }
189*cdf0e10cSrcweir 		void			SetFilterPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_FILTER, rPath ); }
190*cdf0e10cSrcweir 		void			SetGalleryPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_GALLERY, rPath ); }
191*cdf0e10cSrcweir 		void			SetGraphicPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_GRAPHIC, rPath ); }
192*cdf0e10cSrcweir 		void			SetHelpPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_HELP, rPath ); }
193*cdf0e10cSrcweir 		void			SetLinguisticPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_LINGUISTIC, rPath ); }
194*cdf0e10cSrcweir 		void			SetModulePath( const String& rPath ) { SetPath( SvtPathOptions::PATH_MODULE, rPath ); }
195*cdf0e10cSrcweir 		void			SetPalettePath( const String& rPath ) { SetPath( SvtPathOptions::PATH_PALETTE, rPath ); }
196*cdf0e10cSrcweir 		void			SetPluginPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_PLUGIN, rPath ); }
197*cdf0e10cSrcweir 		void			SetStoragePath( const String& rPath ) { SetPath( SvtPathOptions::PATH_STORAGE, rPath ); }
198*cdf0e10cSrcweir 		void			SetTempPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_TEMP, rPath ); }
199*cdf0e10cSrcweir 		void			SetTemplatePath( const String& rPath ) { SetPath( SvtPathOptions::PATH_TEMPLATE, rPath ); }
200*cdf0e10cSrcweir 		void			SetUserConfigPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_USERCONFIG, rPath ); }
201*cdf0e10cSrcweir 		void			SetWorkPath( const String& rPath ) { SetPath( SvtPathOptions::PATH_WORK, rPath ); }
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 		rtl::OUString	SubstVar( const rtl::OUString& rVar ) const;
204*cdf0e10cSrcweir 		rtl::OUString	ExpandMacros( const rtl::OUString& rPath ) const;
205*cdf0e10cSrcweir 		rtl::OUString	UsePathVariables( const rtl::OUString& rPath ) const;
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 		::com::sun::star::lang::Locale	GetLocale() const { return m_aLocale; }
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir         sal_Bool            IsPathReadonly(SvtPathOptions::Pathes ePath)const;
210*cdf0e10cSrcweir };
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir // global ----------------------------------------------------------------
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir static SvtPathOptions_Impl* pOptions = NULL;
215*cdf0e10cSrcweir static sal_Int32 nRefCount = 0;
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir // functions -------------------------------------------------------------
218*cdf0e10cSrcweir struct PropertyStruct
219*cdf0e10cSrcweir {
220*cdf0e10cSrcweir 	const char*				pPropName;	// The ascii name of the Office path
221*cdf0e10cSrcweir 	SvtPathOptions::Pathes	ePath;		// The enum value used by SvtPathOptions
222*cdf0e10cSrcweir };
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir struct VarNameAttribute
225*cdf0e10cSrcweir {
226*cdf0e10cSrcweir 	const char*				pVarName;		// The name of the path variable
227*cdf0e10cSrcweir 	VarNameProperty			eVarProperty;	// Which return value is needed by this path variable
228*cdf0e10cSrcweir };
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir static PropertyStruct aPropNames[] =
231*cdf0e10cSrcweir {
232*cdf0e10cSrcweir 	{ "Addin",			SvtPathOptions::PATH_ADDIN			},
233*cdf0e10cSrcweir 	{ "AutoCorrect",	SvtPathOptions::PATH_AUTOCORRECT	},
234*cdf0e10cSrcweir 	{ "AutoText",		SvtPathOptions::PATH_AUTOTEXT		},
235*cdf0e10cSrcweir 	{ "Backup",			SvtPathOptions::PATH_BACKUP			},
236*cdf0e10cSrcweir 	{ "Basic",			SvtPathOptions::PATH_BASIC			},
237*cdf0e10cSrcweir 	{ "Bitmap",			SvtPathOptions::PATH_BITMAP			},
238*cdf0e10cSrcweir 	{ "Config",			SvtPathOptions::PATH_CONFIG			},
239*cdf0e10cSrcweir 	{ "Dictionary",		SvtPathOptions::PATH_DICTIONARY		},
240*cdf0e10cSrcweir 	{ "Favorite",		SvtPathOptions::PATH_FAVORITES		},
241*cdf0e10cSrcweir 	{ "Filter",			SvtPathOptions::PATH_FILTER			},
242*cdf0e10cSrcweir 	{ "Gallery",		SvtPathOptions::PATH_GALLERY		},
243*cdf0e10cSrcweir 	{ "Graphic",		SvtPathOptions::PATH_GRAPHIC		},
244*cdf0e10cSrcweir 	{ "Help",			SvtPathOptions::PATH_HELP			},
245*cdf0e10cSrcweir 	{ "Linguistic",		SvtPathOptions::PATH_LINGUISTIC		},
246*cdf0e10cSrcweir 	{ "Module",			SvtPathOptions::PATH_MODULE			},
247*cdf0e10cSrcweir 	{ "Palette",		SvtPathOptions::PATH_PALETTE		},
248*cdf0e10cSrcweir 	{ "Plugin",			SvtPathOptions::PATH_PLUGIN			},
249*cdf0e10cSrcweir 	{ "Storage",		SvtPathOptions::PATH_STORAGE		},
250*cdf0e10cSrcweir 	{ "Temp",			SvtPathOptions::PATH_TEMP			},
251*cdf0e10cSrcweir 	{ "Template",		SvtPathOptions::PATH_TEMPLATE		},
252*cdf0e10cSrcweir 	{ "UserConfig",		SvtPathOptions::PATH_USERCONFIG		},
253*cdf0e10cSrcweir     { "Work",           SvtPathOptions::PATH_WORK			},
254*cdf0e10cSrcweir     { "UIConfig",       SvtPathOptions::PATH_UICONFIG		},
255*cdf0e10cSrcweir     { "Fingerprint",    SvtPathOptions::PATH_FINGERPRINT	}
256*cdf0e10cSrcweir };
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir static VarNameAttribute aVarNameAttribute[] =
259*cdf0e10cSrcweir {
260*cdf0e10cSrcweir 	{ SUBSTITUTE_INSTPATH,	VAR_NEEDS_SYSTEM_PATH },	// $(instpath)
261*cdf0e10cSrcweir 	{ SUBSTITUTE_PROGPATH,	VAR_NEEDS_SYSTEM_PATH },	// $(progpath)
262*cdf0e10cSrcweir 	{ SUBSTITUTE_USERPATH,	VAR_NEEDS_SYSTEM_PATH },	// $(userpath)
263*cdf0e10cSrcweir 	{ SUBSTITUTE_PATH,		VAR_NEEDS_SYSTEM_PATH },	// $(path)
264*cdf0e10cSrcweir };
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir #if 0
267*cdf0e10cSrcweir // currently unused
268*cdf0e10cSrcweir static Sequence< OUString > GetPathPropertyNames()
269*cdf0e10cSrcweir {
270*cdf0e10cSrcweir 	const int nCount = sizeof( aPropNames ) / sizeof( PropertyStruct );
271*cdf0e10cSrcweir 	Sequence< OUString > aNames( nCount );
272*cdf0e10cSrcweir 	OUString* pNames = aNames.getArray();
273*cdf0e10cSrcweir 	for ( int i = 0; i < nCount; i++ )
274*cdf0e10cSrcweir 		pNames[i] = OUString::createFromAscii( aPropNames[i].pPropName );
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir 	return aNames;
277*cdf0e10cSrcweir }
278*cdf0e10cSrcweir #endif
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir // class SvtPathOptions_Impl ---------------------------------------------
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir const String& SvtPathOptions_Impl::GetPath( SvtPathOptions::Pathes ePath )
283*cdf0e10cSrcweir {
284*cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir 	if ( ePath >= SvtPathOptions::PATH_COUNT )
287*cdf0e10cSrcweir         return m_aEmptyString;
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir     OUString 	aPathValue;
290*cdf0e10cSrcweir 	String		aResult;
291*cdf0e10cSrcweir 	sal_Int32	nHandle = m_aMapEnumToPropHandle[ (sal_Int32)ePath ];
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir 	// Substitution is done by the service itself using the substition service
294*cdf0e10cSrcweir 	Any 		a = m_xPathSettings->getFastPropertyValue( nHandle );
295*cdf0e10cSrcweir 	a >>= aPathValue;
296*cdf0e10cSrcweir 	if( ePath == SvtPathOptions::PATH_ADDIN     ||
297*cdf0e10cSrcweir         ePath == SvtPathOptions::PATH_FILTER    ||
298*cdf0e10cSrcweir         ePath == SvtPathOptions::PATH_HELP      ||
299*cdf0e10cSrcweir         ePath == SvtPathOptions::PATH_MODULE    ||
300*cdf0e10cSrcweir         ePath == SvtPathOptions::PATH_PLUGIN    ||
301*cdf0e10cSrcweir         ePath == SvtPathOptions::PATH_STORAGE
302*cdf0e10cSrcweir       )
303*cdf0e10cSrcweir 	{
304*cdf0e10cSrcweir         // These office paths have to be converted to system pathes
305*cdf0e10cSrcweir         utl::LocalFileHelper::ConvertURLToPhysicalName( aPathValue, aResult );
306*cdf0e10cSrcweir         aPathValue = aResult;
307*cdf0e10cSrcweir 	}
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir 	m_aPathArray[ ePath ] = aPathValue;
310*cdf0e10cSrcweir     return m_aPathArray[ ePath ];
311*cdf0e10cSrcweir }
312*cdf0e10cSrcweir // -----------------------------------------------------------------------
313*cdf0e10cSrcweir sal_Bool SvtPathOptions_Impl::IsPathReadonly(SvtPathOptions::Pathes ePath)const
314*cdf0e10cSrcweir {
315*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
316*cdf0e10cSrcweir     sal_Bool bReadonly = sal_False;
317*cdf0e10cSrcweir     if ( ePath < SvtPathOptions::PATH_COUNT )
318*cdf0e10cSrcweir     {
319*cdf0e10cSrcweir         Reference<XPropertySet> xPrSet(m_xPathSettings, UNO_QUERY);
320*cdf0e10cSrcweir         if(xPrSet.is())
321*cdf0e10cSrcweir         {
322*cdf0e10cSrcweir             Reference<XPropertySetInfo> xInfo = xPrSet->getPropertySetInfo();
323*cdf0e10cSrcweir 			const char* pA = aPropNames[ePath].pPropName;
324*cdf0e10cSrcweir 			::rtl::OUString sU = OUString::createFromAscii(pA);
325*cdf0e10cSrcweir             Property aProperty = xInfo->getPropertyByName(sU);
326*cdf0e10cSrcweir             bReadonly = 0 != (aProperty.Attributes & PropertyAttribute::READONLY);
327*cdf0e10cSrcweir         }
328*cdf0e10cSrcweir     }
329*cdf0e10cSrcweir     return bReadonly;
330*cdf0e10cSrcweir }
331*cdf0e10cSrcweir // -----------------------------------------------------------------------
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir void SvtPathOptions_Impl::SetPath( SvtPathOptions::Pathes ePath, const String& rNewPath )
334*cdf0e10cSrcweir {
335*cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 	if ( ePath < SvtPathOptions::PATH_COUNT )
338*cdf0e10cSrcweir 	{
339*cdf0e10cSrcweir 		String 		aResult;
340*cdf0e10cSrcweir 		OUString	aNewValue;
341*cdf0e10cSrcweir 		Any			a;
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir 		switch ( ePath )
344*cdf0e10cSrcweir 		{
345*cdf0e10cSrcweir 			case SvtPathOptions::PATH_ADDIN:
346*cdf0e10cSrcweir 			case SvtPathOptions::PATH_FILTER:
347*cdf0e10cSrcweir 			case SvtPathOptions::PATH_HELP:
348*cdf0e10cSrcweir 			case SvtPathOptions::PATH_MODULE:
349*cdf0e10cSrcweir 			case SvtPathOptions::PATH_PLUGIN:
350*cdf0e10cSrcweir 			case SvtPathOptions::PATH_STORAGE:
351*cdf0e10cSrcweir 			{
352*cdf0e10cSrcweir 				// These office paths have to be convert back to UCB-URL's
353*cdf0e10cSrcweir 				utl::LocalFileHelper::ConvertPhysicalNameToURL( rNewPath, aResult );
354*cdf0e10cSrcweir 				aNewValue = aResult;
355*cdf0e10cSrcweir 			}
356*cdf0e10cSrcweir 			break;
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir 			default:
359*cdf0e10cSrcweir 				aNewValue = rNewPath;
360*cdf0e10cSrcweir 		}
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir 		// Resubstitution is done by the service itself using the substition service
363*cdf0e10cSrcweir 		a <<= aNewValue;
364*cdf0e10cSrcweir 		try
365*cdf0e10cSrcweir 		{
366*cdf0e10cSrcweir 			m_xPathSettings->setFastPropertyValue( m_aMapEnumToPropHandle[ (sal_Int32)ePath], a );
367*cdf0e10cSrcweir 		}
368*cdf0e10cSrcweir 		catch (const Exception&)
369*cdf0e10cSrcweir 		{
370*cdf0e10cSrcweir 		}
371*cdf0e10cSrcweir 	}
372*cdf0e10cSrcweir }
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir //-------------------------------------------------------------------------
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir OUString SvtPathOptions_Impl::ExpandMacros( const rtl::OUString& rPath ) const
377*cdf0e10cSrcweir {
378*cdf0e10cSrcweir     ::rtl::OUString sExpanded( rPath );
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir     const INetURLObject aParser( rPath );
381*cdf0e10cSrcweir     if ( aParser.GetProtocol() == INET_PROT_VND_SUN_STAR_EXPAND )
382*cdf0e10cSrcweir         sExpanded = m_xMacroExpander->expandMacros( aParser.GetURLPath( INetURLObject::DECODE_WITH_CHARSET ) );
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir     return sExpanded;
385*cdf0e10cSrcweir }
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir //-------------------------------------------------------------------------
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir OUString SvtPathOptions_Impl::UsePathVariables( const OUString& rPath ) const
390*cdf0e10cSrcweir {
391*cdf0e10cSrcweir 	return m_xSubstVariables->reSubstituteVariables( rPath );
392*cdf0e10cSrcweir }
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir // -----------------------------------------------------------------------
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir OUString SvtPathOptions_Impl::SubstVar( const OUString& rVar ) const
397*cdf0e10cSrcweir {
398*cdf0e10cSrcweir 	// Don't work at parameter-string directly. Copy it.
399*cdf0e10cSrcweir 	OUString aWorkText = rVar;
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 	// Convert the returned path to system path!
402*cdf0e10cSrcweir 	sal_Bool bConvertLocal = sal_False;
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir 	// Search for first occure of "$(...".
405*cdf0e10cSrcweir 	sal_Int32 nPosition	= aWorkText.indexOf( SIGN_STARTVARIABLE );	// = first position of "$(" in string
406*cdf0e10cSrcweir 	sal_Int32 nLength	= 0;										// = count of letters from "$(" to ")" in string
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir 	// Have we found any variable like "$(...)"?
409*cdf0e10cSrcweir 	if ( nPosition != STRPOS_NOTFOUND )
410*cdf0e10cSrcweir 	{
411*cdf0e10cSrcweir 		// Yes; Get length of found variable.
412*cdf0e10cSrcweir 		// If no ")" was found - nLength is set to 0 by default! see before.
413*cdf0e10cSrcweir 		sal_Int32 nEndPosition = aWorkText.indexOf( SIGN_ENDVARIABLE, nPosition );
414*cdf0e10cSrcweir 		if ( nEndPosition != STRPOS_NOTFOUND )
415*cdf0e10cSrcweir 			nLength = nEndPosition - nPosition + 1;
416*cdf0e10cSrcweir 	}
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir 	// Is there another path variable?
419*cdf0e10cSrcweir 	while ( ( nPosition != STRPOS_NOTFOUND ) && ( nLength > 0 ) )
420*cdf0e10cSrcweir 	{
421*cdf0e10cSrcweir 		// YES; Get the next variable for replace.
422*cdf0e10cSrcweir 		OUString aReplacement;
423*cdf0e10cSrcweir 		OUString aSubString = aWorkText.copy( nPosition, nLength );
424*cdf0e10cSrcweir         aSubString = aSubString.toAsciiLowerCase();
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir 		// Look for special variable that needs a system path.
427*cdf0e10cSrcweir 		VarNameToEnumMap::const_iterator pIter = m_aMapVarNamesToEnum.find( aSubString );
428*cdf0e10cSrcweir 		if ( pIter != m_aMapVarNamesToEnum.end() )
429*cdf0e10cSrcweir 			bConvertLocal = sal_True;
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir 		nPosition += nLength;
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir 		// We must control index in string before call something at OUString!
434*cdf0e10cSrcweir 		// The OUString-implementation don't do it for us :-( but the result is not defined otherwise.
435*cdf0e10cSrcweir 		if ( nPosition + 1 > aWorkText.getLength() )
436*cdf0e10cSrcweir 		{
437*cdf0e10cSrcweir 			// Position is out of range. Break loop!
438*cdf0e10cSrcweir 			nPosition = STRPOS_NOTFOUND;
439*cdf0e10cSrcweir 			nLength = 0;
440*cdf0e10cSrcweir 		}
441*cdf0e10cSrcweir 		else
442*cdf0e10cSrcweir 		{
443*cdf0e10cSrcweir 			// Else; Position is valid. Search for next variable.
444*cdf0e10cSrcweir 			nPosition = aWorkText.indexOf( SIGN_STARTVARIABLE, nPosition );
445*cdf0e10cSrcweir 			// Have we found any variable like "$(...)"?
446*cdf0e10cSrcweir 			if ( nPosition != STRPOS_NOTFOUND )
447*cdf0e10cSrcweir 			{
448*cdf0e10cSrcweir 				// Yes; Get length of found variable. If no ")" was found - nLength must set to 0!
449*cdf0e10cSrcweir 				nLength	= 0;
450*cdf0e10cSrcweir 				sal_Int32 nEndPosition = aWorkText.indexOf( SIGN_ENDVARIABLE, nPosition );
451*cdf0e10cSrcweir 				if ( nEndPosition != STRPOS_NOTFOUND )
452*cdf0e10cSrcweir 					nLength = nEndPosition - nPosition + 1;
453*cdf0e10cSrcweir 			}
454*cdf0e10cSrcweir 		}
455*cdf0e10cSrcweir 	}
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir 	aWorkText = m_xSubstVariables->substituteVariables( rVar, sal_False );
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir 	if ( bConvertLocal )
460*cdf0e10cSrcweir 	{
461*cdf0e10cSrcweir 		// Convert the URL to a system path for special path variables
462*cdf0e10cSrcweir         String aReturn;
463*cdf0e10cSrcweir 		utl::LocalFileHelper::ConvertURLToPhysicalName( aWorkText, aReturn );
464*cdf0e10cSrcweir 		return aReturn;
465*cdf0e10cSrcweir 	}
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir     return aWorkText;
468*cdf0e10cSrcweir }
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir // -----------------------------------------------------------------------
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir SvtPathOptions_Impl::SvtPathOptions_Impl() :
473*cdf0e10cSrcweir 	m_aPathArray( (sal_Int32)SvtPathOptions::PATH_COUNT )
474*cdf0e10cSrcweir {
475*cdf0e10cSrcweir 	Reference< XMultiServiceFactory > xSMgr = comphelper::getProcessServiceFactory();
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir 	// Create necessary services
478*cdf0e10cSrcweir 	m_xPathSettings = Reference< XFastPropertySet >( xSMgr->createInstance(
479*cdf0e10cSrcweir 													::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
480*cdf0e10cSrcweir 														"com.sun.star.util.PathSettings" ))),
481*cdf0e10cSrcweir 												UNO_QUERY );
482*cdf0e10cSrcweir     if ( !m_xPathSettings.is() )
483*cdf0e10cSrcweir 	{
484*cdf0e10cSrcweir         // #112719#: check for existance
485*cdf0e10cSrcweir 		DBG_ERROR( "SvtPathOptions_Impl::SvtPathOptions_Impl(): #112719# happened again!" );
486*cdf0e10cSrcweir         throw RuntimeException(
487*cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Service com.sun.star.util.PathSettings cannot be created" )),
488*cdf0e10cSrcweir             Reference< XInterface >() );
489*cdf0e10cSrcweir 	}
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir     ::comphelper::ComponentContext aContext( xSMgr );
492*cdf0e10cSrcweir     m_xSubstVariables.set( aContext.createComponent( "com.sun.star.util.PathSubstitution" ), UNO_QUERY_THROW );
493*cdf0e10cSrcweir     m_xMacroExpander.set( aContext.getSingleton( "com.sun.star.util.theMacroExpander" ), UNO_QUERY_THROW );
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir     // Create temporary hash map to have a mapping between property names and property handles
496*cdf0e10cSrcweir 	Reference< XPropertySet > xPropertySet = Reference< XPropertySet >( m_xPathSettings, UNO_QUERY );
497*cdf0e10cSrcweir 	Reference< XPropertySetInfo > xPropSetInfo = xPropertySet->getPropertySetInfo();
498*cdf0e10cSrcweir 	Sequence< Property > aPathPropSeq = xPropSetInfo->getProperties();
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 	NameToHandleMap aTempHashMap;
501*cdf0e10cSrcweir 	for ( sal_Int32 n = 0; n < aPathPropSeq.getLength(); n++ )
502*cdf0e10cSrcweir 	{
503*cdf0e10cSrcweir 		const com::sun::star::beans::Property& aProperty = aPathPropSeq[n];
504*cdf0e10cSrcweir 		aTempHashMap.insert( NameToHandleMap::value_type( aProperty.Name, aProperty.Handle ));
505*cdf0e10cSrcweir 	}
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir 	// Create mapping between internal enum (SvtPathOptions::Pathes) and property handle
508*cdf0e10cSrcweir 	sal_Int32 nCount = sizeof( aPropNames ) / sizeof( PropertyStruct );
509*cdf0e10cSrcweir 	sal_Int32 i;
510*cdf0e10cSrcweir 	for ( i = 0; i < nCount; i++ )
511*cdf0e10cSrcweir 	{
512*cdf0e10cSrcweir 		NameToHandleMap::const_iterator pIter =
513*cdf0e10cSrcweir 			aTempHashMap.find( rtl::OUString::createFromAscii( aPropNames[i].pPropName ));
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir 		if ( pIter != aTempHashMap.end() )
516*cdf0e10cSrcweir 		{
517*cdf0e10cSrcweir 			sal_Int32 nHandle	= pIter->second;
518*cdf0e10cSrcweir 			sal_Int32 nEnum		= aPropNames[i].ePath;
519*cdf0e10cSrcweir 			m_aMapEnumToPropHandle.insert( EnumToHandleMap::value_type( nEnum, nHandle ));
520*cdf0e10cSrcweir 		}
521*cdf0e10cSrcweir 	}
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir 	// Create hash map for path variables that need a system path as a return value!
524*cdf0e10cSrcweir 	nCount = sizeof( aVarNameAttribute ) / sizeof( VarNameAttribute );
525*cdf0e10cSrcweir 	for ( i = 0; i < nCount; i++ )
526*cdf0e10cSrcweir 	{
527*cdf0e10cSrcweir 		m_aMapVarNamesToEnum.insert( VarNameToEnumMap::value_type(
528*cdf0e10cSrcweir 				OUString::createFromAscii( aVarNameAttribute[i].pVarName ),
529*cdf0e10cSrcweir 				aVarNameAttribute[i].eVarProperty ));
530*cdf0e10cSrcweir 	}
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir 	// Set language type!
533*cdf0e10cSrcweir 	Any aLocale = ConfigManager::GetConfigManager()->GetDirectConfigProperty( ConfigManager::LOCALE );
534*cdf0e10cSrcweir 	OUString aLocaleStr;
535*cdf0e10cSrcweir 	if ( aLocale >>= aLocaleStr )
536*cdf0e10cSrcweir     {
537*cdf0e10cSrcweir         sal_Int32 nIndex = 0;
538*cdf0e10cSrcweir         m_aLocale.Language = aLocaleStr.getToken(0, '-', nIndex );
539*cdf0e10cSrcweir         m_aLocale.Country = aLocaleStr.getToken(0, '-', nIndex );
540*cdf0e10cSrcweir         m_aLocale.Variant = aLocaleStr.getToken(0, '-', nIndex );
541*cdf0e10cSrcweir     }
542*cdf0e10cSrcweir 	else
543*cdf0e10cSrcweir 	{
544*cdf0e10cSrcweir 		DBG_ERRORFILE( "wrong any type" );
545*cdf0e10cSrcweir         m_aLocale.Language = OStringToOUString(OString("en"), RTL_TEXTENCODING_UTF8);
546*cdf0e10cSrcweir         m_aLocale.Country =  OStringToOUString(OString("US"), RTL_TEXTENCODING_UTF8);
547*cdf0e10cSrcweir         m_aLocale.Variant =  OStringToOUString(OString(""), RTL_TEXTENCODING_UTF8);
548*cdf0e10cSrcweir 	}
549*cdf0e10cSrcweir }
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir // -----------------------------------------------------------------------
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir // class SvtPathOptions --------------------------------------------------
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir namespace { struct lclMutex : public rtl::Static< ::osl::Mutex, lclMutex > {}; }
556*cdf0e10cSrcweir 
557*cdf0e10cSrcweir SvtPathOptions::SvtPathOptions()
558*cdf0e10cSrcweir {
559*cdf0e10cSrcweir     // Global access, must be guarded (multithreading)
560*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( lclMutex::get() );
561*cdf0e10cSrcweir     if ( !pOptions )
562*cdf0e10cSrcweir 	{
563*cdf0e10cSrcweir         pOptions = new SvtPathOptions_Impl;
564*cdf0e10cSrcweir         ItemHolder1::holdConfigItem(E_PATHOPTIONS);
565*cdf0e10cSrcweir 	}
566*cdf0e10cSrcweir     ++nRefCount;
567*cdf0e10cSrcweir     pImp = pOptions;
568*cdf0e10cSrcweir }
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir // -----------------------------------------------------------------------
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir SvtPathOptions::~SvtPathOptions()
573*cdf0e10cSrcweir {
574*cdf0e10cSrcweir     // Global access, must be guarded (multithreading)
575*cdf0e10cSrcweir     ::osl::MutexGuard aGuard( lclMutex::get() );
576*cdf0e10cSrcweir     if ( !--nRefCount )
577*cdf0e10cSrcweir 	{
578*cdf0e10cSrcweir         DELETEZ( pOptions );
579*cdf0e10cSrcweir 	}
580*cdf0e10cSrcweir }
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir // -----------------------------------------------------------------------
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir const String& SvtPathOptions::GetAddinPath() const
585*cdf0e10cSrcweir {
586*cdf0e10cSrcweir 	return pImp->GetAddinPath();
587*cdf0e10cSrcweir }
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir // -----------------------------------------------------------------------
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir const String& SvtPathOptions::GetAutoCorrectPath() const
592*cdf0e10cSrcweir {
593*cdf0e10cSrcweir 	return pImp->GetAutoCorrectPath();
594*cdf0e10cSrcweir }
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir // -----------------------------------------------------------------------
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir const String& SvtPathOptions::GetAutoTextPath() const
599*cdf0e10cSrcweir {
600*cdf0e10cSrcweir 	return pImp->GetAutoTextPath();
601*cdf0e10cSrcweir }
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir // -----------------------------------------------------------------------
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir const String& SvtPathOptions::GetBackupPath() const
606*cdf0e10cSrcweir {
607*cdf0e10cSrcweir 	return pImp->GetBackupPath();
608*cdf0e10cSrcweir }
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir // -----------------------------------------------------------------------
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir const String& SvtPathOptions::GetBasicPath() const
613*cdf0e10cSrcweir {
614*cdf0e10cSrcweir 	return pImp->GetBasicPath();
615*cdf0e10cSrcweir }
616*cdf0e10cSrcweir 
617*cdf0e10cSrcweir // -----------------------------------------------------------------------
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir const String& SvtPathOptions::GetBitmapPath() const
620*cdf0e10cSrcweir {
621*cdf0e10cSrcweir 	return pImp->GetBitmapPath();
622*cdf0e10cSrcweir }
623*cdf0e10cSrcweir 
624*cdf0e10cSrcweir // -----------------------------------------------------------------------
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir const String& SvtPathOptions::GetConfigPath() const
627*cdf0e10cSrcweir {
628*cdf0e10cSrcweir 	return pImp->GetConfigPath();
629*cdf0e10cSrcweir }
630*cdf0e10cSrcweir 
631*cdf0e10cSrcweir // -----------------------------------------------------------------------
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir const String& SvtPathOptions::GetDictionaryPath() const
634*cdf0e10cSrcweir {
635*cdf0e10cSrcweir 	return pImp->GetDictionaryPath();
636*cdf0e10cSrcweir }
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir // -----------------------------------------------------------------------
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir const String& SvtPathOptions::GetFavoritesPath() const
641*cdf0e10cSrcweir {
642*cdf0e10cSrcweir 	return pImp->GetFavoritesPath();
643*cdf0e10cSrcweir }
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir // -----------------------------------------------------------------------
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir const String& SvtPathOptions::GetFilterPath() const
648*cdf0e10cSrcweir {
649*cdf0e10cSrcweir 	return pImp->GetFilterPath();
650*cdf0e10cSrcweir }
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir // -----------------------------------------------------------------------
653*cdf0e10cSrcweir 
654*cdf0e10cSrcweir const String& SvtPathOptions::GetGalleryPath() const
655*cdf0e10cSrcweir {
656*cdf0e10cSrcweir 	return pImp->GetGalleryPath();
657*cdf0e10cSrcweir }
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir // -----------------------------------------------------------------------
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir const String& SvtPathOptions::GetGraphicPath() const
662*cdf0e10cSrcweir {
663*cdf0e10cSrcweir 	return pImp->GetGraphicPath();
664*cdf0e10cSrcweir }
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir // -----------------------------------------------------------------------
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir const String& SvtPathOptions::GetHelpPath() const
669*cdf0e10cSrcweir {
670*cdf0e10cSrcweir 	return pImp->GetHelpPath();
671*cdf0e10cSrcweir }
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir // -----------------------------------------------------------------------
674*cdf0e10cSrcweir 
675*cdf0e10cSrcweir const String& SvtPathOptions::GetLinguisticPath() const
676*cdf0e10cSrcweir {
677*cdf0e10cSrcweir 	return pImp->GetLinguisticPath();
678*cdf0e10cSrcweir }
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir // -----------------------------------------------------------------------
681*cdf0e10cSrcweir 
682*cdf0e10cSrcweir const String& SvtPathOptions::GetFingerprintPath() const
683*cdf0e10cSrcweir {
684*cdf0e10cSrcweir     return pImp->GetFingerprintPath();
685*cdf0e10cSrcweir }
686*cdf0e10cSrcweir 
687*cdf0e10cSrcweir // -----------------------------------------------------------------------
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir const String& SvtPathOptions::GetModulePath() const
690*cdf0e10cSrcweir {
691*cdf0e10cSrcweir 	return pImp->GetModulePath();
692*cdf0e10cSrcweir }
693*cdf0e10cSrcweir 
694*cdf0e10cSrcweir // -----------------------------------------------------------------------
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir const String& SvtPathOptions::GetPalettePath() const
697*cdf0e10cSrcweir {
698*cdf0e10cSrcweir 	return pImp->GetPalettePath();
699*cdf0e10cSrcweir }
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir // -----------------------------------------------------------------------
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir const String& SvtPathOptions::GetPluginPath() const
704*cdf0e10cSrcweir {
705*cdf0e10cSrcweir 	return pImp->GetPluginPath();
706*cdf0e10cSrcweir }
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir // -----------------------------------------------------------------------
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir const String& SvtPathOptions::GetStoragePath() const
711*cdf0e10cSrcweir {
712*cdf0e10cSrcweir 	return pImp->GetStoragePath();
713*cdf0e10cSrcweir }
714*cdf0e10cSrcweir 
715*cdf0e10cSrcweir // -----------------------------------------------------------------------
716*cdf0e10cSrcweir 
717*cdf0e10cSrcweir const String& SvtPathOptions::GetTempPath() const
718*cdf0e10cSrcweir {
719*cdf0e10cSrcweir 	return pImp->GetTempPath();
720*cdf0e10cSrcweir }
721*cdf0e10cSrcweir 
722*cdf0e10cSrcweir // -----------------------------------------------------------------------
723*cdf0e10cSrcweir 
724*cdf0e10cSrcweir const String& SvtPathOptions::GetTemplatePath() const
725*cdf0e10cSrcweir {
726*cdf0e10cSrcweir 	return pImp->GetTemplatePath();
727*cdf0e10cSrcweir }
728*cdf0e10cSrcweir 
729*cdf0e10cSrcweir // -----------------------------------------------------------------------
730*cdf0e10cSrcweir 
731*cdf0e10cSrcweir const String& SvtPathOptions::GetUserConfigPath() const
732*cdf0e10cSrcweir {
733*cdf0e10cSrcweir 	return pImp->GetUserConfigPath();
734*cdf0e10cSrcweir }
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir const String& SvtPathOptions::GetUIConfigPath() const
737*cdf0e10cSrcweir {
738*cdf0e10cSrcweir     return pImp->GetUIConfigPath();
739*cdf0e10cSrcweir }
740*cdf0e10cSrcweir 
741*cdf0e10cSrcweir // -----------------------------------------------------------------------
742*cdf0e10cSrcweir 
743*cdf0e10cSrcweir const String& SvtPathOptions::GetWorkPath() const
744*cdf0e10cSrcweir {
745*cdf0e10cSrcweir 	return pImp->GetWorkPath();
746*cdf0e10cSrcweir }
747*cdf0e10cSrcweir 
748*cdf0e10cSrcweir // -----------------------------------------------------------------------
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir void SvtPathOptions::SetAddinPath( const String& rPath )
751*cdf0e10cSrcweir {
752*cdf0e10cSrcweir 	pImp->SetAddinPath( rPath );
753*cdf0e10cSrcweir }
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir // -----------------------------------------------------------------------
756*cdf0e10cSrcweir 
757*cdf0e10cSrcweir void SvtPathOptions::SetAutoCorrectPath( const String& rPath )
758*cdf0e10cSrcweir {
759*cdf0e10cSrcweir 	pImp->SetAutoCorrectPath( rPath );
760*cdf0e10cSrcweir }
761*cdf0e10cSrcweir 
762*cdf0e10cSrcweir // -----------------------------------------------------------------------
763*cdf0e10cSrcweir 
764*cdf0e10cSrcweir void SvtPathOptions::SetAutoTextPath( const String& rPath )
765*cdf0e10cSrcweir {
766*cdf0e10cSrcweir 	pImp->SetAutoTextPath( rPath );
767*cdf0e10cSrcweir }
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir // -----------------------------------------------------------------------
770*cdf0e10cSrcweir 
771*cdf0e10cSrcweir void SvtPathOptions::SetBackupPath( const String& rPath )
772*cdf0e10cSrcweir {
773*cdf0e10cSrcweir 	pImp->SetBackupPath( rPath );
774*cdf0e10cSrcweir }
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir // -----------------------------------------------------------------------
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir void SvtPathOptions::SetBasicPath( const String& rPath )
779*cdf0e10cSrcweir {
780*cdf0e10cSrcweir 	pImp->SetBasicPath( rPath );
781*cdf0e10cSrcweir }
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir // -----------------------------------------------------------------------
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir void SvtPathOptions::SetBitmapPath( const String& rPath )
786*cdf0e10cSrcweir {
787*cdf0e10cSrcweir 	pImp->SetBitmapPath( rPath );
788*cdf0e10cSrcweir }
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir // -----------------------------------------------------------------------
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir void SvtPathOptions::SetConfigPath( const String& rPath )
793*cdf0e10cSrcweir {
794*cdf0e10cSrcweir 	pImp->SetConfigPath( rPath );
795*cdf0e10cSrcweir }
796*cdf0e10cSrcweir 
797*cdf0e10cSrcweir // -----------------------------------------------------------------------
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir void SvtPathOptions::SetDictionaryPath( const String& rPath )
800*cdf0e10cSrcweir {
801*cdf0e10cSrcweir 	pImp->SetDictionaryPath( rPath );
802*cdf0e10cSrcweir }
803*cdf0e10cSrcweir 
804*cdf0e10cSrcweir // -----------------------------------------------------------------------
805*cdf0e10cSrcweir 
806*cdf0e10cSrcweir void SvtPathOptions::SetFavoritesPath( const String& rPath )
807*cdf0e10cSrcweir {
808*cdf0e10cSrcweir 	pImp->SetFavoritesPath( rPath );
809*cdf0e10cSrcweir }
810*cdf0e10cSrcweir 
811*cdf0e10cSrcweir // -----------------------------------------------------------------------
812*cdf0e10cSrcweir 
813*cdf0e10cSrcweir void SvtPathOptions::SetFilterPath( const String& rPath )
814*cdf0e10cSrcweir {
815*cdf0e10cSrcweir 	pImp->SetFilterPath( rPath );
816*cdf0e10cSrcweir }
817*cdf0e10cSrcweir 
818*cdf0e10cSrcweir // -----------------------------------------------------------------------
819*cdf0e10cSrcweir 
820*cdf0e10cSrcweir void SvtPathOptions::SetGalleryPath( const String& rPath )
821*cdf0e10cSrcweir {
822*cdf0e10cSrcweir 	pImp->SetGalleryPath( rPath );
823*cdf0e10cSrcweir }
824*cdf0e10cSrcweir 
825*cdf0e10cSrcweir // -----------------------------------------------------------------------
826*cdf0e10cSrcweir 
827*cdf0e10cSrcweir void SvtPathOptions::SetGraphicPath( const String& rPath )
828*cdf0e10cSrcweir {
829*cdf0e10cSrcweir 	pImp->SetGraphicPath( rPath );
830*cdf0e10cSrcweir }
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir // -----------------------------------------------------------------------
833*cdf0e10cSrcweir 
834*cdf0e10cSrcweir void SvtPathOptions::SetHelpPath( const String& rPath )
835*cdf0e10cSrcweir {
836*cdf0e10cSrcweir 	pImp->SetHelpPath( rPath );
837*cdf0e10cSrcweir }
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir // -----------------------------------------------------------------------
840*cdf0e10cSrcweir 
841*cdf0e10cSrcweir void SvtPathOptions::SetLinguisticPath( const String& rPath )
842*cdf0e10cSrcweir {
843*cdf0e10cSrcweir 	pImp->SetLinguisticPath( rPath );
844*cdf0e10cSrcweir }
845*cdf0e10cSrcweir 
846*cdf0e10cSrcweir // -----------------------------------------------------------------------
847*cdf0e10cSrcweir 
848*cdf0e10cSrcweir void SvtPathOptions::SetModulePath( const String& rPath )
849*cdf0e10cSrcweir {
850*cdf0e10cSrcweir 	pImp->SetModulePath( rPath );
851*cdf0e10cSrcweir }
852*cdf0e10cSrcweir 
853*cdf0e10cSrcweir // -----------------------------------------------------------------------
854*cdf0e10cSrcweir 
855*cdf0e10cSrcweir void SvtPathOptions::SetPalettePath( const String& rPath )
856*cdf0e10cSrcweir {
857*cdf0e10cSrcweir 	pImp->SetPalettePath( rPath );
858*cdf0e10cSrcweir }
859*cdf0e10cSrcweir 
860*cdf0e10cSrcweir // -----------------------------------------------------------------------
861*cdf0e10cSrcweir 
862*cdf0e10cSrcweir void SvtPathOptions::SetPluginPath( const String& rPath )
863*cdf0e10cSrcweir {
864*cdf0e10cSrcweir 	pImp->SetPluginPath( rPath );
865*cdf0e10cSrcweir }
866*cdf0e10cSrcweir 
867*cdf0e10cSrcweir // -----------------------------------------------------------------------
868*cdf0e10cSrcweir 
869*cdf0e10cSrcweir void SvtPathOptions::SetStoragePath( const String& rPath )
870*cdf0e10cSrcweir {
871*cdf0e10cSrcweir 	pImp->SetStoragePath( rPath );
872*cdf0e10cSrcweir }
873*cdf0e10cSrcweir 
874*cdf0e10cSrcweir // -----------------------------------------------------------------------
875*cdf0e10cSrcweir 
876*cdf0e10cSrcweir void SvtPathOptions::SetTempPath( const String& rPath )
877*cdf0e10cSrcweir {
878*cdf0e10cSrcweir 	pImp->SetTempPath( rPath );
879*cdf0e10cSrcweir }
880*cdf0e10cSrcweir 
881*cdf0e10cSrcweir // -----------------------------------------------------------------------
882*cdf0e10cSrcweir 
883*cdf0e10cSrcweir void SvtPathOptions::SetTemplatePath( const String& rPath )
884*cdf0e10cSrcweir {
885*cdf0e10cSrcweir 	pImp->SetTemplatePath( rPath );
886*cdf0e10cSrcweir }
887*cdf0e10cSrcweir 
888*cdf0e10cSrcweir // -----------------------------------------------------------------------
889*cdf0e10cSrcweir 
890*cdf0e10cSrcweir void SvtPathOptions::SetUserConfigPath( const String& rPath )
891*cdf0e10cSrcweir {
892*cdf0e10cSrcweir 	pImp->SetUserConfigPath( rPath );
893*cdf0e10cSrcweir }
894*cdf0e10cSrcweir 
895*cdf0e10cSrcweir // -----------------------------------------------------------------------
896*cdf0e10cSrcweir 
897*cdf0e10cSrcweir void SvtPathOptions::SetWorkPath( const String& rPath )
898*cdf0e10cSrcweir {
899*cdf0e10cSrcweir 	pImp->SetWorkPath( rPath );
900*cdf0e10cSrcweir }
901*cdf0e10cSrcweir 
902*cdf0e10cSrcweir // -----------------------------------------------------------------------
903*cdf0e10cSrcweir 
904*cdf0e10cSrcweir String SvtPathOptions::SubstituteVariable( const String& rVar ) const
905*cdf0e10cSrcweir {
906*cdf0e10cSrcweir     String aRet = pImp->SubstVar( rVar );
907*cdf0e10cSrcweir 	return aRet;
908*cdf0e10cSrcweir }
909*cdf0e10cSrcweir 
910*cdf0e10cSrcweir // -----------------------------------------------------------------------
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir String SvtPathOptions::ExpandMacros( const String& rPath ) const
913*cdf0e10cSrcweir {
914*cdf0e10cSrcweir     return pImp->ExpandMacros( rPath );
915*cdf0e10cSrcweir }
916*cdf0e10cSrcweir 
917*cdf0e10cSrcweir // -----------------------------------------------------------------------
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir String SvtPathOptions::UseVariable( const String& rPath ) const
920*cdf0e10cSrcweir {
921*cdf0e10cSrcweir     String aRet = pImp->UsePathVariables( rPath );
922*cdf0e10cSrcweir 	return aRet;
923*cdf0e10cSrcweir }
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir // -----------------------------------------------------------------------
926*cdf0e10cSrcweir 
927*cdf0e10cSrcweir sal_Bool SvtPathOptions::SearchFile( String& rIniFile, Pathes ePath )
928*cdf0e10cSrcweir {
929*cdf0e10cSrcweir 	// check parameter: empty inifile name?
930*cdf0e10cSrcweir 	if ( !rIniFile.Len() )
931*cdf0e10cSrcweir 	{
932*cdf0e10cSrcweir 		DBG_ERRORFILE( "SvtPathOptions::SearchFile(): invalid parameter" );
933*cdf0e10cSrcweir 		return sal_False;
934*cdf0e10cSrcweir 	}
935*cdf0e10cSrcweir 
936*cdf0e10cSrcweir     String aIniFile = pImp->SubstVar( rIniFile );
937*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
938*cdf0e10cSrcweir 
939*cdf0e10cSrcweir 	switch ( ePath )
940*cdf0e10cSrcweir 	{
941*cdf0e10cSrcweir 		case PATH_USERCONFIG:
942*cdf0e10cSrcweir 		{
943*cdf0e10cSrcweir             // path is a URL
944*cdf0e10cSrcweir 			bRet = sal_True;
945*cdf0e10cSrcweir             INetURLObject aObj( GetUserConfigPath() );
946*cdf0e10cSrcweir 			xub_StrLen i, nCount = aIniFile.GetTokenCount( '/' );
947*cdf0e10cSrcweir 			for ( i = 0; i < nCount; ++i )
948*cdf0e10cSrcweir 				aObj.insertName( aIniFile.GetToken( i, '/' ) );
949*cdf0e10cSrcweir 
950*cdf0e10cSrcweir             if ( !::utl::UCBContentHelper::Exists( aObj.GetMainURL( INetURLObject::NO_DECODE ) ) )
951*cdf0e10cSrcweir 			{
952*cdf0e10cSrcweir                 aObj.SetSmartURL( GetConfigPath() );
953*cdf0e10cSrcweir 				aObj.insertName( aIniFile );
954*cdf0e10cSrcweir                 bRet = ::utl::UCBContentHelper::Exists( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
955*cdf0e10cSrcweir 			}
956*cdf0e10cSrcweir 
957*cdf0e10cSrcweir 			if ( bRet )
958*cdf0e10cSrcweir 				rIniFile = aObj.GetMainURL( INetURLObject::NO_DECODE );
959*cdf0e10cSrcweir 
960*cdf0e10cSrcweir 			break;
961*cdf0e10cSrcweir 		}
962*cdf0e10cSrcweir 
963*cdf0e10cSrcweir 		default:
964*cdf0e10cSrcweir 		{
965*cdf0e10cSrcweir 			String aPath;
966*cdf0e10cSrcweir 			switch ( ePath )
967*cdf0e10cSrcweir 			{
968*cdf0e10cSrcweir 				case PATH_ADDIN:		aPath = GetAddinPath();			break;
969*cdf0e10cSrcweir 				case PATH_AUTOCORRECT:	aPath = GetAutoCorrectPath();	break;
970*cdf0e10cSrcweir 				case PATH_AUTOTEXT:		aPath = GetAutoTextPath();		break;
971*cdf0e10cSrcweir 				case PATH_BACKUP:		aPath = GetBackupPath();		break;
972*cdf0e10cSrcweir 				case PATH_BASIC:		aPath = GetBasicPath();			break;
973*cdf0e10cSrcweir 				case PATH_BITMAP:		aPath = GetBitmapPath();		break;
974*cdf0e10cSrcweir 				case PATH_CONFIG:		aPath = GetConfigPath();		break;
975*cdf0e10cSrcweir 				case PATH_DICTIONARY:	aPath = GetDictionaryPath();	break;
976*cdf0e10cSrcweir 				case PATH_FAVORITES:	aPath = GetFavoritesPath();		break;
977*cdf0e10cSrcweir 				case PATH_FILTER:		aPath = GetFilterPath();		break;
978*cdf0e10cSrcweir 				case PATH_GALLERY:		aPath = GetGalleryPath();		break;
979*cdf0e10cSrcweir 				case PATH_GRAPHIC:		aPath = GetGraphicPath();		break;
980*cdf0e10cSrcweir 				case PATH_HELP:			aPath = GetHelpPath();			break;
981*cdf0e10cSrcweir 				case PATH_LINGUISTIC:	aPath = GetLinguisticPath();	break;
982*cdf0e10cSrcweir 				case PATH_MODULE:		aPath = GetModulePath();		break;
983*cdf0e10cSrcweir 				case PATH_PALETTE:		aPath = GetPalettePath();		break;
984*cdf0e10cSrcweir 				case PATH_PLUGIN:		aPath = GetPluginPath();		break;
985*cdf0e10cSrcweir 				case PATH_STORAGE:		aPath = GetStoragePath();		break;
986*cdf0e10cSrcweir 				case PATH_TEMP:			aPath = GetTempPath();			break;
987*cdf0e10cSrcweir 				case PATH_TEMPLATE:		aPath = GetTemplatePath();      break;
988*cdf0e10cSrcweir 				case PATH_WORK:			aPath = GetWorkPath();			break;
989*cdf0e10cSrcweir                 case PATH_UICONFIG:     aPath = GetUIConfigPath();      break;
990*cdf0e10cSrcweir                 case PATH_FINGERPRINT:  aPath = GetFingerprintPath();   break;
991*cdf0e10cSrcweir 				case PATH_USERCONFIG:/*-Wall???*/			break;
992*cdf0e10cSrcweir                 case PATH_COUNT: /*-Wall???*/ break;
993*cdf0e10cSrcweir 			}
994*cdf0e10cSrcweir 
995*cdf0e10cSrcweir 			sal_uInt16 j, nIdx = 0, nTokenCount = aPath.GetTokenCount( SEARCHPATH_DELIMITER );
996*cdf0e10cSrcweir 			for ( j = 0; j < nTokenCount; ++j )
997*cdf0e10cSrcweir 			{
998*cdf0e10cSrcweir                 sal_Bool bIsURL = sal_True;
999*cdf0e10cSrcweir 				String aPathToken = aPath.GetToken( 0, SEARCHPATH_DELIMITER, nIdx );
1000*cdf0e10cSrcweir 				INetURLObject aObj( aPathToken );
1001*cdf0e10cSrcweir 				if ( aObj.HasError() )
1002*cdf0e10cSrcweir 				{
1003*cdf0e10cSrcweir                     bIsURL = sal_False;
1004*cdf0e10cSrcweir 					String aURL;
1005*cdf0e10cSrcweir 					if ( LocalFileHelper::ConvertPhysicalNameToURL( aPathToken, aURL ) )
1006*cdf0e10cSrcweir 						aObj.SetURL( aURL );
1007*cdf0e10cSrcweir 				}
1008*cdf0e10cSrcweir                 if ( aObj.GetProtocol() == INET_PROT_VND_SUN_STAR_EXPAND )
1009*cdf0e10cSrcweir                 {
1010*cdf0e10cSrcweir                     ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
1011*cdf0e10cSrcweir                     Reference< XMacroExpander > xMacroExpander( aContext.getSingleton( "com.sun.star.util.theMacroExpander" ), UNO_QUERY );
1012*cdf0e10cSrcweir                     OSL_ENSURE( xMacroExpander.is(), "SvtPathOptions::SearchFile: unable to access the MacroExpander singleton!" );
1013*cdf0e10cSrcweir                     if ( xMacroExpander.is() )
1014*cdf0e10cSrcweir                     {
1015*cdf0e10cSrcweir                         const ::rtl::OUString sExpandedPath = xMacroExpander->expandMacros( aObj.GetURLPath( INetURLObject::DECODE_WITH_CHARSET ) );
1016*cdf0e10cSrcweir                         aObj.SetURL( sExpandedPath );
1017*cdf0e10cSrcweir                     }
1018*cdf0e10cSrcweir                 }
1019*cdf0e10cSrcweir 
1020*cdf0e10cSrcweir 				xub_StrLen i, nCount = aIniFile.GetTokenCount( '/' );
1021*cdf0e10cSrcweir 				for ( i = 0; i < nCount; ++i )
1022*cdf0e10cSrcweir 					aObj.insertName( aIniFile.GetToken( i, '/' ) );
1023*cdf0e10cSrcweir                 bRet = ::utl::UCBContentHelper::Exists( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
1024*cdf0e10cSrcweir 
1025*cdf0e10cSrcweir 				if ( bRet )
1026*cdf0e10cSrcweir 				{
1027*cdf0e10cSrcweir                     if ( !bIsURL )
1028*cdf0e10cSrcweir                         ::utl::LocalFileHelper::ConvertURLToPhysicalName(
1029*cdf0e10cSrcweir 											aObj.GetMainURL( INetURLObject::NO_DECODE ), rIniFile );
1030*cdf0e10cSrcweir 					else
1031*cdf0e10cSrcweir 						rIniFile = aObj.GetMainURL( INetURLObject::NO_DECODE );
1032*cdf0e10cSrcweir 					break;
1033*cdf0e10cSrcweir 				}
1034*cdf0e10cSrcweir 			}
1035*cdf0e10cSrcweir 		}
1036*cdf0e10cSrcweir 	}
1037*cdf0e10cSrcweir 
1038*cdf0e10cSrcweir 	return bRet;
1039*cdf0e10cSrcweir }
1040*cdf0e10cSrcweir 
1041*cdf0e10cSrcweir // -----------------------------------------------------------------------
1042*cdf0e10cSrcweir 
1043*cdf0e10cSrcweir ::com::sun::star::lang::Locale SvtPathOptions::GetLocale() const
1044*cdf0e10cSrcweir {
1045*cdf0e10cSrcweir 	return pImp->GetLocale();
1046*cdf0e10cSrcweir }
1047*cdf0e10cSrcweir // -----------------------------------------------------------------------
1048*cdf0e10cSrcweir sal_Bool SvtPathOptions::IsPathReadonly(Pathes ePath)const
1049*cdf0e10cSrcweir {
1050*cdf0e10cSrcweir     return pImp->IsPathReadonly(ePath);
1051*cdf0e10cSrcweir }
1052*cdf0e10cSrcweir // -----------------------------------------------------------------------
1053*cdf0e10cSrcweir const String& SvtPathOptions::GetPath(Pathes ePath)const
1054*cdf0e10cSrcweir {
1055*cdf0e10cSrcweir     return pImp->GetPath(ePath);
1056*cdf0e10cSrcweir }
1057*cdf0e10cSrcweir // -----------------------------------------------------------------------
1058*cdf0e10cSrcweir void SvtPathOptions::SetPath( SvtPathOptions::Pathes ePath, const String& rNewPath )
1059*cdf0e10cSrcweir {
1060*cdf0e10cSrcweir     pImp->SetPath(ePath, rNewPath);
1061*cdf0e10cSrcweir }
1062*cdf0e10cSrcweir 
1063*cdf0e10cSrcweir // class PathService -----------------------------------------------------
1064*cdf0e10cSrcweir #include <com/sun/star/frame/XConfigManager.hpp>
1065*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
1066*cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
1067*cdf0e10cSrcweir 
1068*cdf0e10cSrcweir class PathService : public ::cppu::WeakImplHelper2< ::com::sun::star::frame::XConfigManager, ::com::sun::star::lang::XServiceInfo >
1069*cdf0e10cSrcweir {
1070*cdf0e10cSrcweir     virtual ::rtl::OUString	SAL_CALL	getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
1071*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL			supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
1072*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
1073*cdf0e10cSrcweir 										getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
1074*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL	substituteVariables( const ::rtl::OUString& sText ) throw(::com::sun::star::uno::RuntimeException);
1075*cdf0e10cSrcweir     virtual void SAL_CALL				addPropertyChangeListener( const ::rtl::OUString& sKeyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
1076*cdf0e10cSrcweir     virtual void SAL_CALL				removePropertyChangeListener( const ::rtl::OUString& sKeyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
1077*cdf0e10cSrcweir     virtual void SAL_CALL				flush(  ) throw(::com::sun::star::uno::RuntimeException);
1078*cdf0e10cSrcweir };
1079*cdf0e10cSrcweir 
1080*cdf0e10cSrcweir // class PathService -----------------------------------------------------
1081*cdf0e10cSrcweir 
1082*cdf0e10cSrcweir void SAL_CALL PathService::addPropertyChangeListener( const ::rtl::OUString&, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& ) throw(::com::sun::star::uno::RuntimeException) {}
1083*cdf0e10cSrcweir void SAL_CALL PathService::removePropertyChangeListener( const ::rtl::OUString&, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& ) throw(::com::sun::star::uno::RuntimeException) {}
1084*cdf0e10cSrcweir void SAL_CALL PathService::flush(  ) throw(::com::sun::star::uno::RuntimeException) {}
1085*cdf0e10cSrcweir 
1086*cdf0e10cSrcweir ::rtl::OUString SAL_CALL PathService::substituteVariables( const ::rtl::OUString& sText ) throw(::com::sun::star::uno::RuntimeException)
1087*cdf0e10cSrcweir {
1088*cdf0e10cSrcweir     return SvtPathOptions().SubstituteVariable( sText );
1089*cdf0e10cSrcweir }
1090*cdf0e10cSrcweir 
1091*cdf0e10cSrcweir ::rtl::OUString SAL_CALL PathService::getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException)
1092*cdf0e10cSrcweir {
1093*cdf0e10cSrcweir     return OUString::createFromAscii("com.sun.star.comp.unotools.PathService");
1094*cdf0e10cSrcweir }
1095*cdf0e10cSrcweir 
1096*cdf0e10cSrcweir sal_Bool SAL_CALL PathService::supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException)
1097*cdf0e10cSrcweir {
1098*cdf0e10cSrcweir     if ( ServiceName.compareToAscii("com.sun.star.config.SpecialConfigManager") == COMPARE_EQUAL )
1099*cdf0e10cSrcweir         return sal_True;
1100*cdf0e10cSrcweir     else
1101*cdf0e10cSrcweir         return sal_False;
1102*cdf0e10cSrcweir }
1103*cdf0e10cSrcweir 
1104*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL PathService::getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException)
1105*cdf0e10cSrcweir {
1106*cdf0e10cSrcweir     Sequence< OUString > aRet(1);
1107*cdf0e10cSrcweir     *aRet.getArray() = OUString::createFromAscii("com.sun.star.config.SpecialConfigManager");
1108*cdf0e10cSrcweir     return aRet;
1109*cdf0e10cSrcweir }
1110