diff options
Diffstat (limited to 'configmgr')
-rw-r--r-- | configmgr/source/valueparser.cxx | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/configmgr/source/valueparser.cxx b/configmgr/source/valueparser.cxx index 249c1c1dbdcb..6b9faf6edbe0 100644 --- a/configmgr/source/valueparser.cxx +++ b/configmgr/source/valueparser.cxx @@ -25,6 +25,7 @@ #include <com/sun/star/uno/RuntimeException.hpp> #include <com/sun/star/uno/Sequence.hxx> #include <comphelper/sequence.hxx> +#include <o3tl/string_view.hxx> #include <rtl/math.h> #include <rtl/string.h> #include <rtl/string.hxx> @@ -99,16 +100,22 @@ bool parseValue(xmlreader::Span const & text, sal_Int16 * value) { bool parseValue(xmlreader::Span const & text, sal_Int32 * value) { assert(text.is() && value != nullptr); // For backwards compatibility, support hexadecimal values: - *value = - rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( + bool bStartWithHexPrefix = rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( text.begin, text.length, RTL_CONSTASCII_STRINGPARAM("0X"), - RTL_CONSTASCII_LENGTH("0X")) == 0 ? - static_cast< sal_Int32 >( - OString( - text.begin + RTL_CONSTASCII_LENGTH("0X"), - text.length - RTL_CONSTASCII_LENGTH("0X")).toUInt32(16)) : - OString(text.begin, text.length).toInt32(); - //TODO: check valid lexical representation + RTL_CONSTASCII_LENGTH("0X")) == 0; + + if (bStartWithHexPrefix) + { + std::string_view sView(text.begin + RTL_CONSTASCII_LENGTH("0X"), + text.length - RTL_CONSTASCII_LENGTH("0X")); + *value = static_cast< sal_Int32 >(o3tl::toUInt32(sView, 16)); + } + else + { + std::string_view sView(text.begin, text.length); + *value = o3tl::toInt32(sView); + } + //TODO: check valid lexical representation return true; } |