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 | |
parent | More removal from TTProperties (diff) | |
download | core-c4f0efc2378cebc3b581bc949da70a2b2f149961.tar.gz core-c4f0efc2378cebc3b581bc949da70a2b2f149961.zip |
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
46 files changed, 353 insertions, 327 deletions
diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx index a2fe3bd9a096..1a63f943d5a7 100644 --- a/basic/source/runtime/iosys.cxx +++ b/basic/source/runtime/iosys.cxx @@ -656,7 +656,7 @@ SbError SbiStream::Read( ByteString& rBuf, sal_uInt16 n, bool bForceReadingPerBy n = nLen; if( !n ) return nError = SbERR_BAD_RECORD_LENGTH; - rtl::OStringBuffer aBuffer(read_uInt8s_AsOString(*pStrm, n)); + rtl::OStringBuffer aBuffer(read_uInt8s_ToOString(*pStrm, n)); //Pad it out with ' ' to the requested length on short read sal_Int32 nRequested = sal::static_int_cast<sal_Int32>(n); comphelper::string::padToLength(aBuffer, nRequested, ' '); diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index fc5afcd3d354..cfabfbff4b0d 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -2739,7 +2739,7 @@ sal_Bool ODbaseTable::ReadMemo(sal_uIntPtr nBlockNo, ORowSetValue& aVariable) { if ( bIsText ) { - rtl::OStringBuffer aBuffer(read_uInt8s_AsOString(*m_pMemoStream, nLength)); + rtl::OStringBuffer aBuffer(read_uInt8s_ToOString(*m_pMemoStream, nLength)); //pad it out with ' ' to expected length on short read sal_Int32 nRequested = sal::static_int_cast<sal_Int32>(nLength); comphelper::string::padToLength(aBuffer, nRequested, ' '); diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx b/connectivity/source/drivers/dbase/dindexnode.cxx index 111745794750..046b457ab808 100644 --- a/connectivity/source/drivers/dbase/dindexnode.cxx +++ b/connectivity/source/drivers/dbase/dindexnode.cxx @@ -673,7 +673,7 @@ void ONDXNode::Read(SvStream &rStream, ODbaseIndex& rIndex) else { sal_uInt16 nLen = rIndex.getHeader().db_keylen; - rtl::OString aBuf = read_uInt8s_AsOString(rStream, nLen); + rtl::OString aBuf = read_uInt8s_ToOString(rStream, nLen); //get length minus trailing whitespace sal_Int32 nContentLen = aBuf.getLength(); while (nContentLen && aBuf[nContentLen-1] == ' ') diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx index 678f31abad56..0fd144b42514 100644 --- a/editeng/source/editeng/editobj.cxx +++ b/editeng/source/editeng/editobj.cxx @@ -1131,10 +1131,10 @@ void BinTextObject::StoreData( SvStream& rOStream ) const // Convert CH_FEATURE to CH_FEATURE_OLD aText.SearchAndReplaceAll( cFeatureConverted, CH_FEATURE_OLD ); - rOStream.WriteByteString( aText ); + write_lenPrefixed_uInt8s_FromOString(rOStream, aText); // StyleName and Family... - rOStream.WriteByteString( rtl::OUStringToOString(pC->GetStyle(), eEncoding) ); + write_lenPrefixed_uInt8s_FromOUString(rOStream, pC->GetStyle(), eEncoding); rOStream << (sal_uInt16)pC->GetFamily(); // Paragraph attributes ... @@ -1226,9 +1226,8 @@ void BinTextObject::CreateData( SvStream& rIStream ) ContentInfo* pC = CreateAndInsertContent(); // The Text... - ByteString aByteString; - rIStream.ReadByteString( aByteString ); - pC->GetText() = String( aByteString, eSrcEncoding ); + ByteString aByteString = read_lenPrefixed_uInt8s_ToOString(rIStream); + pC->GetText() = rtl::OStringToOUString(aByteString, eSrcEncoding); // StyleName and Family... rIStream.ReadByteString( pC->GetStyle(), eSrcEncoding ); diff --git a/filter/source/msfilter/mstoolbar.cxx b/filter/source/msfilter/mstoolbar.cxx index 2776e724d1f5..ed1c986dd2c7 100644 --- a/filter/source/msfilter/mstoolbar.cxx +++ b/filter/source/msfilter/mstoolbar.cxx @@ -412,7 +412,7 @@ WString::Read( SvStream &rS ) nOffSet = rS.Tell(); sal_uInt8 nChars = 0; rS >> nChars; - sString = read_LEuInt16s_AsOUString(rS, nChars); + sString = read_LEuInt16s_ToOUString(rS, nChars); return true; } diff --git a/idl/source/objects/bastype.cxx b/idl/source/objects/bastype.cxx index 15c56c088ea0..afeb0046730d 100644 --- a/idl/source/objects/bastype.cxx +++ b/idl/source/objects/bastype.cxx @@ -228,13 +228,13 @@ sal_Bool SvIdentifier::WriteSvIdl( SvStringHashEntry * pName, SvStream& operator << (SvStream & rStm, const SvIdentifier & r ) { - rStm.WriteByteString( r ); + write_lenPrefixed_uInt8s_FromOString(rStm, r); return rStm; } SvStream& operator >> (SvStream & rStm, SvIdentifier & r ) { - rStm.ReadByteString( r ); + r = read_lenPrefixed_uInt8s_ToOString(rStm); return rStm; } @@ -343,13 +343,13 @@ sal_Bool SvString::WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm, SvStream& operator << (SvStream & rStm, const SvString & r ) { - rStm.WriteByteString( r ); + write_lenPrefixed_uInt8s_FromOString(rStm, r); return rStm; } SvStream& operator >> (SvStream & rStm, SvString & r ) { - rStm.ReadByteString( r ); + r = read_lenPrefixed_uInt8s_ToOString(rStm); return rStm; } diff --git a/idl/source/objects/module.cxx b/idl/source/objects/module.cxx index c2be3e232494..4fd5c78f7f6f 100644 --- a/idl/source/objects/module.cxx +++ b/idl/source/objects/module.cxx @@ -66,9 +66,9 @@ void SvMetaModule::Load( SvPersistStream & rStm ) rStm >> aAttrList; // browser rStm.ReadByteString( aIdlFileName ); - rStm.ReadByteString( aHelpFileName ); - rStm.ReadByteString( aSlotIdFile ); - rStm.ReadByteString( aModulePrefix ); + aHelpFileName = read_lenPrefixed_uInt8s_ToOString(rStm); + aSlotIdFile = read_lenPrefixed_uInt8s_ToOString(rStm); + aModulePrefix = read_lenPrefixed_uInt8s_ToOString(rStm); // read compiler data sal_uInt16 nCmpLen; @@ -91,9 +91,9 @@ void SvMetaModule::Save( SvPersistStream & rStm ) rStm << aAttrList; // browser rStm.WriteByteString( aIdlFileName ); - rStm.WriteByteString( aHelpFileName ); - rStm.WriteByteString( aSlotIdFile ); - rStm.WriteByteString( aModulePrefix ); + write_lenPrefixed_uInt8s_FromOString(rStm, aHelpFileName); + write_lenPrefixed_uInt8s_FromOString(rStm, aSlotIdFile); + write_lenPrefixed_uInt8s_FromOString(rStm, aModulePrefix); // write compiler data sal_uInt16 nCmpLen = 0; diff --git a/idl/source/objects/object.cxx b/idl/source/objects/object.cxx index 0b3e1cf193e3..798acbc1e180 100644 --- a/idl/source/objects/object.cxx +++ b/idl/source/objects/object.cxx @@ -55,7 +55,7 @@ void SvClassElement::Load( SvPersistStream & rStm ) return; } if( nMask & 0x01 ) rStm >> aAutomation; - if( nMask & 0x02 ) rStm.ReadByteString( aPrefix ); + if( nMask & 0x02 ) aPrefix = read_lenPrefixed_uInt8s_ToOString(rStm); if( nMask & 0x04 ) { SvMetaClass * p; @@ -75,7 +75,7 @@ void SvClassElement::Save( SvPersistStream & rStm ) // write data rStm << nMask; if( nMask & 0x01 ) rStm << aAutomation; - if( nMask & 0x02 ) rStm.WriteByteString( aPrefix ); + if( nMask & 0x02 ) write_lenPrefixed_uInt8s_FromOString(rStm, aPrefix); if( nMask & 0x04 ) rStm << xClass; } diff --git a/idl/source/objects/types.cxx b/idl/source/objects/types.cxx index 06db9ed18910..f2488aa0498b 100644 --- a/idl/source/objects/types.cxx +++ b/idl/source/objects/types.cxx @@ -1780,7 +1780,7 @@ void SvMetaEnumValue::Load( SvPersistStream & rStm ) OSL_FAIL( "wrong format" ); return; } - if( nMask & 0x01 ) rStm.ReadByteString( aEnumValue ); + if( nMask & 0x01 ) aEnumValue = read_lenPrefixed_uInt8s_ToOString(rStm); } void SvMetaEnumValue::Save( SvPersistStream & rStm ) @@ -1793,7 +1793,7 @@ void SvMetaEnumValue::Save( SvPersistStream & rStm ) // write data rStm << nMask; - if( nMask & 0x01 ) rStm.WriteByteString( aEnumValue ); + if( nMask & 0x01 ) write_lenPrefixed_uInt8s_FromOString(rStm, aEnumValue); } sal_Bool SvMetaEnumValue::ReadSvIdl( SvIdlDataBase & rBase, @@ -1837,7 +1837,7 @@ void SvMetaTypeEnum::Load( SvPersistStream & rStm ) return; } if( nMask & 0x01 ) rStm >> aEnumValueList; - if( nMask & 0x02 ) rStm.ReadByteString( aPrefix ); + if( nMask & 0x02 ) aPrefix = read_lenPrefixed_uInt8s_ToOString(rStm); } void SvMetaTypeEnum::Save( SvPersistStream & rStm ) @@ -1852,7 +1852,7 @@ void SvMetaTypeEnum::Save( SvPersistStream & rStm ) // write data rStm << nMask; if( nMask & 0x01 ) rStm << aEnumValueList; - if( nMask & 0x02 ) rStm.WriteByteString( aPrefix ); + if( nMask & 0x02 ) write_lenPrefixed_uInt8s_FromOString(rStm, aPrefix); } void SvMetaTypeEnum::ReadContextSvIdl( SvIdlDataBase & rBase, diff --git a/sc/source/filter/ftools/ftools.cxx b/sc/source/filter/ftools/ftools.cxx index 21d3e12fc803..bbfbe41a2881 100644 --- a/sc/source/filter/ftools/ftools.cxx +++ b/sc/source/filter/ftools/ftools.cxx @@ -276,9 +276,9 @@ ScStyleSheet& ScfTools::MakePageStyleSheet( ScStyleSheetPool& rPool, const Strin // *** byte string import operations *** -------------------------------------- -rtl::OString ScfTools::read_zeroTerminated_uInt8s_AsOString(SvStream& rStrm, sal_Int32& rnBytesLeft) +rtl::OString ScfTools::read_zeroTerminated_uInt8s_ToOString(SvStream& rStrm, sal_Int32& rnBytesLeft) { - rtl::OString aRet(::read_zeroTerminated_uInt8s_AsOString(rStrm)); + rtl::OString aRet(::read_zeroTerminated_uInt8s_ToOString(rStrm)); rnBytesLeft -= aRet.getLength(); //we read this number of bytes anyway if (rStrm.good()) //if the stream is happy we read the null terminator as well --rnBytesLeft; @@ -287,7 +287,7 @@ rtl::OString ScfTools::read_zeroTerminated_uInt8s_AsOString(SvStream& rStrm, sal void ScfTools::AppendCString( SvStream& rStrm, String& rString, rtl_TextEncoding eTextEnc ) { - rString += ::read_zeroTerminated_uInt8s_AsOUString(rStrm, eTextEnc); + rString += ::read_zeroTerminated_uInt8s_ToOUString(rStrm, eTextEnc); } // *** HTML table names <-> named range names *** ----------------------------- diff --git a/sc/source/filter/inc/ftools.hxx b/sc/source/filter/inc/ftools.hxx index e57d42c27599..4bfac0961c83 100644 --- a/sc/source/filter/inc/ftools.hxx +++ b/sc/source/filter/inc/ftools.hxx @@ -237,11 +237,11 @@ public: // *** byte string import operations *** -------------------------------------- /** Reads and returns a zero terminated byte string and decreases a stream counter. */ - static rtl::OString read_zeroTerminated_uInt8s_AsOString(SvStream& rStrm, sal_Int32& rnBytesLeft); + static rtl::OString read_zeroTerminated_uInt8s_ToOString(SvStream& rStrm, sal_Int32& rnBytesLeft); /** Reads and returns a zero terminated byte string and decreases a stream counter. */ - inline static rtl::OUString read_zeroTerminated_uInt8s_AsOUString(SvStream& rStrm, sal_Int32& rnBytesLeft, rtl_TextEncoding eTextEnc) + inline static rtl::OUString read_zeroTerminated_uInt8s_ToOUString(SvStream& rStrm, sal_Int32& rnBytesLeft, rtl_TextEncoding eTextEnc) { - return rtl::OStringToOUString(read_zeroTerminated_uInt8s_AsOString(rStrm, rnBytesLeft), eTextEnc); + return rtl::OStringToOUString(read_zeroTerminated_uInt8s_ToOString(rStrm, rnBytesLeft), eTextEnc); } /** Appends a zero terminated byte string. */ diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx index 5bd02b10d99e..d649c447ff65 100644 --- a/sc/source/filter/lotus/lotform.cxx +++ b/sc/source/filter/lotus/lotform.cxx @@ -542,7 +542,7 @@ ConvErr LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest, break; case FT_ConstString: { - String aTmp(ScfTools::read_zeroTerminated_uInt8s_AsOUString(aIn, nBytesLeft, eSrcChar)); + String aTmp(ScfTools::read_zeroTerminated_uInt8s_ToOUString(aIn, nBytesLeft, eSrcChar)); aStack << aPool.Store( aTmp ); } break; @@ -561,7 +561,7 @@ ConvErr LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest, break; case FT_Nrref: { - String aTmp(ScfTools::read_zeroTerminated_uInt8s_AsOUString(aIn, nBytesLeft, eSrcChar)); + String aTmp(ScfTools::read_zeroTerminated_uInt8s_ToOUString(aIn, nBytesLeft, eSrcChar)); if( rRangeNameBufferWK3.FindRel( aTmp, nRngIndex ) ) aStack << aPool.Store( nRngIndex ); else @@ -574,7 +574,7 @@ ConvErr LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest, break; case FT_Absnref: { - String aTmp(ScfTools::read_zeroTerminated_uInt8s_AsOUString(aIn, nBytesLeft, eSrcChar)); + String aTmp(ScfTools::read_zeroTerminated_uInt8s_ToOUString(aIn, nBytesLeft, eSrcChar)); if( rRangeNameBufferWK3.FindAbs( aTmp, nRngIndex ) ) aStack << aPool.Store( nRngIndex ); else diff --git a/sc/source/filter/qpro/qproform.cxx b/sc/source/filter/qpro/qproform.cxx index 30b7d6032745..6c8e8b7d371c 100644 --- a/sc/source/filter/qpro/qproform.cxx +++ b/sc/source/filter/qpro/qproform.cxx @@ -249,7 +249,7 @@ ConvErr QProToSc::Convert( const ScTokenArray*& pArray, sal_uInt16 /*nLen*/, con } if( nFmla[ i ] == 0x06 ) { - String aTmp(::read_zeroTerminated_uInt8s_AsOUString(maIn, maIn.GetStreamCharSet())); + String aTmp(::read_zeroTerminated_uInt8s_ToOUString(maIn, maIn.GetStreamCharSet())); sStringArray[ nStringCount ] = aTmp; nStringCount++; SAFEDEC_OR_RET(nRef, aTmp.Len() + 1, ConvErrCount); diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx index 9d33f09eca2f..fd3b0d264ebd 100644 --- a/sc/source/ui/unoobj/scdetect.cxx +++ b/sc/source/ui/unoobj/scdetect.cxx @@ -734,7 +734,7 @@ static sal_Bool lcl_MayBeDBase( SvStream& rStream ) // get file header rStr.Seek( 0 ); const sal_Size nTrySize = 80; - ByteString aHeader = read_uInt8s_AsOString(rStr, nTrySize); + ByteString aHeader = read_uInt8s_ToOString(rStr, nTrySize); if ( HTMLParser::IsHTMLFormat( aHeader.GetBuffer() ) ) { diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx index 7e8064f781ea..c320f0c762d3 100644 --- a/sd/source/filter/eppt/epptso.cxx +++ b/sd/source/filter/eppt/epptso.cxx @@ -2605,7 +2605,7 @@ void PPTWriter::ImplWritePage( const PHLayout& rLayout, EscherSolverContainer& a *xCompObj >> nStringLen; if ( ( nStringLen > 1 ) && ( ( xCompObj->Tell() + nStringLen ) < nStreamLen ) ) { // i think that the OleIdentifier will follow - rtl::OString aTemp = read_uInt8s_AsOString(*xCompObj, nStringLen - 1); + rtl::OString aTemp = read_uInt8s_ToOString(*xCompObj, nStringLen - 1); aOleIdentifier = rtl::OStringToOUString(aTemp, RTL_TEXTENCODING_MS_1252); } } diff --git a/sfx2/source/bastyp/sfxhtml.cxx b/sfx2/source/bastyp/sfxhtml.cxx index 18214c5db042..acf69186d2ac 100644 --- a/sfx2/source/bastyp/sfxhtml.cxx +++ b/sfx2/source/bastyp/sfxhtml.cxx @@ -274,7 +274,7 @@ sal_Bool SfxHTMLParser::FinishFileDownload( String& rStr ) : STRING_MAXLEN; aStream.Seek( 0 ); - rtl::OString sBuffer = read_uInt8s_AsOString(aStream, nLen); + rtl::OString sBuffer = read_uInt8s_ToOString(aStream, nLen); rStr = S2U(sBuffer); } diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx index b6fb581057fc..f1cf5c0c3127 100644 --- a/sot/source/sdstor/ucbstorage.cxx +++ b/sot/source/sdstor/ucbstorage.cxx @@ -3303,8 +3303,7 @@ String UCBStorage::GetLinkedFile( SvStream &rStream ) rStream >> nBytes; if( nBytes == 0x04034b50 ) { - ByteString aTmp; - rStream.ReadByteString( aTmp ); + ByteString aTmp = read_lenPrefixed_uInt8s_ToOString(rStream); if ( aTmp.CompareTo( "ContentURL=", 11 ) == COMPARE_EQUAL ) { aTmp.Erase( 0, 11 ); diff --git a/svl/source/items/cntwall.cxx b/svl/source/items/cntwall.cxx index f81bd487d48a..31ef07e8a06e 100644 --- a/svl/source/items/cntwall.cxx +++ b/svl/source/items/cntwall.cxx @@ -80,8 +80,7 @@ CntWallpaperItem::CntWallpaperItem( sal_uInt16 which, SvStream& rStream, sal_uIn readUnicodeString(rStream, _aURL, false); // "Read" SfxWallpaperItem's string member _aFilter. - ByteString aDummy; - rStream.ReadByteString(aDummy); + read_lenPrefixed_uInt8s_ToOString(rStream); } } diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index a85491e4f30d..424aaa0204ce 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -1768,8 +1768,7 @@ void SvNumberformat::ConvertLanguage( SvNumberFormatter& rConverter, void SvNumberformat::LoadString( SvStream& rStream, String& rStr ) { CharSet eStream = rStream.GetStreamCharSet(); - ByteString aStr; - rStream.ReadByteString( aStr ); + ByteString aStr = read_lenPrefixed_uInt8s_ToOString(rStream); sal_Char cStream = NfCurrencyEntry::GetEuroSymbol( eStream ); if ( aStr.Search( cStream ) == STRING_NOTFOUND ) { // simple conversion to unicode diff --git a/svtools/source/filter/igif/gifread.cxx b/svtools/source/filter/igif/gifread.cxx index 81dee55fabf5..607b6a877af3 100644 --- a/svtools/source/filter/igif/gifread.cxx +++ b/svtools/source/filter/igif/gifread.cxx @@ -257,8 +257,8 @@ sal_Bool GIFReader::ReadExtension() // Appl.-Extension hat Laenge 11 if ( cSize == 0x0b ) { - rtl::OString aAppId = read_uInt8s_AsOString(rIStm, 8); - rtl::OString aAppCode = read_uInt8s_AsOString(rIStm, 3); + rtl::OString aAppId = read_uInt8s_ToOString(rIStm, 8); + rtl::OString aAppCode = read_uInt8s_ToOString(rIStm, 3); rIStm >> cSize; // NetScape-Extension diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx index f259ccb06af4..db3e8728f8d2 100644 --- a/svtools/source/graphic/grfmgr.cxx +++ b/svtools/source/graphic/grfmgr.cxx @@ -1125,7 +1125,6 @@ SvStream& operator>>( SvStream& rIStm, GraphicObject& rGraphicObj ) VersionCompat aCompat( rIStm, STREAM_READ ); Graphic aGraphic; GraphicAttr aAttr; - ByteString aLink; sal_Bool bLink; rIStm >> aGraphic >> aAttr >> bLink; @@ -1135,8 +1134,8 @@ SvStream& operator>>( SvStream& rIStm, GraphicObject& rGraphicObj ) if( bLink ) { - rIStm.ReadByteString(aLink); - rGraphicObj.SetLink( UniString( aLink, RTL_TEXTENCODING_UTF8 ) ); + rtl::OUString aLink = read_lenPrefixed_uInt8s_ToOUString(rIStm, RTL_TEXTENCODING_UTF8); + rGraphicObj.SetLink(aLink); } else rGraphicObj.SetLink(); @@ -1154,7 +1153,7 @@ SvStream& operator<<( SvStream& rOStm, const GraphicObject& rGraphicObj ) rOStm << rGraphicObj.GetGraphic() << rGraphicObj.GetAttr() << bLink; if( bLink ) - rOStm.WriteByteString(rtl::OUStringToOString(rGraphicObj.GetLink(), RTL_TEXTENCODING_UTF8)); + write_lenPrefixed_uInt8s_FromOUString(rOStm, rGraphicObj.GetLink(), RTL_TEXTENCODING_UTF8); return rOStm; } diff --git a/svtools/source/misc/imap.cxx b/svtools/source/misc/imap.cxx index 016250c23c8c..bb720f6838e7 100644 --- a/svtools/source/misc/imap.cxx +++ b/svtools/source/misc/imap.cxx @@ -104,16 +104,16 @@ void IMapObject::Write( SvStream& rOStm, const String& rBaseURL ) const const rtl::OString aRelURL = rtl::OUStringToOString( URIHelper::simpleNormalizedMakeRelative(rBaseURL, aURL), eEncoding); - rOStm.WriteByteString(aRelURL); - rOStm.WriteByteString(rtl::OUStringToOString(aAltText, eEncoding)); + write_lenPrefixed_uInt8s_FromOString(rOStm, aRelURL); + write_lenPrefixed_uInt8s_FromOUString(rOStm, aAltText, eEncoding); rOStm << bActive; - rOStm.WriteByteString(rtl::OUStringToOString(aTarget, eEncoding)); + write_lenPrefixed_uInt8s_FromOUString(rOStm, aTarget, eEncoding); pCompat = new IMapCompat( rOStm, STREAM_WRITE ); WriteIMapObject( rOStm ); - aEventList.Write( rOStm ); // V4 - rOStm.WriteByteString(rtl::OUStringToOString(aName, eEncoding)); // V5 + aEventList.Write( rOStm ); // V4 + write_lenPrefixed_uInt8s_FromOUString(rOStm, aName, eEncoding); // V5 delete pCompat; } @@ -129,16 +129,15 @@ void IMapObject::Read( SvStream& rIStm, const String& rBaseURL ) { IMapCompat* pCompat; rtl_TextEncoding nTextEncoding; - ByteString aString; // Typ und Version ueberlesen wir rIStm.SeekRel( 2 ); rIStm >> nReadVersion; rIStm >> nTextEncoding; - rIStm.ReadByteString( aString ); aURL = String( aString.GetBuffer(), nTextEncoding ); - rIStm.ReadByteString( aString ); aAltText = String( aString.GetBuffer(), nTextEncoding ); + aURL = read_lenPrefixed_uInt8s_ToOUString(rIStm, nTextEncoding); + aAltText = read_lenPrefixed_uInt8s_ToOUString(rIStm, nTextEncoding); rIStm >> bActive; - rIStm.ReadByteString( aString ); aTarget = String( aString.GetBuffer(), nTextEncoding ); + aTarget = read_lenPrefixed_uInt8s_ToOUString(rIStm, nTextEncoding); // URL absolut machen aURL = URIHelper::SmartRel2Abs( INetURLObject(rBaseURL), aURL, URIHelper::GetMaybeFileHdl(), true, false, INetURLObject::WAS_ENCODED, INetURLObject::DECODE_UNAMBIGUOUS ); @@ -153,9 +152,7 @@ void IMapObject::Read( SvStream& rIStm, const String& rBaseURL ) // ab Version 5 kann ein Objektname vorhanden sein if ( nReadVersion >= 0x0005 ) - { - rIStm.ReadByteString( aString ); aName = String( aString.GetBuffer(), nTextEncoding ); - } + aName = read_lenPrefixed_uInt8s_ToOUString(rIStm, nTextEncoding); } delete pCompat; @@ -1117,20 +1114,19 @@ void ImageMap::Write( SvStream& rOStm, const String& rBaseURL ) const { IMapCompat* pCompat; String aImageName( GetName() ); - String aDummy; sal_uInt16 nOldFormat = rOStm.GetNumberFormatInt(); sal_uInt16 nCount = (sal_uInt16) GetIMapObjectCount(); - const rtl_TextEncoding eEncoding = osl_getThreadTextEncoding(); + const rtl_TextEncoding eEncoding = osl_getThreadTextEncoding(); //vomit! rOStm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); // MagicCode schreiben rOStm << IMAPMAGIC; rOStm << GetVersion(); - rOStm.WriteByteString(rtl::OUStringToOString(aImageName, eEncoding)); - rOStm.WriteByteString(rtl::OUStringToOString(aDummy, eEncoding)); + write_lenPrefixed_uInt8s_FromOUString(rOStm, aImageName, eEncoding); + write_lenPrefixed_uInt8s_FromOString(rOStm, rtl::OString()); //dummy rOStm << nCount; - rOStm.WriteByteString(rtl::OUStringToOString(aImageName, eEncoding)); + write_lenPrefixed_uInt8s_FromOUString(rOStm, aImageName, eEncoding); pCompat = new IMapCompat( rOStm, STREAM_WRITE ); @@ -1152,7 +1148,6 @@ void ImageMap::Write( SvStream& rOStm, const String& rBaseURL ) const void ImageMap::Read( SvStream& rIStm, const String& rBaseURL ) { - ByteString aString; char cMagic[6]; sal_uInt16 nOldFormat = rIStm.GetNumberFormatInt(); sal_uInt16 nCount; @@ -1170,10 +1165,10 @@ void ImageMap::Read( SvStream& rIStm, const String& rBaseURL ) // Version ueberlesen wir rIStm.SeekRel( 2 ); - rIStm.ReadByteString( aString ); aName = String( aString, osl_getThreadTextEncoding() ); - rIStm.ReadByteString( aString ); // Dummy + aName = read_lenPrefixed_uInt8s_ToOUString(rIStm, osl_getThreadTextEncoding()); + read_lenPrefixed_uInt8s_ToOString(rIStm); // Dummy rIStm >> nCount; - rIStm.ReadByteString( aString ); // Dummy + read_lenPrefixed_uInt8s_ToOString(rIStm); // Dummy pCompat = new IMapCompat( rIStm, STREAM_READ ); diff --git a/svtools/source/urlobj/inetimg.cxx b/svtools/source/urlobj/inetimg.cxx index fff9d170399a..8ed7996c16d0 100644 --- a/svtools/source/urlobj/inetimg.cxx +++ b/svtools/source/urlobj/inetimg.cxx @@ -73,7 +73,7 @@ sal_Bool INetImage::Read( SvStream& rIStm, sal_uLong nFormat ) { case SOT_FORMATSTR_ID_INET_IMAGE: { - String sINetImg = read_zeroTerminated_uInt8s_AsOUString(rIStm, RTL_TEXTENCODING_UTF8); + String sINetImg = read_zeroTerminated_uInt8s_ToOUString(rIStm, RTL_TEXTENCODING_UTF8); xub_StrLen nStart = 0; aImageURL = sINetImg.GetToken( 0, TOKEN_SEPARATOR, nStart ); aTargetURL = sINetImg.GetToken( 0, TOKEN_SEPARATOR, nStart ); @@ -119,11 +119,11 @@ sal_Bool INetImage::Read( SvStream& rIStm, sal_uLong nFormat ) // skip over iExtraHTML_Offset rIStm.SeekRel( sizeof( int ) ); - aImageURL = read_zeroTerminated_uInt8s_AsOUString(rIStm, eSysCSet); + aImageURL = read_zeroTerminated_uInt8s_ToOUString(rIStm, eSysCSet); if( nAltOffset ) { rIStm.Seek( nFilePos + nAltOffset ); - aAlternateText = read_zeroTerminated_uInt8s_AsOUString(rIStm, eSysCSet); + aAlternateText = read_zeroTerminated_uInt8s_ToOUString(rIStm, eSysCSet); } else if( aAlternateText.Len() ) aAlternateText.Erase(); @@ -131,7 +131,7 @@ sal_Bool INetImage::Read( SvStream& rIStm, sal_uLong nFormat ) if( nAnchorOffset ) { rIStm.Seek( nFilePos + nAnchorOffset ); - aTargetURL = read_zeroTerminated_uInt8s_AsOUString(rIStm, eSysCSet); + aTargetURL = read_zeroTerminated_uInt8s_ToOUString(rIStm, eSysCSet); } else if( aTargetURL.Len() ) aTargetURL.Erase(); diff --git a/svx/inc/svx/gallery1.hxx b/svx/inc/svx/gallery1.hxx index aa5cc4aa0f8e..de6ebc684a32 100644 --- a/svx/inc/svx/gallery1.hxx +++ b/svx/inc/svx/gallery1.hxx @@ -47,16 +47,16 @@ class GalleryThemeEntry { private: - String aName; + rtl::OUString aName; INetURLObject aThmURL; INetURLObject aSdgURL; INetURLObject aSdvURL; - sal_uInt32 nFileNumber; - sal_uInt32 nId; - sal_Bool bReadOnly; - sal_Bool bImported; - sal_Bool bModified; - sal_Bool bThemeNameFromResource; + sal_uInt32 nFileNumber; + sal_uInt32 nId; + sal_Bool bReadOnly; + sal_Bool bImported; + sal_Bool bModified; + sal_Bool bThemeNameFromResource; GalleryThemeEntry(); INetURLObject ImplGetURLIgnoreCase( const INetURLObject& rURL ) const; @@ -68,26 +68,26 @@ public: sal_Bool bNewFile, sal_uInt32 nId, sal_Bool bThemeNameFromResource ); ~GalleryThemeEntry() {}; - const String& GetThemeName() const { return aName; } - sal_uInt32 GetFileNumber() const { return nFileNumber; } + const rtl::OUString& GetThemeName() const { return aName; } + sal_uInt32 GetFileNumber() const { return nFileNumber; } const INetURLObject& GetThmURL() const { return aThmURL; } const INetURLObject& GetSdgURL() const { return aSdgURL; } const INetURLObject& GetSdvURL() const { return aSdvURL; } - sal_Bool IsImported() const { return bImported; } - sal_Bool IsReadOnly() const { return bReadOnly; } - sal_Bool IsDefault() const; + sal_Bool IsImported() const { return bImported; } + sal_Bool IsReadOnly() const { return bReadOnly; } + sal_Bool IsDefault() const; - sal_Bool IsHidden() const { return aName.SearchAscii( "private://gallery/hidden/" ) == 0; } + sal_Bool IsHidden() const { return aName.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("private://gallery/hidden/")); } - sal_Bool IsModified() const { return bModified; } + sal_Bool IsModified() const { return bModified; } void SetModified( sal_Bool bSet ) { bModified = ( bSet && !IsImported() && !IsReadOnly() ); } - void SetName( const String& rNewName ); - sal_Bool IsNameFromResource() const { return bThemeNameFromResource; } + void SetName( const rtl::OUString& rNewName ); + sal_Bool IsNameFromResource() const { return bThemeNameFromResource; } - sal_uInt32 GetId() const { return nId; } + sal_uInt32 GetId() const { return nId; } void SetId( sal_uInt32 nNewId, sal_Bool bResetThemeName ); }; @@ -99,10 +99,10 @@ typedef ::std::vector< GalleryThemeEntry* > GalleryThemeList; struct GalleryImportThemeEntry { - String aThemeName; - String aUIName; - INetURLObject aURL; - String aImportName; + rtl::OUString aThemeName; + rtl::OUString aUIName; + INetURLObject aURL; + rtl::OUString aImportName; }; typedef ::std::vector< GalleryImportThemeEntry* > GalleryImportThemeList; @@ -144,9 +144,9 @@ private: void ImplLoadImports(); void ImplWriteImportList(); - SVX_DLLPUBLIC GalleryThemeEntry* ImplGetThemeEntry( const String& rThemeName ); + SVX_DLLPUBLIC GalleryThemeEntry* ImplGetThemeEntry( const rtl::OUString& rThemeName ); GalleryThemeEntry* ImplGetThemeEntry( sal_uIntPtr nThemeId ); - GalleryImportThemeEntry* ImplGetImportThemeEntry( const String& rImportName ); + GalleryImportThemeEntry* ImplGetImportThemeEntry( const rtl::OUString& rImportName ); GalleryTheme* ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry ); void ImplDeleteCachedTheme( GalleryTheme* pTheme ); @@ -164,7 +164,7 @@ public: const GalleryThemeEntry* GetThemeInfo( const String& rThemeName ) { return ImplGetThemeEntry( rThemeName ); } SVX_DLLPUBLIC sal_Bool HasTheme( const String& rThemeName ); - String GetThemeName( sal_uIntPtr nThemeId ) const; + rtl::OUString GetThemeName( sal_uIntPtr nThemeId ) const; SVX_DLLPUBLIC sal_Bool CreateTheme( const String& rThemeName, sal_uInt32 nNumFrom = 0 ); sal_Bool RenameTheme( const String& rOldName, const String& rNewName ); diff --git a/svx/inc/svx/galmisc.hxx b/svx/inc/svx/galmisc.hxx index c7ed89c2f953..7f4563e89f7e 100644 --- a/svx/inc/svx/galmisc.hxx +++ b/svx/inc/svx/galmisc.hxx @@ -245,8 +245,8 @@ class GalleryHint : public SfxHint private: sal_uIntPtr mnType; - String maThemeName; - String maStringData; + rtl::OUString maThemeName; + rtl::OUString maStringData; sal_uIntPtr mnData1; sal_uIntPtr mnData2; @@ -258,11 +258,11 @@ public: GalleryHint( sal_uIntPtr nType, const String& rThemeName, const String& rStringData, sal_uIntPtr nData1 = 0UL, sal_uIntPtr nData2 = 0UL ) : mnType( nType ), maThemeName( rThemeName ), maStringData( rStringData ), mnData1( nData1 ), mnData2( nData2 ) {} - sal_uIntPtr GetType() const { return mnType; } - const String& GetThemeName() const { return maThemeName; } - const String& GetStringData() const { return maStringData; } - sal_uIntPtr GetData1() const { return mnData1; } - sal_uIntPtr GetData2() const { return mnData2; } + sal_uIntPtr GetType() const { return mnType; } + const rtl::OUString& GetThemeName() const { return maThemeName; } + const rtl::OUString& GetStringData() const { return maStringData; } + sal_uIntPtr GetData1() const { return mnData1; } + sal_uIntPtr GetData2() const { return mnData2; } }; #endif diff --git a/svx/inc/svx/galtheme.hxx b/svx/inc/svx/galtheme.hxx index 2bfdddf8ab4f..766bb449a78f 100644 --- a/svx/inc/svx/galtheme.hxx +++ b/svx/inc/svx/galtheme.hxx @@ -70,10 +70,10 @@ class ListBox; struct GalDragParams { - Region aDragRegion; - sal_uIntPtr nDragObjPos; - String aThemeName; - String aFileName; + Region aDragRegion; + sal_uIntPtr nDragObjPos; + rtl::OUString aThemeName; + rtl::OUString aFileName; SgaObjKind eObjKind; }; @@ -99,7 +99,7 @@ class GalleryTheme : public SfxBroadcaster private: GalleryObjectList aObjectList; - String aImportName; + rtl::OUString aImportName; String m_aDestDir; SotStorageRef aSvDrawStorageRef; Gallery* pParent; @@ -147,10 +147,10 @@ public: SVX_DLLPUBLIC bool RemoveObject( size_t nPos ); bool ChangeObjectPos( size_t nOldPos, size_t nNewPos ); - SVX_DLLPUBLIC const String& GetName() const; - const String& GetRealName() const; - const String& GetImportName() const { return aImportName; } - void SetImportName(const String& rImportName) { aImportName = rImportName; } + SVX_DLLPUBLIC const rtl::OUString& GetName() const; + const rtl::OUString& GetRealName() const; + const rtl::OUString& GetImportName() const { return aImportName; } + void SetImportName(const rtl::OUString& rImportName) { aImportName = rImportName; } const String& GetDestDir() const { return m_aDestDir; } void SetDestDir(const String& rDestDir) { m_aDestDir = rDestDir; } diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx index 4c10186cac9b..9b7cfe2739e6 100644 --- a/svx/source/gallery2/gallery1.cxx +++ b/svx/source/gallery2/gallery1.cxx @@ -78,7 +78,7 @@ GalleryThemeEntry::GalleryThemeEntry( const INetURLObject& rBaseURL, const Strin if( nId && bThemeNameFromResource ) aName = String( GAL_RESID( RID_GALLERYSTR_THEME_START + (sal_uInt16) nId ) ); - if( !aName.Len() ) + if( !aName.getLength() ) aName = rName; } @@ -107,7 +107,7 @@ INetURLObject GalleryThemeEntry::ImplGetURLIgnoreCase( const INetURLObject& rURL // ----------------------------------------------------------------------------- -void GalleryThemeEntry::SetName( const String& rNewName ) +void GalleryThemeEntry::SetName( const rtl::OUString& rNewName ) { if( aName != rNewName ) { @@ -132,16 +132,12 @@ void GalleryThemeEntry::SetId( sal_uInt32 nNewId, sal_Bool bResetThemeName ) SvStream& operator<<( SvStream& rOut, const GalleryImportThemeEntry& rEntry ) { - rOut.WriteByteString(rtl::OUStringToOString(rEntry.aThemeName, RTL_TEXTENCODING_UTF8)); - - rOut.WriteByteString(rtl::OUStringToOString(rEntry.aUIName, RTL_TEXTENCODING_UTF8)); - - rOut.WriteByteString(rtl::OUStringToOString(String(rEntry.aURL.GetMainURL( INetURLObject::NO_DECODE )), RTL_TEXTENCODING_UTF8)); - - rOut.WriteByteString(rtl::OUStringToOString(rEntry.aImportName, RTL_TEXTENCODING_UTF8)); - - rOut.WriteByteString(rtl::OUString()); + write_lenPrefixed_uInt8s_FromOUString(rOut, rEntry.aThemeName, RTL_TEXTENCODING_UTF8); + write_lenPrefixed_uInt8s_FromOUString(rOut, rEntry.aUIName, RTL_TEXTENCODING_UTF8); + write_lenPrefixed_uInt8s_FromOUString(rOut, (rEntry.aURL.GetMainURL( INetURLObject::NO_DECODE )), RTL_TEXTENCODING_UTF8); + write_lenPrefixed_uInt8s_FromOUString(rOut, rEntry.aImportName, RTL_TEXTENCODING_UTF8); + write_lenPrefixed_uInt8s_FromOString(rOut, rtl::OString()); return rOut; } @@ -149,22 +145,11 @@ SvStream& operator<<( SvStream& rOut, const GalleryImportThemeEntry& rEntry ) SvStream& operator>>( SvStream& rIn, GalleryImportThemeEntry& rEntry ) { - ByteString aTmpStr; - - rIn.ReadByteString(aTmpStr); - rEntry.aThemeName = String( aTmpStr, RTL_TEXTENCODING_UTF8 ); - - rIn.ReadByteString(aTmpStr); - rEntry.aUIName = String( aTmpStr, RTL_TEXTENCODING_UTF8 ); - - rIn.ReadByteString(aTmpStr); - rEntry.aURL = INetURLObject( String( aTmpStr, RTL_TEXTENCODING_UTF8 ) ); - - rIn.ReadByteString(aTmpStr); - rEntry.aImportName = String( aTmpStr, RTL_TEXTENCODING_UTF8 ); - - rIn.ReadByteString(aTmpStr); - + rEntry.aThemeName = read_lenPrefixed_uInt8s_ToOUString(rIn, RTL_TEXTENCODING_UTF8); + rEntry.aUIName = read_lenPrefixed_uInt8s_ToOUString(rIn, RTL_TEXTENCODING_UTF8); + rEntry.aURL = read_lenPrefixed_uInt8s_ToOUString(rIn, RTL_TEXTENCODING_UTF8); + rEntry.aImportName = read_lenPrefixed_uInt8s_ToOUString(rIn, RTL_TEXTENCODING_UTF8); + read_lenPrefixed_uInt8s_ToOString(rIn); return rIn; } @@ -547,21 +532,23 @@ void Gallery::ImplWriteImportList() // ------------------------------------------------------------------------ -GalleryThemeEntry* Gallery::ImplGetThemeEntry( const String& rThemeName ) +GalleryThemeEntry* Gallery::ImplGetThemeEntry( const rtl::OUString& rThemeName ) { GalleryThemeEntry* pFound = NULL; - if( rThemeName.Len() ) + if( rThemeName.getLength() ) + { for ( size_t i = 0, n = aThemeList.size(); i < n && !pFound; ++i ) if( rThemeName == aThemeList[ i ]->GetThemeName() ) pFound = aThemeList[ i ]; + } return pFound; } // ------------------------------------------------------------------------ -GalleryImportThemeEntry* Gallery::ImplGetImportThemeEntry( const String& rImportName ) +GalleryImportThemeEntry* Gallery::ImplGetImportThemeEntry( const rtl::OUString& rImportName ) { for ( size_t i = 0, n = aImportList.size(); i < n; ++i ) if ( rImportName == aImportList[ i ]->aUIName ) @@ -571,7 +558,7 @@ GalleryImportThemeEntry* Gallery::ImplGetImportThemeEntry( const String& rImport // ------------------------------------------------------------------------ -String Gallery::GetThemeName( sal_uIntPtr nThemeId ) const +rtl::OUString Gallery::GetThemeName( sal_uIntPtr nThemeId ) const { GalleryThemeEntry* pFound = NULL; @@ -606,7 +593,7 @@ String Gallery::GetThemeName( sal_uIntPtr nThemeId ) const pFound = ( (Gallery*) this )->ImplGetThemeEntry( String::CreateFromAscii( aFallback.GetBuffer() ) ); } - return( pFound ? pFound->GetThemeName() : String() ); + return( pFound ? pFound->GetThemeName() : rtl::OUString() ); } // ------------------------------------------------------------------------ diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx index 1f03f1397b43..ddf56cbd7c01 100644 --- a/svx/source/gallery2/galobj.cxx +++ b/svx/source/gallery2/galobj.cxx @@ -168,7 +168,7 @@ void SgaObject::WriteData( SvStream& rOut, const String& rDestDir ) const String aURLWithoutDestDir = String(aURL.GetMainURL( INetURLObject::NO_DECODE )); aURLWithoutDestDir.SearchAndReplace(rDestDir, String()); - rOut.WriteByteString(rtl::OUStringToOString(aURLWithoutDestDir, RTL_TEXTENCODING_UTF8)); + write_lenPrefixed_uInt8s_FromOUString(rOut, aURLWithoutDestDir, RTL_TEXTENCODING_UTF8); } // ------------------------------------------------------------------------ @@ -185,9 +185,8 @@ void SgaObject::ReadData(SvStream& rIn, sal_uInt16& rReadVersion ) else rIn >> aThumbMtf; - ByteString aTmpStr; - rIn.ReadByteString(aTmpStr); - aURL = INetURLObject(rtl::OStringToOUString(aTmpStr,RTL_TEXTENCODING_UTF8)); + rtl::OUString aTmpStr = read_lenPrefixed_uInt8s_ToOUString(rIn, RTL_TEXTENCODING_UTF8); + aURL = INetURLObject(aTmpStr); } // ------------------------------------------------------------------------ @@ -294,9 +293,8 @@ void SgaObjectBmp::WriteData( SvStream& rOut, const String& rDestDir ) const SgaObject::WriteData( rOut, rDestDir ); char aDummy[ 10 ]; rOut.Write( aDummy, 10 ); - String aDummyStr; - rOut.WriteByteString(rtl::OUStringToOString(aDummyStr, RTL_TEXTENCODING_UTF8)); - rOut.WriteByteString(rtl::OUStringToOString(aTitle, RTL_TEXTENCODING_UTF8)); + write_lenPrefixed_uInt8s_FromOString(rOut, rtl::OString()); //dummy + write_lenPrefixed_uInt8s_FromOUString(rOut, aTitle, RTL_TEXTENCODING_UTF8); } // ------------------------------------------------------------------------ @@ -306,14 +304,10 @@ void SgaObjectBmp::ReadData( SvStream& rIn, sal_uInt16& rReadVersion ) SgaObject::ReadData( rIn, rReadVersion ); rIn.SeekRel( 10 ); // 16, 16, 32, 16 - ByteString aTmpStr; - rIn.ReadByteString(aTmpStr); // dummy + read_lenPrefixed_uInt8s_ToOString(rIn); //dummy if( rReadVersion >= 5 ) - { - rIn.ReadByteString(aTmpStr); - aTitle = rtl::OStringToOUString(aTmpStr, RTL_TEXTENCODING_UTF8); - } + aTitle = read_lenPrefixed_uInt8s_ToOUString(rIn, RTL_TEXTENCODING_UTF8); } // ------------------ @@ -380,7 +374,7 @@ void SgaObjectSound::WriteData( SvStream& rOut, const String& rDestDir ) const { SgaObject::WriteData( rOut, rDestDir ); rOut << (sal_uInt16) eSoundType; - rOut.WriteByteString(rtl::OUStringToOString(aTitle, RTL_TEXTENCODING_UTF8)); + write_lenPrefixed_uInt8s_FromOUString(rOut, aTitle, RTL_TEXTENCODING_UTF8); } // ------------------------------------------------------------------------ @@ -396,11 +390,7 @@ void SgaObjectSound::ReadData( SvStream& rIn, sal_uInt16& rReadVersion ) rIn >> nTmp16; eSoundType = (GalSoundType) nTmp16; if( rReadVersion >= 6 ) - { - ByteString aTmpStr; - rIn.ReadByteString(aTmpStr); - aTitle = rtl::OStringToOUString(aTmpStr, RTL_TEXTENCODING_UTF8); - } + aTitle = read_lenPrefixed_uInt8s_ToOUString(rIn, RTL_TEXTENCODING_UTF8); } } @@ -591,7 +581,7 @@ sal_Bool SgaObjectSvDraw::DrawCentered( OutputDevice* pOut, const FmFormModel& r void SgaObjectSvDraw::WriteData( SvStream& rOut, const String& rDestDir ) const { SgaObject::WriteData( rOut, rDestDir ); - rOut.WriteByteString(rtl::OUStringToOString(aTitle, RTL_TEXTENCODING_UTF8)); + write_lenPrefixed_uInt8s_FromOUString(rOut, aTitle, RTL_TEXTENCODING_UTF8); } // ------------------------------------------------------------------------ @@ -601,11 +591,7 @@ void SgaObjectSvDraw::ReadData( SvStream& rIn, sal_uInt16& rReadVersion ) SgaObject::ReadData( rIn, rReadVersion ); if( rReadVersion >= 5 ) - { - ByteString aTmpStr; - rIn.ReadByteString(aTmpStr); - aTitle = rtl::OStringToOUString(aTmpStr, RTL_TEXTENCODING_UTF8); - } + aTitle = read_lenPrefixed_uInt8s_ToOUString(rIn, RTL_TEXTENCODING_UTF8); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx index 12f1e6d257ab..4a34a85ee611 100644 --- a/svx/source/gallery2/galtheme.cxx +++ b/svx/source/gallery2/galtheme.cxx @@ -733,8 +733,7 @@ GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, sa { sal_uInt32 nThemeId = 0; - ByteString aTmpStr; - pIStm->ReadByteString(aTmpStr); + rtl::OString aTmpStr = read_lenPrefixed_uInt8s_ToOString(*pIStm); aThemeName = rtl::OStringToOUString(aTmpStr, RTL_TEXTENCODING_UTF8); // Charakterkonvertierung durchfuehren @@ -1355,7 +1354,7 @@ SvStream& GalleryTheme::WriteData( SvStream& rOStm ) const sal_Bool bRel; rOStm << (sal_uInt16) 0x0004; - rOStm.WriteByteString(rtl::OUStringToOString(GetRealName(), RTL_TEXTENCODING_UTF8)); + write_lenPrefixed_uInt8s_FromOUString(rOStm, GetRealName(), RTL_TEXTENCODING_UTF8); rOStm << nCount << (sal_uInt16) osl_getThreadTextEncoding(); for( sal_uInt32 i = 0; i < nCount; i++ ) @@ -1395,7 +1394,7 @@ SvStream& GalleryTheme::WriteData( SvStream& rOStm ) const aPath.SearchAndReplace(m_aDestDir, String()); rOStm << bRel; - rOStm.WriteByteString(rtl::OUStringToOString(aPath, RTL_TEXTENCODING_UTF8)); + write_lenPrefixed_uInt8s_FromOUString(rOStm, aPath, RTL_TEXTENCODING_UTF8); rOStm << pObj->nOffset << (sal_uInt16) pObj->eObjKind; } @@ -1433,10 +1432,9 @@ SvStream& GalleryTheme::ReadData( SvStream& rIStm ) String aThemeName; rtl_TextEncoding nTextEncoding; - aImportName = String(); + aImportName = rtl::OUString(); rIStm >> nVersion; - ByteString aTmpStr; - rIStm.ReadByteString(aTmpStr); + rtl::OString aTmpStr = read_lenPrefixed_uInt8s_ToOString(rIStm); rIStm >> nCount; if( nVersion >= 0x0004 ) @@ -1471,13 +1469,12 @@ SvStream& GalleryTheme::ReadData( SvStream& rIStm ) { pObj = new GalleryObject; - ByteString aTempFileName; String aFileName; String aPath; sal_uInt16 nTemp; rIStm >> bRel; - rIStm.ReadByteString(aTempFileName); + rtl::OString aTempFileName = read_lenPrefixed_uInt8s_ToOString(rIStm); rIStm >> pObj->nOffset; rIStm >> nTemp; pObj->eObjKind = (SgaObjKind) nTemp; @@ -1583,7 +1580,7 @@ SvStream& operator>>( SvStream& rIn, GalleryTheme& rTheme ) void GalleryTheme::ImplSetModified( sal_Bool bModified ) { pThm->SetModified( bModified ); } -const String& GalleryTheme::GetRealName() const { return pThm->GetThemeName(); } +const rtl::OUString& GalleryTheme::GetRealName() const { return pThm->GetThemeName(); } const INetURLObject& GalleryTheme::GetThmURL() const { return pThm->GetThmURL(); } const INetURLObject& GalleryTheme::GetSdgURL() const { return pThm->GetSdgURL(); } const INetURLObject& GalleryTheme::GetSdvURL() const { return pThm->GetSdvURL(); } @@ -1594,7 +1591,7 @@ sal_Bool GalleryTheme::IsImported() const { return pThm->IsImported(); } sal_Bool GalleryTheme::IsReadOnly() const { return pThm->IsReadOnly(); } sal_Bool GalleryTheme::IsDefault() const { return pThm->IsDefault(); } sal_Bool GalleryTheme::IsModified() const { return pThm->IsModified(); } -const String& GalleryTheme::GetName() const { return IsImported() ? aImportName : pThm->GetThemeName(); } +const rtl::OUString& GalleryTheme::GetName() const { return IsImported() ? aImportName : pThm->GetThemeName(); } void GalleryTheme::InsertAllThemes( ListBox& rListBox ) { diff --git a/sw/source/filter/ww1/w1class.cxx b/sw/source/filter/ww1/w1class.cxx index 3e5c3e6e0c25..a7e35cd65e41 100644 --- a/sw/source/filter/ww1/w1class.cxx +++ b/sw/source/filter/ww1/w1class.cxx @@ -85,7 +85,7 @@ String Ww1PlainText::GetText( sal_uLong ulOffset, sal_uLong nLen ) const bool bSeekOk = rFib.GetStream().Seek(nPos) == nPos; rtl::OString a8BitStr = bSeekOk ? - read_uInt8s_AsOString(rFib.GetStream(), nLen) : + read_uInt8s_ToOString(rFib.GetStream(), nLen) : rtl::OString(); return rtl::OStringToOUString(a8BitStr, RTL_TEXTENCODING_MS_1252); } diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 99237686e660..0ab1cf6e175a 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -281,7 +281,7 @@ bool Sttb::Read( SvStream& rS ) { SBBItem aItem; rS >> aItem.cchData; - aItem.data = read_LEuInt16s_AsOUString(rS, aItem.cchData); + aItem.data = read_LEuInt16s_ToOUString(rS, aItem.cchData); dataItems.push_back( aItem ); } } diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index c6702c55fc50..b72fcd55ab51 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -4334,7 +4334,7 @@ void WW8RStyle::ImportOldFormatStyles() } else // user style { - rtl::OString aTmp = read_uInt8s_AsOString(rSt, nCount); + rtl::OString aTmp = read_uInt8s_ToOString(rSt, nCount); nByteCount += aTmp.getLength(); sName = rtl::OStringToOUString(aTmp, eStructChrSet); } diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 56631b9bb225..56981ace6280 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -1910,23 +1910,16 @@ Err: return false; } -String read_uInt8_PascalString(SvStream& rStrm, rtl_TextEncoding eEnc) -{ - sal_uInt8 nLen(0); - rStrm >> nLen; - return rtl::OStringToOUString(read_uInt8s_AsOString(rStrm, nLen), eEnc); -} - String read_LEuInt16_PascalString(SvStream& rStrm) { sal_uInt16 nLen(0); rStrm >> nLen; - return read_LEuInt16s_AsOUString(rStrm, nLen); + return read_LEuInt16s_ToOUString(rStrm, nLen); } String read_uInt8_BeltAndBracesString(SvStream& rStrm, rtl_TextEncoding eEnc) { - String aRet = read_uInt8_PascalString(rStrm, eEnc); + rtl::OUString aRet = read_lenPrefixed_uInt8s_ToOUString<sal_uInt8>(rStrm, eEnc); rStrm.SeekRel(sizeof(sal_uInt8)); // skip null-byte at end return aRet; } @@ -1968,11 +1961,11 @@ xub_StrLen WW8ScannerBase::WW8ReadString( SvStream& rStrm, String& rStr, nLen = USHRT_MAX - 1; if( bIsUnicode ) - rStr.Append(String(read_LEuInt16s_AsOUString(rStrm, nLen))); + rStr.Append(String(read_LEuInt16s_ToOUString(rStrm, nLen))); else { // Alloc method automatically sets Zero at the end - rtl::OString aByteStr = read_uInt8s_AsOString(rStrm, nLen); + rtl::OString aByteStr = read_uInt8s_ToOString(rStrm, nLen); rStr.Append(String(rtl::OStringToOUString(aByteStr, eEnc))); } nTotalRead += nLen; @@ -3876,7 +3869,7 @@ void WW8ReadSTTBF(bool bVer8, SvStream& rStrm, sal_uInt32 nStart, sal_Int32 nLen { sal_uInt8 nBChar(0); rStrm >> nBChar; - rtl::OString aTmp = read_uInt8s_AsOString(rStrm, nBChar); + rtl::OString aTmp = read_uInt8s_ToOString(rStrm, nBChar); rArray.push_back(rtl::OStringToOUString(aTmp, eCS)); } @@ -3909,7 +3902,7 @@ void WW8ReadSTTBF(bool bVer8, SvStream& rStrm, sal_uInt32 nStart, sal_Int32 nLen { sal_uInt8 nBChar(0); rStrm >> nBChar; - rtl::OString aTmp = read_uInt8s_AsOString(rStrm, nBChar); + rtl::OString aTmp = read_uInt8s_ToOString(rStrm, nBChar); pValueArray->push_back(rtl::OStringToOUString(aTmp, eCS)); } } @@ -3935,7 +3928,7 @@ void WW8ReadSTTBF(bool bVer8, SvStream& rStrm, sal_uInt32 nStart, sal_Int32 nLen ++nRead; if (nBChar) { - rtl::OString aTmp = read_uInt8s_AsOString(rStrm, nBChar); + rtl::OString aTmp = read_uInt8s_ToOString(rStrm, nBChar); nRead += aTmp.getLength(); rArray.push_back(rtl::OStringToOUString(aTmp, eCS)); } diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx index a323b84bae6e..9cac3eb94c28 100644 --- a/sw/source/filter/ww8/ww8scan.hxx +++ b/sw/source/filter/ww8/ww8scan.hxx @@ -136,7 +136,10 @@ public: //Read a Pascal-style, i.e. single byte string length followed //by string contents -String read_uInt8_PascalString(SvStream& rStrm, rtl_TextEncoding eEnc); +inline String read_uInt8_PascalString(SvStream& rStrm, rtl_TextEncoding eEnc) +{ + return read_lenPrefixed_uInt8s_ToOUString<sal_uInt8>(rStrm, eEnc); +} String read_LEuInt16_PascalString(SvStream& rStrm); //Belt and Braces strings, i.e. Pascal-style strings followed by diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx index d615d860619c..06cf7e707e2b 100644 --- a/sw/source/filter/ww8/ww8toolbar.cxx +++ b/sw/source/filter/ww8/ww8toolbar.cxx @@ -1128,7 +1128,7 @@ bool TcgSttbfCore::Read( SvStream& rS ) for ( sal_Int32 index = 0; index < cData; ++index ) { rS >> dataItems[ index ].cchData; - dataItems[ index ].data = read_LEuInt16s_AsOUString(rS, dataItems[index].cchData); + dataItems[ index ].data = read_LEuInt16s_ToOUString(rS, dataItems[index].cchData); rS >> dataItems[ index ].extraData; } } diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx index 6f3905105b8b..422e090b06e9 100755 --- a/sw/source/ui/dochdl/swdtflvr.cxx +++ b/sw/source/ui/dochdl/swdtflvr.cxx @@ -1993,9 +1993,9 @@ int SwTransferable::_PasteDDE( TransferableDataHelper& rData, } // report useful error!! rtl_TextEncoding eEncoding = DDE_TXT_ENCODING; - aApp = read_zeroTerminated_uInt8s_AsOUString(*xStrm, eEncoding); - aTopic = read_zeroTerminated_uInt8s_AsOUString(*xStrm, eEncoding); - aItem = read_zeroTerminated_uInt8s_AsOUString(*xStrm, eEncoding); + aApp = read_zeroTerminated_uInt8s_ToOUString(*xStrm, eEncoding); + aTopic = read_zeroTerminated_uInt8s_ToOUString(*xStrm, eEncoding); + aItem = read_zeroTerminated_uInt8s_ToOUString(*xStrm, eEncoding); } String aCmd; diff --git a/tools/inc/tools/inetmsg.hxx b/tools/inc/tools/inetmsg.hxx index 610b804e7502..7c88b9c3aa7a 100644 --- a/tools/inc/tools/inetmsg.hxx +++ b/tools/inc/tools/inetmsg.hxx @@ -51,7 +51,7 @@ class INetMessageHeader ByteString m_aValue; public: - INetMessageHeader (void) + INetMessageHeader() {} INetMessageHeader ( @@ -64,7 +64,7 @@ public: : m_aName (rHdr.m_aName), m_aValue (rHdr.m_aValue) {} - ~INetMessageHeader (void) + ~INetMessageHeader() {} INetMessageHeader& operator= (const INetMessageHeader& rHdr) @@ -74,22 +74,22 @@ public: return *this; } - const ByteString& GetName (void) const { return m_aName; } - const ByteString& GetValue (void) const { return m_aValue; } + const ByteString& GetName() const { return m_aName; } + const ByteString& GetValue() const { return m_aValue; } friend SvStream& operator<< ( SvStream& rStrm, const INetMessageHeader& rHdr) { - rStrm.WriteByteString (rHdr.m_aName); - rStrm.WriteByteString (rHdr.m_aValue); + write_lenPrefixed_uInt8s_FromOString(rStrm, rHdr.m_aName); + write_lenPrefixed_uInt8s_FromOString(rStrm, rHdr.m_aValue); return rStrm; } friend SvStream& operator>> ( SvStream& rStrm, INetMessageHeader& rHdr) { - rStrm.ReadByteString (rHdr.m_aName); - rStrm.ReadByteString (rHdr.m_aValue); + rHdr.m_aName = read_lenPrefixed_uInt8s_ToOString(rStrm); + rHdr.m_aValue = read_lenPrefixed_uInt8s_ToOString(rStrm); return rStrm; } }; @@ -108,7 +108,7 @@ class INetMessage UniString m_aDocName; SvLockBytesRef m_xDocLB; - void ListCleanup_Impl (void); + void ListCleanup_Impl(); void ListCopy (const INetMessage& rMsg); protected: @@ -158,8 +158,8 @@ protected: virtual SvStream& operator>> (SvStream& rStrm); public: - INetMessage (void) : m_nDocSize(0) {} - virtual ~INetMessage (void); + INetMessage() : m_nDocSize(0) {} + virtual ~INetMessage(); INetMessage (const INetMessage& rMsg) : m_nDocSize (rMsg.m_nDocSize), @@ -178,7 +178,7 @@ public: return *this; } - sal_uIntPtr GetHeaderCount (void) const { return m_aHeaderList.size(); } + sal_uIntPtr GetHeaderCount() const { return m_aHeaderList.size(); } UniString GetHeaderName (sal_uIntPtr nIndex) const { @@ -204,13 +204,13 @@ public: sal_uIntPtr nIndex = ((sal_uIntPtr)-1) ); - sal_uIntPtr GetDocumentSize (void) const { return m_nDocSize; } + sal_uIntPtr GetDocumentSize() const { return m_nDocSize; } void SetDocumentSize (sal_uIntPtr nSize) { m_nDocSize = nSize; } - const UniString& GetDocumentName (void) const { return m_aDocName; } + const UniString& GetDocumentName() const { return m_aDocName; } void SetDocumentName (const UniString& rName) { m_aDocName = rName; } - SvLockBytes* GetDocumentLB (void) const { return m_xDocLB; } + SvLockBytes* GetDocumentLB() const { return m_xDocLB; } void SetDocumentLB (SvLockBytes *pDocLB) { m_xDocLB = pDocLB; } friend SvStream& operator<< ( @@ -260,9 +260,9 @@ protected: virtual SvStream& operator>> (SvStream& rStrm); public: - INetRFC822Message (void); + INetRFC822Message(); INetRFC822Message (const INetRFC822Message& rMsg); - virtual ~INetRFC822Message (void); + virtual ~INetRFC822Message(); INetRFC822Message& operator= (const INetRFC822Message& rMsg); @@ -277,105 +277,105 @@ public: /** Header fields. */ - UniString GetBCC (void) const + UniString GetBCC() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_BCC], INetMIME::HEADER_FIELD_ADDRESS); } - UniString GetCC (void) const + UniString GetCC() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_CC], INetMIME::HEADER_FIELD_ADDRESS); } - UniString GetComments (void) const + UniString GetComments() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_COMMENTS], INetMIME::HEADER_FIELD_TEXT); } - UniString GetDate (void) const + UniString GetDate() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_DATE], INetMIME::HEADER_FIELD_STRUCTURED); } - UniString GetFrom (void) const + UniString GetFrom() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_FROM], INetMIME::HEADER_FIELD_ADDRESS); } - UniString GetInReplyTo (void) const + UniString GetInReplyTo() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_IN_REPLY_TO], INetMIME::HEADER_FIELD_ADDRESS); // ??? MESSAGE_ID ??? } - UniString GetKeywords (void) const + UniString GetKeywords() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_KEYWORDS], INetMIME::HEADER_FIELD_PHRASE); } - UniString GetMessageID (void) const + UniString GetMessageID() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_MESSAGE_ID], INetMIME::HEADER_FIELD_MESSAGE_ID); } - UniString GetReferences (void) const + UniString GetReferences() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_REFERENCES], INetMIME::HEADER_FIELD_ADDRESS); } - UniString GetReplyTo (void) const + UniString GetReplyTo() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_REPLY_TO], INetMIME::HEADER_FIELD_ADDRESS); } - UniString GetReturnPath (void) const + UniString GetReturnPath() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_RETURN_PATH], INetMIME::HEADER_FIELD_ADDRESS); } - UniString GetReturnReceiptTo (void) const + UniString GetReturnReceiptTo() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_RETURN_RECEIPT_TO], INetMIME::HEADER_FIELD_ADDRESS); } - UniString GetSender (void) const + UniString GetSender() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_SENDER], INetMIME::HEADER_FIELD_ADDRESS); } - UniString GetSubject (void) const + UniString GetSubject() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_SUBJECT], INetMIME::HEADER_FIELD_TEXT); } - UniString GetTo (void) const + UniString GetTo() const { return GetHeaderValue_Impl ( m_nIndex[INETMSG_RFC822_TO], @@ -430,15 +430,15 @@ class TOOLS_DLLPUBLIC INetMIMEMessage : public INetRFC822Message INetMIMEMessage* pParent; INetMIMEMessgeList_impl aChildren; - ByteString m_aBoundary; + rtl::OString m_aBoundary; sal_Bool bHeaderParsed; friend class INetMIMEMessageStream; - const ByteString& GetMultipartBoundary (void) const { return m_aBoundary; } - void SetMultipartBoundary (const ByteString& rBnd) { m_aBoundary = rBnd; } + const rtl::OString& GetMultipartBoundary() const { return m_aBoundary; } + void SetMultipartBoundary (const rtl::OString& rBnd) { m_aBoundary = rBnd; } - void CleanupImp (void); + void CleanupImp(); void CopyImp (const INetMIMEMessage& rMsg); void SetHeaderParsed() { bHeaderParsed = sal_True; } @@ -447,9 +447,9 @@ protected: virtual SvStream& operator>> (SvStream& rStrm); public: - INetMIMEMessage (void); + INetMIMEMessage(); INetMIMEMessage (const INetMIMEMessage& rMsg); - virtual ~INetMIMEMessage (void); + virtual ~INetMIMEMessage(); INetMIMEMessage& operator= (const INetMIMEMessage& rMsg); @@ -467,35 +467,35 @@ public: /** Header fields. */ void SetMIMEVersion (const UniString& rVersion); - UniString GetMIMEVersion (void) const + UniString GetMIMEVersion() const { return GetHeaderValue (m_nIndex[INETMSG_MIME_VERSION]); } - UniString GetContentDescription (void) const + UniString GetContentDescription() const { return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_DESCRIPTION]); } void SetContentDisposition (const UniString& rDisposition); - UniString GetContentDisposition (void) const + UniString GetContentDisposition() const { return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_DISPOSITION]); } - UniString GetContentID (void) const + UniString GetContentID() const { return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_ID]); } void SetContentType (const UniString& rType); - UniString GetContentType (void) const + UniString GetContentType() const { return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_TYPE]); } void SetContentTransferEncoding (const UniString& rEncoding); - UniString GetContentTransferEncoding (void) const + UniString GetContentTransferEncoding() const { return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_TRANSFER_ENCODING]); } @@ -504,16 +504,16 @@ public: /** Message container methods. */ - sal_Bool IsContainer (void) const + sal_Bool IsContainer() const { return (IsMessage() || IsMultipart()); } - sal_Bool IsMessage (void) const + sal_Bool IsMessage() const { UniString aType (GetContentType()); return (aType.CompareIgnoreCaseToAscii("message/", 8) == 0); } - sal_Bool IsMultipart (void) const + sal_Bool IsMultipart() const { UniString aType (GetContentType()); return (aType.CompareIgnoreCaseToAscii("multipart/", 10) == 0); @@ -523,7 +523,7 @@ public: { return ( nIndex < aChildren.size() ) ? aChildren[ nIndex ] : NULL; } - INetMIMEMessage* GetParent (void) const { return pParent; } + INetMIMEMessage* GetParent() const { return pParent; } sal_Bool EnableAttachChild ( INetMessageContainerType eType = INETMSG_MULTIPART_MIXED); diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx index 66312b76faaf..e6e939bbbd1b 100644 --- a/tools/inc/tools/stream.hxx +++ b/tools/inc/tools/stream.hxx @@ -28,6 +28,7 @@ #ifndef _STREAM_HXX #define _STREAM_HXX +#include <limits> #include "tools/toolsdllapi.h" #include <tools/solar.h> #include <tools/string.hxx> @@ -364,10 +365,8 @@ public: SvStream& ReadByteString( UniString& rStr, rtl_TextEncoding eSrcCharSet ); SvStream& ReadByteString( UniString& rStr ) { return ReadByteString( rStr, GetStreamCharSet() ); } - SvStream& ReadByteString( ByteString& rStr ); SvStream& WriteByteString( const UniString& rStr, rtl_TextEncoding eDestCharSet ); SvStream& WriteByteString( const UniString& rStr ) { return WriteByteString( rStr, GetStreamCharSet() ); } - SvStream& WriteByteString( const ByteString& rStr ); SvStream& WriteNumber( sal_uInt32 nUInt32 ); SvStream& WriteNumber( sal_Int32 nInt32 ); @@ -546,22 +545,70 @@ TOOLS_DLLPUBLIC SvStream& endlub( SvStream& rStr ); //Attempt to read nLen 8bit units to an OString, returned rtl::OString's length //is number of units successfully read -TOOLS_DLLPUBLIC rtl::OString read_uInt8s_AsOString(SvStream& rStr, sal_Size nLen); +TOOLS_DLLPUBLIC rtl::OString read_uInt8s_ToOString(SvStream& rStrm, sal_Size nLen); //Attempt to read nLen little endian 16bit units to an OUString, returned //rtl::OUString's length is number of units successfully read -TOOLS_DLLPUBLIC rtl::OUString read_LEuInt16s_AsOUString(SvStream& rStr, sal_Size nLen); +TOOLS_DLLPUBLIC rtl::OUString read_LEuInt16s_ToOUString(SvStream& rStrm, sal_Size nLen); //Attempt to read 8bit units to an OString until a zero terminator is //encountered, returned rtl::OString's length is number of units *definitely* //successfully read, check SvStream::good() to see if null terminator was //sucessfully read -TOOLS_DLLPUBLIC rtl::OString read_zeroTerminated_uInt8s_AsOString(SvStream& rStr); +TOOLS_DLLPUBLIC rtl::OString read_zeroTerminated_uInt8s_ToOString(SvStream& rStrm); //Attempt to read 8bit units assuming source encoding eEnc to an OUString until //a zero terminator is encountered. Check SvStream::good() to see if null //terminator was sucessfully read -TOOLS_DLLPUBLIC rtl::OUString read_zeroTerminated_uInt8s_AsOUString(SvStream& rStr, rtl_TextEncoding eEnc); +TOOLS_DLLPUBLIC rtl::OUString read_zeroTerminated_uInt8s_ToOUString(SvStream& rStrm, rtl_TextEncoding eEnc); + +//Attempt to read a pascal-style length (of type prefix) prefixed sequence of +//8bit units to an OString, returned rtl::OString's length is number of units +//successfully read. +template<typename prefix=sal_uInt16> rtl::OString read_lenPrefixed_uInt8s_ToOString(SvStream& rStrm) +{ + prefix nLen = 0; + rStrm >> nLen; + return read_uInt8s_ToOString(rStrm, nLen); +} + +//Attempt to read a pascal-style length (of type prefix) prefixed sequence of +//8bit units to an OUString +template<typename prefix=sal_uInt16> rtl::OUString read_lenPrefixed_uInt8s_ToOUString(SvStream& rStrm, + rtl_TextEncoding eEnc) +{ + return rtl::OStringToOUString(read_lenPrefixed_uInt8s_ToOString<prefix>(rStrm), eEnc); +} + +//Attempt to write a pascal-style length (of type prefix) prefixed sequence of +//8bit units from an OString, returned value is number of bytes written (including +//byte-count of prefix) +template<typename prefix=sal_uInt16> sal_Size write_lenPrefixed_uInt8s_FromOString(SvStream& rStrm, + const rtl::OString &rStr) +{ + SAL_WARN_IF(rStr.getLength() > std::numeric_limits<prefix>::max(), + "tools.stream", + "string too long for prefix count to fit in output type"); + + sal_Size nWritten = 0; + prefix nLen = std::min<sal_Size>(rStr.getLength(), std::numeric_limits<prefix>::max()); + rStrm << nLen; + if (rStrm.good()) + { + nWritten += sizeof(prefix); + nWritten += rStrm.Write(rStr.getStr(), nLen); + } + return nWritten; +} + +//Attempt to write a pascal-style length (of type prefix) prefixed sequence of +//8bit units from an OUString, returned value is number of bytes written (including +//byte-count of prefix) +template<typename prefix=sal_uInt16> sal_Size write_lenPrefixed_uInt8s_FromOUString(SvStream& rStrm, + const rtl::OUString &rStr, rtl_TextEncoding eEnc) +{ + return write_lenPrefixed_uInt8s_FromOString<prefix>(rStrm, rtl::OUStringToOString(rStr, eEnc)); +} // -------------- // - FileStream - diff --git a/tools/qa/cppunit/test_stream.cxx b/tools/qa/cppunit/test_stream.cxx index 77c2b9ed75ae..3e7580f40377 100644 --- a/tools/qa/cppunit/test_stream.cxx +++ b/tools/qa/cppunit/test_stream.cxx @@ -47,11 +47,13 @@ namespace void test_stdstream(); void test_fastostring(); void test_read_cstring(); + void test_read_pstring(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(test_stdstream); CPPUNIT_TEST(test_fastostring); CPPUNIT_TEST(test_read_cstring); + CPPUNIT_TEST(test_read_pstring); CPPUNIT_TEST_SUITE_END(); }; @@ -67,7 +69,7 @@ namespace char tools_a(78); aMemStream >> tools_a; - CPPUNIT_ASSERT(std_a == 'f'); + CPPUNIT_ASSERT(tools_a == 'f'); iss.seekg(0, std::ios_base::end); //seeking to end doesn't set eof, reading past eof does @@ -98,7 +100,7 @@ namespace //a failed read doesn't change the data, it remains unchanged CPPUNIT_ASSERT(tools_a == 78); //nothing wrong with the stream, so not bad - CPPUNIT_ASSERT(!aMemStream.GetError()); + CPPUNIT_ASSERT(!aMemStream.bad()); //yet, the read didn't succeed CPPUNIT_ASSERT(!aMemStream.good()); @@ -133,18 +135,18 @@ namespace char foo[] = "foobar"; SvMemoryStream aMemStream(RTL_CONSTASCII_STRINGPARAM(foo), STREAM_READ); - rtl::OString aOne = read_uInt8s_AsOString(aMemStream, 3); + rtl::OString aOne = read_uInt8s_ToOString(aMemStream, 3); CPPUNIT_ASSERT(aOne.equalsL(RTL_CONSTASCII_STRINGPARAM("foo"))); - rtl::OString aTwo = read_uInt8s_AsOString(aMemStream, 3); + rtl::OString aTwo = read_uInt8s_ToOString(aMemStream, 3); CPPUNIT_ASSERT(aTwo.equalsL(RTL_CONSTASCII_STRINGPARAM("bar"))); - rtl::OString aThree = read_uInt8s_AsOString(aMemStream, 3); + rtl::OString aThree = read_uInt8s_ToOString(aMemStream, 3); CPPUNIT_ASSERT(!aThree.getLength()); aMemStream.Seek(0); - rtl::OString aFour = read_uInt8s_AsOString(aMemStream, 100); + rtl::OString aFour = read_uInt8s_ToOString(aMemStream, 100); CPPUNIT_ASSERT(aFour.equalsL(RTL_CONSTASCII_STRINGPARAM(foo))); } @@ -153,7 +155,7 @@ namespace char foo[] = "foobar"; SvMemoryStream aMemStream(RTL_CONSTASCII_STRINGPARAM(foo), STREAM_READ); - rtl::OString aOne = read_zeroTerminated_uInt8s_AsOString(aMemStream); + rtl::OString aOne = read_zeroTerminated_uInt8s_ToOString(aMemStream); CPPUNIT_ASSERT(aOne.equalsL(RTL_CONSTASCII_STRINGPARAM("foobar"))); CPPUNIT_ASSERT(!aMemStream.good()); CPPUNIT_ASSERT(!aMemStream.bad()); @@ -161,11 +163,52 @@ namespace aMemStream.Seek(0); foo[3] = 0; - rtl::OString aTwo = read_zeroTerminated_uInt8s_AsOString(aMemStream); + rtl::OString aTwo = read_zeroTerminated_uInt8s_ToOString(aMemStream); CPPUNIT_ASSERT(aTwo.equalsL(RTL_CONSTASCII_STRINGPARAM("foo"))); CPPUNIT_ASSERT(aMemStream.good()); } + void Test::test_read_pstring() + { + char foo[] = "\3foobar"; + SvMemoryStream aMemStream(RTL_CONSTASCII_STRINGPARAM(foo), STREAM_READ); + + rtl::OString aFoo = read_lenPrefixed_uInt8s_ToOString<sal_uInt8>(aMemStream); + CPPUNIT_ASSERT(aFoo.equalsL(RTL_CONSTASCII_STRINGPARAM("foo"))); + CPPUNIT_ASSERT(aMemStream.good()); + CPPUNIT_ASSERT(!aMemStream.bad()); + CPPUNIT_ASSERT(!aMemStream.eof()); + + aMemStream.Seek(0); + foo[0] = 10; + aFoo = read_lenPrefixed_uInt8s_ToOString<sal_uInt8>(aMemStream); + CPPUNIT_ASSERT(aFoo.equalsL(RTL_CONSTASCII_STRINGPARAM("foobar"))); + CPPUNIT_ASSERT(!aMemStream.good()); + CPPUNIT_ASSERT(!aMemStream.bad()); + CPPUNIT_ASSERT(aMemStream.eof()); + + aMemStream.SetNumberFormatInt(NUMBERFORMAT_INT_BIGENDIAN); + aMemStream.Seek(0); + foo[0] = 0; + foo[1] = 3; + aFoo = read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(aMemStream); + CPPUNIT_ASSERT(aFoo.equalsL(RTL_CONSTASCII_STRINGPARAM("oob"))); + CPPUNIT_ASSERT(aMemStream.good()); + CPPUNIT_ASSERT(!aMemStream.bad()); + CPPUNIT_ASSERT(!aMemStream.eof()); + + aMemStream.SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN); + aMemStream.Seek(0); + foo[0] = 3; + foo[1] = 0; + foo[2] = 0; + foo[3] = 0; + aFoo = read_lenPrefixed_uInt8s_ToOString<sal_uInt32>(aMemStream); + CPPUNIT_ASSERT(aFoo.equalsL(RTL_CONSTASCII_STRINGPARAM("bar"))); + CPPUNIT_ASSERT(aMemStream.good()); + CPPUNIT_ASSERT(!aMemStream.bad()); + CPPUNIT_ASSERT(!aMemStream.eof()); + } CPPUNIT_TEST_SUITE_REGISTRATION(Test); } diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx index f5fa071ad15a..f626dcccd508 100644 --- a/tools/source/inet/inetmsg.cxx +++ b/tools/source/inet/inetmsg.cxx @@ -66,7 +66,7 @@ inline sal_Unicode ascii_toLowerCase( sal_Unicode ch ) /* * ~INetMessage. */ -INetMessage::~INetMessage (void) +INetMessage::~INetMessage() { ListCleanup_Impl(); } @@ -74,7 +74,7 @@ INetMessage::~INetMessage (void) /* * ListCleanup_Impl. */ -void INetMessage::ListCleanup_Impl (void) +void INetMessage::ListCleanup_Impl() { // Cleanup. sal_uIntPtr i, n = m_aHeaderList.size(); @@ -243,7 +243,7 @@ enum _ImplINetRFC822MessageHeaderState /* * INetRFC822Message. */ -INetRFC822Message::INetRFC822Message (void) +INetRFC822Message::INetRFC822Message() : INetMessage() { for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) @@ -275,7 +275,7 @@ INetRFC822Message& INetRFC822Message::operator= (const INetRFC822Message& rMsg) /* * ~INetRFC822Message. */ -INetRFC822Message::~INetRFC822Message (void) +INetRFC822Message::~INetRFC822Message() { } @@ -753,7 +753,7 @@ enum _ImplINetMIMEMessageHeaderState /* * INetMIMEMessage. */ -INetMIMEMessage::INetMIMEMessage (void) +INetMIMEMessage::INetMIMEMessage() : INetRFC822Message (), pParent (NULL), bHeaderParsed (sal_False) @@ -792,7 +792,7 @@ INetMIMEMessage& INetMIMEMessage::operator= ( /* * ~INetMIMEMessage. */ -INetMIMEMessage::~INetMIMEMessage (void) +INetMIMEMessage::~INetMIMEMessage() { // Cleanup. CleanupImp(); @@ -801,7 +801,7 @@ INetMIMEMessage::~INetMIMEMessage (void) /* * CleanupImp. */ -void INetMIMEMessage::CleanupImp (void) +void INetMIMEMessage::CleanupImp() { for( size_t i = 0, n = aChildren.size(); i < n; ++i ) { delete aChildren[ i ]; @@ -1161,7 +1161,7 @@ SvStream& INetMIMEMessage::operator<< (SvStream& rStrm) const for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++) rStrm << static_cast<sal_uInt32>(m_nIndex[i]); - rStrm.WriteByteString (m_aBoundary); + write_lenPrefixed_uInt8s_FromOString(rStrm, m_aBoundary); rStrm << static_cast<sal_uInt32>(aChildren.size()); return rStrm; @@ -1181,7 +1181,7 @@ SvStream& INetMIMEMessage::operator>> (SvStream& rStrm) m_nIndex[i] = nTemp; } - rStrm.ReadByteString (m_aBoundary); + m_aBoundary = read_lenPrefixed_uInt8s_ToOString(rStrm); rStrm >> nTemp; diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx index d70d84d2c30c..5345067aa0f8 100644 --- a/tools/source/inet/inetstrm.cxx +++ b/tools/source/inet/inetstrm.cxx @@ -1608,7 +1608,7 @@ int INetMIMEMessageStream::PutMsgLine (const sal_Char *pData, sal_uIntPtr nSize) // Multipart message body. Initialize multipart delimiters. // Multipart message. - if (pMsg->GetMultipartBoundary().Len() == 0) + if (pMsg->GetMultipartBoundary().getLength() == 0) { // Determine boundary. rtl::OString aType(rtl::OUStringToOString( diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index 5fa5b0e43380..b70195978008 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -806,7 +806,7 @@ sal_Bool SvStream::ReadUniOrByteStringLine( String& rStr, rtl_TextEncoding eSrcC return ReadByteStringLine( rStr, eSrcCharSet ); } -rtl::OString read_zeroTerminated_uInt8s_AsOString(SvStream& rStream) +rtl::OString read_zeroTerminated_uInt8s_ToOString(SvStream& rStream) { rtl::OStringBuffer aOutput; @@ -839,10 +839,10 @@ rtl::OString read_zeroTerminated_uInt8s_AsOString(SvStream& rStream) return aOutput.makeStringAndClear(); } -rtl::OUString read_zeroTerminated_uInt8s_AsOUString(SvStream& rStream, rtl_TextEncoding eEnc) +rtl::OUString read_zeroTerminated_uInt8s_ToOUString(SvStream& rStream, rtl_TextEncoding eEnc) { return rtl::OStringToOUString( - read_zeroTerminated_uInt8s_AsOString(rStream), eEnc); + read_zeroTerminated_uInt8s_ToOString(rStream), eEnc); } /************************************************************************* @@ -1517,19 +1517,7 @@ SvStream& SvStream::ReadByteString( UniString& rStr, rtl_TextEncoding eSrcCharSe return *this; } - ByteString aStr; - ReadByteString( aStr ); - rStr = UniString( aStr, eSrcCharSet ); - return *this; -} - -// ----------------------------------------------------------------------- - -SvStream& SvStream::ReadByteString( ByteString& rStr ) -{ - sal_uInt16 nLen = 0; - operator>>( nLen ); - rStr = read_uInt8s_AsOString(*this, nLen); + rStr = read_lenPrefixed_uInt8s_ToOUString(*this, eSrcCharSet); return *this; } @@ -1563,17 +1551,7 @@ SvStream& SvStream::WriteByteString( const UniString& rStr, rtl_TextEncoding eDe return *this; } - return WriteByteString(rtl::OUStringToOString(rStr, eDestCharSet)); -} - -// ----------------------------------------------------------------------- - -SvStream& SvStream::WriteByteString( const ByteString& rStr) -{ - sal_uInt16 nLen = rStr.Len(); - operator<< ( nLen ); - if( nLen != 0 ) - Write( rStr.GetBuffer(), nLen ); + write_lenPrefixed_uInt8s_FromOUString(*this, rStr, eDestCharSet); return *this; } @@ -2454,7 +2432,7 @@ void SvDataCopyStream::Assign( const SvDataCopyStream& ) } //Create a OString of nLen bytes from rStream -rtl::OString read_uInt8s_AsOString(SvStream& rStrm, sal_Size nLen) +rtl::OString read_uInt8s_ToOString(SvStream& rStrm, sal_Size nLen) { using comphelper::string::rtl_string_alloc; @@ -2481,7 +2459,7 @@ rtl::OString read_uInt8s_AsOString(SvStream& rStrm, sal_Size nLen) } //Create a OUString of nLen little endian sal_Unicodes from rStream -rtl::OUString read_LEuInt16s_AsOUString(SvStream& rStrm, sal_Size nLen) +rtl::OUString read_LEuInt16s_ToOUString(SvStream& rStrm, sal_Size nLen) { using comphelper::string::rtl_uString_alloc; 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 ) { |