[Libreoffice-commits] core.git: configmgr/source framework/source i18npool/source include/rtl jvmfwk/source odk/examples oox/source sal/qa sal/rtl sal/util sc/source stoc/source svl/source svx/source vcl/generic vcl/source vcl/unx writerfilter/source xmloff/source xmlscript/source
Stephan Bergmann
sbergman at redhat.com
Thu Jun 13 08:09:04 PDT 2013
configmgr/source/valueparser.cxx | 21 +++---
framework/source/xml/imagesdocumenthandler.cxx | 2
i18npool/source/localedata/localedata.cxx | 2
include/rtl/string.h | 21 ++++++
include/rtl/string.hxx | 17 +++++
include/rtl/ustring.h | 21 ++++++
include/rtl/ustring.hxx | 17 +++++
jvmfwk/source/elements.cxx | 4 +
odk/examples/cpp/custompanel/ctp_factory.cxx | 2
oox/source/helper/attributelist.cxx | 6 +
oox/source/vml/vmlformatting.cxx | 8 +-
sal/qa/rtl/strings/test_strings_toint.cxx | 7 ++
sal/rtl/strtmpl.cxx | 69 ++++++++++++---------
sal/util/sal.map | 6 +
sc/source/filter/html/htmlpars.cxx | 2
sc/source/filter/oox/drawingfragment.cxx | 8 +-
sc/source/filter/oox/pagesettings.cxx | 2
stoc/source/typeconv/convert.cxx | 6 -
svl/source/numbers/zforlist.cxx | 3
svl/source/passwordcontainer/passwordcontainer.cxx | 6 -
svx/source/customshapes/EnhancedCustomShape2d.cxx | 2
vcl/generic/fontmanager/fontmanager.cxx | 2
vcl/source/app/settings.cxx | 2
vcl/unx/generic/window/salframe.cxx | 2
writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx | 2
xmloff/source/style/xmlnumfe.cxx | 7 +-
xmlscript/source/xmldlg_imexp/imp_share.hxx | 2
xmlscript/source/xmllib_imexp/imp_share.hxx | 2
28 files changed, 186 insertions(+), 65 deletions(-)
New commits:
commit 3af0114a295d2a6c600117adb5bcd6689c0c787e
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Jun 12 15:58:17 2013 +0200
Introduce O[U]String::toUInt32
...which has become necessary since bd60d41176da540b01d7583cfe00637431967f39
"Handle oveflow in O(U)String::toInt() functions" reduces values in the range
(SAL_MAX_INT32 .. SAL_MAX_UINT32] to zero, but some calls of toInt32(16) relied
on getting a correct (unsigned) value for the whole input range ["0" ..
"FFFFFFFF"] (see libreoffice-4-1 commit 9bf6c83367cedb7be81bf67f30d2147d26c7a8c3
"Revert overflow checks in O[U]String::toInt{32,64} again").
Audited all uses of toInt32/64 with non-decimal radix. (There is still a TODO
comment in oox/source/helper/attributelist.cxx, and
stoc/source/typeconv/convert.cxx will still need some love and test code.)
Change-Id: Iadaca1c0e41dab553687d0ce41c20c10cd657a95
diff --git a/configmgr/source/valueparser.cxx b/configmgr/source/valueparser.cxx
index a8dad19..9f93cd8 100644
--- a/configmgr/source/valueparser.cxx
+++ b/configmgr/source/valueparser.cxx
@@ -85,9 +85,10 @@ bool parseValue(xmlreader::Span const & text, sal_Int16 * value) {
rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
text.begin, text.length, RTL_CONSTASCII_STRINGPARAM("0X"),
RTL_CONSTASCII_LENGTH("0X")) == 0 ?
- OString(
- text.begin + RTL_CONSTASCII_LENGTH("0X"),
- text.length - RTL_CONSTASCII_LENGTH("0X")).toInt32(16) :
+ 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
if (n >= SAL_MIN_INT16 && n <= SAL_MAX_INT16) {
@@ -104,9 +105,10 @@ bool parseValue(xmlreader::Span const & text, sal_Int32 * value) {
rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
text.begin, text.length, RTL_CONSTASCII_STRINGPARAM("0X"),
RTL_CONSTASCII_LENGTH("0X")) == 0 ?
- OString(
- text.begin + RTL_CONSTASCII_LENGTH("0X"),
- text.length - RTL_CONSTASCII_LENGTH("0X")).toInt32(16) :
+ 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
return true;
@@ -119,9 +121,10 @@ bool parseValue(xmlreader::Span const & text, sal_Int64 * value) {
rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
text.begin, text.length, RTL_CONSTASCII_STRINGPARAM("0X"),
RTL_CONSTASCII_LENGTH("0X")) == 0 ?
- OString(
- text.begin + RTL_CONSTASCII_LENGTH("0X"),
- text.length - RTL_CONSTASCII_LENGTH("0X")).toInt64(16) :
+ static_cast< sal_Int64 >(
+ OString(
+ text.begin + RTL_CONSTASCII_LENGTH("0X"),
+ text.length - RTL_CONSTASCII_LENGTH("0X")).toUInt64(16)) :
OString(text.begin, text.length).toInt64();
//TODO: check valid lexical representation
return true;
diff --git a/framework/source/xml/imagesdocumenthandler.cxx b/framework/source/xml/imagesdocumenthandler.cxx
index 5821266..253944b 100644
--- a/framework/source/xml/imagesdocumenthandler.cxx
+++ b/framework/source/xml/imagesdocumenthandler.cxx
@@ -233,7 +233,7 @@ throw( SAXException, RuntimeException )
if ( aColor.getStr()[0] == '#' )
{
// the color value is given as #rrggbb and used the hexadecimal system!!
- sal_uInt32 nColor = aColor.copy( 1 ).toInt32( 16 );
+ sal_uInt32 nColor = aColor.copy( 1 ).toUInt32( 16 );
m_pImages->aMaskColor = Color( COLORDATA_RGB( nColor ) );
}
diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx
index e469634..c980d2a 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -1422,7 +1422,7 @@ LocaleData::getOutlineNumberingLevels( const lang::Locale& rLocale ) throw(Runti
case 0: level[j].sPrefix = tmp; break;
case 1: level[j].nNumType = sal::static_int_cast<sal_Int16>(tmp.toInt32()); break;
case 2: level[j].sSuffix = tmp; break;
- case 3: level[j].cBulletChar = sal::static_int_cast<sal_Unicode>(tmp.toInt32(16)); break; // base 16
+ case 3: level[j].cBulletChar = sal::static_int_cast<sal_Unicode>(tmp.toUInt32(16)); break; // base 16
case 4: level[j].sBulletFontName = U2C( tmp ); break;
case 5: level[j].nParentNumbering = sal::static_int_cast<sal_Int16>(tmp.toInt32()); break;
case 6: level[j].nLeftMargin = tmp.toInt32(); break;
diff --git a/include/rtl/string.h b/include/rtl/string.h
index 9cd81aa..28b089b 100644
--- a/include/rtl/string.h
+++ b/include/rtl/string.h
@@ -743,6 +743,27 @@ SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_str_toBoolean(
SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_toInt32(
const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+/** Interpret a string as an unsigned integer.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param radix
+ the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the unsigned integer value represented by the string, or 0 if the string
+ does not represent an unsigned integer.
+
+ @since LibreOffice 4.2
+ */
+SAL_DLLPUBLIC sal_uInt32 SAL_CALL rtl_str_toUInt32(
+ const sal_Char * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+
/** Interpret a string as a long integer.
This function cannot be used for language-specific conversion. The string
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index 9432b74..c1cbba9 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -1338,6 +1338,23 @@ public:
}
/**
+ Returns the uint32 value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @param radix the radix (between 2 and 36)
+ @return the uint32 represented from this string.
+ 0 if this string represents no number or one of too large
+ magnitude.
+
+ @since LibreOffice 4.2
+ */
+ sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const SAL_THROW(())
+ {
+ return rtl_str_toUInt32( pData->buffer, radix );
+ }
+
+ /**
Returns the int64 value from this string.
This function can't be used for language specific conversion.
diff --git a/include/rtl/ustring.h b/include/rtl/ustring.h
index da6720b..8d20651 100644
--- a/include/rtl/ustring.h
+++ b/include/rtl/ustring.h
@@ -1073,6 +1073,27 @@ SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_ustr_toBoolean(
SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_toInt32(
const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+/** Interpret a string as an unsigned integer.
+
+ This function cannot be used for language-specific conversion. The string
+ must be null-terminated.
+
+ @param str
+ a null-terminated string.
+
+ @param radix
+ the radix. Must be between RTL_USTR_MIN_RADIX (2) and RTL_USTR_MAX_RADIX
+ (36), inclusive.
+
+ @return
+ the unsigned integer value represented by the string, or 0 if the string
+ does not represent an unsigned integer.
+
+ @since LibreOffice 4.2
+ */
+SAL_DLLPUBLIC sal_uInt32 SAL_CALL rtl_ustr_toUInt32(
+ const sal_Unicode * str, sal_Int16 radix ) SAL_THROW_EXTERN_C();
+
/** Interpret a string as a long integer.
This function cannot be used for language-specific conversion. The string
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index 112486d..fedd35f 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -1799,6 +1799,23 @@ public:
}
/**
+ Returns the uint32 value from this string.
+
+ This function can't be used for language specific conversion.
+
+ @param radix the radix (between 2 and 36)
+ @return the uint32 represented from this string.
+ 0 if this string represents no number or one of too large
+ magnitude.
+
+ @since LibreOffice 4.2
+ */
+ sal_uInt32 toUInt32( sal_Int16 radix = 10 ) const SAL_THROW(())
+ {
+ return rtl_ustr_toUInt32( pData->buffer, radix );
+ }
+
+ /**
Returns the int64 value from this string.
This function can't be used for language specific conversion.
diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx
index f9f481f..712939b 100644
--- a/jvmfwk/source/elements.cxx
+++ b/jvmfwk/source/elements.cxx
@@ -33,6 +33,10 @@
#include "boost/optional.hpp"
#include <string.h>
+// For backwards compatibility, the nFeatures and nRequirements flag words are
+// read/written as potentially signed hexadecimal numbers (though that has no
+// practical relevance given that each has only one flag with value 0x01
+// defined).
using namespace osl;
namespace jfw
diff --git a/odk/examples/cpp/custompanel/ctp_factory.cxx b/odk/examples/cpp/custompanel/ctp_factory.cxx
index 1fb01a5..581e131 100644
--- a/odk/examples/cpp/custompanel/ctp_factory.cxx
+++ b/odk/examples/cpp/custompanel/ctp_factory.cxx
@@ -73,7 +73,7 @@ namespace sd { namespace colortoolpanel
throw NoSuchElementException( i_rResourceURL, *this );
const OUString sColor( i_rResourceURL.copy( i_rResourceURL.lastIndexOf( '/' ) + 1 ) );
- const sal_Int32 nPanelColor = sColor.toInt32( 16 );
+ const sal_Int32 nPanelColor = static_cast< sal_Int32 >( sColor.toUInt32( 16 ) );
// retrieve the parent window
Reference< XWindow > xParentWindow;
diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx
index debd1f8..2c0eb23 100644
--- a/oox/source/helper/attributelist.cxx
+++ b/oox/source/helper/attributelist.cxx
@@ -107,7 +107,11 @@ sal_Int64 AttributeConversion::decodeHyper( const OUString& rValue )
sal_Int32 AttributeConversion::decodeIntegerHex( const OUString& rValue )
{
- return rValue.toInt32( 16 );
+ // It looks like all Office Open XML attributes containing hexadecimal
+ // values are based on xsd:hexBinary and so use an unsigned representation:
+ return static_cast< sal_Int32 >(rValue.toUInt32( 16 ));
+ //TODO: Change this function to return sal_uInt32 and get rid of the
+ // cast, but that will have a ripple effect
}
// ============================================================================
diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index 9be2c68..806c624 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -205,16 +205,16 @@ Color ConversionHelper::decodeColor( const GraphicHelper& rGraphicHelper,
// RGB colors in the format '#RRGGBB'
if( (aColorName.getLength() == 7) && (aColorName[ 0 ] == '#') )
{
- aDmlColor.setSrgbClr( aColorName.copy( 1 ).toInt32( 16 ) );
+ aDmlColor.setSrgbClr( aColorName.copy( 1 ).toUInt32( 16 ) );
return aDmlColor;
}
// RGB colors in the format '#RGB'
if( (aColorName.getLength() == 4) && (aColorName[ 0 ] == '#') )
{
- sal_Int32 nR = aColorName.copy( 1, 1 ).toInt32( 16 ) * 0x11;
- sal_Int32 nG = aColorName.copy( 2, 1 ).toInt32( 16 ) * 0x11;
- sal_Int32 nB = aColorName.copy( 3, 1 ).toInt32( 16 ) * 0x11;
+ sal_Int32 nR = aColorName.copy( 1, 1 ).toUInt32( 16 ) * 0x11;
+ sal_Int32 nG = aColorName.copy( 2, 1 ).toUInt32( 16 ) * 0x11;
+ sal_Int32 nB = aColorName.copy( 3, 1 ).toUInt32( 16 ) * 0x11;
aDmlColor.setSrgbClr( (nR << 16) | (nG << 8) | nB );
return aDmlColor;
}
diff --git a/sal/qa/rtl/strings/test_strings_toint.cxx b/sal/qa/rtl/strings/test_strings_toint.cxx
index 4a4f549..cf5de4a 100644
--- a/sal/qa/rtl/strings/test_strings_toint.cxx
+++ b/sal/qa/rtl/strings/test_strings_toint.cxx
@@ -22,6 +22,7 @@ template< typename T > class Test: public CppUnit::TestFixture {
private:
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testToInt32Overflow);
+ CPPUNIT_TEST(testToUInt32Overflow);
CPPUNIT_TEST(testToInt64Overflow);
CPPUNIT_TEST(testToUInt64Overflow);
CPPUNIT_TEST_SUITE_END();
@@ -35,6 +36,12 @@ private:
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), T("2147483648").toInt32());
}
+ void testToUInt32Overflow() {
+ CPPUNIT_ASSERT_EQUAL(SAL_MAX_UINT32 - 1, T("4294967294").toUInt32());
+ CPPUNIT_ASSERT_EQUAL(SAL_MAX_UINT32, T("4294967295").toUInt32());
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), T("4294967296").toUInt32());
+ }
+
void testToInt64Overflow() {
CPPUNIT_ASSERT_EQUAL(sal_Int64(0), T("-9223372036854775809").toInt64());
CPPUNIT_ASSERT_EQUAL(
diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx
index 78aa1f5..dc54945 100644
--- a/sal/rtl/strtmpl.cxx
+++ b/sal/rtl/strtmpl.cxx
@@ -999,42 +999,57 @@ sal_Int64 SAL_CALL IMPL_RTL_STRNAME( toInt64 )( const IMPL_RTL_STRCODE* pStr,
}
/* ----------------------------------------------------------------------- */
+namespace {
+ template <typename T> static inline T IMPL_RTL_STRNAME( toUInt )( const IMPL_RTL_STRCODE* pStr,
+ sal_Int16 nRadix )
+ {
+ BOOST_STATIC_ASSERT(!std::numeric_limits<T>::is_signed);
+ sal_Int16 nDigit;
+ T n = 0;
-sal_uInt64 SAL_CALL IMPL_RTL_STRNAME( toUInt64 )( const IMPL_RTL_STRCODE* pStr,
- sal_Int16 nRadix )
- SAL_THROW_EXTERN_C()
-{
- sal_Int16 nDigit;
- sal_uInt64 n = 0;
+ if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) )
+ nRadix = 10;
- if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) )
- nRadix = 10;
+ /* Skip whitespaces */
+ while ( *pStr && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE( *pStr ) ) )
+ ++pStr;
- /* Skip whitespaces */
- while ( *pStr && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE( *pStr ) ) )
- ++pStr;
+ // skip optional explicit sign
+ if ( *pStr == '+' )
+ ++pStr;
- // skip optional explicit sign
- if ( *pStr == '+' )
- ++pStr;
+ T nDiv = std::numeric_limits<T>::max() / nRadix;
+ sal_Int16 nMod = std::numeric_limits<T>::max() % nRadix;
+ while ( *pStr )
+ {
+ nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix );
+ if ( nDigit < 0 )
+ break;
+ if( ( nMod < nDigit ? nDiv-1 : nDiv ) < n )
+ return 0;
- const sal_uInt64 nDiv = SAL_MAX_UINT64/nRadix;
- const sal_Int16 nMod = SAL_MAX_UINT64%nRadix;
- while ( *pStr )
- {
- nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix );
- if ( nDigit < 0 )
- break;
- if( ( nMod < nDigit ? nDiv-1 : nDiv ) < n )
- return 0;
+ n *= nRadix;
+ n += nDigit;
- n *= nRadix;
- n += nDigit;
+ ++pStr;
+ }
- ++pStr;
+ return n;
}
+}
- return n;
+sal_uInt32 SAL_CALL IMPL_RTL_STRNAME( toUInt32 )( const IMPL_RTL_STRCODE* pStr,
+ sal_Int16 nRadix )
+ SAL_THROW_EXTERN_C()
+{
+ return IMPL_RTL_STRNAME( toUInt )<sal_uInt32>(pStr, nRadix);
+}
+
+sal_uInt64 SAL_CALL IMPL_RTL_STRNAME( toUInt64 )( const IMPL_RTL_STRCODE* pStr,
+ sal_Int16 nRadix )
+ SAL_THROW_EXTERN_C()
+{
+ return IMPL_RTL_STRNAME( toUInt )<sal_uInt64>(pStr, nRadix);
}
/* ======================================================================= */
diff --git a/sal/util/sal.map b/sal/util/sal.map
index f2790d5..1456d6d 100644
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -664,6 +664,12 @@ LIBO_UDK_4.1 { # symbols available in >= LibO 4.1
rtl_ustr_toUInt64;
} LIBO_UDK_4.0;
+LIBO_UDK_4.2 { # symbols available in >= LibO 4.2
+ global:
+ rtl_str_toUInt32;
+ rtl_ustr_toUInt32;
+} LIBO_UDK_4.1;
+
PRIVATE_1.0 {
global:
osl_detail_ObjectRegistry_storeAddresses;
diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx
index 584aaef..6d93c4e 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -2191,7 +2191,7 @@ OUString decodeNumberFormat(const OUString& rFmt)
// Hex-encoded character found. Decode it back into its
// original character. An example of number format with
// hex-encoded chars: "\0022$\0022\#\,\#\#0\.00"
- sal_Int32 nVal = OUString(p1, nDigitCount).toInt32(16);
+ sal_uInt32 nVal = OUString(p1, nDigitCount).toUInt32(16);
aBuf.append(static_cast<sal_Unicode>(nVal));
}
}
diff --git a/sc/source/filter/oox/drawingfragment.cxx b/sc/source/filter/oox/drawingfragment.cxx
index dc047d4..c8338a9 100644
--- a/sc/source/filter/oox/drawingfragment.cxx
+++ b/sc/source/filter/oox/drawingfragment.cxx
@@ -678,14 +678,14 @@ sal_uInt32 VmlDrawing::convertControlTextColor( const OUString& rTextColor ) con
{
// RGB colors in the format '#RRGGBB'
if( rTextColor.getLength() == 7 )
- return OleHelper::encodeOleColor( rTextColor.copy( 1 ).toInt32( 16 ) );
+ return OleHelper::encodeOleColor( rTextColor.copy( 1 ).toUInt32( 16 ) );
// RGB colors in the format '#RGB'
if( rTextColor.getLength() == 4 )
{
- sal_Int32 nR = rTextColor.copy( 1, 1 ).toInt32( 16 ) * 0x11;
- sal_Int32 nG = rTextColor.copy( 2, 1 ).toInt32( 16 ) * 0x11;
- sal_Int32 nB = rTextColor.copy( 3, 1 ).toInt32( 16 ) * 0x11;
+ sal_Int32 nR = rTextColor.copy( 1, 1 ).toUInt32( 16 ) * 0x11;
+ sal_Int32 nG = rTextColor.copy( 2, 1 ).toUInt32( 16 ) * 0x11;
+ sal_Int32 nB = rTextColor.copy( 3, 1 ).toUInt32( 16 ) * 0x11;
return OleHelper::encodeOleColor( (nR << 16) | (nG << 8) | nB );
}
diff --git a/sc/source/filter/oox/pagesettings.cxx b/sc/source/filter/oox/pagesettings.cxx
index 28553dc..fd90cc5 100644
--- a/sc/source/filter/oox/pagesettings.cxx
+++ b/sc/source/filter/oox/pagesettings.cxx
@@ -872,7 +872,7 @@ void HeaderFooterParser::convertFontColor( const OUString& rColor )
static_cast< double >( rColor.copy( 2 ).toInt32() ) / 100.0 );
else
// RGB color: RRGGBB
- maFontModel.maColor.setRgb( rColor.toInt32( 16 ) );
+ maFontModel.maColor.setRgb( rColor.toUInt32( 16 ) );
}
void HeaderFooterParser::finalizePortion()
diff --git a/stoc/source/typeconv/convert.cxx b/stoc/source/typeconv/convert.cxx
index 799bae3..ec83601 100644
--- a/stoc/source/typeconv/convert.cxx
+++ b/stoc/source/typeconv/convert.cxx
@@ -143,7 +143,7 @@ static sal_Bool getNumericValue( double & rfVal, const OUString & rStr )
}
OUString aHexRest( trim.copy( nX+1 ) );
- sal_Int64 nRet = aHexRest.toInt64( 16 );
+ sal_uInt64 nRet = aHexRest.toUInt64( 16 );
if (nRet == 0)
{
@@ -223,7 +223,7 @@ static sal_Bool getHyperValue( sal_Int64 & rnVal, const OUString & rStr )
}
OUString aHexRest( trim.copy( nX+1 ) );
- sal_Int64 nRet = aHexRest.toInt64( 16 );
+ sal_uInt64 nRet = aHexRest.toUInt64( 16 );
if (nRet == 0)
{
@@ -234,7 +234,7 @@ static sal_Bool getHyperValue( sal_Int64 & rnVal, const OUString & rStr )
}
}
- rnVal = (bNeg ? -nRet : nRet);
+ rnVal = (bNeg ? -static_cast<sal_Int64>(nRet) : nRet);
return sal_True;
}
return sal_False;
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index ae0a163..1a34380 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -3527,6 +3527,9 @@ const NfCurrencyEntry* SvNumberFormatter::GetCurrencyEntry( bool & bFoundBank,
LanguageType eExtLang;
if ( nExtLen )
{
+ // rExtension should be a 16-bit hex value max FFFF which may contain a
+ // leading "-" separator (that is not a minus sign, but toInt32 can be
+ // used to parse it, with post-processing as necessary):
sal_Int32 nExtLang = rExtension.toInt32( 16 );
if ( !nExtLang )
{
diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx
index 8cf17ee..3e9c3b0 100644
--- a/svl/source/passwordcontainer/passwordcontainer.cxx
+++ b/svl/source/passwordcontainer/passwordcontainer.cxx
@@ -118,7 +118,7 @@ static vector< OUString > getInfoFromInd( OUString aInd )
aNum += OUString::valueOf( (sal_Unicode) pLine[i] );
}
- newItem += OUString::valueOf( (sal_Unicode) aNum.toInt32( 16 ) );
+ newItem += OUString::valueOf( (sal_Unicode) aNum.toUInt32( 16 ) );
pLine += 3;
}
@@ -482,7 +482,7 @@ vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLine, co
unsigned char code[RTL_DIGEST_LENGTH_MD5];
for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ )
- code[ ind ] = (char)(aMasterPasswd.copy( ind*2, 2 ).toInt32(16));
+ code[ ind ] = (char)(aMasterPasswd.copy( ind*2, 2 ).toUInt32(16));
rtlCipherError result = rtl_cipher_init (
aDecoder, rtl_Cipher_DirectionDecode,
@@ -536,7 +536,7 @@ OUString PasswordContainer::EncodePasswords( vector< OUString > lines, const OUS
unsigned char code[RTL_DIGEST_LENGTH_MD5];
for( int ind = 0; ind < RTL_DIGEST_LENGTH_MD5; ind++ )
- code[ ind ] = (char)(aMasterPasswd.copy( ind*2, 2 ).toInt32(16));
+ code[ ind ] = (char)(aMasterPasswd.copy( ind*2, 2 ).toUInt32(16));
rtlCipherError result = rtl_cipher_init (
aEncoder, rtl_Cipher_DirectionEncode,
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index f17e145..c6bc397 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -813,7 +813,7 @@ EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) :
if( sShapeType.getLength() > 4 &&
sShapeType.match( "col-" ))
{
- nColorData = sShapeType.copy( 4 ).toInt32( 16 );
+ nColorData = sShapeType.copy( 4 ).toUInt32( 16 );
}
}
break;
diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx
index d3adb50..7f2332c 100644
--- a/vcl/generic/fontmanager/fontmanager.cxx
+++ b/vcl/generic/fontmanager/fontmanager.cxx
@@ -2790,7 +2790,7 @@ std::list< sal_Unicode > PrintFontManager::getUnicodeFromAdobeName( const OStri
{
if( rName.getLength() == 7 && rName.indexOf( "uni" ) == 0 )
{
- sal_Unicode aCode = (sal_Unicode)rName.copy( 3 ).toInt32( 16 );
+ sal_Unicode aCode = (sal_Unicode)rName.copy( 3 ).toUInt32( 16 );
aRet.push_back( aCode );
}
}
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index d62966b..63f056e 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -767,7 +767,7 @@ static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFoot
if ( nIndex > 0 )
{
OUString aColor = aPersonaSettings.getToken( 0, ';', ++nIndex );
- maMenuBarTextColor = Color( aColor.toInt64( 16 ) );
+ maMenuBarTextColor = Color( aColor.toUInt64( 16 ) );
}
}
else if ( aPersona == "default" )
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index 0ef369e..1a2c166 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -3028,7 +3028,7 @@ bool X11SalFrame::endUnicodeSequence()
{
// cut the "u"
OUString aNumbers( rSeq.copy( 1 ) );
- sal_Int32 nValue = aNumbers.toInt32( 16 );
+ sal_uInt32 nValue = aNumbers.toUInt32( 16 );
if( nValue >= 32 )
{
sal_uInt16 nTextAttr = EXTTEXTINPUT_ATTR_UNDERLINE;
diff --git a/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx b/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx
index b8f5aa3..d77fdeb 100644
--- a/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLPropertySetImpl.cxx
@@ -636,7 +636,7 @@ OOXMLHexValue::OOXMLHexValue(sal_uInt32 nValue)
OOXMLHexValue::OOXMLHexValue(const OUString & rValue)
{
- mnValue = static_cast<sal_uInt32>(rValue.toInt32(16));
+ mnValue = rValue.toUInt32(16);
}
OOXMLHexValue::~OOXMLHexValue()
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index 8beeab7..8e0b23b6 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -400,8 +400,11 @@ void SvXMLNumFmtExport::WriteCurrencyElement_Impl( const OUString& rString,
if ( !rExt.isEmpty() )
{
- sal_Int32 nLang = rExt.toInt32(16); // hex
- if ( nLang < 0 ) // extension string may contain "-" separator
+ // rExt should be a 16-bit hex value max FFFF which may contain a
+ // leading "-" separator (that is not a minus sign, but toInt32 can be
+ // used to parse it, with post-processing as necessary):
+ sal_Int32 nLang = rExt.toInt32(16);
+ if ( nLang < 0 )
nLang = -nLang;
AddLanguageAttr_Impl( nLang ); // adds to pAttrList
}
diff --git a/xmlscript/source/xmldlg_imexp/imp_share.hxx b/xmlscript/source/xmldlg_imexp/imp_share.hxx
index d82dffa..2df45c0 100644
--- a/xmlscript/source/xmldlg_imexp/imp_share.hxx
+++ b/xmlscript/source/xmldlg_imexp/imp_share.hxx
@@ -45,7 +45,7 @@ inline sal_Int32 toInt32( OUString const & rStr ) SAL_THROW(())
{
sal_Int32 nVal;
if (rStr.getLength() > 2 && rStr[ 0 ] == '0' && rStr[ 1 ] == 'x')
- nVal = rStr.copy( 2 ).toInt32( 16 );
+ nVal = rStr.copy( 2 ).toUInt32( 16 );
else
nVal = rStr.toInt32();
return nVal;
diff --git a/xmlscript/source/xmllib_imexp/imp_share.hxx b/xmlscript/source/xmllib_imexp/imp_share.hxx
index bbeeea6..d0eaf94 100644
--- a/xmlscript/source/xmllib_imexp/imp_share.hxx
+++ b/xmlscript/source/xmllib_imexp/imp_share.hxx
@@ -45,7 +45,7 @@ inline sal_Int32 toInt32( OUString const & rStr ) SAL_THROW(())
sal_Int32 nVal;
if (rStr.getLength() > 2 && rStr[ 0 ] == '0' && rStr[ 1 ] == 'x')
{
- nVal = rStr.copy( 2 ).toInt32( 16 );
+ nVal = rStr.copy( 2 ).toUInt32( 16 );
}
else
{
More information about the Libreoffice-commits
mailing list