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