toolkit/source/awt/vclxtoolkit.cxx | 39 ++++++++++++------------------------- 1 file changed, 13 insertions(+), 26 deletions(-)
New commits: commit fb80e10994bd997ef9589defc6310939a3836854 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Aug 15 08:28:35 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Aug 15 11:01:31 2025 +0200 toolkit: Use OUString, range-based for Change-Id: I6a731cbef76be5f23e2c1ddc43b0acf9fff1212a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189659 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 7cd2ead5a0cb..3ab9db1e8ed1 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -811,30 +811,24 @@ WindowType ImplGetComponentType( const OUString& rServiceName ) struct MessageBoxTypeInfo { css::awt::MessageBoxType eType; - const char *pName; - sal_Int32 nLen; + OUString sName; }; -const MessageBoxTypeInfo aMessageBoxTypeInfo[] = +constexpr MessageBoxTypeInfo aMessageBoxTypeInfo[] = { - { css::awt::MessageBoxType_MESSAGEBOX, RTL_CONSTASCII_STRINGPARAM("messbox") }, - { css::awt::MessageBoxType_INFOBOX, RTL_CONSTASCII_STRINGPARAM("infobox") }, - { css::awt::MessageBoxType_WARNINGBOX, RTL_CONSTASCII_STRINGPARAM("warningbox") }, - { css::awt::MessageBoxType_ERRORBOX, RTL_CONSTASCII_STRINGPARAM("errorbox") }, - { css::awt::MessageBoxType_QUERYBOX, RTL_CONSTASCII_STRINGPARAM("querybox") }, - { css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE, nullptr, 0 } + { css::awt::MessageBoxType_MESSAGEBOX, u"messbox"_ustr }, + { css::awt::MessageBoxType_INFOBOX, u"infobox"_ustr }, + { css::awt::MessageBoxType_WARNINGBOX, u"warningbox"_ustr }, + { css::awt::MessageBoxType_ERRORBOX, u"errorbox"_ustr }, + { css::awt::MessageBoxType_QUERYBOX, u"querybox"_ustr } }; OUString lcl_convertMessageBoxType(css::awt::MessageBoxType eType) { - const MessageBoxTypeInfo* pMap = aMessageBoxTypeInfo; - while ( pMap->pName ) + for (const MessageBoxTypeInfo& rInfo : aMessageBoxTypeInfo) { - if ( pMap->eType == eType ) - { - return OUString(pMap->pName, pMap->nLen, RTL_TEXTENCODING_ASCII_US); - } - pMap++; + if (rInfo.eType == eType) + return rInfo.sName; } return OUString(); commit 9effdf988468cac239d49cd1c4f8deae06931f0a Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Aug 15 08:24:40 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Aug 15 11:01:26 2025 +0200 toolkit: Simplify lcl_convertMessageBoxType The bool return value is unused. Drop it and use a string return value instead of an out param. Change-Id: Icd13b882cbeec25029d571988cc722e396361aab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189658 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 9c8658695422..7cd2ead5a0cb 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -825,25 +825,19 @@ const MessageBoxTypeInfo aMessageBoxTypeInfo[] = { css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE, nullptr, 0 } }; -bool lcl_convertMessageBoxType( - OUString &sType, - css::awt::MessageBoxType eType ) +OUString lcl_convertMessageBoxType(css::awt::MessageBoxType eType) { - const MessageBoxTypeInfo *pMap = aMessageBoxTypeInfo; - css::awt::MessageBoxType eVal = css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE; - + const MessageBoxTypeInfo* pMap = aMessageBoxTypeInfo; while ( pMap->pName ) { if ( pMap->eType == eType ) { - eVal = eType; - sType = OUString( pMap->pName, pMap->nLen, RTL_TEXTENCODING_ASCII_US ); - break; + return OUString(pMap->pName, pMap->nLen, RTL_TEXTENCODING_ASCII_US); } pMap++; } - return ( eVal != css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE ); + return OUString(); } #ifndef IOS @@ -2036,8 +2030,7 @@ css::uno::Reference< css::awt::XMessageBox > SAL_CALL VCLXToolkit::createMessage if ( sal_Int32( aButtons & 0xffff0000L ) == css::awt::MessageBoxButtons::DEFAULT_BUTTON_IGNORE ) nAddWinBits |= MessBoxStyle::DefaultIgnore; - OUString aType; - lcl_convertMessageBoxType( aType, eType ); + OUString aType = lcl_convertMessageBoxType(eType); aDescriptor.Type = css::awt::WindowClass_MODALTOP; aDescriptor.WindowServiceName = aType;