unotools/source/config/pathoptions.cxx | 84 +++++++++++++++------------------ unotools/source/config/useroptions.cxx | 48 +++++++++--------- 2 files changed, 63 insertions(+), 69 deletions(-)
New commits: commit be9f2bdfb74e6a3917752cf462160e100457ca28 Author: Noel Grandin <[email protected]> AuthorDate: Thu May 2 15:52:12 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sun May 5 08:51:54 2024 +0200 replace createFromAscii with OUString literals in SvtUserOptions Change-Id: I472c132513622a8b2064ea78ef38161804b1f5ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167138 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/unotools/source/config/useroptions.cxx b/unotools/source/config/useroptions.cxx index 1e181e8813d6..9256d874f14b 100644 --- a/unotools/source/config/useroptions.cxx +++ b/unotools/source/config/useroptions.cxx @@ -45,27 +45,27 @@ using namespace com::sun::star; // vOptionNames[] -- names of the user option entries // The order must correspond to the enum class UserOptToken in useroptions.hxx. -static o3tl::enumarray<UserOptToken, char const *> vOptionNames = { - "l", // UserOptToken::City - "o", // UserOptToken::Company - "c", // UserOptToken::Country - "mail", // UserOptToken::Email - "facsimiletelephonenumber", // UserOptToken::Fax - "givenname", // UserOptToken::FirstName - "sn", // UserOptToken::LastName - "position", // UserOptToken::Position - "st", // UserOptToken::State - "street", // UserOptToken::Street - "homephone", // UserOptToken::TelephoneHome - "telephonenumber", // UserOptToken::TelephoneWork - "title", // UserOptToken::Title - "initials", // UserOptToken::ID - "postalcode", // UserOptToken::Zip - "fathersname", // UserOptToken::FathersName - "apartment", // UserOptToken::Apartment - "signingkey", // UserOptToken::SigningKey - "encryptionkey", // UserOptToken::EncryptionKey - "encrypttoself" // UserOptToken::EncryptToSelf +constexpr o3tl::enumarray<UserOptToken, OUString> vOptionNames = { + u"l"_ustr, // UserOptToken::City + u"o"_ustr, // UserOptToken::Company + u"c"_ustr, // UserOptToken::Country + u"mail"_ustr, // UserOptToken::Email + u"facsimiletelephonenumber"_ustr, // UserOptToken::Fax + u"givenname"_ustr, // UserOptToken::FirstName + u"sn"_ustr, // UserOptToken::LastName + u"position"_ustr, // UserOptToken::Position + u"st"_ustr, // UserOptToken::State + u"street"_ustr, // UserOptToken::Street + u"homephone"_ustr, // UserOptToken::TelephoneHome + u"telephonenumber"_ustr, // UserOptToken::TelephoneWork + u"title"_ustr, // UserOptToken::Title + u"initials"_ustr, // UserOptToken::ID + u"postalcode"_ustr, // UserOptToken::Zip + u"fathersname"_ustr, // UserOptToken::FathersName + u"apartment"_ustr, // UserOptToken::Apartment + u"signingkey"_ustr, // UserOptToken::SigningKey + u"encryptionkey"_ustr, // UserOptToken::EncryptionKey + u"encrypttoself"_ustr // UserOptToken::EncryptToSelf }; std::weak_ptr<SvtUserOptions::Impl> SvtUserOptions::xSharedImpl; @@ -165,7 +165,7 @@ ValueType SvtUserOptions::Impl::GetValue_Impl (UserOptToken nToken) const try { if (m_xData.is()) - m_xData->getPropertyValue(OUString::createFromAscii(vOptionNames[nToken])) >>= sToken; + m_xData->getPropertyValue(vOptionNames[nToken]) >>= sToken; } catch (uno::Exception const&) { @@ -180,7 +180,7 @@ void SvtUserOptions::Impl::SetValue_Impl (UserOptToken nToken, ValueType const& try { if (m_xData.is()) - m_xData->setPropertyValue(OUString::createFromAscii(vOptionNames[nToken]), uno::Any(sToken)); + m_xData->setPropertyValue(vOptionNames[nToken], uno::Any(sToken)); comphelper::ConfigurationHelper::flush(m_xCfg); } catch (uno::Exception const&) @@ -254,7 +254,7 @@ bool SvtUserOptions::Impl::IsTokenReadonly (UserOptToken nToken) const { uno::Reference<beans::XPropertySet> xData(m_xCfg, uno::UNO_QUERY); uno::Reference<beans::XPropertySetInfo> xInfo = xData->getPropertySetInfo(); - beans::Property aProp = xInfo->getPropertyByName(OUString::createFromAscii(vOptionNames[nToken])); + beans::Property aProp = xInfo->getPropertyByName(vOptionNames[nToken]); return ((aProp.Attributes & beans::PropertyAttribute::READONLY) == beans::PropertyAttribute::READONLY); } commit 76e6c60b67351095bf8756c374ec7ced77696376 Author: Noel Grandin <[email protected]> AuthorDate: Thu May 2 15:47:16 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sun May 5 08:51:44 2024 +0200 replace createFromAscii with OUString literals in SvtPathOptions_Impl Change-Id: I1740e4be5ea2295cdf89fd5771d2902c620af301 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167136 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx index be02f7c8f2ac..dbce328105c2 100644 --- a/unotools/source/config/pathoptions.cxx +++ b/unotools/source/config/pathoptions.cxx @@ -55,12 +55,6 @@ using namespace com::sun::star::util; #define SIGN_STARTVARIABLE "$(" #define SIGN_ENDVARIABLE ")" -// Supported variables by the old SvtPathOptions implementation -#define SUBSTITUTE_INSTPATH "$(instpath)" -#define SUBSTITUTE_PROGPATH "$(progpath)" -#define SUBSTITUTE_USERPATH "$(userpath)" -#define SUBSTITUTE_PATH "$(path)" - #define STRPOS_NOTFOUND -1 typedef std::unordered_map<OUString, sal_Int32> NameToHandleMap; @@ -137,54 +131,55 @@ namespace { // functions ------------------------------------------------------------- struct PropertyStruct { - const char* pPropName; // The ascii name of the Office path + OUString aPropName; // The ascii name of the Office path SvtPathOptions::Paths ePath; // The enum value used by SvtPathOptions }; struct VarNameAttribute { - const char* pVarName; // The name of the path variable + OUString aVarName; // The name of the path variable }; } -const PropertyStruct aPropNames[] = -{ - { "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 } +constexpr PropertyStruct aPropNames[] = +{ + { u"Addin"_ustr, SvtPathOptions::Paths::AddIn }, + { u"AutoCorrect"_ustr, SvtPathOptions::Paths::AutoCorrect }, + { u"AutoText"_ustr, SvtPathOptions::Paths::AutoText }, + { u"Backup"_ustr, SvtPathOptions::Paths::Backup }, + { u"Basic"_ustr, SvtPathOptions::Paths::Basic }, + { u"Bitmap"_ustr, SvtPathOptions::Paths::Bitmap }, + { u"Config"_ustr, SvtPathOptions::Paths::Config }, + { u"Dictionary"_ustr, SvtPathOptions::Paths::Dictionary }, + { u"Favorite"_ustr, SvtPathOptions::Paths::Favorites }, + { u"Filter"_ustr, SvtPathOptions::Paths::Filter }, + { u"Gallery"_ustr, SvtPathOptions::Paths::Gallery }, + { u"Graphic"_ustr, SvtPathOptions::Paths::Graphic }, + { u"Help"_ustr, SvtPathOptions::Paths::Help }, + { u"Iconset"_ustr, SvtPathOptions::Paths::IconSet }, + { u"Linguistic"_ustr, SvtPathOptions::Paths::Linguistic }, + { u"Module"_ustr, SvtPathOptions::Paths::Module }, + { u"Palette"_ustr, SvtPathOptions::Paths::Palette }, + { u"Plugin"_ustr, SvtPathOptions::Paths::Plugin }, + { u"Storage"_ustr, SvtPathOptions::Paths::Storage }, + { u"Temp"_ustr, SvtPathOptions::Paths::Temp }, + { u"Template"_ustr, SvtPathOptions::Paths::Template }, + { u"UserConfig"_ustr, SvtPathOptions::Paths::UserConfig }, + { u"Work"_ustr, SvtPathOptions::Paths::Work }, + { u"UIConfig"_ustr, SvtPathOptions::Paths::UIConfig }, + { u"Fingerprint"_ustr, SvtPathOptions::Paths::Fingerprint }, + { u"Numbertext"_ustr, SvtPathOptions::Paths::NumberText }, + { u"Classification"_ustr, SvtPathOptions::Paths::Classification } }; -const VarNameAttribute aVarNameAttribute[] = +// Supported variables by the old SvtPathOptions implementation +constexpr VarNameAttribute aVarNameAttribute[] = { - { SUBSTITUTE_INSTPATH }, // $(instpath) - { SUBSTITUTE_PROGPATH }, // $(progpath) - { SUBSTITUTE_USERPATH }, // $(userpath) - { SUBSTITUTE_PATH }, // $(path) + { u"$(instpath)"_ustr }, // $(instpath) + { u"$(progpath)"_ustr }, // $(progpath) + { u"$(userpath)"_ustr }, // $(userpath) + { u"$(path)"_ustr }, // $(path) }; // class SvtPathOptions_Impl --------------------------------------------- @@ -393,8 +388,7 @@ SvtPathOptions_Impl::SvtPathOptions_Impl() // Create mapping between internal enum (SvtPathOptions::Paths) and property handle for ( auto const & p : aPropNames ) { - NameToHandleMap::const_iterator pIter = - aTempHashMap.find( OUString::createFromAscii( p.pPropName )); + NameToHandleMap::const_iterator pIter = aTempHashMap.find( p.aPropName ); if ( pIter != aTempHashMap.end() ) { @@ -407,7 +401,7 @@ SvtPathOptions_Impl::SvtPathOptions_Impl() // Create hash map for path variables that need a system path as a return value! for ( auto const & i : aVarNameAttribute ) { - m_aSystemPathVarNames.insert( OUString::createFromAscii( i.pVarName ) ); + m_aSystemPathVarNames.insert( i.aVarName ); } }
