Index: basic/source/classes/image.cxx =================================================================== --- basic/source/classes/image.cxx (revision 1232873) +++ basic/source/classes/image.cxx (working copy) @@ -134,7 +134,9 @@ r >> nVersion >> nCharSet >> lDimBase >> nFlags >> nReserved1 >> nReserved2 >> nReserved3; eCharSet = (CharSet) nCharSet; - eCharSet = GetSOLoadTextEncoding( eCharSet ); + if (eCharSet != RTL_TEXTENCODING_UTF8) + eCharSet = GetSOLoadTextEncoding( eCharSet ); + bBadVer = sal_Bool( nVersion > B_CURVERSION ); nDimBase = (sal_uInt16) lDimBase; } @@ -210,30 +212,48 @@ case B_LINERANGES: break; case B_STRINGPOOL: + { if( bBadVer ) break; MakeStrings( nCount ); + sal_uInt16* pRawOffset = new sal_uInt16[ nStrings ]; for( i = 0; i < nStrings && SbiGood( r ); i++ ) { r >> nOff; - pStringOff[ i ] = (sal_uInt16) nOff; + pRawOffset[ i ] = (sal_uInt16) nOff; } r >> nLen; if( SbiGood( r ) ) { delete [] pStrings; - pStrings = new sal_Unicode[ nLen ]; - nStringSize = (sal_uInt16) nLen; - + sal_Int32 nDecodedLen = 0; + String* pDecodedStrings = new String[ nStrings ]; char* pByteStrings = new char[ nLen ]; r.Read( pByteStrings, nStringSize ); for( short j = 0; j < nStrings; j++ ) { + sal_uInt16 nOff2 = (sal_uInt16) pRawOffset[ j ]; + String aStr( pByteStrings + nOff2, eCharSet ); + pDecodedStrings[j] = aStr; + pStringOff[ j ] = nDecodedLen; + nDecodedLen += aStr.Len() + 1; + } + + pStrings = new sal_Unicode[ nDecodedLen ]; + nStringSize = (sal_uInt16) nDecodedLen; + + for( short j = 0; j < nStrings; j++ ) + { sal_uInt16 nOff2 = (sal_uInt16) pStringOff[ j ]; - String aStr( pByteStrings + nOff2, eCharSet ); + String aStr = pDecodedStrings[j]; memcpy( pStrings + nOff2, aStr.GetBuffer(), (aStr.Len() + 1) * sizeof( sal_Unicode ) ); + ByteString bstr(aStr.GetBuffer(), eCharSet); } + delete[] pDecodedStrings; delete[] pByteStrings; - } break; + } + delete[] pRawOffset; + break; + } case B_MODEND: goto done; default: @@ -269,7 +289,7 @@ sal_uIntPtr nStart = SbiOpenRecord( r, B_MODULE, 1 ); sal_uIntPtr nPos; - eCharSet = GetSOStoreTextEncoding( eCharSet ); + eCharSet = RTL_TEXTENCODING_UTF8; if ( bLegacy ) r << (sal_Int32) B_LEGACYVERSION; else @@ -355,20 +375,30 @@ // sal_uInt32 Offset of the Strings in the Stringblock short i; + ByteString* pEncodedByteStrings = new ByteString[ nStrings ]; + int nEncodedStringSize = 0; for( i = 0; i < nStrings && SbiGood( r ); i++ ) - r << (sal_uInt32) pStringOff[ i ]; + { + r << (sal_uInt32) nEncodedStringSize; + sal_uInt16 nOff = (sal_uInt16) pStringOff[ i ]; + ByteString aStr( pStrings + nOff, eCharSet ); + nEncodedStringSize += aStr.Len() + 1; + pEncodedByteStrings[i] = aStr; + } // Then the String-Block - char* pByteStrings = new char[ nStringSize ]; + int nEncodedOffset = 0; + char* pByteStrings = new char[ nEncodedStringSize ]; for( i = 0; i < nStrings; i++ ) { - sal_uInt16 nOff = (sal_uInt16) pStringOff[ i ]; - ByteString aStr( pStrings + nOff, eCharSet ); - memcpy( pByteStrings + nOff, aStr.GetBuffer(), (aStr.Len() + 1) * sizeof( char ) ); + ByteString aStr = pEncodedByteStrings[i]; + memcpy( pByteStrings + nEncodedOffset, aStr.GetBuffer(), (aStr.Len() + 1) * sizeof( char ) ); + nEncodedOffset += (aStr.Len() + 1) * sizeof( char ); } - r << (sal_uInt32) nStringSize; - r.Write( pByteStrings, nStringSize ); + r << (sal_uInt32) nEncodedStringSize; + r.Write( pByteStrings, nEncodedStringSize ); + delete[] pEncodedByteStrings; delete[] pByteStrings; SbiCloseRecord( r, nPos ); }