From b69864f3f8c9be2e1f28f4b422074d2040b084a0 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 8 Jan 2014 08:48:26 +0200 Subject: re-write SvStream operator<< to non-overloaded methods This is the actual re-write. Use a clang rewriter to rewrite SvStream::operator<< to methods like WriteuInt32. Note that the rewriter is not perfect, and I hand-tweaked the output. In particular, I had to adjust places doing things like (*this) << 1; Change-Id: I5923eda3f4ebaa8b452b6ef109e726e116235a2a Reviewed-on: https://gerrit.libreoffice.org/7342 Tested-by: LibreOffice gerrit bot Reviewed-by: Michael Stahl --- tools/source/generic/color.cxx | 10 +++++----- tools/source/generic/fract.cxx | 4 ++-- tools/source/generic/gen.cxx | 10 +++++----- tools/source/generic/poly.cxx | 10 +++++----- tools/source/generic/poly2.cxx | 4 ++-- tools/source/inet/inetmsg.cxx | 10 +++++----- tools/source/inet/inetstrm.cxx | 30 +++++++++++++++--------------- tools/source/ref/globname.cxx | 6 +++--- tools/source/ref/pstm.cxx | 36 ++++++++++++++++++------------------ tools/source/stream/vcompat.cxx | 4 ++-- 10 files changed, 62 insertions(+), 62 deletions(-) (limited to 'tools') diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx index d1ae8023ed18..1bce440ec8b8 100644 --- a/tools/source/generic/color.cxx +++ b/tools/source/generic/color.cxx @@ -225,7 +225,7 @@ SvStream& Color::Read( SvStream& rIStm, bool bNewFormat ) SvStream& Color::Write( SvStream& rOStm, bool bNewFormat ) { if ( bNewFormat ) - rOStm << mnColor; + rOStm.WriteUInt32( mnColor ); else rOStm << *this; @@ -312,10 +312,10 @@ SvStream& operator<<( SvStream& rOStream, const Color& rColor ) nGreen = (nGreen<<8) + nGreen; nBlue = (nBlue<<8) + nBlue; - rOStream << nColorName; - rOStream << nRed; - rOStream << nGreen; - rOStream << nBlue; + rOStream.WriteUInt16( nColorName ); + rOStream.WriteUInt16( nRed ); + rOStream.WriteUInt16( nGreen ); + rOStream.WriteUInt16( nBlue ); return rOStream; } diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx index 6c13f05d87b8..3610065222bd 100644 --- a/tools/source/generic/fract.cxx +++ b/tools/source/generic/fract.cxx @@ -496,8 +496,8 @@ SvStream& operator >> ( SvStream& rIStream, Fraction& rFract ) SvStream& operator << ( SvStream& rOStream, const Fraction& rFract ) { //fdo#39428 SvStream no longer supports operator<<(long) - rOStream << sal::static_int_cast(rFract.nNumerator); - rOStream << sal::static_int_cast(rFract.nDenominator); + rOStream.WriteInt32( sal::static_int_cast(rFract.nNumerator) ); + rOStream.WriteInt32( sal::static_int_cast(rFract.nDenominator) ); return rOStream; } diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx index b011a90e3578..a0c74b5c3713 100644 --- a/tools/source/generic/gen.cxx +++ b/tools/source/generic/gen.cxx @@ -39,7 +39,7 @@ SvStream& operator<<( SvStream& rOStream, const Pair& rPair ) DBG_ASSERTWARNING( rOStream.GetVersion(), "Pair::<< - Solar-Version not set on rOStream" ); //39428 SvStream no longer supports operator<<(long) - rOStream << sal::static_int_cast(rPair.nA) << sal::static_int_cast(rPair.nB); + rOStream.WriteInt32( sal::static_int_cast(rPair.nA) ).WriteInt32( sal::static_int_cast(rPair.nB) ); return rOStream; } @@ -191,10 +191,10 @@ SvStream& operator<<( SvStream& rOStream, const Rectangle& rRect ) DBG_ASSERTWARNING( rOStream.GetVersion(), "Rectangle::<< - Solar-Version not set on rOStream" ); //fdo#39428 SvStream no longer supports operator<<(long) - rOStream << sal::static_int_cast(rRect.nLeft) - << sal::static_int_cast(rRect.nTop) - << sal::static_int_cast(rRect.nRight) - << sal::static_int_cast(rRect.nBottom); + rOStream.WriteInt32( sal::static_int_cast(rRect.nLeft) ) + .WriteInt32( sal::static_int_cast(rRect.nTop) ) + .WriteInt32( sal::static_int_cast(rRect.nRight) ) + .WriteInt32( sal::static_int_cast(rRect.nBottom) ); return rOStream; } diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index 60e4a145377b..580ab8940e57 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -1604,7 +1604,7 @@ SvStream& operator<<( SvStream& rOStream, const Polygon& rPoly ) sal_uInt16 nPoints = rPoly.GetSize(); // Write number of points - rOStream << nPoints; + rOStream.WriteUInt16( nPoints ); { // Determine whether we need to write through operators @@ -1621,8 +1621,8 @@ SvStream& operator<<( SvStream& rOStream, const Polygon& rPoly ) for( i = 0; i < nPoints; i++ ) { //fdo#39428 SvStream no longer supports operator<<(long) - rOStream << sal::static_int_cast( rPoly.mpImplPolygon->mpPointAry[i].X() ) - << sal::static_int_cast( rPoly.mpImplPolygon->mpPointAry[i].Y() ); + rOStream.WriteInt32( sal::static_int_cast( rPoly.mpImplPolygon->mpPointAry[i].X() ) ) + .WriteInt32( sal::static_int_cast( rPoly.mpImplPolygon->mpPointAry[i].Y() ) ); } } else @@ -1659,8 +1659,8 @@ void Polygon::Read( SvStream& rIStream ) void Polygon::ImplWrite( SvStream& rOStream ) const { sal_uInt8 bHasPolyFlags = mpImplPolygon->mpFlagAry != NULL; - rOStream << *this - << bHasPolyFlags; + rOStream << *this; + rOStream.WriteUChar( bHasPolyFlags ); if ( bHasPolyFlags ) rOStream.Write( mpImplPolygon->mpFlagAry, mpImplPolygon->mnPoints ); diff --git a/tools/source/generic/poly2.cxx b/tools/source/generic/poly2.cxx index 4fa9a839f0ae..7b92501a6cb5 100644 --- a/tools/source/generic/poly2.cxx +++ b/tools/source/generic/poly2.cxx @@ -630,7 +630,7 @@ SvStream& operator<<( SvStream& rOStream, const PolyPolygon& rPolyPoly ) // Write number of polygons sal_uInt16 nPolyCount = rPolyPoly.mpImplPolyPolygon->mnCount; - rOStream << nPolyCount; + rOStream.WriteUInt16( nPolyCount ); // output polygons for ( sal_uInt16 i = 0; i < nPolyCount; i++ ) @@ -681,7 +681,7 @@ void PolyPolygon::Write( SvStream& rOStream ) const // Write number of polygons sal_uInt16 nPolyCount = mpImplPolyPolygon->mnCount; - rOStream << nPolyCount; + rOStream.WriteUInt16( nPolyCount ); // Output polygons for ( sal_uInt16 i = 0; i < nPolyCount; i++ ) diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx index 5855cd2958f2..3cd6300ddfbf 100644 --- a/tools/source/inet/inetmsg.cxx +++ b/tools/source/inet/inetmsg.cxx @@ -102,11 +102,11 @@ sal_uIntPtr INetMessage::SetHeaderField ( SvStream& INetMessage::operator<< (SvStream& rStrm) const { - rStrm << static_cast(m_nDocSize); + rStrm.WriteUInt32( static_cast(m_nDocSize) ); write_lenPrefixed_uInt8s_FromOUString(rStrm, m_aDocName, RTL_TEXTENCODING_UTF8); sal_uIntPtr i, n = m_aHeaderList.size(); - rStrm << static_cast(n); + rStrm.WriteUInt32( static_cast(n) ); for (i = 0; i < n; i++) rStrm << *( m_aHeaderList[ i ] ); @@ -611,7 +611,7 @@ SvStream& INetRFC822Message::operator<< (SvStream& rStrm) const INetMessage::operator<< (rStrm); for (sal_uInt16 i = 0; i < INETMSG_RFC822_NUMHDR; i++) - rStrm << static_cast(m_nIndex[i]); + rStrm.WriteUInt32( static_cast(m_nIndex[i]) ); return rStrm; } @@ -1016,10 +1016,10 @@ SvStream& INetMIMEMessage::operator<< (SvStream& rStrm) const INetRFC822Message::operator<< (rStrm); for (sal_uInt16 i = 0; i < INETMSG_MIME_NUMHDR; i++) - rStrm << static_cast(m_nIndex[i]); + rStrm.WriteUInt32( static_cast(m_nIndex[i]) ); write_lenPrefixed_uInt8s_FromOString(rStrm, m_aBoundary); - rStrm << static_cast(aChildren.size()); + rStrm.WriteUInt32( static_cast(aChildren.size()) ); return rStrm; } diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx index ec412bd01a4d..584d43da6eaa 100644 --- a/tools/source/inet/inetstrm.cxx +++ b/tools/source/inet/inetstrm.cxx @@ -234,10 +234,10 @@ int INetMessageIStream::GetMsgLine(sal_Char* pData, sal_uIntPtr nSize) if (aHeader.GetValue().getLength()) { // NYI: Folding long lines. - *pMsgBuffer << aHeader.GetName().getStr(); - *pMsgBuffer << ": "; - *pMsgBuffer << aHeader.GetValue().getStr(); - *pMsgBuffer << "\r\n"; + pMsgBuffer->WriteCharPtr( aHeader.GetName().getStr() ); + pMsgBuffer->WriteCharPtr( ": " ); + pMsgBuffer->WriteCharPtr( aHeader.GetValue().getStr() ); + pMsgBuffer->WriteCharPtr( "\r\n" ); } } @@ -323,7 +323,7 @@ int INetMessageOStream::PutData(const sal_Char* pData, sal_uIntPtr nSize) // Emit any buffered last header field. if (pMsgBuffer->Tell() > 0) { - *pMsgBuffer << '\0'; + pMsgBuffer->WriteChar( '\0' ); int status = PutMsgLine( (const sal_Char*) pMsgBuffer->GetData(), pMsgBuffer->Tell()); if (status != INETSTREAM_STATUS_OK) return status; @@ -339,7 +339,7 @@ int INetMessageOStream::PutData(const sal_Char* pData, sal_uIntPtr nSize) else if ((*pData == ' ') || (*pData == '\t')) { // Continuation line. Unfold multi-line field-body. - *pMsgBuffer << ' '; + pMsgBuffer->WriteChar( ' ' ); pData++; } else @@ -348,7 +348,7 @@ int INetMessageOStream::PutData(const sal_Char* pData, sal_uIntPtr nSize) if (pMsgBuffer->Tell() > 0) { // Emit buffered header field now. - *pMsgBuffer << '\0'; + pMsgBuffer->WriteChar( '\0' ); int status = PutMsgLine((const sal_Char*) pMsgBuffer->GetData(), pMsgBuffer->Tell()); if (status != INETSTREAM_STATUS_OK) return status; @@ -358,7 +358,7 @@ int INetMessageOStream::PutData(const sal_Char* pData, sal_uIntPtr nSize) pMsgBuffer->Seek(STREAM_SEEK_TO_BEGIN); // Insert current character into buffer. - *pMsgBuffer << *pData++; + pMsgBuffer->WriteChar( *pData++ ); } // Search for next line break character. @@ -381,7 +381,7 @@ int INetMessageOStream::PutData(const sal_Char* pData, sal_uIntPtr nSize) { // Any is folded into a single character. sal_Char c = *((const sal_Char*) pMsgBuffer->GetData() + pMsgBuffer->Tell() - 1); - if (!ascii_isWhitespace(c & 0x7f)) *pMsgBuffer << ' '; + if (!ascii_isWhitespace(c & 0x7f)) pMsgBuffer->WriteChar( ' ' ); // Skip over this character. pData++; @@ -389,7 +389,7 @@ int INetMessageOStream::PutData(const sal_Char* pData, sal_uIntPtr nSize) else { // Any other character is inserted into line buffer. - *pMsgBuffer << *pData++; + pMsgBuffer->WriteChar( *pData++ ); } } @@ -714,9 +714,9 @@ int INetMessageDecodeQPStream_Impl::PutMsgLine( const sal_Char* pData, else { // Decode token. - *pMsgBuffer << sal_uInt8 ( + pMsgBuffer->WriteUChar( sal_uInt8 ( (pr2hex[(int)(pTokBuffer[0] & 0x7f)] << 4) | - (pr2hex[(int)(pTokBuffer[1] & 0x7f)] & 15) ); + (pr2hex[(int)(pTokBuffer[1] & 0x7f)] & 15) ) ); // Search for next . eState = INETMSG_EOL_SCR; @@ -734,17 +734,17 @@ int INetMessageDecodeQPStream_Impl::PutMsgLine( const sal_Char* pData, } else if (eState == INETMSG_EOL_FCR) { - *pMsgBuffer << *pData++; + pMsgBuffer->WriteChar( *pData++ ); eState = INETMSG_EOL_BEGIN; } else if (*pData == '\r') { - *pMsgBuffer << *pData++; + pMsgBuffer->WriteChar( *pData++ ); eState = INETMSG_EOL_FCR; } else { - *pMsgBuffer << *pData++; + pMsgBuffer->WriteChar( *pData++ ); } if (eState == INETMSG_EOL_BEGIN) diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx index d6ce83115b90..7eb2022d1599 100644 --- a/tools/source/ref/globname.cxx +++ b/tools/source/ref/globname.cxx @@ -124,14 +124,14 @@ SvStream& operator << ( SvStream& rOStr, const SvGlobalName & rObj ) { sal_uInt32 a; memcpy(&a, rObj.pImp->szData, sizeof(sal_uInt32)); - rOStr << a; + rOStr.WriteUInt32( a ); sal_uInt16 b; memcpy(&b, rObj.pImp->szData+4, sizeof(sal_uInt16)); - rOStr << b; + rOStr.WriteUInt16( b ); memcpy(&b, rObj.pImp->szData+6, sizeof(sal_uInt16)); - rOStr << b; + rOStr.WriteUInt16( b ); rOStr.Write( (sal_Char *)&rObj.pImp->szData[ 8 ], 8 ); return rOStr; diff --git a/tools/source/ref/pstm.cxx b/tools/source/ref/pstm.cxx index fae8e124d80f..e84f9fd47f86 100644 --- a/tools/source/ref/pstm.cxx +++ b/tools/source/ref/pstm.cxx @@ -50,7 +50,7 @@ TYPEINIT0( SvRttiBase ); void TOOLS_DLLPUBLIC WritePersistListObjects(const SvPersistListWriteable& rList, SvPersistStream & rStm, bool bOnlyStreamed ) { #ifdef STOR_NO_OPTIMIZE - rStm << (sal_uInt8)(PERSIST_LIST_VER | PERSIST_LIST_DBGUTIL); + rStm.WriteUChar( (sal_uInt8)(PERSIST_LIST_VER | PERSIST_LIST_DBGUTIL) ); sal_uInt32 nObjPos = rStm.WriteDummyLen(); #else sal_uInt8 bTmp = PERSIST_LIST_VER; @@ -59,7 +59,7 @@ void TOOLS_DLLPUBLIC WritePersistListObjects(const SvPersistListWriteable& rList sal_uInt32 nCountMember = rList.size(); sal_uIntPtr nCountPos = rStm.Tell(); sal_uInt32 nWriteCount = 0; - rStm << nCountMember; + rStm.WriteUInt32( nCountMember ); // Don't change the list, as it causes side-effects while saving for( sal_uIntPtr n = 0; n < nCountMember; n++ ) { @@ -75,7 +75,7 @@ void TOOLS_DLLPUBLIC WritePersistListObjects(const SvPersistListWriteable& rList // Didn't write all members, adjust count sal_uIntPtr nPos = rStm.Tell(); rStm.Seek( nCountPos ); - rStm << nWriteCount; + rStm.WriteUInt32( nWriteCount ); rStm.Seek( nPos ); } #ifdef STOR_NO_OPTIMIZE @@ -324,25 +324,25 @@ void SvPersistStream::WriteCompressed( SvStream & rStm, sal_uInt32 nVal ) { #ifdef STOR_NO_OPTIMIZE if( nVal < 0x80 ) - rStm << (sal_uInt8)(LEN_1 | nVal); + rStm.WriteUChar( (sal_uInt8)(LEN_1 | nVal) ); else if( nVal < 0x4000 ) { - rStm << (sal_uInt8)(LEN_2 | (nVal >> 8)); - rStm << (sal_uInt8)nVal; + rStm.WriteUChar( (sal_uInt8)(LEN_2 | (nVal >> 8)) ); + rStm.WriteUChar( (sal_uInt8)nVal ); } else if( nVal < 0x20000000 ) { // highest sal_uInt8 - rStm << (sal_uInt8)(LEN_4 | (nVal >> 24)); + rStm.WriteUChar( (sal_uInt8)(LEN_4 | (nVal >> 24)) ); // 2nd highest sal_uInt8 - rStm << (sal_uInt8)(nVal >> 16); - rStm << (sal_uInt16)(nVal); + rStm.WriteUChar( (sal_uInt8)(nVal >> 16) ); + rStm.WriteUInt16( (sal_uInt16)(nVal) ); } else #endif { - rStm << (sal_uInt8)LEN_5; - rStm << nVal; + rStm.WriteUChar( (sal_uInt8)LEN_5 ); + rStm.WriteUInt32( nVal ); } } @@ -369,7 +369,7 @@ sal_uInt32 SvPersistStream::WriteDummyLen() sal_uInt32 nPos = Tell(); #endif sal_uInt32 n0 = 0; - *this << n0; // Because of Sun sp + WriteUInt32( n0 ); // Because of Sun sp // Don't assert on stream error DBG_ASSERT( GetError() != SVSTREAM_OK || (sizeof( sal_uInt32 ) == Tell() -nPos), @@ -404,7 +404,7 @@ void SvPersistStream::WriteLen( sal_uInt32 nObjPos ) // Length in stream must be 4 Bytes Seek( nObjPos - sizeof( sal_uInt32 ) ); // write length - *this << nLen; + WriteUInt32( nLen ); Seek( nPos ); } @@ -457,17 +457,17 @@ static void WriteId { if( (nHdr & P_OBJ) || nId != 0 ) { // Id set only for pointers or DBGUTIL - rStm << (sal_uInt8)(nHdr); + rStm.WriteUChar( (sal_uInt8)(nHdr) ); SvPersistStream::WriteCompressed( rStm, nId ); } else { // NULL Pointer - rStm << (sal_uInt8)(nHdr | P_ID_0); + rStm.WriteUChar( (sal_uInt8)(nHdr | P_ID_0) ); return; } } else - rStm << nHdr; + rStm.WriteUChar( nHdr ); if( (nHdr & P_DBGUTIL) || (nHdr & P_OBJ) ) // Objects always have a class id @@ -670,9 +670,9 @@ SvStream& operator << rThis.SetStream( &rStm ); sal_uInt8 bTmp = 0; - rThis << bTmp; // Version + rThis.WriteUChar( bTmp ); // Version sal_uInt32 nCount = (sal_uInt32)rThis.aPUIdx.Count(); - rThis << nCount; + rThis.WriteUInt32( nCount ); sal_uIntPtr aIndex = rThis.aPUIdx.FirstIndex(); for( sal_uInt32 i = 0; i < nCount; i++ ) { diff --git a/tools/source/stream/vcompat.cxx b/tools/source/stream/vcompat.cxx index b81f95636a24..63575a951aa0 100644 --- a/tools/source/stream/vcompat.cxx +++ b/tools/source/stream/vcompat.cxx @@ -31,7 +31,7 @@ VersionCompat::VersionCompat( SvStream& rStm, sal_uInt16 nStreamMode, sal_uInt16 { if( STREAM_WRITE == mnStmMode ) { - *mpRWStm << mnVersion; + mpRWStm->WriteUInt16( mnVersion ); mnTotalSize = ( mnCompatPos = mpRWStm->Tell() ) + 4UL; mpRWStm->SeekRel( 4L ); } @@ -51,7 +51,7 @@ VersionCompat::~VersionCompat() const sal_uInt32 nEndPos = mpRWStm->Tell(); mpRWStm->Seek( mnCompatPos ); - *mpRWStm << ( nEndPos - mnTotalSize ); + mpRWStm->WriteUInt32( nEndPos - mnTotalSize ); mpRWStm->Seek( nEndPos ); } else -- cgit