26#include <com/sun/star/uno/Any.hxx>
27#include <com/sun/star/uno/Sequence.hxx>
28#include <osl/mutex.hxx>
29#include <osl/file.hxx>
34#include <com/sun/star/beans/XFastPropertySet.hpp>
35#include <com/sun/star/beans/XPropertySetInfo.hpp>
36#include <com/sun/star/util/thePathSettings.hpp>
37#include <com/sun/star/util/PathSubstitution.hpp>
38#include <com/sun/star/util/XStringSubstitution.hpp>
39#include <com/sun/star/util/theMacroExpander.hpp>
46#include <unordered_map>
55#define SEARCHPATH_DELIMITER ';'
56#define SIGN_STARTVARIABLE "$("
57#define SIGN_ENDVARIABLE ")"
60#define SUBSTITUTE_INSTPATH "$(instpath)"
61#define SUBSTITUTE_PROGPATH "$(progpath)"
62#define SUBSTITUTE_USERPATH "$(userpath)"
63#define SUBSTITUTE_PATH "$(path)"
65#define STRPOS_NOTFOUND -1
80 mutable std::unordered_map<SvtPathOptions::Paths, sal_Int32>
126 OUString
SubstVar(
const OUString& rVar )
const;
140 const char* pPropName;
144struct VarNameAttribute
146 const char* pVarName;
194 std::unique_lock aGuard(
m_aMutex );
214 osl::FileBase::getSystemPathFromFileURL( aPathValue, aResult );
215 aPathValue = aResult;
221 OUStringBuffer buf(aPathValue.getLength()*2);
222 for (sal_Int32
i = 0;;)
226 ctx, aPathValue.getToken(0,
';',
i)));
232 aPathValue = buf.makeStringAndClear();
238 catch (UnknownPropertyException &)
247 std::unique_lock aGuard(
m_aMutex );
263 osl::FileBase::getFileURLFromSystemPath( rNewPath, aResult );
269 aNewValue = rNewPath;
286 OUString sExpanded( rPath );
289 if ( aParser.
GetProtocol() == INetProtocol::VndSunStarExpand )
303 OUString aWorkText = rVar;
306 bool bConvertLocal =
false;
319 nLength = nEndPosition - nPosition + 1;
326 OUString aSubString = aWorkText.copy( nPosition,
nLength );
327 aSubString = aSubString.toAsciiLowerCase();
332 bConvertLocal =
true;
338 if ( nPosition + 1 > aWorkText.getLength() )
355 nLength = nEndPosition - nPosition + 1;
366 osl::FileBase::getSystemPathFromFileURL( aWorkText, aReturn );
388 for (
const css::beans::Property& aProperty : aPathPropSeq )
390 aTempHashMap.emplace(aProperty.Name, aProperty.Handle);
396 NameToHandleMap::const_iterator pIter =
397 aTempHashMap.find( OUString::createFromAscii(
p.pPropName ));
399 if ( pIter != aTempHashMap.end() )
401 sal_Int32
nHandle = pIter->second;
428 std::unique_lock aGuard( lclMutex() );
432 pImpl = std::make_shared<SvtPathOptions_Impl>();
442 std::unique_lock aGuard( lclMutex() );
449 return pImpl->GetAddinPath();
454 return pImpl->GetAutoCorrectPath();
459 return pImpl->GetAutoTextPath();
464 return pImpl->GetBackupPath();
469 return pImpl->GetBasicPath();
474 return pImpl->GetBitmapPath();
479 return pImpl->GetConfigPath();
484 return pImpl->GetDictionaryPath();
489 return pImpl->GetFavoritesPath();
494 return pImpl->GetFilterPath();
499 return pImpl->GetGalleryPath();
504 return pImpl->GetGraphicPath();
509 return pImpl->GetHelpPath();
514 return pImpl->GetLinguisticPath();
519 return pImpl->GetFingerprintPath();
524 return pImpl->GetNumbertextPath();
529 return pImpl->GetModulePath();
534 return pImpl->GetPalettePath();
539 return pImpl->GetIconsetPath();
544 return pImpl->GetPluginPath();
549 return pImpl->GetStoragePath();
554 return pImpl->GetTempPath();
559 return pImpl->GetTemplatePath();
564 return pImpl->GetUserConfigPath();
569 return pImpl->GetWorkPath();
574 return pImpl->GetClassificationPath();
579 pImpl->SetAutoTextPath( rPath );
584 pImpl->SetBasicPath( rPath );
589 pImpl->SetTempPath( rPath );
594 return pImpl->SubstVar( rVar );
599 return pImpl->ExpandMacros( rPath );
604 return pImpl->UsePathVariables( rPath );
610 if ( rIniFile.isEmpty() )
612 SAL_WARN(
"unotools.config",
"SvtPathOptions::SearchFile(): invalid parameter" );
616 OUString aIniFile =
pImpl->SubstVar( rIniFile );
627 sal_Int32 nIniIndex = 0;
630 std::u16string_view aToken =
o3tl::getToken(aIniFile, 0,
'/', nIniIndex );
633 while ( nIniIndex >= 0 );
685 sal_Int32 nPathIndex = 0;
695 if ( osl::FileBase::getFileURLFromSystemPath( aPathToken,
aURL )
696 == osl::FileBase::E_None )
699 if ( aObj.
GetProtocol() == INetProtocol::VndSunStarExpand )
703 aObj.
SetURL( sExpandedPath );
706 sal_Int32 nIniIndex = 0;
709 std::u16string_view aToken =
o3tl::getToken(aIniFile, 0,
'/', nIniIndex );
712 while ( nIniIndex >= 0 );
721 osl::FileBase::getSystemPathFromFileURL(
730 while ( nPathIndex >= 0 );
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool SetSmartURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
OUString GetURLPath(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool insertName(std::u16string_view rTheName, bool bAppendFinalSlash=false, sal_Int32 nIndex=LAST_SEGMENT, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
INetProtocol GetProtocol() const
bool SetURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
static void holdConfigItem(EItem eItem)
const OUString & GetTempPath()
const OUString & GetDictionaryPath()
void SetBasicPath(const OUString &rPath)
const OUString & GetNumbertextPath()
VarNameSet m_aSystemPathVarNames
const OUString & GetGalleryPath()
void SetTempPath(const OUString &rPath)
OUString ExpandMacros(const OUString &rPath) const
const OUString & GetAutoCorrectPath()
const OUString & GetModulePath()
std::unordered_map< SvtPathOptions::Paths, sal_Int32 > m_aMapEnumToPropHandle
Reference< XMacroExpander > m_xMacroExpander
const OUString & GetBasicPath()
OUString SubstVar(const OUString &rVar) const
const OUString & GetPalettePath()
const OUString & GetLinguisticPath()
OUString UsePathVariables(const OUString &rPath) const
Reference< XFastPropertySet > m_xPathSettings
const OUString & GetIconsetPath()
const OUString & GetFingerprintPath()
const OUString & GetHelpPath()
void SetAutoTextPath(const OUString &rPath)
const OUString & GetGraphicPath()
const OUString & GetAddinPath()
const OUString & GetWorkPath()
Reference< XStringSubstitution > m_xSubstVariables
const OUString & GetPluginPath()
const OUString & GetPath(SvtPathOptions::Paths)
const OUString & GetUserConfigPath()
void SetPath(SvtPathOptions::Paths, const OUString &rNewPath)
const OUString & GetFavoritesPath()
const OUString & GetUIConfigPath()
const OUString & GetConfigPath()
const OUString & GetBackupPath()
const OUString & GetAutoTextPath()
const OUString & GetTemplatePath()
o3tl::enumarray< SvtPathOptions::Paths, OUString > m_aPathArray
const OUString & GetStoragePath()
const OUString & GetFilterPath()
const OUString & GetClassificationPath()
const OUString & GetBitmapPath()
const OUString & GetConfigPath() const
bool SearchFile(OUString &rIniFile, Paths ePath=Paths::UserConfig)
const OUString & GetGalleryPath() const
const OUString & GetDictionaryPath() const
const OUString & GetHelpPath() const
void SetBasicPath(const OUString &rPath)
const OUString & GetNumbertextPath() const
const OUString & GetPalettePath() const
const OUString & GetStoragePath() const
const OUString & GetFilterPath() const
const OUString & GetFingerprintPath() const
const OUString & GetAutoCorrectPath() const
OUString UseVariable(const OUString &rVar) const
const OUString & GetIconsetPath() const
const OUString & GetGraphicPath() const
OUString ExpandMacros(const OUString &rPath) const
OUString SubstituteVariable(const OUString &rVar) const
void SetTempPath(const OUString &rPath)
virtual ~SvtPathOptions() override
const OUString & GetTemplatePath() const
const OUString & GetClassificationPath() const
const OUString & GetLinguisticPath() const
const OUString & GetWorkPath() const
const OUString & GetFavoritesPath() const
std::shared_ptr< SvtPathOptions_Impl > pImpl
const OUString & GetModulePath() const
void SetAutoTextPath(const OUString &rPath)
const OUString & GetPluginPath() const
const OUString & GetAutoTextPath() const
const OUString & GetBitmapPath() const
const OUString & GetAddinPath() const
const OUString & GetBackupPath() const
const OUString & GetBasicPath() const
const OUString & GetTempPath() const
const OUString & GetUserConfigPath() const
#define TOOLS_WARN_EXCEPTION(area, stream)
#define SAL_WARN(area, stream)
OUString get(TranslateId sContextAndId, const std::locale &loc)
COMPHELPER_DLLPUBLIC OUString getExpandedUri(css::uno::Reference< css::uno::XComponentContext > const &context, OUString const &uri)
Reference< XComponentContext > getProcessComponentContext()
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
UNOTOOLS_DLLPUBLIC bool Exists(OUString const &url)
#define SIGN_STARTVARIABLE
const PropertyStruct aPropNames[]
#define SUBSTITUTE_INSTPATH
#define SEARCHPATH_DELIMITER
#define SUBSTITUTE_USERPATH
static std::weak_ptr< SvtPathOptions_Impl > g_pOptions
const VarNameAttribute aVarNameAttribute[]
std::unordered_map< OUString, sal_Int32 > NameToHandleMap
std::set< OUString > VarNameSet
#define SUBSTITUTE_PROGPATH