diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-01-13 11:02:34 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-01-13 11:02:34 +0000 |
commit | 30bb1eddba2b4a36b4354303ffcb37a3a15f38a6 (patch) | |
tree | c5ed2f7004f53f67c7ce1483f01889602c1b5d63 /vcl | |
parent | 2265c8789c9587a447cb3ce5479b5450c9e1376a (diff) |
longparas: drop 16bit string limits in meta text actions
Change-Id: I35144034f002cdaaa759a84731aae5fa48c6aa5a
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/filter/wmf/emfwr.cxx | 6 | ||||
-rw-r--r-- | vcl/source/gdi/cvtsvm.cxx | 65 | ||||
-rw-r--r-- | vcl/source/gdi/metaact.cxx | 46 |
3 files changed, 58 insertions, 59 deletions
diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index b3684b199f5d..1f435d02704a 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -1354,7 +1354,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case META_TEXT_ACTION: { const MetaTextAction* pA = (const MetaTextAction*) pAction; - const OUString aText = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); + const OUString aText = pA->GetText().copy( pA->GetIndex(), std::min(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); ImplCheckTextAttr(); ImplWriteTextRecord( pA->GetPoint(), aText, NULL, 0 ); @@ -1374,7 +1374,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case META_TEXTARRAY_ACTION: { const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pAction; - const OUString aText = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); + const OUString aText = pA->GetText().copy( pA->GetIndex(), std::min(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); ImplCheckTextAttr(); ImplWriteTextRecord( pA->GetPoint(), aText, pA->GetDXArray(), 0 ); @@ -1384,7 +1384,7 @@ void EMFWriter::ImplWrite( const GDIMetaFile& rMtf ) case META_STRETCHTEXT_ACTION: { const MetaStretchTextAction* pA = (const MetaStretchTextAction*) pAction; - const OUString aText = pA->GetText().copy( pA->GetIndex(), std::min<sal_Int32>(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); + const OUString aText = pA->GetText().copy( pA->GetIndex(), std::min(pA->GetText().getLength() - pA->GetIndex(), pA->GetLen()) ); ImplCheckTextAttr(); ImplWriteTextRecord( pA->GetPoint(), aText, NULL, pA->GetWidth() ); diff --git a/vcl/source/gdi/cvtsvm.cxx b/vcl/source/gdi/cvtsvm.cxx index 43b285cf8148..1d1b2773c499 100644 --- a/vcl/source/gdi/cvtsvm.cxx +++ b/vcl/source/gdi/cvtsvm.cxx @@ -161,7 +161,7 @@ void ImplWritePopAction( SvStream& rOStm ) rOStm.WriteInt32( (sal_Int32) 4 ); } -void ImplWriteLineColor( SvStream& rOStm, const Color& rColor, sal_Int16 nStyle, sal_Int32 nWidth = 0L ) +void ImplWriteLineColor( SvStream& rOStm, const Color& rColor, sal_Int16 nStyle, sal_Int32 nWidth = 0 ) { if( rColor.GetTransparency() > 127 ) nStyle = 0; @@ -497,7 +497,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) rMtf.SetPrefMapMode( aMapMode ); size_t nLastPolygonAction(0); - for( sal_Int32 i = 0L; i < nActions; i++ ) + for (sal_Int32 i = 0; i < nActions; ++i) { rIStm >> nType; sal_Int32 nActBegin = rIStm.Tell(); @@ -828,7 +828,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) sal_Int32 nIndex, nLen; rIStm >> aPt >> nIndex >> nLen >> nTmp; - if ( nTmp && ( static_cast< sal_uInt32 >( nTmp ) < ( SAL_MAX_UINT16 - 1 ) ) ) + if (nTmp > 0) { OString aByteStr = read_uInt8s_ToOString(rIStm, nTmp); sal_uInt8 nTerminator = 0; @@ -838,7 +838,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) OUString aStr(OStringToOUString(aByteStr, eActualCharSet)); if ( nUnicodeCommentActionNumber == i ) ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr ); - rMtf.AddAction( new MetaTextAction( aPt, aStr, (sal_uInt16) nIndex, (sal_uInt16) nLen ) ); + rMtf.AddAction( new MetaTextAction( aPt, aStr, nIndex, nLen ) ); } rIStm.Seek( nActBegin + nActionSize ); } @@ -850,7 +850,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) sal_Int32 nIndex, nLen, nAryLen; rIStm >> aPt >> nIndex >> nLen >> nTmp >> nAryLen; - if ( nTmp && ( static_cast< sal_uInt32 >( nTmp ) < ( SAL_MAX_UINT16 - 1 ) ) ) + if (nTmp > 0) { OString aByteStr = read_uInt8s_ToOString(rIStm, nTmp); sal_uInt8 nTerminator = 0; @@ -859,13 +859,13 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) OUString aStr(OStringToOUString(aByteStr, eActualCharSet)); - if( nAryLen > 0L ) + if (nAryLen > 0) { sal_Int32 nStrLen( aStr.getLength() ); pDXAry = new sal_Int32[ std::max( nAryLen, nStrLen ) ]; - for( long j = 0L; j < nAryLen; j++ ) + for (sal_Int32 j = 0; j < nAryLen; ++j) rIStm >> nTmp, pDXAry[ j ] = nTmp; // #106172# Add last DX array elem, if missing @@ -899,10 +899,9 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) } if ( nUnicodeCommentActionNumber == i ) ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr ); - rMtf.AddAction( new MetaTextArrayAction( aPt, aStr, pDXAry, (sal_uInt16) nIndex, (sal_uInt16) nLen ) ); + rMtf.AddAction( new MetaTextArrayAction( aPt, aStr, pDXAry, nIndex, nLen ) ); - if( pDXAry ) - delete[] pDXAry; + delete[] pDXAry; } rIStm.Seek( nActBegin + nActionSize ); } @@ -913,7 +912,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) sal_Int32 nIndex, nLen, nWidth; rIStm >> aPt >> nIndex >> nLen >> nTmp >> nWidth; - if ( nTmp && ( static_cast< sal_uInt32 >( nTmp ) < ( SAL_MAX_INT16 - 1 ) ) ) + if (nTmp > 0) { OString aByteStr = read_uInt8s_ToOString(rIStm, nTmp); sal_uInt8 nTerminator = 0; @@ -923,7 +922,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf ) OUString aStr(OStringToOUString(aByteStr, eActualCharSet)); if ( nUnicodeCommentActionNumber == i ) ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr ); - rMtf.AddAction( new MetaStretchTextAction( aPt, nWidth, aStr, (sal_uInt16) nIndex, (sal_uInt16) nLen ) ); + rMtf.AddAction( new MetaStretchTextAction( aPt, nWidth, aStr, nIndex, nLen ) ); } rIStm.Seek( nActBegin + nActionSize ); } @@ -1686,17 +1685,17 @@ sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, OUString aUniText( pAct->GetText() ); OString aText(OUStringToOString(aUniText, rActualCharSet)); - const sal_uLong nStrLen = aText.getLength(); + const sal_Int32 nStrLen = aText.getLength(); if ( ImplWriteUnicodeComment( rOStm, aUniText ) ) nCount++; rOStm.WriteInt16( (sal_Int16) GDI_TEXT_ACTION ); - rOStm.WriteInt32( (sal_Int32) ( 24 + ( nStrLen + 1 ) ) ); + rOStm.WriteInt32( ( 24 + ( nStrLen + 1 ) ) ); rOStm << pAct->GetPoint(); - rOStm.WriteInt32( (sal_Int32) pAct->GetIndex() ); - rOStm.WriteInt32( (sal_Int32) pAct->GetLen() ); - rOStm.WriteInt32( (sal_Int32) nStrLen ); + rOStm.WriteInt32( pAct->GetIndex() ); + rOStm.WriteInt32( pAct->GetLen() ); + rOStm.WriteInt32( nStrLen ); rOStm.Write( aText.getStr(), nStrLen + 1 ); nCount++; } @@ -1708,9 +1707,9 @@ sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, OString aText(OUStringToOString(pAct->GetText(), rActualCharSet)); OUString aUniText = pAct->GetText().copy( pAct->GetIndex(), std::min<sal_Int32>(pAct->GetText().getLength() - pAct->GetIndex(), pAct->GetLen()) ); - sal_uLong nAryLen; - sal_uLong nLen = pAct->GetLen(); - const sal_uLong nTextLen = aText.getLength(); + sal_Int32 nAryLen; + sal_Int32 nLen = pAct->GetLen(); + const sal_Int32 nTextLen = aText.getLength(); sal_Int32* pDXArray = pAct->GetDXArray(); if ( ImplWriteUnicodeComment( rOStm, aUniText ) ) @@ -1721,7 +1720,7 @@ sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, if( pAct->GetIndex() <= nTextLen ) nLen = nTextLen - pAct->GetIndex(); else - nLen = 0UL; + nLen = 0; } if( !pDXArray || !nLen ) @@ -1730,16 +1729,16 @@ sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, nAryLen = nLen; // #105987# Write out all of DX array rOStm.WriteInt16( (sal_Int16) GDI_TEXTARRAY_ACTION ); - rOStm.WriteInt32( (sal_Int32) ( 28 + ( nLen + 1 ) + ( nAryLen * 4 ) ) ); + rOStm.WriteInt32( ( 28 + ( nLen + 1 ) + ( nAryLen * 4 ) ) ); rOStm << pAct->GetPoint(); - rOStm.WriteInt32( (sal_Int32) 0 ); - rOStm.WriteInt32( (sal_Int32) nLen ); - rOStm.WriteInt32( (sal_Int32) nLen ); - rOStm.WriteInt32( (sal_Int32) nAryLen ); + rOStm.WriteInt32( 0 ); + rOStm.WriteInt32( nLen ); + rOStm.WriteInt32( nLen ); + rOStm.WriteInt32( nAryLen ); rOStm.Write( aText.getStr()+pAct->GetIndex(), nLen + 1 ); - for( sal_uLong n = 0UL ; n < nAryLen; n++ ) - rOStm.WriteInt32( (sal_Int32) pDXArray[ n ] ); + for (sal_Int32 n = 0; n < nAryLen; ++n) + rOStm.WriteInt32( pDXArray[ n ] ); nCount++; } @@ -1751,17 +1750,17 @@ sal_uLong SVMConverter::ImplWriteActions( SvStream& rOStm, GDIMetaFile& rMtf, OUString aUniText( pAct->GetText() ); OString aText(OUStringToOString(aUniText, rActualCharSet)); - const sal_uLong nStrLen = aText.getLength(); + const sal_Int32 nStrLen = aText.getLength(); if ( ImplWriteUnicodeComment( rOStm, aUniText ) ) nCount++; rOStm.WriteInt16( (sal_Int16) GDI_STRETCHTEXT_ACTION ); - rOStm.WriteInt32( (sal_Int32) ( 28 + ( nStrLen + 1 ) ) ); + rOStm.WriteInt32( ( 28 + ( nStrLen + 1 ) ) ); rOStm << pAct->GetPoint(); - rOStm.WriteInt32( (sal_Int32) pAct->GetIndex() ); - rOStm.WriteInt32( (sal_Int32) pAct->GetLen() ); - rOStm.WriteInt32( (sal_Int32) nStrLen ); + rOStm.WriteInt32( pAct->GetIndex() ); + rOStm.WriteInt32( pAct->GetLen() ); + rOStm.WriteInt32( nStrLen ); rOStm.WriteInt32( (sal_Int32) pAct->GetWidth() ); rOStm.Write( aText.getStr(), nStrLen + 1 ); nCount++; diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 6b5fe5316b14..c622fecfb57d 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -1188,7 +1188,7 @@ IMPL_META_ACTION( Text, META_TEXT_ACTION ) // ------------------------------------------------------------------------ MetaTextAction::MetaTextAction( const Point& rPt, const OUString& rStr, - sal_uInt16 nIndex, sal_uInt16 nLen ) : + sal_Int32 nIndex, sal_Int32 nLen ) : MetaAction ( META_TEXT_ACTION ), maPt ( rPt ), maStr ( rStr ), @@ -1242,10 +1242,10 @@ sal_Bool MetaTextAction::Compare( const MetaAction& rMetaAction ) const void MetaTextAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) { WRITE_BASE_COMPAT( rOStm, 2, pData ); - rOStm << maPt; + rOStm << maPt; rOStm.WriteUniOrByteString( maStr, pData->meActualCharSet ); - rOStm .WriteUInt16( mnIndex ); - rOStm .WriteUInt16( mnLen ); + rOStm.WriteInt32(mnIndex); + rOStm.WriteInt32(mnLen); write_lenPrefixed_uInt16s_FromOUString<sal_uInt16>(rOStm, maStr); // version 2 } @@ -1299,13 +1299,13 @@ MetaTextArrayAction::MetaTextArrayAction( const MetaTextArrayAction& rAction ) : MetaTextArrayAction::MetaTextArrayAction( const Point& rStartPt, const OUString& rStr, const sal_Int32* pDXAry, - sal_uInt16 nIndex, - sal_uInt16 nLen ) : + sal_Int32 nIndex, + sal_Int32 nLen ) : MetaAction ( META_TEXTARRAY_ACTION ), maStartPt ( rStartPt ), maStr ( rStr ), mnIndex ( nIndex ), - mnLen ( ( nLen == STRING_LEN ) ? rStr.getLength() : nLen ) + mnLen ( nLen ) { const sal_uLong nAryLen = pDXAry ? mnLen : 0; @@ -1376,16 +1376,16 @@ sal_Bool MetaTextArrayAction::Compare( const MetaAction& rMetaAction ) const void MetaTextArrayAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) { - const sal_uInt32 nAryLen = mpDXAry ? mnLen : 0; + const sal_Int32 nAryLen = mpDXAry ? mnLen : 0; WRITE_BASE_COMPAT( rOStm, 2, pData ); - rOStm << maStartPt; + rOStm << maStartPt; rOStm.WriteUniOrByteString( maStr, pData->meActualCharSet ); - rOStm .WriteUInt16( mnIndex ); - rOStm .WriteUInt16( mnLen ); - rOStm .WriteUInt32( nAryLen ); + rOStm.WriteInt32(mnIndex); + rOStm.WriteInt32(mnLen); + rOStm.WriteInt32(nAryLen); - for( sal_uLong i = 0UL; i < nAryLen; i++ ) + for (sal_Int32 i = 0; i < nAryLen; ++i) rOStm.WriteInt32( mpDXAry[ i ] ); write_lenPrefixed_uInt16s_FromOUString<sal_uInt16>(rOStm, maStr); // version 2 @@ -1395,7 +1395,7 @@ void MetaTextArrayAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) void MetaTextArrayAction::Read( SvStream& rIStm, ImplMetaReadData* pData ) { - sal_uInt32 nAryLen; + sal_Int32 nAryLen; delete[] mpDXAry; @@ -1421,8 +1421,8 @@ void MetaTextArrayAction::Read( SvStream& rIStm, ImplMetaReadData* pData ) mpDXAry = new (std::nothrow)sal_Int32[ mnLen ]; if ( mpDXAry ) { - sal_uLong i; - for( i = 0UL; i < nAryLen; i++ ) + sal_Int32 i; + for( i = 0; i < nAryLen; i++ ) rIStm >> mpDXAry[ i ]; // #106172# setup remainder @@ -1459,7 +1459,7 @@ IMPL_META_ACTION( StretchText, META_STRETCHTEXT_ACTION ) MetaStretchTextAction::MetaStretchTextAction( const Point& rPt, sal_uInt32 nWidth, const OUString& rStr, - sal_uInt16 nIndex, sal_uInt16 nLen ) : + sal_Int32 nIndex, sal_Int32 nLen ) : MetaAction ( META_STRETCHTEXT_ACTION ), maPt ( rPt ), maStr ( rStr ), @@ -1516,11 +1516,11 @@ sal_Bool MetaStretchTextAction::Compare( const MetaAction& rMetaAction ) const void MetaStretchTextAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) { WRITE_BASE_COMPAT( rOStm, 2, pData ); - rOStm << maPt; + rOStm << maPt; rOStm.WriteUniOrByteString( maStr, pData->meActualCharSet ); - rOStm .WriteUInt32( mnWidth ); - rOStm .WriteUInt16( mnIndex ); - rOStm .WriteUInt16( mnLen ); + rOStm.WriteUInt32( mnWidth ); + rOStm.WriteInt32( mnIndex ); + rOStm.WriteInt32( mnLen ); write_lenPrefixed_uInt16s_FromOUString<sal_uInt16>(rOStm, maStr); // version 2 } @@ -1599,9 +1599,9 @@ sal_Bool MetaTextRectAction::Compare( const MetaAction& rMetaAction ) const void MetaTextRectAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) { WRITE_BASE_COMPAT( rOStm, 2, pData ); - rOStm << maRect; + rOStm << maRect; rOStm.WriteUniOrByteString( maStr, pData->meActualCharSet ); - rOStm .WriteUInt16( mnStyle ); + rOStm.WriteUInt16( mnStyle ); write_lenPrefixed_uInt16s_FromOUString<sal_uInt16>(rOStm, maStr); // version 2 } |