diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-12-21 10:44:56 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-12-21 13:44:52 +0000 |
commit | c4f0efc2378cebc3b581bc949da70a2b2f149961 (patch) | |
tree | 3c0a330f7811c9407a787cec45382993b4037a6f /vcl | |
parent | 073431d26d39216a7f5f85489ecd4eb60806ee88 (diff) |
convert ReadByteString/WriteByteString from ByteString to OString
Nobody ever used the return values anyway, so for reading just
return the string and for writing the number of bytes written
Doesn't need to be members, make standalone functions
Rename to
read_lenPrefixed_uInt8s_ToO[U]String and
write_lenPrefixed_uInt8s_FromO[U]String, lengthy,
but much less unambiguous, seeing as a lot of users of it don't
seem to be aware that they read/write pascal-style length
prefixed strings, which isn't surprising given the
apparent simplicity of their original name.
added a unit test
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/gdi/animate.cxx | 6 | ||||
-rw-r--r-- | vcl/source/gdi/cvtsvm.cxx | 11 | ||||
-rw-r--r-- | vcl/source/gdi/jobset.cxx | 18 | ||||
-rw-r--r-- | vcl/source/gdi/metaact.cxx | 9 |
4 files changed, 23 insertions, 21 deletions
diff --git a/vcl/source/gdi/animate.cxx b/vcl/source/gdi/animate.cxx index 30a23372661c..636df96a6c66 100644 --- a/vcl/source/gdi/animate.cxx +++ b/vcl/source/gdi/animate.cxx @@ -795,7 +795,6 @@ SvStream& operator<<( SvStream& rOStm, const Animation& rAnimation ) if( nCount ) { - const ByteString aDummyStr; const sal_uInt32 nDummy32 = 0UL; // Falls keine BitmapEx gesetzt wurde, schreiben wir @@ -825,7 +824,7 @@ SvStream& operator<<( SvStream& rOStm, const Animation& rAnimation ) rOStm << nDummy32; // unbenutzt rOStm << nDummy32; // unbenutzt rOStm << nDummy32; // unbenutzt - rOStm.WriteByteString(aDummyStr); // unbenutzt + write_lenPrefixed_uInt8s_FromOString(rOStm, rtl::OString()); // dummy rOStm << nRest; // Anzahl der Strukturen, die noch _folgen_ } } @@ -872,7 +871,6 @@ SvStream& operator>>( SvStream& rIStm, Animation& rAnimation ) { AnimationBitmap aAnimBmp; BitmapEx aBmpEx; - ByteString aDummyStr; sal_uInt32 nTmp32; sal_uInt16 nTmp16; sal_uInt8 cTmp; @@ -890,7 +888,7 @@ SvStream& operator>>( SvStream& rIStm, Animation& rAnimation ) rIStm >> nTmp32; // unbenutzt rIStm >> nTmp32; // unbenutzt rIStm >> nTmp32; // unbenutzt - rIStm.ReadByteString(aDummyStr); // unbenutzt + read_lenPrefixed_uInt8s_ToOString(rIStm); // unbenutzt rIStm >> nTmp16; // Rest zu lesen rAnimation.Insert( aAnimBmp ); diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx index 7efd1f6f6e82..738a5907172b 100644 --- a/vcl/source/gdi/cvtsvm.cxx +++ b/vcl/source/gdi/cvtsvm.cxx @@ -877,7 +877,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rIStm >> aPt >> nIndex >> nLen >> nTmp; if ( nTmp && ( static_cast< sal_uInt32 >( nTmp ) < ( SAL_MAX_UINT16 - 1 ) ) ) { - rtl::OString aByteStr = read_uInt8s_AsOString(rIStm, nTmp); + rtl::OString aByteStr = read_uInt8s_ToOString(rIStm, nTmp); sal_uInt8 nTerminator = 0; rIStm >> nTerminator; DBG_ASSERT( nTerminator == 0, "expected string to be NULL terminated" ); @@ -899,7 +899,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rIStm >> aPt >> nIndex >> nLen >> nTmp >> nAryLen; if ( nTmp && ( static_cast< sal_uInt32 >( nTmp ) < ( SAL_MAX_UINT16 - 1 ) ) ) { - rtl::OString aByteStr = read_uInt8s_AsOString(rIStm, nTmp); + rtl::OString aByteStr = read_uInt8s_ToOString(rIStm, nTmp); sal_uInt8 nTerminator = 0; rIStm >> nTerminator; DBG_ASSERT( nTerminator == 0, "expected string to be NULL terminated" ); @@ -962,7 +962,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rIStm >> aPt >> nIndex >> nLen >> nTmp >> nWidth; if ( nTmp && ( static_cast< sal_uInt32 >( nTmp ) < ( SAL_MAX_INT16 - 1 ) ) ) { - rtl::OString aByteStr = read_uInt8s_AsOString(rIStm, nTmp); + rtl::OString aByteStr = read_uInt8s_ToOString(rIStm, nTmp); sal_uInt8 nTerminator = 0; rIStm >> nTerminator; DBG_ASSERT( nTerminator == 0, "expected string to be NULL terminated" ); @@ -1322,13 +1322,12 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) case( GDI_COMMENT_COMMENT ): { - ByteString aComment; sal_Int32 nValue; sal_uInt32 nDataSize; sal_uInt8* pData; sal_Int32 nFollowingActionCount; - rIStm.ReadByteString(aComment); + rtl::OString aComment = read_lenPrefixed_uInt8s_ToOString(rIStm); rIStm >> nValue >> nDataSize; if( nDataSize ) @@ -2413,7 +2412,7 @@ sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, rOStm.SeekRel( 4 ); // write data - rOStm.WriteByteString(pA->GetComment()); + write_lenPrefixed_uInt8s_FromOString(rOStm, pA->GetComment()); rOStm << pA->GetValue() << nDataSize; if( nDataSize ) diff --git a/vcl/source/gdi/jobset.cxx b/vcl/source/gdi/jobset.cxx index 14b86b236068..796659cfdaa5 100644 --- a/vcl/source/gdi/jobset.cxx +++ b/vcl/source/gdi/jobset.cxx @@ -410,13 +410,21 @@ SvStream& operator<<( SvStream& rOStream, const JobSetup& rJobSetup ) rOStream.WriteByteString( it->first, RTL_TEXTENCODING_UTF8 ); rOStream.WriteByteString( it->second, RTL_TEXTENCODING_UTF8 ); } - rOStream.WriteByteString( "COMPAT_DUPLEX_MODE" ) ; + write_lenPrefixed_uInt8s_FromOString(rOStream, "COMPAT_DUPLEX_MODE"); switch( pJobData->meDuplexMode ) { - case DUPLEX_UNKNOWN: rOStream.WriteByteString( "DUPLEX_UNKNOWN" );break; - case DUPLEX_OFF: rOStream.WriteByteString( "DUPLEX_OFF" );break; - case DUPLEX_SHORTEDGE: rOStream.WriteByteString( "DUPLEX_SHORTEDGE" );break; - case DUPLEX_LONGEDGE: rOStream.WriteByteString( "DUPLEX_LONGEDGE" );break; + case DUPLEX_UNKNOWN: + write_lenPrefixed_uInt8s_FromOString(rOStream, "DUPLEX_UNKNOWN"); + break; + case DUPLEX_OFF: + write_lenPrefixed_uInt8s_FromOString(rOStream, "DUPLEX_OFF"); + break; + case DUPLEX_SHORTEDGE: + write_lenPrefixed_uInt8s_FromOString(rOStream, "DUPLEX_SHORTEDGE"); + break; + case DUPLEX_LONGEDGE: + write_lenPrefixed_uInt8s_FromOString(rOStream, "DUPLEX_LONGEDGE"); + break; } nLen = sal::static_int_cast<sal_uInt16>(rOStream.Tell() - nPos); rOStream.Seek( nPos ); diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index a0b6c3b27c6b..9961705cbb6c 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -4198,7 +4198,7 @@ sal_Bool MetaCommentAction::Compare( const MetaAction& rMetaAction ) const void MetaCommentAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) { WRITE_BASE_COMPAT( rOStm, 1, pData ); - rOStm.WriteByteString(maComment); + write_lenPrefixed_uInt8s_FromOString(rOStm, maComment); rOStm << mnValue << mnDataSize; if ( mnDataSize ) @@ -4210,13 +4210,10 @@ void MetaCommentAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) void MetaCommentAction::Read( SvStream& rIStm, ImplMetaReadData* ) { COMPAT( rIStm ); - ByteString sTmp; - rIStm.ReadByteString(sTmp); - maComment = sTmp; + maComment = read_lenPrefixed_uInt8s_ToOString(rIStm); rIStm >> mnValue >> mnDataSize; - if( mpData ) - delete[] mpData; + delete[] mpData; if( mnDataSize ) { |