diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-06-12 15:58:17 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-06-13 17:08:36 +0200 |
commit | 3af0114a295d2a6c600117adb5bcd6689c0c787e (patch) | |
tree | 262f32143b99a8754e517be454681267cadaa85f /oox | |
parent | 4edbfa892bfe6ca81c88363b2249e0b7d5eef31f (diff) |
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
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/helper/attributelist.cxx | 6 | ||||
-rw-r--r-- | oox/source/vml/vmlformatting.cxx | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx index debd1f8a98c9..2c0eb23fc85f 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 9be2c6881cee..806c62460b25 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; } |