fdo#39428 Remove/audit SvStream operator>>/<<(long)

Replaced calls to operator>>(long) with operator>>(sal_Int32)
Replaced calls to operator<<(long) with sal::static_int_cast<sal_Int32>
This commit is contained in:
Keith McRae 2012-01-18 16:21:17 +00:00 committed by Kohei Yoshida
parent 33e318faea
commit db7fb9cdf2
6 changed files with 80 additions and 47 deletions

View file

@ -514,8 +514,12 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
rIStm.Read( (char*) &aCode, sizeof( aCode ) ); // Kennung
rIStm >> nSize; // Size
rIStm >> nVersion; // Version
rIStm >> aPrefSz.Width(); // PrefSize.Width()
rIStm >> aPrefSz.Height(); // PrefSize.Height()
//#fdo39428 SvStream no longer supports operator>>(long&)
sal_Int32 nTmp32(0);
rIStm >> nTmp32;
aPrefSz.Width() = nTmp32; // PrefSize.Width()
rIStm >> nTmp32;
aPrefSz.Height() = nTmp32; // PrefSize.Height()
// check header-magic and version
if( rIStm.GetError()
@ -1290,7 +1294,8 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
case( GDI_TEXTLINE_COMMENT ):
{
Point aStartPt;
long nWidth;
//#fdo39428 SvStream no longer supports operator>>(long&)
sal_Int32 nWidth;
sal_uInt32 nStrikeout;
sal_uInt32 nUnderline;
sal_Int32 nFollowingActionCount;
@ -2367,7 +2372,7 @@ sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf,
{
const MetaTextLineAction* pA = (MetaTextLineAction*) pAction;
const Point& rStartPt = pA->GetStartPoint();
const long nWidth = pA->GetWidth();
const sal_Int32 nWidth = (sal_Int32) pA->GetWidth();
const FontStrikeout eStrikeout = pA->GetStrikeout();
const FontUnderline eUnderline = pA->GetUnderline();
sal_uLong nOldPos, nNewPos;

View file

@ -184,9 +184,12 @@ SvStream& operator>>( SvStream& rIStm, ImplHatch& rImplHatch )
{
VersionCompat aCompat( rIStm, STREAM_READ );
sal_uInt16 nTmp16;
sal_Int32 nTmp32(0);
rIStm >> nTmp16; rImplHatch.meStyle = (HatchStyle) nTmp16;
rIStm >> rImplHatch.maColor >> rImplHatch.mnDistance >> rImplHatch.mnAngle;
//#fdo39428 SvStream no longer supports operator>>(long&)
rIStm >> rImplHatch.maColor >> nTmp32 >> rImplHatch.mnAngle;
rImplHatch.mnDistance = nTmp32;
return rIStm;
}
@ -198,7 +201,8 @@ SvStream& operator<<( SvStream& rOStm, const ImplHatch& rImplHatch )
VersionCompat aCompat( rOStm, STREAM_WRITE, 1 );
rOStm << (sal_uInt16) rImplHatch.meStyle << rImplHatch.maColor;
rOStm << rImplHatch.mnDistance << rImplHatch.mnAngle;
//#fdo39428 SvStream no longer supports operator<<(long)
rOStm << sal::static_int_cast<sal_Int32>(rImplHatch.mnDistance) << rImplHatch.mnAngle;
return rOStm;
}

View file

@ -941,8 +941,9 @@ sal_Bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm, sal_Bool bSwap )
const sal_uLong nStartPos = rIStm.Tell();
sal_uInt32 nId;
sal_uLong nHeaderLen;
long nType;
long nLen;
//#fdo39428 SvStream no longer supports operator>>(long&)
sal_Int32 nType;
sal_Int32 nLen;
const sal_uInt16 nOldFormat = rIStm.GetNumberFormatInt();
sal_Bool bRet = sal_False;
@ -976,9 +977,10 @@ sal_Bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm, sal_Bool bSwap )
else
{
// read old style header
long nWidth, nHeight;
long nMapMode, nScaleNumX, nScaleDenomX;
long nScaleNumY, nScaleDenomY, nOffsX, nOffsY;
//#fdo39428 SvStream no longer supports operator>>(long&)
sal_Int32 nWidth, nHeight;
sal_Int32 nMapMode, nScaleNumX, nScaleDenomX;
sal_Int32 nScaleNumY, nScaleDenomY, nOffsX, nOffsY;
rIStm.SeekRel( -4L );
@ -1185,11 +1187,12 @@ sal_Bool ImpGraphic::ImplWriteEmbedded( SvStream& rOStm )
// write new style header
VersionCompat* pCompat = new VersionCompat( rOStm, STREAM_WRITE, 1 );
rOStm << (long) meType;
//#fdo39428 SvStream no longer supports operator<<(long)
rOStm << sal::static_int_cast<sal_Int32>(meType);
// data size is updated later
nDataFieldPos = rOStm.Tell();
rOStm << (long) 0;
rOStm << (sal_Int32) 0;
rOStm << aSize;
rOStm << aMapMode;
@ -1199,21 +1202,21 @@ sal_Bool ImpGraphic::ImplWriteEmbedded( SvStream& rOStm )
else
{
// write old style (<=4.0) header
rOStm << (long) meType;
rOStm << (sal_Int32) meType;
// data size is updated later
nDataFieldPos = rOStm.Tell();
rOStm << (long) 0;
rOStm << (long) aSize.Width();
rOStm << (long) aSize.Height();
rOStm << (long) aMapMode.GetMapUnit();
rOStm << (long) aMapMode.GetScaleX().GetNumerator();
rOStm << (long) aMapMode.GetScaleX().GetDenominator();
rOStm << (long) aMapMode.GetScaleY().GetNumerator();
rOStm << (long) aMapMode.GetScaleY().GetDenominator();
rOStm << (long) aMapMode.GetOrigin().X();
rOStm << (long) aMapMode.GetOrigin().Y();
rOStm << (sal_Int32) 0;
//#fdo39428 SvStream no longer supports operator<<(long)
rOStm << sal::static_int_cast<sal_Int32>(aSize.Width());
rOStm << sal::static_int_cast<sal_Int32>(aSize.Height());
rOStm << sal::static_int_cast<sal_Int32>(aMapMode.GetMapUnit());
rOStm << sal::static_int_cast<sal_Int32>(aMapMode.GetScaleX().GetNumerator());
rOStm << sal::static_int_cast<sal_Int32>(aMapMode.GetScaleX().GetDenominator());
rOStm << sal::static_int_cast<sal_Int32>(aMapMode.GetScaleY().GetNumerator());
rOStm << sal::static_int_cast<sal_Int32>(aMapMode.GetScaleY().GetDenominator());
rOStm << sal::static_int_cast<sal_Int32>(aMapMode.GetOrigin().X());
rOStm << sal::static_int_cast<sal_Int32>(aMapMode.GetOrigin().Y());
}
// write data block
@ -1228,7 +1231,8 @@ sal_Bool ImpGraphic::ImplWriteEmbedded( SvStream& rOStm )
{
const sal_uLong nStmPos2 = rOStm.Tell();
rOStm.Seek( nDataFieldPos );
rOStm << (long) ( nStmPos2 - nDataStart );
//fdo39428 SvStream no longer supports operator<<(long)
rOStm << sal::static_int_cast<sal_Int32>(nStmPos2 - nDataStart);
rOStm.Seek( nStmPos2 );
bRet = sal_True;
}

View file

@ -235,17 +235,23 @@ void LineInfo::SetLineJoin(basegfx::B2DLineJoin eLineJoin)
SvStream& operator>>( SvStream& rIStm, ImplLineInfo& rImplLineInfo )
{
VersionCompat aCompat( rIStm, STREAM_READ );
sal_uInt16 nTmp16;
sal_uInt16 nTmp16(0);
sal_Int32 nTmp32(0);
//#fdo39428 SvStream no longer supports operator>>(long&)
rIStm >> nTmp16; rImplLineInfo.meStyle = (LineStyle) nTmp16;
rIStm >> rImplLineInfo.mnWidth;
rIStm >> nTmp32;
rImplLineInfo.mnWidth = nTmp32;
if( aCompat.GetVersion() >= 2 )
{
// version 2
rIStm >> rImplLineInfo.mnDashCount >> rImplLineInfo.mnDashLen;
rIStm >> rImplLineInfo.mnDotCount >> rImplLineInfo.mnDotLen;
rIStm >> rImplLineInfo.mnDistance;
rIStm >> rImplLineInfo.mnDashCount >> nTmp32;
rImplLineInfo.mnDashLen = nTmp32;
rIStm >> rImplLineInfo.mnDotCount >> nTmp32;
rImplLineInfo.mnDotLen = nTmp32;
rIStm >> nTmp32;
rImplLineInfo.mnDistance = nTmp32;
}
if( aCompat.GetVersion() >= 3 )
@ -263,13 +269,14 @@ SvStream& operator<<( SvStream& rOStm, const ImplLineInfo& rImplLineInfo )
{
VersionCompat aCompat( rOStm, STREAM_WRITE, 3 );
//#fdo39428 SvStream no longer supports operator<<(long)
// version 1
rOStm << (sal_uInt16) rImplLineInfo.meStyle << rImplLineInfo.mnWidth;
rOStm << (sal_uInt16) rImplLineInfo.meStyle << sal::static_int_cast<sal_Int32>(rImplLineInfo.mnWidth);
// since version2
rOStm << rImplLineInfo.mnDashCount << rImplLineInfo.mnDashLen;
rOStm << rImplLineInfo.mnDotCount << rImplLineInfo.mnDotLen;
rOStm << rImplLineInfo.mnDistance;
rOStm << rImplLineInfo.mnDashCount << sal::static_int_cast<sal_Int32>(rImplLineInfo.mnDashLen);
rOStm << rImplLineInfo.mnDotCount << sal::static_int_cast<sal_Int32>(rImplLineInfo.mnDotLen);
rOStm << sal::static_int_cast<sal_Int32>(rImplLineInfo.mnDistance);
// since version3
rOStm << (sal_uInt16) rImplLineInfo.meLineJoin;

View file

@ -1748,8 +1748,9 @@ void MetaTextLineAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
WRITE_BASE_COMPAT( rOStm, 2, pData );
//#fdo39428 SvStream no longer supports operator<<(long)
rOStm << maPos;
rOStm << mnWidth;
rOStm << sal::static_int_cast<sal_Int32>(mnWidth);
rOStm << static_cast<sal_uInt32>(meStrikeout);
rOStm << static_cast<sal_uInt32>(meUnderline);
// new in version 2
@ -1762,9 +1763,12 @@ void MetaTextLineAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
COMPAT( rIStm );
//#fdo39428 SvStream no longer supports operator>>(long&)
sal_uInt32 nTemp;
sal_Int32 nTemp2;
rIStm >> maPos;
rIStm >> mnWidth;
rIStm >> nTemp2;
mnWidth = nTemp2;
rIStm >> nTemp;
meStrikeout = (FontStrikeout)nTemp;
rIStm >> nTemp;
@ -3016,7 +3020,8 @@ sal_Bool MetaMoveClipRegionAction::Compare( const MetaAction& rMetaAction ) cons
void MetaMoveClipRegionAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
WRITE_BASE_COMPAT( rOStm, 1, pData );
rOStm << mnHorzMove << mnVertMove;
//#fdo39428 SvStream no longer supports operator<<(long)
rOStm << sal::static_int_cast<sal_Int32>(mnHorzMove) << sal::static_int_cast<sal_Int32>(mnVertMove);
}
// ------------------------------------------------------------------------
@ -3024,7 +3029,11 @@ void MetaMoveClipRegionAction::Write( SvStream& rOStm, ImplMetaWriteData* pData
void MetaMoveClipRegionAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
COMPAT( rIStm );
rIStm >> mnHorzMove >> mnVertMove;
//#fdo39428 SvStream no longer supports operator>>(long&)
sal_Int32 nTmpHM(0), nTmpVM(0);
rIStm >> nTmpHM >> nTmpVM;
mnHorzMove = nTmpHM;
mnVertMove = nTmpVM;
}
// ========================================================================

View file

@ -2587,8 +2587,9 @@ SvStream& operator>>( SvStream& rIStrm, Region& rRegion )
// insert new band or new separation?
if ( (StreamEntryType)nTmp16 == STREAMENTRY_BANDHEADER )
{
long nYTop;
long nYBottom;
//#fdo39428 SvStream no longer supports operator>>(long&)
sal_Int32 nYTop;
sal_Int32 nYBottom;
rIStrm >> nYTop;
rIStrm >> nYBottom;
@ -2607,8 +2608,9 @@ SvStream& operator>>( SvStream& rIStrm, Region& rRegion )
}
else
{
long nXLeft;
long nXRight;
//#fdo39428 SvStream no longer supports operator>>(long&)
sal_Int32 nXLeft;
sal_Int32 nXRight;
rIStrm >> nXLeft;
rIStrm >> nXRight;
@ -2679,18 +2681,20 @@ SvStream& operator<<( SvStream& rOStrm, const Region& rRegion )
while ( pBand )
{
// put boundaries
//#fdo39428 SvStream no longer supports operator<<(long)
rOStrm << (sal_uInt16) STREAMENTRY_BANDHEADER;
rOStrm << pBand->mnYTop;
rOStrm << pBand->mnYBottom;
rOStrm << sal::static_int_cast<sal_Int32>(pBand->mnYTop);
rOStrm << sal::static_int_cast<sal_Int32>(pBand->mnYBottom);
// put separations of current band
ImplRegionBandSep* pSep = pBand->mpFirstSep;
while ( pSep )
{
// put separation
//#fdo39428 SvStream no longer supports operator<<(long)
rOStrm << (sal_uInt16) STREAMENTRY_SEPARATION;
rOStrm << pSep->mnXLeft;
rOStrm << pSep->mnXRight;
rOStrm << sal::static_int_cast<sal_Int32>(pSep->mnXLeft);
rOStrm << sal::static_int_cast<sal_Int32>(pSep->mnXRight);
// next separation from current band
pSep = pSep->mpNextSep;