diff options
author | sb <sb@openoffice.org> | 2009-12-10 13:45:13 +0100 |
---|---|---|
committer | sb <sb@openoffice.org> | 2009-12-10 13:45:13 +0100 |
commit | b069d0fabfa30848596bdc106380f75a725b686e (patch) | |
tree | daa0b9d6ba328d675ef39e9ec5ad166fc7b90972 /configmgr | |
parent | fbd61e28d2ef33d609bac8a9e1c049c57f8da11c (diff) |
sb111: #i107578# for backward compatibility, support hexadecimal configuration values; however, change uses to decimal notation, anyway
Diffstat (limited to 'configmgr')
-rw-r--r-- | configmgr/source/valueparser.cxx | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/configmgr/source/valueparser.cxx b/configmgr/source/valueparser.cxx index 479485311826..f36ccba850ad 100644 --- a/configmgr/source/valueparser.cxx +++ b/configmgr/source/valueparser.cxx @@ -95,7 +95,15 @@ bool parseValue(Span const & text, sal_Bool * value) { bool parseValue(Span const & text, sal_Int16 * value) { OSL_ASSERT(text.is() && value != 0); - sal_Int32 n = rtl::OString(text.begin, text.length).toInt32(); + // For backwards compatibility, support hexadecimal values: + sal_Int32 n = + rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( + text.begin, text.length, RTL_CONSTASCII_STRINGPARAM("0X"), + RTL_CONSTASCII_LENGTH("0X")) == 0 ? + rtl::OString( + text.begin + RTL_CONSTASCII_LENGTH("0X"), + text.length - RTL_CONSTASCII_LENGTH("0X")).toInt32(16) : + rtl::OString(text.begin, text.length).toInt32(); //TODO: check valid lexical representation if (n >= SAL_MIN_INT16 && n <= SAL_MAX_INT16) { *value = static_cast< sal_Int16 >(n); @@ -106,14 +114,30 @@ bool parseValue(Span const & text, sal_Int16 * value) { bool parseValue(Span const & text, sal_Int32 * value) { OSL_ASSERT(text.is() && value != 0); - *value = rtl::OString(text.begin, text.length).toInt32(); + // For backwards compatibility, support hexadecimal values: + *value = + rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( + text.begin, text.length, RTL_CONSTASCII_STRINGPARAM("0X"), + RTL_CONSTASCII_LENGTH("0X")) == 0 ? + rtl::OString( + text.begin + RTL_CONSTASCII_LENGTH("0X"), + text.length - RTL_CONSTASCII_LENGTH("0X")).toInt32(16) : + rtl::OString(text.begin, text.length).toInt32(); //TODO: check valid lexical representation return true; } bool parseValue(Span const & text, sal_Int64 * value) { OSL_ASSERT(text.is() && value != 0); - *value = rtl::OString(text.begin, text.length).toInt64(); + // For backwards compatibility, support hexadecimal values: + *value = + rtl_str_shortenedCompareIgnoreAsciiCase_WithLength( + text.begin, text.length, RTL_CONSTASCII_STRINGPARAM("0X"), + RTL_CONSTASCII_LENGTH("0X")) == 0 ? + rtl::OString( + text.begin + RTL_CONSTASCII_LENGTH("0X"), + text.length - RTL_CONSTASCII_LENGTH("0X")).toInt64(16) : + rtl::OString(text.begin, text.length).toInt64(); //TODO: check valid lexical representation return true; } |