From a5216cf1eb647862f377bed9b9a447e8bccf338f Mon Sep 17 00:00:00 2001 From: Noel Date: Wed, 2 Dec 2020 09:41:10 +0200 Subject: convert SvtPathOptions::Paths to scoped enum Change-Id: I2e6cab798309a1bc2ade00661bc95dd5ae20f748 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107045 Tested-by: Jenkins Reviewed-by: Noel Grandin --- basic/source/basmgr/basmgr.cxx | 2 +- cui/source/inc/optpath.hxx | 5 +- cui/source/options/optpath.cxx | 105 ++++++------ include/unotools/defaultoptions.hxx | 3 +- include/unotools/pathoptions.hxx | 62 +++---- sd/source/filter/ppt/pptin.cxx | 4 +- sd/source/filter/ppt/propread.cxx | 2 +- sd/source/filter/ppt/propread.hxx | 4 +- sfx2/source/appl/appcfg.cxx | 97 +++++------ sw/source/filter/html/swhtml.cxx | 4 +- sw/source/ui/index/cnttab.cxx | 2 +- unotools/source/config/defaultoptions.cxx | 62 +++---- unotools/source/config/pathoptions.cxx | 260 +++++++++++++++--------------- 13 files changed, 306 insertions(+), 306 deletions(-) diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index 50ff14effade..77f5939cd9d0 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -715,7 +715,7 @@ void BasicManager::LoadBasicManager( SotStorage& rStorage, const OUString& rBase OUString aSearchFile = pInfo->GetRelStorageName(); OUString aSearchFileOldFormat(aSearchFile); SvtPathOptions aPathCFG; - if( aPathCFG.SearchFile( aSearchFileOldFormat, SvtPathOptions::PATH_BASIC ) ) + if( aPathCFG.SearchFile( aSearchFileOldFormat, SvtPathOptions::Paths::Basic ) ) { pInfo->SetStorageName( aSearchFile ); } diff --git a/cui/source/inc/optpath.hxx b/cui/source/inc/optpath.hxx index 4447c98425b9..d4eca9c83413 100644 --- a/cui/source/inc/optpath.hxx +++ b/cui/source/inc/optpath.hxx @@ -23,6 +23,7 @@ #include #include +#include // forward --------------------------------------------------------------- struct OptPath_Impl; @@ -51,9 +52,9 @@ private: DECL_LINK(DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void); - void GetPathList( sal_uInt16 _nPathHandle, OUString& _rInternalPath, + void GetPathList( SvtPathOptions::Paths _nPathHandle, OUString& _rInternalPath, OUString& _rUserPath, OUString& _rWritablePath, bool& _rReadOnly ); - void SetPathList( sal_uInt16 _nPathHandle, + void SetPathList( SvtPathOptions::Paths _nPathHandle, const OUString& _rUserPath, const OUString& _rWritablePath ); public: diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx index 45b2c14d5c0d..b5cf2dc2378b 100644 --- a/cui/source/options/optpath.cxx +++ b/cui/source/options/optpath.cxx @@ -76,13 +76,13 @@ namespace { struct PathUserData_Impl { - sal_uInt16 nRealId; + SvtPathOptions::Paths nRealId; SfxItemState eState; OUString sUserPath; OUString sWritablePath; bool bReadOnly; - explicit PathUserData_Impl(sal_uInt16 nId) + explicit PathUserData_Impl(SvtPathOptions::Paths nId) : nRealId(nId) , eState(SfxItemState::UNKNOWN) , bReadOnly(false) @@ -92,7 +92,7 @@ struct PathUserData_Impl struct Handle2CfgNameMapping_Impl { - sal_uInt16 m_nHandle; + SvtPathOptions::Paths m_nHandle; const char* m_pCfgName; }; @@ -100,27 +100,27 @@ struct Handle2CfgNameMapping_Impl Handle2CfgNameMapping_Impl const Hdl2CfgMap_Impl[] = { - { SvtPathOptions::PATH_AUTOCORRECT, "AutoCorrect" }, - { SvtPathOptions::PATH_AUTOTEXT, "AutoText" }, - { SvtPathOptions::PATH_BACKUP, "Backup" }, - { SvtPathOptions::PATH_GALLERY, "Gallery" }, - { SvtPathOptions::PATH_GRAPHIC, "Graphic" }, - { SvtPathOptions::PATH_TEMP, "Temp" }, - { SvtPathOptions::PATH_TEMPLATE, "Template" }, - { SvtPathOptions::PATH_WORK, "Work" }, - { SvtPathOptions::PATH_DICTIONARY, "Dictionary" }, - { SvtPathOptions::PATH_CLASSIFICATION, "Classification" }, + { SvtPathOptions::Paths::AutoCorrect, "AutoCorrect" }, + { SvtPathOptions::Paths::AutoText, "AutoText" }, + { SvtPathOptions::Paths::Backup, "Backup" }, + { SvtPathOptions::Paths::Gallery, "Gallery" }, + { SvtPathOptions::Paths::Graphic, "Graphic" }, + { SvtPathOptions::Paths::Temp, "Temp" }, + { SvtPathOptions::Paths::Template, "Template" }, + { SvtPathOptions::Paths::Work, "Work" }, + { SvtPathOptions::Paths::Dictionary, "Dictionary" }, + { SvtPathOptions::Paths::Classification, "Classification" }, #if OSL_DEBUG_LEVEL > 1 - { SvtPathOptions::PATH_LINGUISTIC, "Linguistic" }, + { SvtPathOptions::Paths::Linguistic, "Linguistic" }, #endif - { USHRT_MAX, nullptr } + { SvtPathOptions::Paths::LAST, nullptr } }; -static OUString getCfgName_Impl( sal_uInt16 _nHandle ) +static OUString getCfgName_Impl( SvtPathOptions::Paths _nHandle ) { OUString sCfgName; sal_uInt16 nIndex = 0; - while ( Hdl2CfgMap_Impl[ nIndex ].m_nHandle != USHRT_MAX ) + while ( Hdl2CfgMap_Impl[ nIndex ].m_nHandle != SvtPathOptions::Paths::LAST ) { if ( Hdl2CfgMap_Impl[ nIndex ].m_nHandle == _nHandle ) { @@ -159,22 +159,22 @@ static OUString Convert_Impl( const OUString& rValue ) // functions ------------------------------------------------------------- -static bool IsMultiPath_Impl( const sal_uInt16 nIndex ) +static bool IsMultiPath_Impl( const SvtPathOptions::Paths nIndex ) { #if OSL_DEBUG_LEVEL > 1 - return ( SvtPathOptions::PATH_AUTOCORRECT == nIndex || - SvtPathOptions::PATH_AUTOTEXT == nIndex || - SvtPathOptions::PATH_BASIC == nIndex || - SvtPathOptions::PATH_GALLERY == nIndex || - SvtPathOptions::PATH_TEMPLATE == nIndex ); + return ( SvtPathOptions::Paths::AutoCorrect == nIndex || + SvtPathOptions::Paths::AutoText == nIndex || + SvtPathOptions::Paths::Basic == nIndex || + SvtPathOptions::Paths::Gallery == nIndex || + SvtPathOptions::Paths::Template == nIndex ); #else - return ( SvtPathOptions::PATH_AUTOCORRECT == nIndex || - SvtPathOptions::PATH_AUTOTEXT == nIndex || - SvtPathOptions::PATH_BASIC == nIndex || - SvtPathOptions::PATH_GALLERY == nIndex || - SvtPathOptions::PATH_TEMPLATE == nIndex || - SvtPathOptions::PATH_LINGUISTIC == nIndex || - SvtPathOptions::PATH_DICTIONARY == nIndex ); + return ( SvtPathOptions::Paths::AutoCorrect == nIndex || + SvtPathOptions::Paths::AutoText == nIndex || + SvtPathOptions::Paths::Basic == nIndex || + SvtPathOptions::Paths::Gallery == nIndex || + SvtPathOptions::Paths::Template == nIndex || + SvtPathOptions::Paths::Linguistic == nIndex || + SvtPathOptions::Paths::Dictionary == nIndex ); #endif } @@ -218,7 +218,7 @@ bool SvxPathTabPage::FillItemSet( SfxItemSet* ) for (int i = 0, nEntryCount = m_xPathBox->n_children(); i < nEntryCount; ++i) { PathUserData_Impl* pPathImpl = reinterpret_cast(m_xPathBox->get_id(i).toInt64()); - sal_uInt16 nRealId = pPathImpl->nRealId; + SvtPathOptions::Paths nRealId = pPathImpl->nRealId; if (pPathImpl->eState == SfxItemState::SET) SetPathList( nRealId, pPathImpl->sUserPath, pPathImpl->sWritablePath ); } @@ -230,52 +230,53 @@ void SvxPathTabPage::Reset( const SfxItemSet* ) m_xPathBox->clear(); std::unique_ptr xIter = m_xPathBox->make_iterator(); - for( sal_uInt16 i = 0; i <= sal_uInt16(SvtPathOptions::PATH_CLASSIFICATION); ++i ) + for( sal_uInt16 i = 0; i <= sal_uInt16(SvtPathOptions::Paths::Classification); ++i ) { // only writer uses autotext - if ( i == SvtPathOptions::PATH_AUTOTEXT + if ( static_cast(i) == SvtPathOptions::Paths::AutoText && !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::EModule::WRITER ) ) continue; const char* pId = nullptr; - switch (i) + switch (static_cast(i)) { - case SvtPathOptions::PATH_AUTOCORRECT: + case SvtPathOptions::Paths::AutoCorrect: pId = RID_SVXSTR_KEY_AUTOCORRECT_DIR; break; - case SvtPathOptions::PATH_AUTOTEXT: + case SvtPathOptions::Paths::AutoText: pId = RID_SVXSTR_KEY_GLOSSARY_PATH; break; - case SvtPathOptions::PATH_BACKUP: + case SvtPathOptions::Paths::Backup: pId = RID_SVXSTR_KEY_BACKUP_PATH; break; - case SvtPathOptions::PATH_GALLERY: + case SvtPathOptions::Paths::Gallery: pId = RID_SVXSTR_KEY_GALLERY_DIR; break; - case SvtPathOptions::PATH_GRAPHIC: + case SvtPathOptions::Paths::Graphic: pId = RID_SVXSTR_KEY_GRAPHICS_PATH; break; - case SvtPathOptions::PATH_TEMP: + case SvtPathOptions::Paths::Temp: pId = RID_SVXSTR_KEY_TEMP_PATH; break; - case SvtPathOptions::PATH_TEMPLATE: + case SvtPathOptions::Paths::Template: pId = RID_SVXSTR_KEY_TEMPLATE_PATH; break; - case SvtPathOptions::PATH_DICTIONARY: + case SvtPathOptions::Paths::Dictionary: pId = RID_SVXSTR_KEY_DICTIONARY_PATH; break; - case SvtPathOptions::PATH_CLASSIFICATION: + case SvtPathOptions::Paths::Classification: pId = RID_SVXSTR_KEY_CLASSIFICATION_PATH; break; #if OSL_DEBUG_LEVEL > 1 - case SvtPathOptions::PATH_LINGUISTIC: + case SvtPathOptions::Paths::Linguistic: pId = RID_SVXSTR_KEY_LINGUISTIC_DIR; break; #endif - case SvtPathOptions::PATH_WORK: + case SvtPathOptions::Paths::Work: pId = RID_SVXSTR_KEY_WORK_PATH; break; + default: break; } if (pId) @@ -287,7 +288,7 @@ void SvxPathTabPage::Reset( const SfxItemSet* ) OUString sInternal, sUser, sWritable; bool bReadOnly = false; - GetPathList( i, sInternal, sUser, sWritable, bReadOnly ); + GetPathList( static_cast(i), sInternal, sUser, sWritable, bReadOnly ); if (bReadOnly) m_xPathBox->set_image(*xIter, RID_SVXBMP_LOCK); @@ -308,7 +309,7 @@ void SvxPathTabPage::Reset( const SfxItemSet* ) m_xPathBox->set_sensitive(*xIter, !bReadOnly, 1); m_xPathBox->set_sensitive(*xIter, !bReadOnly, 2); - PathUserData_Impl* pPathImpl = new PathUserData_Impl(i); + PathUserData_Impl* pPathImpl = new PathUserData_Impl(static_cast(i)); pPathImpl->sUserPath = sUser; pPathImpl->sWritablePath = sWritable; pPathImpl->bReadOnly = bReadOnly; @@ -439,7 +440,7 @@ void SvxPathTabPage::ChangeCurrentEntry( const OUString& _rFolder ) m_xPathBox->set_text(nEntry, Convert_Impl(sNewPathStr), 1); pPathImpl->eState = SfxItemState::SET; pPathImpl->sWritablePath = sNewPathStr; - if ( SvtPathOptions::PATH_WORK == pPathImpl->nRealId ) + if ( SvtPathOptions::Paths::Work == pPathImpl->nRealId ) { // Remove view options entry so the new work path // will be used for the next open dialog. @@ -464,14 +465,14 @@ IMPL_LINK_NOARG(SvxPathTabPage, PathHdl_Impl, weld::Button&, void) if (!pPathImpl || pPathImpl->bReadOnly) return; - sal_uInt16 nPos = pPathImpl->nRealId; + SvtPathOptions::Paths nPos = pPathImpl->nRealId; OUString sInternal, sUser, sWritable; bool bPickFile = false; bool bReadOnly = false; GetPathList( pPathImpl->nRealId, sInternal, sUser, sWritable, bReadOnly ); sUser = pPathImpl->sUserPath; sWritable = pPathImpl->sWritablePath; - bPickFile = pPathImpl->nRealId == SvtPathOptions::PATH_CLASSIFICATION; + bPickFile = pPathImpl->nRealId == SvtPathOptions::Paths::Classification; if (IsMultiPath_Impl(nPos)) { @@ -583,7 +584,7 @@ IMPL_LINK( SvxPathTabPage, DialogClosedHdl, DialogClosedEvent*, pEvt, void ) } void SvxPathTabPage::GetPathList( - sal_uInt16 _nPathHandle, OUString& _rInternalPath, + SvtPathOptions::Paths _nPathHandle, OUString& _rInternalPath, OUString& _rUserPath, OUString& _rWritablePath, bool& _rReadOnly ) { OUString sCfgName = getCfgName_Impl( _nPathHandle ); @@ -648,7 +649,7 @@ void SvxPathTabPage::GetPathList( void SvxPathTabPage::SetPathList( - sal_uInt16 _nPathHandle, const OUString& _rUserPath, const OUString& _rWritablePath ) + SvtPathOptions::Paths _nPathHandle, const OUString& _rUserPath, const OUString& _rWritablePath ) { OUString sCfgName = getCfgName_Impl( _nPathHandle ); diff --git a/include/unotools/defaultoptions.hxx b/include/unotools/defaultoptions.hxx index 7d96f44f5034..6192522c5002 100644 --- a/include/unotools/defaultoptions.hxx +++ b/include/unotools/defaultoptions.hxx @@ -22,6 +22,7 @@ #include #include #include +#include #include class SvtDefaultOptions_Impl; @@ -35,7 +36,7 @@ public: SvtDefaultOptions(); virtual ~SvtDefaultOptions() override; - OUString GetDefaultPath(sal_uInt16 nId) const; + OUString GetDefaultPath(SvtPathOptions::Paths nId) const; }; #endif // INCLUDED_UNOTOOLS_DEFAULTOPTIONS_HXX diff --git a/include/unotools/pathoptions.hxx b/include/unotools/pathoptions.hxx index 5e68b8fe5932..6388a54bcc5f 100644 --- a/include/unotools/pathoptions.hxx +++ b/include/unotools/pathoptions.hxx @@ -37,38 +37,40 @@ private: std::shared_ptr pImpl; public: - enum Paths + + enum class Paths : sal_uInt16 { - PATH_ADDIN, - PATH_AUTOCORRECT, - PATH_AUTOTEXT, - PATH_BACKUP, - PATH_BASIC, - PATH_BITMAP, - PATH_CONFIG, - PATH_DICTIONARY, - PATH_FAVORITES, - PATH_FILTER, - PATH_GALLERY, - PATH_GRAPHIC, - PATH_HELP, - PATH_ICONSET, - PATH_LINGUISTIC, - PATH_MODULE, - PATH_PALETTE, - PATH_PLUGIN, - PATH_STORAGE, - PATH_TEMP, - PATH_TEMPLATE, - PATH_USERCONFIG, - PATH_WORK, - PATH_CLASSIFICATION, - PATH_UICONFIG, - PATH_FINGERPRINT, - PATH_NUMBERTEXT, - PATH_COUNT // should always be the last element + AddIn, + AutoCorrect, + AutoText, + Backup, + Basic, + Bitmap, + Config, + Dictionary, + Favorites, + Filter, + Gallery, + Graphic, + Help, + IconSet, + Linguistic, + Module, + Palette, + Plugin, + Storage, + Temp, + Template, + UserConfig, + Work, + Classification, + UIConfig, + Fingerprint, + NumberText, + LAST // should always be the last element }; + SvtPathOptions(); virtual ~SvtPathOptions() override; @@ -127,7 +129,7 @@ public: OUString SubstituteVariable( const OUString& rVar ) const; OUString ExpandMacros( const OUString& rPath ) const; OUString UseVariable( const OUString& rVar ) const; - bool SearchFile( OUString& rIniFile, Paths ePath = PATH_USERCONFIG ); + bool SearchFile( OUString& rIniFile, Paths ePath = Paths::UserConfig ); }; #endif // INCLUDED_UNOTOOLS_PATHOPTIONS_HXX diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx index 3883f9d50cfe..02a2b544215d 100644 --- a/sd/source/filter/ppt/pptin.cxx +++ b/sd/source/filter/ppt/pptin.cxx @@ -359,11 +359,11 @@ bool ImplSdPPTImport::Import() pSection = const_cast(pDInfoSec2->GetSection( aUserPropSetGUID )); if ( pSection ) { - Dictionary aDict; + PropDictionary aDict; pSection->GetDictionary(aDict); if (!aDict.empty()) { - Dictionary::const_iterator iter = aDict.find( OUString("_PID_HLINKS") ); + auto iter = aDict.find( OUString("_PID_HLINKS") ); if ( iter != aDict.end() ) { diff --git a/sd/source/filter/ppt/propread.cxx b/sd/source/filter/ppt/propread.cxx index 6a8416343d6d..2a1b4e440178 100644 --- a/sd/source/filter/ppt/propread.cxx +++ b/sd/source/filter/ppt/propread.cxx @@ -259,7 +259,7 @@ void Section::AddProperty( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBu } } -void Section::GetDictionary(Dictionary& rDict) +void Section::GetDictionary(PropDictionary& rDict) { auto iter = std::find_if(maEntries.begin(), maEntries.end(), [](const std::unique_ptr& rxEntry) { return rxEntry->mnId == 0; }); diff --git a/sd/source/filter/ppt/propread.hxx b/sd/source/filter/ppt/propread.hxx index 6ec04df7d9d4..f0edafb72802 100644 --- a/sd/source/filter/ppt/propread.hxx +++ b/sd/source/filter/ppt/propread.hxx @@ -81,7 +81,7 @@ #define VT_BYREF 0x4000 #define VT_TYPEMASK 0xFFF -typedef std::map Dictionary; +typedef std::map PropDictionary; struct PropEntry { @@ -126,7 +126,7 @@ class Section final Section& operator=( const Section& rSection ); bool GetProperty( sal_uInt32 nId, PropItem& rPropItem ); - void GetDictionary( Dictionary& rDict ); + void GetDictionary( PropDictionary& rDict ); const sal_uInt8* GetFMTID() const { return aFMTID; }; void Read( SotStorageStream* pStrm ); }; diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx index d41136789ce7..0edc35c70396 100644 --- a/sfx2/source/appl/appcfg.cxx +++ b/sfx2/source/appl/appcfg.cxx @@ -386,34 +386,35 @@ void SfxApplication::GetOptions( SfxItemSet& rSet ) { SfxAllEnumItem aValues(rPool.GetWhich(SID_ATTR_PATHNAME)); SvtPathOptions aPathCfg; - for ( sal_uInt16 nProp = SvtPathOptions::PATH_ADDIN; - nProp <= SvtPathOptions::PATH_WORK; nProp++ ) + for ( sal_uInt16 nProp = static_cast(SvtPathOptions::Paths::AddIn); + nProp <= static_cast(SvtPathOptions::Paths::Work); nProp++ ) { OUString aValue; - switch ( nProp ) + switch ( static_cast(nProp) ) { - case SvtPathOptions::PATH_ADDIN: osl::FileBase::getFileURLFromSystemPath( aPathCfg.GetAddinPath(), aValue ); break; - case SvtPathOptions::PATH_AUTOCORRECT: aValue = aPathCfg.GetAutoCorrectPath(); break; - case SvtPathOptions::PATH_AUTOTEXT: aValue = aPathCfg.GetAutoTextPath(); break; - case SvtPathOptions::PATH_BACKUP: aValue = aPathCfg.GetBackupPath(); break; - case SvtPathOptions::PATH_BASIC: aValue = aPathCfg.GetBasicPath(); break; - case SvtPathOptions::PATH_BITMAP: aValue = aPathCfg.GetBitmapPath(); break; - case SvtPathOptions::PATH_CONFIG: aValue = aPathCfg.GetConfigPath(); break; - case SvtPathOptions::PATH_DICTIONARY: aValue = aPathCfg.GetDictionaryPath(); break; - case SvtPathOptions::PATH_FAVORITES: aValue = aPathCfg.GetFavoritesPath(); break; - case SvtPathOptions::PATH_FILTER: osl::FileBase::getFileURLFromSystemPath( aPathCfg.GetFilterPath(), aValue ); break; - case SvtPathOptions::PATH_GALLERY: aValue = aPathCfg.GetGalleryPath(); break; - case SvtPathOptions::PATH_GRAPHIC: aValue = aPathCfg.GetGraphicPath(); break; - case SvtPathOptions::PATH_HELP: osl::FileBase::getFileURLFromSystemPath( aPathCfg.GetHelpPath(), aValue ); break; - case SvtPathOptions::PATH_LINGUISTIC: aValue = aPathCfg.GetLinguisticPath(); break; - case SvtPathOptions::PATH_MODULE: osl::FileBase::getFileURLFromSystemPath( aPathCfg.GetModulePath(), aValue ); break; - case SvtPathOptions::PATH_PALETTE: aValue = aPathCfg.GetPalettePath(); break; - case SvtPathOptions::PATH_PLUGIN: osl::FileBase::getFileURLFromSystemPath( aPathCfg.GetPluginPath(), aValue ); break; - case SvtPathOptions::PATH_STORAGE: osl::FileBase::getFileURLFromSystemPath( aPathCfg.GetStoragePath(), aValue ); break; - case SvtPathOptions::PATH_TEMP: aValue = aPathCfg.GetTempPath(); break; - case SvtPathOptions::PATH_TEMPLATE: aValue = aPathCfg.GetTemplatePath(); break; - case SvtPathOptions::PATH_USERCONFIG: aValue = aPathCfg.GetUserConfigPath(); break; - case SvtPathOptions::PATH_WORK: aValue = aPathCfg.GetWorkPath(); break; + case SvtPathOptions::Paths::AddIn: osl::FileBase::getFileURLFromSystemPath( aPathCfg.GetAddinPath(), aValue ); break; + case SvtPathOptions::Paths::AutoCorrect: aValue = aPathCfg.GetAutoCorrectPath(); break; + case SvtPathOptions::Paths::AutoText: aValue = aPathCfg.GetAutoTextPath(); break; + case SvtPathOptions::Paths::Backup: aValue = aPathCfg.GetBackupPath(); break; + case SvtPathOptions::Paths::Basic: aValue = aPathCfg.GetBasicPath(); break; + case SvtPathOptions::Paths::Bitmap: aValue = aPathCfg.GetBitmapPath(); break; + case SvtPathOptions::Paths::Config: aValue = aPathCfg.GetConfigPath(); break; + case SvtPathOptions::Paths::Dictionary: aValue = aPathCfg.GetDictionaryPath(); break; + case SvtPathOptions::Paths::Favorites: aValue = aPathCfg.GetFavoritesPath(); break; + case SvtPathOptions::Paths::Filter: osl::FileBase::getFileURLFromSystemPath( aPathCfg.GetFilterPath(), aValue ); break; + case SvtPathOptions::Paths::Gallery: aValue = aPathCfg.GetGalleryPath(); break; + case SvtPathOptions::Paths::Graphic: aValue = aPathCfg.GetGraphicPath(); break; + case SvtPathOptions::Paths::Help: osl::FileBase::getFileURLFromSystemPath( aPathCfg.GetHelpPath(), aValue ); break; + case SvtPathOptions::Paths::Linguistic: aValue = aPathCfg.GetLinguisticPath(); break; + case SvtPathOptions::Paths::Module: osl::FileBase::getFileURLFromSystemPath( aPathCfg.GetModulePath(), aValue ); break; + case SvtPathOptions::Paths::Palette: aValue = aPathCfg.GetPalettePath(); break; + case SvtPathOptions::Paths::Plugin: osl::FileBase::getFileURLFromSystemPath( aPathCfg.GetPluginPath(), aValue ); break; + case SvtPathOptions::Paths::Storage: osl::FileBase::getFileURLFromSystemPath( aPathCfg.GetStoragePath(), aValue ); break; + case SvtPathOptions::Paths::Temp: aValue = aPathCfg.GetTempPath(); break; + case SvtPathOptions::Paths::Template: aValue = aPathCfg.GetTemplatePath(); break; + case SvtPathOptions::Paths::UserConfig: aValue = aPathCfg.GetUserConfigPath(); break; + case SvtPathOptions::Paths::Work: aValue = aPathCfg.GetWorkPath(); break; + default: break; } aValues.SetTextByPos( nProp, aValue ); } @@ -707,9 +708,9 @@ void SfxApplication::SetOptions(const SfxItemSet &rSet) const OUString& sValue = pEnumItem->GetTextByPos(static_cast(nPath)); if ( sValue != aNoChangeStr ) { - switch( nPath ) + switch( static_cast(nPath) ) { - case SvtPathOptions::PATH_ADDIN: + case SvtPathOptions::Paths::AddIn: { OUString aTmp; if( osl::FileBase::getSystemPathFromFileURL( sValue, aTmp ) == osl::FileBase::E_None ) @@ -717,24 +718,24 @@ void SfxApplication::SetOptions(const SfxItemSet &rSet) break; } - case SvtPathOptions::PATH_AUTOCORRECT: aPathOptions.SetAutoCorrectPath( sValue );break; - case SvtPathOptions::PATH_AUTOTEXT: aPathOptions.SetAutoTextPath( sValue );break; - case SvtPathOptions::PATH_BACKUP: aPathOptions.SetBackupPath( sValue );break; - case SvtPathOptions::PATH_BASIC: aPathOptions.SetBasicPath( sValue );break; - case SvtPathOptions::PATH_BITMAP: aPathOptions.SetBitmapPath( sValue );break; - case SvtPathOptions::PATH_CONFIG: aPathOptions.SetConfigPath( sValue );break; - case SvtPathOptions::PATH_DICTIONARY: aPathOptions.SetDictionaryPath( sValue );break; - case SvtPathOptions::PATH_FAVORITES: aPathOptions.SetFavoritesPath( sValue );break; - case SvtPathOptions::PATH_FILTER: + case SvtPathOptions::Paths::AutoCorrect: aPathOptions.SetAutoCorrectPath( sValue );break; + case SvtPathOptions::Paths::AutoText: aPathOptions.SetAutoTextPath( sValue );break; + case SvtPathOptions::Paths::Backup: aPathOptions.SetBackupPath( sValue );break; + case SvtPathOptions::Paths::Basic: aPathOptions.SetBasicPath( sValue );break; + case SvtPathOptions::Paths::Bitmap: aPathOptions.SetBitmapPath( sValue );break; + case SvtPathOptions::Paths::Config: aPathOptions.SetConfigPath( sValue );break; + case SvtPathOptions::Paths::Dictionary: aPathOptions.SetDictionaryPath( sValue );break; + case SvtPathOptions::Paths::Favorites: aPathOptions.SetFavoritesPath( sValue );break; + case SvtPathOptions::Paths::Filter: { OUString aTmp; if( osl::FileBase::getSystemPathFromFileURL( sValue, aTmp ) == osl::FileBase::E_None ) aPathOptions.SetFilterPath( aTmp ); break; } - case SvtPathOptions::PATH_GALLERY: aPathOptions.SetGalleryPath( sValue );break; - case SvtPathOptions::PATH_GRAPHIC: aPathOptions.SetGraphicPath( sValue );break; - case SvtPathOptions::PATH_HELP: + case SvtPathOptions::Paths::Gallery: aPathOptions.SetGalleryPath( sValue );break; + case SvtPathOptions::Paths::Graphic: aPathOptions.SetGraphicPath( sValue );break; + case SvtPathOptions::Paths::Help: { OUString aTmp; if( osl::FileBase::getSystemPathFromFileURL( sValue, aTmp ) == osl::FileBase::E_None ) @@ -742,8 +743,8 @@ void SfxApplication::SetOptions(const SfxItemSet &rSet) break; } - case SvtPathOptions::PATH_LINGUISTIC: aPathOptions.SetLinguisticPath( sValue );break; - case SvtPathOptions::PATH_MODULE: + case SvtPathOptions::Paths::Linguistic: aPathOptions.SetLinguisticPath( sValue );break; + case SvtPathOptions::Paths::Module: { OUString aTmp; if( osl::FileBase::getSystemPathFromFileURL( sValue, aTmp ) == osl::FileBase::E_None ) @@ -751,8 +752,8 @@ void SfxApplication::SetOptions(const SfxItemSet &rSet) break; } - case SvtPathOptions::PATH_PALETTE: aPathOptions.SetPalettePath( sValue );break; - case SvtPathOptions::PATH_PLUGIN: + case SvtPathOptions::Paths::Palette: aPathOptions.SetPalettePath( sValue );break; + case SvtPathOptions::Paths::Plugin: { OUString aTmp; if( osl::FileBase::getSystemPathFromFileURL( sValue, aTmp ) == osl::FileBase::E_None ) @@ -760,7 +761,7 @@ void SfxApplication::SetOptions(const SfxItemSet &rSet) break; } - case SvtPathOptions::PATH_STORAGE: + case SvtPathOptions::Paths::Storage: { OUString aTmp; if( osl::FileBase::getSystemPathFromFileURL( sValue, aTmp ) == osl::FileBase::E_None ) @@ -768,10 +769,10 @@ void SfxApplication::SetOptions(const SfxItemSet &rSet) break; } - case SvtPathOptions::PATH_TEMP: aPathOptions.SetTempPath( sValue );break; - case SvtPathOptions::PATH_TEMPLATE: aPathOptions.SetTemplatePath( sValue );break; - case SvtPathOptions::PATH_USERCONFIG: aPathOptions.SetUserConfigPath( sValue );break; - case SvtPathOptions::PATH_WORK: aPathOptions.SetWorkPath( sValue );break; + case SvtPathOptions::Paths::Temp: aPathOptions.SetTempPath( sValue );break; + case SvtPathOptions::Paths::Template: aPathOptions.SetTemplatePath( sValue );break; + case SvtPathOptions::Paths::UserConfig: aPathOptions.SetUserConfigPath( sValue );break; + case SvtPathOptions::Paths::Work: aPathOptions.SetWorkPath( sValue );break; default: SAL_WARN( "sfx.appl", "SfxApplication::SetOptions_Impl() Invalid path number found for set directories!" ); } } diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 5dd73ace4179..d0173d398fa9 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -175,13 +175,13 @@ OUString HTMLReader::GetTemplateName(SwDoc& rDoc) const // first search for OpenDocument Writer/Web template // OpenDocument Writer/Web template (extension .oth) OUString sTemplate( sTemplateWithoutExt + ".oth" ); - if (aPathOpt.SearchFile( sTemplate, SvtPathOptions::PATH_TEMPLATE )) + if (aPathOpt.SearchFile( sTemplate, SvtPathOptions::Paths::Template )) return sTemplate; // no OpenDocument Writer/Web template found. // search for OpenOffice.org Writer/Web template sTemplate = sTemplateWithoutExt + ".stw"; - if (aPathOpt.SearchFile( sTemplate, SvtPathOptions::PATH_TEMPLATE )) + if (aPathOpt.SearchFile( sTemplate, SvtPathOptions::Paths::Template )) return sTemplate; OSL_ENSURE( false, "The default HTML template cannot be found in the defined template directories!"); diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index bcabdc6aabbb..9dd318322d01 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -416,7 +416,7 @@ IMPL_LINK_NOARG(SwMultiTOXTabDialog, ShowPreviewHdl, weld::ToggleButton&, void) OUString sTemplate("internal/idxexample.odt"); SvtPathOptions aOpt; - bool bExist = aOpt.SearchFile( sTemplate, SvtPathOptions::PATH_TEMPLATE ); + bool bExist = aOpt.SearchFile( sTemplate, SvtPathOptions::Paths::Template ); if(!bExist) { diff --git a/unotools/source/config/defaultoptions.cxx b/unotools/source/config/defaultoptions.cxx index c19df2979057..c24d7daf8388 100644 --- a/unotools/source/config/defaultoptions.cxx +++ b/unotools/source/config/defaultoptions.cxx @@ -93,7 +93,7 @@ public: SvtDefaultOptions_Impl(); virtual ~SvtDefaultOptions_Impl() override; - OUString GetDefaultPath( sal_uInt16 nId ) const; + OUString GetDefaultPath( SvtPathOptions::Paths nId ) const; virtual void Notify( const css::uno::Sequence& aPropertyNames) override; private: @@ -122,28 +122,28 @@ struct PathToDefaultMapping_Impl PathToDefaultMapping_Impl const PathMap_Impl[] = { - { SvtPathOptions::PATH_ADDIN, &SvtDefaultOptions_Impl::m_aAddinPath }, - { SvtPathOptions::PATH_AUTOCORRECT, &SvtDefaultOptions_Impl::m_aAutoCorrectPath }, - { SvtPathOptions::PATH_AUTOTEXT, &SvtDefaultOptions_Impl::m_aAutoTextPath }, - { SvtPathOptions::PATH_BACKUP, &SvtDefaultOptions_Impl::m_aBackupPath }, - { SvtPathOptions::PATH_BASIC, &SvtDefaultOptions_Impl::m_aBasicPath }, - { SvtPathOptions::PATH_BITMAP, &SvtDefaultOptions_Impl::m_aBitmapPath }, - { SvtPathOptions::PATH_CONFIG, &SvtDefaultOptions_Impl::m_aConfigPath }, - { SvtPathOptions::PATH_DICTIONARY, &SvtDefaultOptions_Impl::m_aDictionaryPath }, - { SvtPathOptions::PATH_FAVORITES, &SvtDefaultOptions_Impl::m_aFavoritesPath }, - { SvtPathOptions::PATH_FILTER, &SvtDefaultOptions_Impl::m_aFilterPath }, - { SvtPathOptions::PATH_GALLERY, &SvtDefaultOptions_Impl::m_aGalleryPath }, - { SvtPathOptions::PATH_GRAPHIC, &SvtDefaultOptions_Impl::m_aGraphicPath }, - { SvtPathOptions::PATH_HELP, &SvtDefaultOptions_Impl::m_aHelpPath }, - { SvtPathOptions::PATH_LINGUISTIC, &SvtDefaultOptions_Impl::m_aLinguisticPath }, - { SvtPathOptions::PATH_MODULE, &SvtDefaultOptions_Impl::m_aModulePath }, - { SvtPathOptions::PATH_PALETTE, &SvtDefaultOptions_Impl::m_aPalettePath }, - { SvtPathOptions::PATH_PLUGIN, &SvtDefaultOptions_Impl::m_aPluginPath }, - { SvtPathOptions::PATH_TEMP, &SvtDefaultOptions_Impl::m_aTempPath }, - { SvtPathOptions::PATH_TEMPLATE, &SvtDefaultOptions_Impl::m_aTemplatePath }, - { SvtPathOptions::PATH_USERCONFIG, &SvtDefaultOptions_Impl::m_aUserConfigPath }, - { SvtPathOptions::PATH_WORK, &SvtDefaultOptions_Impl::m_aWorkPath }, - { SvtPathOptions::PATH_CLASSIFICATION, &SvtDefaultOptions_Impl::m_aClassificationPath } + { SvtPathOptions::Paths::AddIn, &SvtDefaultOptions_Impl::m_aAddinPath }, + { SvtPathOptions::Paths::AutoCorrect, &SvtDefaultOptions_Impl::m_aAutoCorrectPath }, + { SvtPathOptions::Paths::AutoText, &SvtDefaultOptions_Impl::m_aAutoTextPath }, + { SvtPathOptions::Paths::Backup, &SvtDefaultOptions_Impl::m_aBackupPath }, + { SvtPathOptions::Paths::Basic, &SvtDefaultOptions_Impl::m_aBasicPath }, + { SvtPathOptions::Paths::Bitmap, &SvtDefaultOptions_Impl::m_aBitmapPath }, + { SvtPathOptions::Paths::Config, &SvtDefaultOptions_Impl::m_aConfigPath }, + { SvtPathOptions::Paths::Dictionary, &SvtDefaultOptions_Impl::m_aDictionaryPath }, + { SvtPathOptions::Paths::Favorites, &SvtDefaultOptions_Impl::m_aFavoritesPath }, + { SvtPathOptions::Paths::Filter, &SvtDefaultOptions_Impl::m_aFilterPath }, + { SvtPathOptions::Paths::Gallery, &SvtDefaultOptions_Impl::m_aGalleryPath }, + { SvtPathOptions::Paths::Graphic, &SvtDefaultOptions_Impl::m_aGraphicPath }, + { SvtPathOptions::Paths::Help, &SvtDefaultOptions_Impl::m_aHelpPath }, + { SvtPathOptions::Paths::Linguistic, &SvtDefaultOptions_Impl::m_aLinguisticPath }, + { SvtPathOptions::Paths::Module, &SvtDefaultOptions_Impl::m_aModulePath }, + { SvtPathOptions::Paths::Palette, &SvtDefaultOptions_Impl::m_aPalettePath }, + { SvtPathOptions::Paths::Plugin, &SvtDefaultOptions_Impl::m_aPluginPath }, + { SvtPathOptions::Paths::Temp, &SvtDefaultOptions_Impl::m_aTempPath }, + { SvtPathOptions::Paths::Template, &SvtDefaultOptions_Impl::m_aTemplatePath }, + { SvtPathOptions::Paths::UserConfig, &SvtDefaultOptions_Impl::m_aUserConfigPath }, + { SvtPathOptions::Paths::Work, &SvtDefaultOptions_Impl::m_aWorkPath }, + { SvtPathOptions::Paths::Classification, &SvtDefaultOptions_Impl::m_aClassificationPath } }; // functions ------------------------------------------------------------- @@ -197,21 +197,21 @@ void SvtDefaultOptions_Impl::ImplCommit() // class SvtDefaultOptions_Impl ------------------------------------------ -OUString SvtDefaultOptions_Impl::GetDefaultPath( sal_uInt16 nId ) const +OUString SvtDefaultOptions_Impl::GetDefaultPath( SvtPathOptions::Paths nId ) const { OUString aRet; sal_uInt16 nIdx = 0; - while ( PathMap_Impl[nIdx]._ePath <= SvtPathOptions::PATH_CLASSIFICATION ) + while ( PathMap_Impl[nIdx]._ePath <= SvtPathOptions::Paths::Classification ) { if ( nId == PathMap_Impl[nIdx]._ePath && PathMap_Impl[nIdx]._pDefaultPath ) { aRet = this->*(PathMap_Impl[nIdx]._pDefaultPath); - if ( nId == SvtPathOptions::PATH_ADDIN || - nId == SvtPathOptions::PATH_FILTER || - nId == SvtPathOptions::PATH_HELP || - nId == SvtPathOptions::PATH_MODULE || - nId == SvtPathOptions::PATH_PLUGIN ) + if ( nId == SvtPathOptions::Paths::AddIn || + nId == SvtPathOptions::Paths::Filter || + nId == SvtPathOptions::Paths::Help || + nId == SvtPathOptions::Paths::Module || + nId == SvtPathOptions::Paths::Plugin ) { OUString aTmp; osl::FileBase::getFileURLFromSystemPath( aRet, aTmp ); @@ -349,7 +349,7 @@ SvtDefaultOptions::~SvtDefaultOptions() pImpl.reset(); } -OUString SvtDefaultOptions::GetDefaultPath( sal_uInt16 nId ) const +OUString SvtDefaultOptions::GetDefaultPath( SvtPathOptions::Paths nId ) const { return pImpl->GetDefaultPath( nId ); } diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx index eb7d9244a897..59e8a978d0b1 100644 --- a/unotools/source/config/pathoptions.cxx +++ b/unotools/source/config/pathoptions.cxx @@ -38,6 +38,7 @@ #include #include #include +#include #include "itemholder1.hxx" @@ -73,11 +74,11 @@ class SvtPathOptions_Impl { private: // Local variables to return const references - std::vector< OUString > m_aPathArray; + o3tl::enumarray< SvtPathOptions::Paths, OUString > m_aPathArray; Reference< XFastPropertySet > m_xPathSettings; Reference< XStringSubstitution > m_xSubstVariables; Reference< XMacroExpander > m_xMacroExpander; - mutable std::unordered_map + mutable std::unordered_map m_aMapEnumToPropHandle; VarNameSet m_aSystemPathVarNames; @@ -89,58 +90,58 @@ class SvtPathOptions_Impl // get the paths, not const because of using a mutex const OUString& GetPath( SvtPathOptions::Paths ); - const OUString& GetAddinPath() { return GetPath( SvtPathOptions::PATH_ADDIN ); } - const OUString& GetAutoCorrectPath() { return GetPath( SvtPathOptions::PATH_AUTOCORRECT ); } - const OUString& GetAutoTextPath() { return GetPath( SvtPathOptions::PATH_AUTOTEXT ); } - const OUString& GetBackupPath() { return GetPath( SvtPathOptions::PATH_BACKUP ); } - const OUString& GetBasicPath() { return GetPath( SvtPathOptions::PATH_BASIC ); } - const OUString& GetBitmapPath() { return GetPath( SvtPathOptions::PATH_BITMAP ); } - const OUString& GetConfigPath() { return GetPath( SvtPathOptions::PATH_CONFIG ); } - const OUString& GetDictionaryPath() { return GetPath( SvtPathOptions::PATH_DICTIONARY ); } - const OUString& GetFavoritesPath() { return GetPath( SvtPathOptions::PATH_FAVORITES ); } - const OUString& GetFilterPath() { return GetPath( SvtPathOptions::PATH_FILTER ); } - const OUString& GetGalleryPath() { return GetPath( SvtPathOptions::PATH_GALLERY ); } - const OUString& GetGraphicPath() { return GetPath( SvtPathOptions::PATH_GRAPHIC ); } - const OUString& GetHelpPath() { return GetPath( SvtPathOptions::PATH_HELP ); } - const OUString& GetLinguisticPath() { return GetPath( SvtPathOptions::PATH_LINGUISTIC ); } - const OUString& GetModulePath() { return GetPath( SvtPathOptions::PATH_MODULE ); } - const OUString& GetPalettePath() { return GetPath( SvtPathOptions::PATH_PALETTE ); } - const OUString& GetIconsetPath() { return GetPath( SvtPathOptions::PATH_ICONSET); } - const OUString& GetPluginPath() { return GetPath( SvtPathOptions::PATH_PLUGIN ); } - const OUString& GetStoragePath() { return GetPath( SvtPathOptions::PATH_STORAGE ); } - const OUString& GetTempPath() { return GetPath( SvtPathOptions::PATH_TEMP ); } - const OUString& GetTemplatePath() { return GetPath( SvtPathOptions::PATH_TEMPLATE ); } - const OUString& GetUserConfigPath() { return GetPath( SvtPathOptions::PATH_USERCONFIG ); } - const OUString& GetWorkPath() { return GetPath( SvtPathOptions::PATH_WORK ); } - const OUString& GetUIConfigPath() { return GetPath( SvtPathOptions::PATH_UICONFIG ); } - const OUString& GetFingerprintPath() { return GetPath( SvtPathOptions::PATH_FINGERPRINT ); } - const OUString& GetNumbertextPath() { return GetPath( SvtPathOptions::PATH_NUMBERTEXT ); } - const OUString& GetClassificationPath() { return GetPath( SvtPathOptions::PATH_CLASSIFICATION ); } + const OUString& GetAddinPath() { return GetPath( SvtPathOptions::Paths::AddIn ); } + const OUString& GetAutoCorrectPath() { return GetPath( SvtPathOptions::Paths::AutoCorrect ); } + const OUString& GetAutoTextPath() { return GetPath( SvtPathOptions::Paths::AutoText ); } + const OUString& GetBackupPath() { return GetPath( SvtPathOptions::Paths::Backup ); } + const OUString& GetBasicPath() { return GetPath( SvtPathOptions::Paths::Basic ); } + const OUString& GetBitmapPath() { return GetPath( SvtPathOptions::Paths::Bitmap ); } + const OUString& GetConfigPath() { return GetPath( SvtPathOptions::Paths::Config ); } + const OUString& GetDictionaryPath() { return GetPath( SvtPathOptions::Paths::Dictionary ); } + const OUString& GetFavoritesPath() { return GetPath( SvtPathOptions::Paths::Favorites ); } + const OUString& GetFilterPath() { return GetPath( SvtPathOptions::Paths::Filter ); } + const OUString& GetGalleryPath() { return GetPath( SvtPathOptions::Paths::Gallery ); } + const OUString& GetGraphicPath() { return GetPath( SvtPathOptions::Paths::Graphic ); } + const OUString& GetHelpPath() { return GetPath( SvtPathOptions::Paths::Help ); } + const OUString& GetLinguisticPath() { return GetPath( SvtPathOptions::Paths::Linguistic ); } + const OUString& GetModulePath() { return GetPath( SvtPathOptions::Paths::Module ); } + const OUString& GetPalettePath() { return GetPath( SvtPathOptions::Paths::Palette ); } + const OUString& GetIconsetPath() { return GetPath( SvtPathOptions::Paths::IconSet); } + const OUString& GetPluginPath() { return GetPath( SvtPathOptions::Paths::Plugin ); } + const OUString& GetStoragePath() { return GetPath( SvtPathOptions::Paths::Storage ); } + const OUString& GetTempPath() { return GetPath( SvtPathOptions::Paths::Temp ); } + const OUString& GetTemplatePath() { return GetPath( SvtPathOptions::Paths::Template ); } + const OUString& GetUserConfigPath() { return GetPath( SvtPathOptions::Paths::UserConfig ); } + const OUString& GetWorkPath() { return GetPath( SvtPathOptions::Paths::Work ); } + const OUString& GetUIConfigPath() { return GetPath( SvtPathOptions::Paths::UIConfig ); } + const OUString& GetFingerprintPath() { return GetPath( SvtPathOptions::Paths::Fingerprint ); } + const OUString& GetNumbertextPath() { return GetPath( SvtPathOptions::Paths::NumberText ); } + const OUString& GetClassificationPath() { return GetPath( SvtPathOptions::Paths::Classification ); } // set the paths void SetPath( SvtPathOptions::Paths, const OUString& rNewPath ); - void SetAddinPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_ADDIN, rPath ); } - void SetAutoCorrectPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_AUTOCORRECT, rPath ); } - void SetAutoTextPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_AUTOTEXT, rPath ); } - void SetBackupPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_BACKUP, rPath ); } - void SetBasicPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_BASIC, rPath ); } - void SetBitmapPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_BITMAP, rPath ); } - void SetConfigPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_CONFIG, rPath ); } - void SetDictionaryPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_DICTIONARY, rPath ); } - void SetFavoritesPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_FAVORITES, rPath ); } - void SetFilterPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_FILTER, rPath ); } - void SetGalleryPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_GALLERY, rPath ); } - void SetGraphicPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_GRAPHIC, rPath ); } - void SetHelpPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_HELP, rPath ); } - void SetLinguisticPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_LINGUISTIC, rPath ); } - void SetModulePath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_MODULE, rPath ); } - void SetPalettePath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_PALETTE, rPath ); } - void SetPluginPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_PLUGIN, rPath ); } - void SetStoragePath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_STORAGE, rPath ); } - void SetTempPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_TEMP, rPath ); } - void SetTemplatePath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_TEMPLATE, rPath ); } - void SetUserConfigPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_USERCONFIG, rPath ); } - void SetWorkPath( const OUString& rPath ) { SetPath( SvtPathOptions::PATH_WORK, rPath ); } + void SetAddinPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::AddIn, rPath ); } + void SetAutoCorrectPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::AutoCorrect, rPath ); } + void SetAutoTextPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::AutoText, rPath ); } + void SetBackupPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Backup, rPath ); } + void SetBasicPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Basic, rPath ); } + void SetBitmapPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Bitmap, rPath ); } + void SetConfigPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Config, rPath ); } + void SetDictionaryPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Dictionary, rPath ); } + void SetFavoritesPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Favorites, rPath ); } + void SetFilterPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Filter, rPath ); } + void SetGalleryPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Gallery, rPath ); } + void SetGraphicPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Graphic, rPath ); } + void SetHelpPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Help, rPath ); } + void SetLinguisticPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Linguistic, rPath ); } + void SetModulePath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Module, rPath ); } + void SetPalettePath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Palette, rPath ); } + void SetPluginPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Plugin, rPath ); } + void SetStoragePath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Storage, rPath ); } + void SetTempPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Temp, rPath ); } + void SetTemplatePath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Template, rPath ); } + void SetUserConfigPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::UserConfig, rPath ); } + void SetWorkPath( const OUString& rPath ) { SetPath( SvtPathOptions::Paths::Work, rPath ); } OUString SubstVar( const OUString& rVar ) const; OUString ExpandMacros( const OUString& rPath ) const; @@ -169,33 +170,33 @@ struct VarNameAttribute const PropertyStruct aPropNames[] = { - { "Addin", SvtPathOptions::PATH_ADDIN }, - { "AutoCorrect", SvtPathOptions::PATH_AUTOCORRECT }, - { "AutoText", SvtPathOptions::PATH_AUTOTEXT }, - { "Backup", SvtPathOptions::PATH_BACKUP }, - { "Basic", SvtPathOptions::PATH_BASIC }, - { "Bitmap", SvtPathOptions::PATH_BITMAP }, - { "Config", SvtPathOptions::PATH_CONFIG }, - { "Dictionary", SvtPathOptions::PATH_DICTIONARY }, - { "Favorite", SvtPathOptions::PATH_FAVORITES }, - { "Filter", SvtPathOptions::PATH_FILTER }, - { "Gallery", SvtPathOptions::PATH_GALLERY }, - { "Graphic", SvtPathOptions::PATH_GRAPHIC }, - { "Help", SvtPathOptions::PATH_HELP }, - { "Iconset", SvtPathOptions::PATH_ICONSET }, - { "Linguistic", SvtPathOptions::PATH_LINGUISTIC }, - { "Module", SvtPathOptions::PATH_MODULE }, - { "Palette", SvtPathOptions::PATH_PALETTE }, - { "Plugin", SvtPathOptions::PATH_PLUGIN }, - { "Storage", SvtPathOptions::PATH_STORAGE }, - { "Temp", SvtPathOptions::PATH_TEMP }, - { "Template", SvtPathOptions::PATH_TEMPLATE }, - { "UserConfig", SvtPathOptions::PATH_USERCONFIG }, - { "Work", SvtPathOptions::PATH_WORK }, - { "UIConfig", SvtPathOptions::PATH_UICONFIG }, - { "Fingerprint", SvtPathOptions::PATH_FINGERPRINT }, - { "Numbertext", SvtPathOptions::PATH_NUMBERTEXT }, - { "Classification", SvtPathOptions::PATH_CLASSIFICATION } + { "Addin", SvtPathOptions::Paths::AddIn }, + { "AutoCorrect", SvtPathOptions::Paths::AutoCorrect }, + { "AutoText", SvtPathOptions::Paths::AutoText }, + { "Backup", SvtPathOptions::Paths::Backup }, + { "Basic", SvtPathOptions::Paths::Basic }, + { "Bitmap", SvtPathOptions::Paths::Bitmap }, + { "Config", SvtPathOptions::Paths::Config }, + { "Dictionary", SvtPathOptions::Paths::Dictionary }, + { "Favorite", SvtPathOptions::Paths::Favorites }, + { "Filter", SvtPathOptions::Paths::Filter }, + { "Gallery", SvtPathOptions::Paths::Gallery }, + { "Graphic", SvtPathOptions::Paths::Graphic }, + { "Help", SvtPathOptions::Paths::Help }, + { "Iconset", SvtPathOptions::Paths::IconSet }, + { "Linguistic", SvtPathOptions::Paths::Linguistic }, + { "Module", SvtPathOptions::Paths::Module }, + { "Palette", SvtPathOptions::Paths::Palette }, + { "Plugin", SvtPathOptions::Paths::Plugin }, + { "Storage", SvtPathOptions::Paths::Storage }, + { "Temp", SvtPathOptions::Paths::Temp }, + { "Template", SvtPathOptions::Paths::Template }, + { "UserConfig", SvtPathOptions::Paths::UserConfig }, + { "Work", SvtPathOptions::Paths::Work }, + { "UIConfig", SvtPathOptions::Paths::UIConfig }, + { "Fingerprint", SvtPathOptions::Paths::Fingerprint }, + { "Numbertext", SvtPathOptions::Paths::NumberText }, + { "Classification", SvtPathOptions::Paths::Classification } }; const VarNameAttribute aVarNameAttribute[] = @@ -210,25 +211,22 @@ const VarNameAttribute aVarNameAttribute[] = const OUString& SvtPathOptions_Impl::GetPath( SvtPathOptions::Paths ePath ) { - if ( ePath >= SvtPathOptions::PATH_COUNT ) - return m_aEmptyString; - ::osl::MutexGuard aGuard( m_aMutex ); try { OUString aPathValue; - sal_Int32 nHandle = m_aMapEnumToPropHandle[ static_cast(ePath) ]; + sal_Int32 nHandle = m_aMapEnumToPropHandle[ePath]; // Substitution is done by the service itself using the substitution service Any a = m_xPathSettings->getFastPropertyValue( nHandle ); a >>= aPathValue; - if( ePath == SvtPathOptions::PATH_ADDIN || - ePath == SvtPathOptions::PATH_FILTER || - ePath == SvtPathOptions::PATH_HELP || - ePath == SvtPathOptions::PATH_MODULE || - ePath == SvtPathOptions::PATH_PLUGIN || - ePath == SvtPathOptions::PATH_STORAGE + if( ePath == SvtPathOptions::Paths::AddIn || + ePath == SvtPathOptions::Paths::Filter || + ePath == SvtPathOptions::Paths::Help || + ePath == SvtPathOptions::Paths::Module || + ePath == SvtPathOptions::Paths::Plugin || + ePath == SvtPathOptions::Paths::Storage ) { // These office paths have to be converted to system pates @@ -236,8 +234,8 @@ const OUString& SvtPathOptions_Impl::GetPath( SvtPathOptions::Paths ePath ) osl::FileBase::getSystemPathFromFileURL( aPathValue, aResult ); aPathValue = aResult; } - else if (ePath == SvtPathOptions::PATH_PALETTE || - ePath == SvtPathOptions::PATH_ICONSET) + else if (ePath == SvtPathOptions::Paths::Palette || + ePath == SvtPathOptions::Paths::IconSet) { auto ctx = comphelper::getProcessComponentContext(); OUStringBuffer buf(aPathValue.getLength()*2); @@ -268,21 +266,18 @@ void SvtPathOptions_Impl::SetPath( SvtPathOptions::Paths ePath, const OUString& { ::osl::MutexGuard aGuard( m_aMutex ); - if ( ePath >= SvtPathOptions::PATH_COUNT ) - return; - OUString aResult; OUString aNewValue; Any a; switch ( ePath ) { - case SvtPathOptions::PATH_ADDIN: - case SvtPathOptions::PATH_FILTER: - case SvtPathOptions::PATH_HELP: - case SvtPathOptions::PATH_MODULE: - case SvtPathOptions::PATH_PLUGIN: - case SvtPathOptions::PATH_STORAGE: + case SvtPathOptions::Paths::AddIn: + case SvtPathOptions::Paths::Filter: + case SvtPathOptions::Paths::Help: + case SvtPathOptions::Paths::Module: + case SvtPathOptions::Paths::Plugin: + case SvtPathOptions::Paths::Storage: { // These office paths have to be convert back to UCB-URL's osl::FileBase::getFileURLFromSystemPath( rNewPath, aResult ); @@ -298,7 +293,7 @@ void SvtPathOptions_Impl::SetPath( SvtPathOptions::Paths ePath, const OUString& a <<= aNewValue; try { - m_xPathSettings->setFastPropertyValue( m_aMapEnumToPropHandle[ static_cast(ePath)], a ); + m_xPathSettings->setFastPropertyValue( m_aMapEnumToPropHandle[ePath], a ); } catch (const Exception&) { @@ -395,8 +390,7 @@ OUString SvtPathOptions_Impl::SubstVar( const OUString& rVar ) const return aWorkText; } -SvtPathOptions_Impl::SvtPathOptions_Impl() : - m_aPathArray( sal_Int32(SvtPathOptions::PATH_COUNT) ) +SvtPathOptions_Impl::SvtPathOptions_Impl() { Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); @@ -425,7 +419,7 @@ SvtPathOptions_Impl::SvtPathOptions_Impl() : if ( pIter != aTempHashMap.end() ) { sal_Int32 nHandle = pIter->second; - sal_Int32 nEnum = p.ePath; + SvtPathOptions::Paths nEnum = p.ePath; m_aMapEnumToPropHandle.emplace( nEnum, nHandle ); } } @@ -717,7 +711,7 @@ OUString SvtPathOptions::UseVariable( const OUString& rPath ) const return pImpl->UsePathVariables( rPath ); } -bool SvtPathOptions::SearchFile( OUString& rIniFile, Paths ePath ) +bool SvtPathOptions::SearchFile( OUString& rIniFile, SvtPathOptions::Paths ePath ) { // check parameter: empty inifile name? if ( rIniFile.isEmpty() ) @@ -731,7 +725,7 @@ bool SvtPathOptions::SearchFile( OUString& rIniFile, Paths ePath ) switch ( ePath ) { - case PATH_USERCONFIG: + case SvtPathOptions::Paths::UserConfig: { // path is a URL bRet = true; @@ -763,35 +757,35 @@ bool SvtPathOptions::SearchFile( OUString& rIniFile, Paths ePath ) OUString aPath; switch ( ePath ) { - case PATH_ADDIN: aPath = GetAddinPath(); break; - case PATH_AUTOCORRECT: aPath = GetAutoCorrectPath(); break; - case PATH_AUTOTEXT: aPath = GetAutoTextPath(); break; - case PATH_BACKUP: aPath = GetBackupPath(); break; - case PATH_BASIC: aPath = GetBasicPath(); break; - case PATH_BITMAP: aPath = GetBitmapPath(); break; - case PATH_CONFIG: aPath = GetConfigPath(); break; - case PATH_DICTIONARY: aPath = GetDictionaryPath(); break; - case PATH_FAVORITES: aPath = GetFavoritesPath(); break; - case PATH_FILTER: aPath = GetFilterPath(); break; - case PATH_GALLERY: aPath = GetGalleryPath(); break; - case PATH_GRAPHIC: aPath = GetGraphicPath(); break; - case PATH_HELP: aPath = GetHelpPath(); break; - case PATH_LINGUISTIC: aPath = GetLinguisticPath(); break; - case PATH_MODULE: aPath = GetModulePath(); break; - case PATH_PALETTE: aPath = GetPalettePath(); break; - case PATH_ICONSET: aPath = GetIconsetPath(); break; - case PATH_PLUGIN: aPath = GetPluginPath(); break; - case PATH_STORAGE: aPath = GetStoragePath(); break; - case PATH_TEMP: aPath = GetTempPath(); break; - case PATH_TEMPLATE: aPath = GetTemplatePath(); break; - case PATH_WORK: aPath = GetWorkPath(); break; - case PATH_UICONFIG: aPath = pImpl->GetUIConfigPath(); break; - case PATH_FINGERPRINT: aPath = GetFingerprintPath(); break; - case PATH_NUMBERTEXT: aPath = GetNumbertextPath(); break; - case PATH_CLASSIFICATION: aPath = GetClassificationPath(); break; + case SvtPathOptions::Paths::AddIn: aPath = GetAddinPath(); break; + case SvtPathOptions::Paths::AutoCorrect: aPath = GetAutoCorrectPath(); break; + case SvtPathOptions::Paths::AutoText: aPath = GetAutoTextPath(); break; + case SvtPathOptions::Paths::Backup: aPath = GetBackupPath(); break; + case SvtPathOptions::Paths::Basic: aPath = GetBasicPath(); break; + case SvtPathOptions::Paths::Bitmap: aPath = GetBitmapPath(); break; + case SvtPathOptions::Paths::Config: aPath = GetConfigPath(); break; + case SvtPathOptions::Paths::Dictionary: aPath = GetDictionaryPath(); break; + case SvtPathOptions::Paths::Favorites: aPath = GetFavoritesPath(); break; + case SvtPathOptions::Paths::Filter: aPath = GetFilterPath(); break; + case SvtPathOptions::Paths::Gallery: aPath = GetGalleryPath(); break; + case SvtPathOptions::Paths::Graphic: aPath = GetGraphicPath(); break; + case SvtPathOptions::Paths::Help: aPath = GetHelpPath(); break; + case SvtPathOptions::Paths::Linguistic: aPath = GetLinguisticPath(); break; + case SvtPathOptions::Paths::Module: aPath = GetModulePath(); break; + case SvtPathOptions::Paths::Palette: aPath = GetPalettePath(); break; + case SvtPathOptions::Paths::IconSet: aPath = GetIconsetPath(); break; + case SvtPathOptions::Paths::Plugin: aPath = GetPluginPath(); break; + case SvtPathOptions::Paths::Storage: aPath = GetStoragePath(); break; + case SvtPathOptions::Paths::Temp: aPath = GetTempPath(); break; + case SvtPathOptions::Paths::Template: aPath = GetTemplatePath(); break; + case SvtPathOptions::Paths::Work: aPath = GetWorkPath(); break; + case SvtPathOptions::Paths::UIConfig: aPath = pImpl->GetUIConfigPath(); break; + case SvtPathOptions::Paths::Fingerprint: aPath = GetFingerprintPath(); break; + case SvtPathOptions::Paths::NumberText: aPath = GetNumbertextPath(); break; + case SvtPathOptions::Paths::Classification: aPath = GetClassificationPath(); break; // coverity[dead_error_begin] - following conditions exist to avoid compiler warning - case PATH_USERCONFIG: - case PATH_COUNT: + case SvtPathOptions::Paths::UserConfig: + case SvtPathOptions::Paths::LAST: break; } -- cgit