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