diff options
-rw-r--r-- | emfio/inc/mtftools.hxx | 14 | ||||
-rw-r--r-- | emfio/source/reader/emfreader.cxx | 324 | ||||
-rw-r--r-- | emfio/source/reader/mtftools.cxx | 8 | ||||
-rw-r--r-- | emfio/source/reader/wmfreader.cxx | 273 |
4 files changed, 303 insertions, 316 deletions
diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index 9565df89cfe1..e2dc6830e1dd 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -20,18 +20,12 @@ #ifndef INCLUDED_EMFIO_INC_MTFTOOLS_HXX #define INCLUDED_EMFIO_INC_MTFTOOLS_HXX -#include <memory> -#include <sal/config.h> - -//#include <vcl/graph.hxx> #include <basegfx/tools/b2dclipstate.hxx> #include <tools/poly.hxx> #include <vcl/font.hxx> #include <vcl/bitmap.hxx> #include <vcl/bitmapex.hxx> -//#include <vcl/bitmapaccess.hxx> #include <vcl/lineinfo.hxx> -//#include <vcl/fltcall.hxx> #include <o3tl/make_unique.hxx> #include <vcl/outdevstate.hxx> #include <vcl/FilterConfigItem.hxx> @@ -239,15 +233,11 @@ namespace emfio #define BS_DIBPATTERN8X8 8 #define BS_MONOPATTERN 9 - -#define RDH_RECTANGLES 1 - +#define RDH_RECTANGLES 1 #define W_MFCOMMENT 15 - #define PRIVATE_ESCAPE_UNICODE 2 //Scalar constants - #define UNDOCUMENTED_WIN_RCL_RELATION 32 #define MS_FIXPOINT_BITCOUNT_28_4 4 #define HUNDREDTH_MILLIMETERS_PER_MILLIINCH 2.54 @@ -503,7 +493,7 @@ namespace emfio GDIMetaFile* mpGDIMetaFile; - SvStream* mpWMF; // the WMF/EMF file to be read + SvStream* mpInputStream; // the WMF/EMF file to be read sal_uInt32 mnStartPos; sal_uInt32 mnEndPos; std::vector<std::unique_ptr<BSaveStruct>> maBmpSaveList; diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index ada03d278e03..158f5bdcbfd7 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -400,25 +400,25 @@ namespace emfio #if OSL_DEBUG_LEVEL > 1 // debug code - write the stream to debug file /tmp/emf-stream.emf - sal_uInt64 const pos = mpWMF->Tell(); - mpWMF->Seek(0); + sal_uInt64 const pos = mpInputStream->Tell(); + mpInputStream->Seek(0); SvFileStream file( OUString( "/tmp/emf-stream.emf" ), StreamMode::WRITE | StreamMode::TRUNC ); - mpWMF->WriteStream(file); + mpInputStream->WriteStream(file); file.Flush(); file.Close(); - mpWMF->Seek( pos ); + mpInputStream->Seek( pos ); #endif } mbEMFPlus = true; - sal_uInt64 const pos = mpWMF->Tell(); + sal_uInt64 const pos = mpInputStream->Tell(); void *buffer = malloc( length ); - PassEMFPlus( buffer, mpWMF->ReadBytes(buffer, length) ); + PassEMFPlus( buffer, mpInputStream->ReadBytes(buffer, length) ); free( buffer ); - mpWMF->Seek( pos ); + mpInputStream->Seek( pos ); bHaveDC = false; @@ -431,7 +431,7 @@ namespace emfio sal_uInt16 type(0), flags(0); sal_uInt32 size(0), dataSize(0); - mpWMF->ReadUInt16( type ).ReadUInt16( flags ).ReadUInt32( size ).ReadUInt32( dataSize ); + mpInputStream->ReadUInt16( type ).ReadUInt16( flags ).ReadUInt32( size ).ReadUInt32( dataSize ); nRemainder -= nRequiredHeaderSize; SAL_INFO ("vcl.emf", "\t\tEMF+ record type: " << std::hex << type << std::dec); @@ -450,10 +450,10 @@ namespace emfio size-nRequiredHeaderSize : 0; // clip to available size nRemainingRecordData = std::min(nRemainingRecordData, nRemainder); - mpWMF->SeekRel(nRemainingRecordData); + mpInputStream->SeekRel(nRemainingRecordData); nRemainder -= nRemainingRecordData; } - mpWMF->SeekRel(nRemainder); + mpInputStream->SeekRel(nRemainder); } /** @@ -465,8 +465,8 @@ namespace emfio tools::Polygon EmfReader::ReadPolygonWithSkip(const bool skipFirst) { sal_uInt32 nPoints(0), nStartIndex(0); - mpWMF->SeekRel( 16 ); - mpWMF->ReadUInt32( nPoints ); + mpInputStream->SeekRel( 16 ); + mpInputStream->ReadUInt32( nPoints ); if (skipFirst) { nPoints ++; @@ -481,7 +481,7 @@ namespace emfio * The \<class T> parameter is for the type of the points * nStartIndex: which is the starting index in the polygon of the first point read * nPoints: number of points - * mpWMF: the stream containing the polygons + * mpInputStream: the stream containing the polygons * */ template <class T> tools::Polygon EmfReader::ReadPolygon(sal_uInt32 nStartIndex, sal_uInt32 nPoints) @@ -492,11 +492,11 @@ namespace emfio return tools::Polygon(); tools::Polygon aPolygon(nPoints); - for (sal_uInt32 i = nStartIndex ; i < nPoints && mpWMF->good(); i++ ) + for (sal_uInt32 i = nStartIndex ; i < nPoints && mpInputStream->good(); i++ ) { T nX, nY; - *mpWMF >> nX >> nY; - if (!mpWMF->good()) + *mpInputStream >> nX >> nY; + if (!mpInputStream->good()) { SAL_WARN("vcl.emf", "short read on polygon, truncating"); aPolygon.SetSize(i); @@ -517,26 +517,26 @@ namespace emfio { sal_uInt32 nPoints; sal_uInt32 i, nNumberOfPolylines( 0 ), nCount( 0 ); - mpWMF->SeekRel( 0x10 ); // TODO Skipping Bounds. A 128-bit WMF RectL object (specifies the bounding rectangle in device units.) - mpWMF->ReadUInt32( nNumberOfPolylines ); - mpWMF->ReadUInt32( nCount ); // total number of points in all polylines - if (mpWMF->Tell() >= mnEndPos) + mpInputStream->SeekRel( 0x10 ); // TODO Skipping Bounds. A 128-bit WMF RectL object (specifies the bounding rectangle in device units.) + mpInputStream->ReadUInt32( nNumberOfPolylines ); + mpInputStream->ReadUInt32( nCount ); // total number of points in all polylines + if (mpInputStream->Tell() >= mnEndPos) return; // taking the amount of points of each polygon, retrieving the total number of points - if ( mpWMF->good() && + if ( mpInputStream->good() && ( nNumberOfPolylines < SAL_MAX_UINT32 / sizeof( sal_uInt16 ) ) && - ( nNumberOfPolylines * sizeof( sal_uInt16 ) ) <= ( mnEndPos - mpWMF->Tell() ) + ( nNumberOfPolylines * sizeof( sal_uInt16 ) ) <= ( mnEndPos - mpInputStream->Tell() ) ) { std::unique_ptr< sal_uInt32[] > pnPolylinePointCount( new sal_uInt32[ nNumberOfPolylines ] ); - for ( i = 0; i < nNumberOfPolylines && mpWMF->good(); i++ ) + for ( i = 0; i < nNumberOfPolylines && mpInputStream->good(); i++ ) { - mpWMF->ReadUInt32( nPoints ); + mpInputStream->ReadUInt32( nPoints ); pnPolylinePointCount[ i ] = nPoints; } // Get polyline points: - for ( i = 0; ( i < nNumberOfPolylines ) && mpWMF->good(); i++ ) + for ( i = 0; ( i < nNumberOfPolylines ) && mpInputStream->good(); i++ ) { tools::Polygon aPolygon = ReadPolygon< T >( 0, pnPolylinePointCount[ i ] ); DrawPolyLine( aPolygon, false, mbRecordPath); @@ -564,41 +564,41 @@ namespace emfio void EmfReader::ReadAndDrawPolyPolygon() { sal_uInt32 nPoly(0), nGesPoints(0), nReadPoints(0); - mpWMF->SeekRel( 0x10 ); + mpInputStream->SeekRel( 0x10 ); // Number of polygons - mpWMF->ReadUInt32( nPoly ).ReadUInt32( nGesPoints ); - if (mpWMF->Tell() >= mnEndPos) + mpInputStream->ReadUInt32( nPoly ).ReadUInt32( nGesPoints ); + if (mpInputStream->Tell() >= mnEndPos) return; - if (!mpWMF->good()) + if (!mpInputStream->good()) return; //check against numeric overflowing if (nGesPoints >= SAL_MAX_UINT32 / sizeof(Point)) return; if (nPoly >= SAL_MAX_UINT32 / sizeof(sal_uInt16)) return; - if (nPoly * sizeof(sal_uInt16) > mnEndPos - mpWMF->Tell()) + if (nPoly * sizeof(sal_uInt16) > mnEndPos - mpInputStream->Tell()) return; // Get number of points in each polygon std::vector<sal_uInt16> aPoints(nPoly); - for (sal_uInt32 i = 0; i < nPoly && mpWMF->good(); ++i) + for (sal_uInt32 i = 0; i < nPoly && mpInputStream->good(); ++i) { sal_uInt32 nPoints(0); - mpWMF->ReadUInt32( nPoints ); + mpInputStream->ReadUInt32( nPoints ); aPoints[i] = (sal_uInt16)nPoints; } - if ( mpWMF->good() && ( nGesPoints * (sizeof(T)+sizeof(T)) ) <= ( mnEndPos - mpWMF->Tell() ) ) + if ( mpInputStream->good() && ( nGesPoints * (sizeof(T)+sizeof(T)) ) <= ( mnEndPos - mpInputStream->Tell() ) ) { // Get polygon points tools::PolyPolygon aPolyPoly(nPoly, nPoly); - for (sal_uInt32 i = 0; i < nPoly && mpWMF->good(); ++i) + for (sal_uInt32 i = 0; i < nPoly && mpInputStream->good(); ++i) { const sal_uInt16 nPointCount(aPoints[i]); std::vector<Point> aPtAry(nPointCount); - for (sal_uInt16 j = 0; j < nPointCount && mpWMF->good(); ++j) + for (sal_uInt16 j = 0; j < nPointCount && mpInputStream->good(); ++j) { T nX(0), nY(0); - *mpWMF >> nX >> nY; + *mpInputStream >> nX >> nY; aPtAry[j] = Point( nX, nY ); ++nReadPoints; } @@ -625,18 +625,18 @@ namespace emfio static bool bEnableEMFPlus = ( getenv( "EMF_PLUS_DISABLE" ) == nullptr ); - while( bStatus && mnRecordCount-- && mpWMF->good()) + while( bStatus && mnRecordCount-- && mpInputStream->good()) { sal_uInt32 nRecType(0), nRecSize(0); - mpWMF->ReadUInt32(nRecType).ReadUInt32(nRecSize); + mpInputStream->ReadUInt32(nRecType).ReadUInt32(nRecSize); - if ( !mpWMF->good() || ( nRecSize < 8 ) || ( nRecSize & 3 ) ) // Parameters are always divisible by 4 + if ( !mpInputStream->good() || ( nRecSize < 8 ) || ( nRecSize & 3 ) ) // Parameters are always divisible by 4 { bStatus = false; break; } - auto nCurPos = mpWMF->Tell(); + auto nCurPos = mpInputStream->Tell(); if (mnEndPos < nCurPos - 8) { @@ -667,14 +667,14 @@ namespace emfio if( bEnableEMFPlus && nRecType == EMR_COMMENT ) { sal_uInt32 length; - mpWMF->ReadUInt32( length ); + mpInputStream->ReadUInt32( length ); SAL_INFO("vcl.emf", "\tGDI comment, length: " << length); - if( mpWMF->good() && length >= 4 && length <= mpWMF->remainingSize() ) { + if( mpInputStream->good() && length >= 4 && length <= mpInputStream->remainingSize() ) { sal_uInt32 nCommentId; - mpWMF->ReadUInt32( nCommentId ); + mpInputStream->ReadUInt32( nCommentId ); SAL_INFO ("vcl.emf", "\t\tbegin " << (char)(nCommentId & 0xff) << (char)((nCommentId & 0xff00) >> 8) << (char)((nCommentId & 0xff0000) >> 16) << (char)((nCommentId & 0xff000000) >> 24) << " id: 0x" << std::hex << nCommentId << std::dec); @@ -732,42 +732,42 @@ namespace emfio case EMR_SETWINDOWEXTEX : { - mpWMF->ReadUInt32( nW ).ReadUInt32( nH ); + mpInputStream->ReadUInt32( nW ).ReadUInt32( nH ); SetWinExt( Size( nW, nH ), true); } break; case EMR_SETWINDOWORGEX : { - mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); + mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ); SetWinOrg( Point( nX32, nY32 ), true); } break; case EMR_SCALEWINDOWEXTEX : { - mpWMF->ReadUInt32( nNom1 ).ReadUInt32( nDen1 ).ReadUInt32( nNom2 ).ReadUInt32( nDen2 ); + mpInputStream->ReadUInt32( nNom1 ).ReadUInt32( nDen1 ).ReadUInt32( nNom2 ).ReadUInt32( nDen2 ); ScaleWinExt( (double)nNom1 / nDen1, (double)nNom2 / nDen2 ); } break; case EMR_SETVIEWPORTORGEX : { - mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); + mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ); SetDevOrg( Point( nX32, nY32 ) ); } break; case EMR_SCALEVIEWPORTEXTEX : { - mpWMF->ReadUInt32( nNom1 ).ReadUInt32( nDen1 ).ReadUInt32( nNom2 ).ReadUInt32( nDen2 ); + mpInputStream->ReadUInt32( nNom1 ).ReadUInt32( nDen1 ).ReadUInt32( nNom2 ).ReadUInt32( nDen2 ); ScaleDevExt( (double)nNom1 / nDen1, (double)nNom2 / nDen2 ); } break; case EMR_SETVIEWPORTEXTEX : { - mpWMF->ReadUInt32( nW ).ReadUInt32( nH ); + mpInputStream->ReadUInt32( nW ).ReadUInt32( nH ); SetDevExt( Size( nW, nH ) ); } break; @@ -778,7 +778,7 @@ namespace emfio case EMR_SETPIXELV : { - mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); + mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ); DrawPixel( Point( nX32, nY32 ), ReadColor() ); } break; @@ -786,14 +786,14 @@ namespace emfio case EMR_SETMAPMODE : { sal_uInt32 nMapMode; - mpWMF->ReadUInt32( nMapMode ); + mpInputStream->ReadUInt32( nMapMode ); SetMapMode( nMapMode ); } break; case EMR_SETBKMODE : { - mpWMF->ReadUInt32( nDat32 ); + mpInputStream->ReadUInt32( nDat32 ); SetBkMode( static_cast<BkMode>(nDat32) ); } break; @@ -803,20 +803,20 @@ namespace emfio case EMR_SETROP2 : { - mpWMF->ReadUInt32( nDat32 ); + mpInputStream->ReadUInt32( nDat32 ); SetRasterOp( (WMFRasterOp)nDat32 ); } break; case EMR_SETSTRETCHBLTMODE : { - mpWMF->ReadUInt32( nStretchBltMode ); + mpInputStream->ReadUInt32( nStretchBltMode ); } break; case EMR_SETTEXTALIGN : { - mpWMF->ReadUInt32( nDat32 ); + mpInputStream->ReadUInt32( nDat32 ); SetTextAlign( nDat32 ); } break; @@ -835,21 +835,21 @@ namespace emfio case EMR_OFFSETCLIPRGN : { - mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); + mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ); MoveClipRegion( Size( nX32, nY32 ) ); } break; case EMR_MOVETOEX : { - mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); + mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ); MoveTo( Point( nX32, nY32 ), mbRecordPath); } break; case EMR_INTERSECTCLIPRECT : { - mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ); + mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ); IntersectClipRect( ReadRectangle( nX32, nY32, nx32, ny32 ) ); } break; @@ -869,7 +869,7 @@ namespace emfio case EMR_SETWORLDTRANSFORM : { XForm aTempXForm; - *mpWMF >> aTempXForm; + *mpInputStream >> aTempXForm; SetWorldTransform( aTempXForm ); } break; @@ -878,22 +878,22 @@ namespace emfio { sal_uInt32 nMode; XForm aTempXForm; - *mpWMF >> aTempXForm; - mpWMF->ReadUInt32( nMode ); + *mpInputStream >> aTempXForm; + mpInputStream->ReadUInt32( nMode ); ModifyWorldTransform( aTempXForm, nMode ); } break; case EMR_SELECTOBJECT : { - mpWMF->ReadUInt32( nIndex ); + mpInputStream->ReadUInt32( nIndex ); SelectObject( nIndex ); } break; case EMR_CREATEPEN : { - mpWMF->ReadUInt32( nIndex ); + mpInputStream->ReadUInt32( nIndex ); if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) { @@ -903,7 +903,7 @@ namespace emfio // #fdo39428 Remove SvStream operator>>(long&) sal_Int32 nTmpW(0), nTmpH(0); - mpWMF->ReadUInt32( nStyle ).ReadInt32( nTmpW ).ReadInt32( nTmpH ); + mpInputStream->ReadUInt32( nStyle ).ReadInt32( nTmpW ).ReadInt32( nTmpH ); aSize.Width() = nTmpW; aSize.Height() = nTmpH; @@ -987,12 +987,12 @@ namespace emfio sal_uInt32 offBmi, cbBmi, offBits, cbBits, nStyle, nWidth, nBrushStyle, elpNumEntries; Color aColorRef; - mpWMF->ReadUInt32( nIndex ); + mpInputStream->ReadUInt32( nIndex ); if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) { - mpWMF->ReadUInt32( offBmi ).ReadUInt32( cbBmi ).ReadUInt32( offBits ).ReadUInt32( cbBits ). ReadUInt32( nStyle ).ReadUInt32( nWidth ).ReadUInt32( nBrushStyle ); + mpInputStream->ReadUInt32( offBmi ).ReadUInt32( cbBmi ).ReadUInt32( offBits ).ReadUInt32( cbBits ). ReadUInt32( nStyle ).ReadUInt32( nWidth ).ReadUInt32( nBrushStyle ); aColorRef = ReadColor(); - mpWMF->ReadInt32( elpHatch ).ReadUInt32( elpNumEntries ); + mpInputStream->ReadInt32( elpHatch ).ReadUInt32( elpNumEntries ); LineInfo aLineInfo; if ( nWidth ) @@ -1074,10 +1074,10 @@ namespace emfio case EMR_CREATEBRUSHINDIRECT : { sal_uInt32 nStyle; - mpWMF->ReadUInt32( nIndex ); + mpInputStream->ReadUInt32( nIndex ); if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) { - mpWMF->ReadUInt32( nStyle ); + mpInputStream->ReadUInt32( nStyle ); CreateObjectIndexed(nIndex, o3tl::make_unique<WinMtfFillStyle>( ReadColor(), ( nStyle == BS_HOLLOW ) )); } } @@ -1085,7 +1085,7 @@ namespace emfio case EMR_DELETEOBJECT : { - mpWMF->ReadUInt32( nIndex ); + mpInputStream->ReadUInt32( nIndex ); if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) DeleteObject( nIndex ); } @@ -1093,21 +1093,21 @@ namespace emfio case EMR_ELLIPSE : { - mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ); + mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ); DrawEllipse( ReadRectangle( nX32, nY32, nx32, ny32 ) ); } break; case EMR_RECTANGLE : { - mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ); + mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ); DrawRect( ReadRectangle( nX32, nY32, nx32, ny32 ) ); } break; case EMR_ROUNDRECT : { - mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nW ).ReadUInt32( nH ); + mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nW ).ReadUInt32( nH ); Size aSize( Size( nW, nH ) ); DrawRoundRect( ReadRectangle( nX32, nY32, nx32, ny32 ), aSize ); } @@ -1116,7 +1116,7 @@ namespace emfio case EMR_ARC : { sal_uInt32 nStartX, nStartY, nEndX, nEndY; - mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); + mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) ); } break; @@ -1124,7 +1124,7 @@ namespace emfio case EMR_CHORD : { sal_uInt32 nStartX, nStartY, nEndX, nEndY; - mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); + mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); DrawChord( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) ); } break; @@ -1132,7 +1132,7 @@ namespace emfio case EMR_PIE : { sal_uInt32 nStartX, nStartY, nEndX, nEndY; - mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); + mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); const tools::Rectangle aRect( ReadRectangle( nX32, nY32, nx32, ny32 )); // #i73608# OutputDevice deviates from WMF @@ -1146,7 +1146,7 @@ namespace emfio case EMR_LINETO : { - mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); + mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ); LineTo( Point( nX32, nY32 ), mbRecordPath); } break; @@ -1154,7 +1154,7 @@ namespace emfio case EMR_ARCTO : { sal_uInt32 nStartX, nStartY, nEndX, nEndY; - mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); + mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ), true ); } break; @@ -1192,7 +1192,7 @@ namespace emfio case EMR_SELECTCLIPPATH : { sal_Int32 nClippingMode; - mpWMF->ReadInt32(nClippingMode); + mpInputStream->ReadInt32(nClippingMode); SetClipPath(GetPathObj(), nClippingMode, true); } break; @@ -1200,8 +1200,8 @@ namespace emfio case EMR_EXTSELECTCLIPRGN : { sal_Int32 nClippingMode, cbRgnData; - mpWMF->ReadInt32(cbRgnData); - mpWMF->ReadInt32(nClippingMode); + mpInputStream->ReadInt32(cbRgnData); + mpInputStream->ReadInt32(nClippingMode); // This record's region data should be ignored if mode // is RGN_COPY - see EMF spec section 2.3.2.2 @@ -1213,7 +1213,7 @@ namespace emfio { tools::PolyPolygon aPolyPoly; if (cbRgnData) - ImplReadRegion(aPolyPoly, *mpWMF, nRecSize); + ImplReadRegion(aPolyPoly, *mpInputStream, nRecSize); SetClipPath(aPolyPoly, nClippingMode, false); } @@ -1230,14 +1230,14 @@ namespace emfio sal_uInt32 BkColorSrc(0), iUsageSrc(0), offBmiSrc(0); sal_uInt32 cbBmiSrc(0), offBitsSrc(0), cbBitsSrc(0); - sal_uInt32 nStart = mpWMF->Tell() - 8; - mpWMF->SeekRel( 0x10 ); + sal_uInt32 nStart = mpInputStream->Tell() - 8; + mpInputStream->SeekRel( 0x10 ); - mpWMF->ReadInt32( xDest ).ReadInt32( yDest ).ReadInt32( cxDest ).ReadInt32( cyDest ); - *mpWMF >> aFunc; - mpWMF->ReadInt32( xSrc ).ReadInt32( ySrc ); - *mpWMF >> xformSrc; - mpWMF->ReadUInt32( BkColorSrc ).ReadUInt32( iUsageSrc ).ReadUInt32( offBmiSrc ).ReadUInt32( cbBmiSrc ) + mpInputStream->ReadInt32( xDest ).ReadInt32( yDest ).ReadInt32( cxDest ).ReadInt32( cyDest ); + *mpInputStream >> aFunc; + mpInputStream->ReadInt32( xSrc ).ReadInt32( ySrc ); + *mpInputStream >> xformSrc; + mpInputStream->ReadUInt32( BkColorSrc ).ReadUInt32( iUsageSrc ).ReadUInt32( offBmiSrc ).ReadUInt32( cbBmiSrc ) .ReadUInt32( offBitsSrc ).ReadUInt32( cbBitsSrc ).ReadInt32( cxSrc ).ReadInt32( cySrc ) ; tools::Rectangle aRect( Point( xDest, yDest ), Size( cxDest+1, cyDest+1 ) ); @@ -1278,8 +1278,8 @@ namespace emfio .WriteUInt32( cbBmiSrc + nDeltaToDIB5HeaderSize + 14 ); // copy DIBInfoHeader from source (cbBmiSrc bytes) - mpWMF->Seek( nStart + offBmiSrc ); - mpWMF->ReadBytes(pBuf + 14, cbBmiSrc); + mpInputStream->Seek( nStart + offBmiSrc ); + mpInputStream->ReadBytes(pBuf + 14, cbBmiSrc); if (bReadAlpha) { @@ -1290,8 +1290,8 @@ namespace emfio } // copy bitmap data from source (offBitsSrc bytes) - mpWMF->Seek( nStart + offBitsSrc ); - mpWMF->ReadBytes(pBuf + 14 + nDeltaToDIB5HeaderSize + cbBmiSrc, cbBitsSrc); + mpInputStream->Seek( nStart + offBitsSrc ); + mpInputStream->ReadBytes(pBuf + 14 + nDeltaToDIB5HeaderSize + cbBmiSrc, cbBitsSrc); aTmp.Seek( 0 ); // prepare to read and fill BitmapEx @@ -1365,16 +1365,16 @@ namespace emfio sal_uInt32 dwRop, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc; XForm xformSrc; - sal_uInt32 nStart = mpWMF->Tell() - 8; + sal_uInt32 nStart = mpInputStream->Tell() - 8; - mpWMF->SeekRel( 0x10 ); - mpWMF->ReadInt32( xDest ).ReadInt32( yDest ).ReadInt32( cxDest ).ReadInt32( cyDest ).ReadUInt32( dwRop ).ReadInt32( xSrc ).ReadInt32( ySrc ) + mpInputStream->SeekRel( 0x10 ); + mpInputStream->ReadInt32( xDest ).ReadInt32( yDest ).ReadInt32( cxDest ).ReadInt32( cyDest ).ReadUInt32( dwRop ).ReadInt32( xSrc ).ReadInt32( ySrc ) >> xformSrc; - mpWMF->ReadUInt32( nColor ).ReadUInt32( iUsageSrc ).ReadUInt32( offBmiSrc ).ReadUInt32( cbBmiSrc ) + mpInputStream->ReadUInt32( nColor ).ReadUInt32( iUsageSrc ).ReadUInt32( offBmiSrc ).ReadUInt32( cbBmiSrc ) .ReadUInt32( offBitsSrc ).ReadUInt32( cbBitsSrc ); if ( nRecType == EMR_STRETCHBLT ) - mpWMF->ReadInt32( cxSrc ).ReadInt32( cySrc ); + mpInputStream->ReadInt32( cxSrc ).ReadInt32( cySrc ); else cxSrc = cySrc = 0; @@ -1397,10 +1397,10 @@ namespace emfio .WriteUInt16( 0 ) .WriteUInt16( 0 ) .WriteUInt32( cbBmiSrc + 14 ); - mpWMF->Seek( nStart + offBmiSrc ); - mpWMF->ReadBytes(pBuf + 14, cbBmiSrc); - mpWMF->Seek( nStart + offBitsSrc ); - mpWMF->ReadBytes(pBuf + 14 + cbBmiSrc, cbBitsSrc); + mpInputStream->Seek( nStart + offBmiSrc ); + mpInputStream->ReadBytes(pBuf + 14, cbBmiSrc); + mpInputStream->Seek( nStart + offBitsSrc ); + mpInputStream->ReadBytes(pBuf + 14 + cbBmiSrc, cbBitsSrc); aTmp.Seek( 0 ); ReadDIB(aBitmap, aTmp, true); @@ -1423,10 +1423,10 @@ namespace emfio { sal_Int32 xDest, yDest, xSrc, ySrc, cxSrc, cySrc, cxDest, cyDest; sal_uInt32 offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc, iUsageSrc, dwRop; - sal_uInt32 nStart = mpWMF->Tell() - 8; + sal_uInt32 nStart = mpInputStream->Tell() - 8; - mpWMF->SeekRel( 0x10 ); - mpWMF->ReadInt32( xDest ) + mpInputStream->SeekRel( 0x10 ); + mpInputStream->ReadInt32( xDest ) .ReadInt32( yDest ) .ReadInt32( xSrc ) .ReadInt32( ySrc ) @@ -1464,10 +1464,10 @@ namespace emfio .WriteUInt16( 0 ) .WriteUInt16( 0 ) .WriteUInt32( cbBmiSrc + 14 ); - mpWMF->Seek( nStart + offBmiSrc ); - mpWMF->ReadBytes(pBuf + 14, cbBmiSrc); - mpWMF->Seek( nStart + offBitsSrc ); - mpWMF->ReadBytes(pBuf + 14 + cbBmiSrc, cbBitsSrc); + mpInputStream->Seek( nStart + offBmiSrc ); + mpInputStream->ReadBytes(pBuf + 14, cbBmiSrc); + mpInputStream->Seek( nStart + offBitsSrc ); + mpInputStream->ReadBytes(pBuf + 14 + cbBmiSrc, cbBitsSrc); aTmp.Seek( 0 ); ReadDIB(aBitmap, aTmp, true); @@ -1488,11 +1488,11 @@ namespace emfio case EMR_EXTCREATEFONTINDIRECTW : { - mpWMF->ReadUInt32( nIndex ); + mpInputStream->ReadUInt32( nIndex ); if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) { LOGFONTW aLogFont; - mpWMF->ReadInt32( aLogFont.lfHeight ) + mpInputStream->ReadInt32( aLogFont.lfHeight ) .ReadInt32( aLogFont.lfWidth ) .ReadInt32( aLogFont.lfEscapement ) .ReadInt32( aLogFont.lfOrientation ) @@ -1511,7 +1511,7 @@ namespace emfio for (int i = 0; i < LF_FACESIZE; ++i) { sal_uInt16 nChar(0); - mpWMF->ReadUInt16(nChar); + mpInputStream->ReadUInt16(nChar); lfFaceName[i] = nChar; } aLogFont.alfFaceName = OUString( lfFaceName ); @@ -1543,13 +1543,13 @@ namespace emfio sal_uInt32 nOffString, nOptions, offDx; sal_Int32 nLen; - nCurPos = mpWMF->Tell() - 8; + nCurPos = mpInputStream->Tell() - 8; - mpWMF->ReadInt32( nLeft ).ReadInt32( nTop ).ReadInt32( nRight ).ReadInt32( nBottom ).ReadInt32( nGfxMode ).ReadInt32( nXScale ).ReadInt32( nYScale ) + mpInputStream->ReadInt32( nLeft ).ReadInt32( nTop ).ReadInt32( nRight ).ReadInt32( nBottom ).ReadInt32( nGfxMode ).ReadInt32( nXScale ).ReadInt32( nYScale ) .ReadInt32( ptlReferenceX ).ReadInt32( ptlReferenceY ).ReadInt32( nLen ).ReadUInt32( nOffString ).ReadUInt32( nOptions ); - mpWMF->SeekRel( 0x10 ); - mpWMF->ReadUInt32( offDx ); + mpInputStream->SeekRel( 0x10 ); + mpInputStream->ReadUInt32( offDx ); ComplexTextLayoutFlags nTextLayoutMode = ComplexTextLayoutFlags::Default; if ( nOptions & ETO_RTLREADING ) @@ -1562,23 +1562,23 @@ namespace emfio bool bOffStringSane = nOffString <= mnEndPos - nCurPos; if (bLenSane && bOffStringSane) { - mpWMF->Seek( nCurPos + nOffString ); + mpInputStream->Seek( nCurPos + nOffString ); OUString aText; if ( bFlag ) { - if ( nLen <= static_cast<sal_Int32>( mnEndPos - mpWMF->Tell() ) ) + if ( nLen <= static_cast<sal_Int32>( mnEndPos - mpInputStream->Tell() ) ) { std::unique_ptr<sal_Char[]> pBuf(new sal_Char[ nLen ]); - mpWMF->ReadBytes(pBuf.get(), nLen); + mpInputStream->ReadBytes(pBuf.get(), nLen); aText = OUString(pBuf.get(), nLen, GetCharSet()); } } else { - if ( ( nLen * sizeof(sal_Unicode) ) <= ( mnEndPos - mpWMF->Tell() ) ) + if ( ( nLen * sizeof(sal_Unicode) ) <= ( mnEndPos - mpInputStream->Tell() ) ) { std::unique_ptr<sal_Unicode[]> pBuf(new sal_Unicode[ nLen ]); - mpWMF->ReadBytes(pBuf.get(), nLen << 1); + mpInputStream->ReadBytes(pBuf.get(), nLen << 1); #ifdef OSL_BIGENDIAN sal_Char nTmp, *pTmp = (sal_Char*)( pBuf.get() + nLen ); while ( pTmp-- != (sal_Char*)pBuf.get() ) @@ -1596,7 +1596,7 @@ namespace emfio sal_Int32 nDxSize = nLen * ((nOptions & ETO_PDY) ? 8 : 4); if ( offDx && (( nCurPos + offDx + nDxSize ) <= nNextPos ) && nNextPos <= mnEndPos ) { - mpWMF->Seek( nCurPos + offDx ); + mpInputStream->Seek( nCurPos + offDx ); pDXAry.reset( new long[aText.getLength()] ); if (nOptions & ETO_PDY) { @@ -1620,12 +1620,12 @@ namespace emfio while (nDxCount--) { sal_Int32 nDxTmp = 0; - mpWMF->ReadInt32(nDxTmp); + mpInputStream->ReadInt32(nDxTmp); nDx += nDxTmp; if (nOptions & ETO_PDY) { sal_Int32 nDyTmp = 0; - mpWMF->ReadInt32(nDyTmp); + mpInputStream->ReadInt32(nDyTmp); nDy += nDyTmp; } } @@ -1674,10 +1674,10 @@ namespace emfio { sal_uInt32 nLen; tools::PolyPolygon aPolyPoly; - mpWMF->SeekRel( 0x10 ); - mpWMF->ReadUInt32( nLen ).ReadUInt32( nIndex ); + mpInputStream->SeekRel( 0x10 ); + mpInputStream->ReadUInt32( nLen ).ReadUInt32( nIndex ); - if ( ImplReadRegion( aPolyPoly, *mpWMF, nRecSize ) ) + if ( ImplReadRegion( aPolyPoly, *mpInputStream, nRecSize ) ) { Push(); SelectObject( nIndex ); @@ -1689,20 +1689,20 @@ namespace emfio case EMR_CREATEDIBPATTERNBRUSHPT : { - sal_uInt32 nStart = mpWMF->Tell() - 8; + sal_uInt32 nStart = mpInputStream->Tell() - 8; Bitmap aBitmap; - mpWMF->ReadUInt32( nIndex ); + mpInputStream->ReadUInt32( nIndex ); if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) { sal_uInt32 usage, offBmi, cbBmi, offBits, cbBits; - mpWMF->ReadUInt32( usage ); - mpWMF->ReadUInt32( offBmi ); - mpWMF->ReadUInt32( cbBmi ); - mpWMF->ReadUInt32( offBits ); - mpWMF->ReadUInt32( cbBits ); + mpInputStream->ReadUInt32( usage ); + mpInputStream->ReadUInt32( offBmi ); + mpInputStream->ReadUInt32( cbBmi ); + mpInputStream->ReadUInt32( offBits ); + mpInputStream->ReadUInt32( cbBits ); if ( (cbBits > (SAL_MAX_UINT32 - 14)) || ((SAL_MAX_UINT32 - 14) - cbBits < cbBmi) ) bStatus = false; @@ -1721,10 +1721,10 @@ namespace emfio .WriteUInt16( 0 ) .WriteUInt16( 0 ) .WriteUInt32( cbBmi + 14 ); - mpWMF->Seek( nStart + offBmi ); - mpWMF->ReadBytes(pBuf + 14, cbBmi); - mpWMF->Seek( nStart + offBits ); - mpWMF->ReadBytes(pBuf + 14 + cbBmi, cbBits); + mpInputStream->Seek( nStart + offBmi ); + mpInputStream->ReadBytes(pBuf + 14, cbBmi); + mpInputStream->Seek( nStart + offBits ); + mpInputStream->ReadBytes(pBuf + 14 + cbBmi, cbBits); aTmp.Seek( 0 ); ReadDIB(aBitmap, aTmp, true); } @@ -1793,13 +1793,13 @@ namespace emfio default : SAL_INFO("vcl.emf", "Unknown Meta Action"); break; } } - mpWMF->Seek( nNextPos ); + mpInputStream->Seek( nNextPos ); } if( !maBmpSaveList.empty() ) ResolveBitmapActions( maBmpSaveList ); if ( bStatus ) - mpWMF->Seek(mnEndPos); + mpInputStream->Seek(mnEndPos); return bStatus; }; @@ -1811,7 +1811,7 @@ namespace emfio // Spare me the METAFILEHEADER here // Reading the METAHEADER - EMR_HEADER ([MS-EMF] section 2.3.4.2 EMR_HEADER Record Types) - mpWMF->ReadUInt32( nType ).ReadUInt32( nHeaderSize ); + mpInputStream->ReadUInt32( nType ).ReadUInt32( nHeaderSize ); if (nType != 0x00000001) { // per [MS-EMF] 2.3.4.2 EMF Header Record Types, type MUST be 0x00000001 @@ -1827,7 +1827,7 @@ namespace emfio // picture frame size (RectL object) tools::Rectangle rclFrame = ReadRectangle(); // rectangle in device units 1/100th mm - mpWMF->ReadUInt32( nSignature ); + mpInputStream->ReadUInt32( nSignature ); // nSignature MUST be the ASCII characters "FME", see [WS-EMF] 2.2.9 Header Object // and 2.1.14 FormatSignature Enumeration @@ -1837,19 +1837,19 @@ namespace emfio return false; } - mpWMF->ReadUInt32(nVersion); // according to [WS-EMF] 2.2.9, this SHOULD be 0x0001000, however + mpInputStream->ReadUInt32(nVersion); // according to [WS-EMF] 2.2.9, this SHOULD be 0x0001000, however // Microsoft note that not even Windows checks this... if (nVersion != 0x00010000) { SAL_WARN("vcl.emf", "EMF\t\tThis really should be 0x00010000, though not absolutely essential..."); } - mpWMF->ReadUInt32(mnEndPos); // size of metafile + mpInputStream->ReadUInt32(mnEndPos); // size of metafile mnEndPos += mnStartPos; - sal_uInt32 nStrmPos = mpWMF->Tell(); // checking if mnEndPos is valid - mpWMF->Seek(STREAM_SEEK_TO_END); - sal_uInt32 nActualFileSize = mpWMF->Tell(); + sal_uInt32 nStrmPos = mpInputStream->Tell(); // checking if mnEndPos is valid + mpInputStream->Seek(STREAM_SEEK_TO_END); + sal_uInt32 nActualFileSize = mpInputStream->Tell(); if ( nActualFileSize < mnEndPos ) { @@ -1858,9 +1858,9 @@ namespace emfio << " bytes. Possible file corruption?"); mnEndPos = nActualFileSize; } - mpWMF->Seek(nStrmPos); + mpInputStream->Seek(nStrmPos); - mpWMF->ReadInt32(mnRecordCount); + mpInputStream->ReadInt32(mnRecordCount); if (mnRecordCount <= 0) { @@ -1872,14 +1872,14 @@ namespace emfio // the number of "handles", or graphics objects used in the metafile sal_uInt16 nHandlesCount; - mpWMF->ReadUInt16(nHandlesCount); + mpInputStream->ReadUInt16(nHandlesCount); // the next 2 bytes are reserved, but according to [MS-EMF] section 2.2.9 // it MUST be 0x000 and MUST be ignored... the thing is, having such a specific // value is actually pretty useful in checking if there is possible corruption sal_uInt16 nReserved; - mpWMF->ReadUInt16(nReserved); + mpInputStream->ReadUInt16(nReserved); if ( nReserved != 0x0000 ) { @@ -1892,31 +1892,31 @@ namespace emfio // metafile description... zero means no description string. // For now, we ignore it. - mpWMF->SeekRel(0x8); + mpInputStream->SeekRel(0x8); sal_Int32 nPixX, nPixY, nMillX, nMillY; - mpWMF->ReadUInt32(nPalEntries); - mpWMF->ReadInt32(nPixX); - mpWMF->ReadInt32(nPixY); - mpWMF->ReadInt32(nMillX); - mpWMF->ReadInt32(nMillY); + mpInputStream->ReadUInt32(nPalEntries); + mpInputStream->ReadInt32(nPixX); + mpInputStream->ReadInt32(nPixY); + mpInputStream->ReadInt32(nMillX); + mpInputStream->ReadInt32(nMillY); SetrclFrame(rclFrame); SetrclBounds(rclBounds); SetRefPix(Size( nPixX, nPixY ) ); SetRefMill(Size( nMillX, nMillY ) ); - mpWMF->Seek(mnStartPos + nHeaderSize); + mpInputStream->Seek(mnStartPos + nHeaderSize); return true; } tools::Rectangle EmfReader::ReadRectangle() { sal_Int32 nLeft, nTop, nRight, nBottom; - mpWMF->ReadInt32(nLeft); - mpWMF->ReadInt32(nTop); - mpWMF->ReadInt32(nRight); - mpWMF->ReadInt32(nBottom); + mpInputStream->ReadInt32(nLeft); + mpInputStream->ReadInt32(nTop); + mpInputStream->ReadInt32(nRight); + mpInputStream->ReadInt32(nBottom); return tools::Rectangle(nLeft, nTop, nRight, nBottom); } diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index 37dfc76d0fd3..96d4d5232e7e 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -311,7 +311,7 @@ namespace emfio { sal_uInt32 nColor; - mpWMF->ReadUInt32( nColor ); + mpInputStream->ReadUInt32( nColor ); return Color( (sal_uInt8)nColor, (sal_uInt8)( nColor >> 8 ), (sal_uInt8)( nColor >> 16 ) ); }; @@ -862,7 +862,7 @@ namespace emfio mrclFrame(), mrclBounds(), mpGDIMetaFile(&rGDIMetaFile), - mpWMF(&rStreamWMF), + mpInputStream(&rStreamWMF), mnStartPos(0), mnEndPos(0), maBmpSaveList(), @@ -873,14 +873,14 @@ namespace emfio mbIsMapWinSet(false), mbIsMapDevSet(false) { - SvLockBytes *pLB = mpWMF->GetLockBytes(); + SvLockBytes *pLB = mpInputStream->GetLockBytes(); if (pLB) { pLB->SetSynchronMode(); } - mnStartPos = mpWMF->Tell(); + mnStartPos = mpInputStream->Tell(); SetDevOrg(Point()); mpGDIMetaFile->AddAction( new MetaPushAction( PushFlags::CLIPREGION ) ); // The original clipregion has to be on top diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index f1a9a1310095..3784153b1499 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -22,8 +22,6 @@ #include <memory> #include <boost/optional.hpp> -//#include <vcl/gdimtf.hxx> -//#include <vcl/wmf.hxx> #include <rtl/crc.h> #include <rtl/tencinfo.h> #include <osl/endian.h> @@ -35,7 +33,6 @@ #include <osl/thread.h> // MS Windows defines - #define W_META_SETBKCOLOR 0x0201 #define W_META_SETBKMODE 0x0102 #define W_META_SETMAPMODE 0x0103 @@ -145,14 +142,14 @@ namespace emfio inline Point WmfReader::ReadPoint() { short nX = 0, nY = 0; - mpWMF->ReadInt16( nX ).ReadInt16( nY ); + mpInputStream->ReadInt16( nX ).ReadInt16( nY ); return Point( nX, nY ); } inline Point WmfReader::ReadYX() { short nX = 0, nY = 0; - mpWMF->ReadInt16( nY ).ReadInt16( nX ); + mpInputStream->ReadInt16( nY ).ReadInt16( nX ); return Point( nX, nY ); } @@ -169,7 +166,7 @@ namespace emfio Size WmfReader::ReadYXExt() { short nW=0, nH=0; - mpWMF->ReadInt16( nH ).ReadInt16( nW ); + mpInputStream->ReadInt16( nH ).ReadInt16( nW ); return Size( nW, nH ); } @@ -186,7 +183,7 @@ namespace emfio case W_META_SETBKMODE: { sal_uInt16 nDat = 0; - mpWMF->ReadUInt16( nDat ); + mpInputStream->ReadUInt16( nDat ); SetBkMode( static_cast<BkMode>(nDat) ); } break; @@ -195,7 +192,7 @@ namespace emfio case W_META_SETMAPMODE: { sal_Int16 nMapMode = 0; - mpWMF->ReadInt16( nMapMode ); + mpInputStream->ReadInt16( nMapMode ); SetMapMode( nMapMode ); } break; @@ -203,7 +200,7 @@ namespace emfio case W_META_SETROP2: { sal_uInt16 nROP2 = 0; - mpWMF->ReadUInt16( nROP2 ); + mpInputStream->ReadUInt16( nROP2 ); SetRasterOp( (WMFRasterOp)nROP2 ); } break; @@ -223,7 +220,7 @@ namespace emfio case W_META_SETWINDOWEXT: { short nWidth = 0, nHeight = 0; - mpWMF->ReadInt16( nHeight ).ReadInt16( nWidth ); + mpInputStream->ReadInt16( nHeight ).ReadInt16( nWidth ); SetWinExt( Size( nWidth, nHeight ) ); } break; @@ -231,7 +228,7 @@ namespace emfio case W_META_OFFSETWINDOWORG: { short nXAdd = 0, nYAdd = 0; - mpWMF->ReadInt16( nYAdd ).ReadInt16( nXAdd ); + mpInputStream->ReadInt16( nYAdd ).ReadInt16( nXAdd ); SetWinOrgOffset( nXAdd, nYAdd ); } break; @@ -239,10 +236,10 @@ namespace emfio case W_META_SCALEWINDOWEXT: { short nXNum = 0, nXDenom = 0, nYNum = 0, nYDenom = 0; - mpWMF->ReadInt16( nYDenom ).ReadInt16( nYNum ).ReadInt16( nXDenom ).ReadInt16( nXNum ); + mpInputStream->ReadInt16( nYDenom ).ReadInt16( nYNum ).ReadInt16( nXDenom ).ReadInt16( nXNum ); if (!nYDenom || !nXDenom) { - mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpInputStream->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } ScaleWinExt( (double)nXNum / nXDenom, (double)nYNum / nYDenom ); @@ -256,7 +253,7 @@ namespace emfio case W_META_OFFSETVIEWPORTORG: { short nXAdd = 0, nYAdd = 0; - mpWMF->ReadInt16( nYAdd ).ReadInt16( nXAdd ); + mpInputStream->ReadInt16( nYAdd ).ReadInt16( nXAdd ); SetDevOrgOffset( nXAdd, nYAdd ); } break; @@ -264,10 +261,10 @@ namespace emfio case W_META_SCALEVIEWPORTEXT: { short nXNum = 0, nXDenom = 0, nYNum = 0, nYDenom = 0; - mpWMF->ReadInt16( nYDenom ).ReadInt16( nYNum ).ReadInt16( nXDenom ).ReadInt16( nXNum ); + mpInputStream->ReadInt16( nYDenom ).ReadInt16( nYNum ).ReadInt16( nXDenom ).ReadInt16( nXNum ); if (!nYDenom || !nXDenom) { - mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpInputStream->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } ScaleDevExt( (double)nXNum / nXDenom, (double)nYNum / nYDenom ); @@ -352,27 +349,27 @@ namespace emfio bool bRecordOk = true; sal_uInt16 nPoints(0); - mpWMF->ReadUInt16(nPoints); + mpInputStream->ReadUInt16(nPoints); - if (nPoints > mpWMF->remainingSize() / (2 * sizeof(sal_uInt16))) + if (nPoints > mpInputStream->remainingSize() / (2 * sizeof(sal_uInt16))) { bRecordOk = false; } else { tools::Polygon aPoly(nPoints); - for (sal_uInt16 i(0); i < nPoints && mpWMF->good(); ++i) + for (sal_uInt16 i(0); i < nPoints && mpInputStream->good(); ++i) aPoly[ i ] = ReadPoint(); DrawPolygon(aPoly, false/*bRecordPath*/); } SAL_WARN_IF(!bRecordOk, "vcl.wmf", "polygon record has more points than we can handle"); - bRecordOk &= mpWMF->good(); + bRecordOk &= mpInputStream->good(); if (!bRecordOk) { - mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpInputStream->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } } @@ -382,11 +379,11 @@ namespace emfio { sal_uInt16 nPolyCount(0); // Number of polygons: - mpWMF->ReadUInt16( nPolyCount ); - if (nPolyCount && mpWMF->good()) + mpInputStream->ReadUInt16( nPolyCount ); + if (nPolyCount && mpInputStream->good()) { bool bRecordOk = true; - if (nPolyCount > mpWMF->remainingSize() / sizeof(sal_uInt16)) + if (nPolyCount > mpInputStream->remainingSize() / sizeof(sal_uInt16)) { break; } @@ -396,9 +393,9 @@ namespace emfio sal_uInt16* pnPoints = xPolygonPointCounts.get(); tools::PolyPolygon aPolyPoly(nPolyCount, nPolyCount); sal_uInt16 nPoints = 0; - for (sal_uInt16 a = 0; a < nPolyCount && mpWMF->good(); ++a) + for (sal_uInt16 a = 0; a < nPolyCount && mpInputStream->good(); ++a) { - mpWMF->ReadUInt16( pnPoints[a] ); + mpInputStream->ReadUInt16( pnPoints[a] ); if (pnPoints[a] > SAL_MAX_UINT16 - nPoints) { @@ -411,20 +408,20 @@ namespace emfio SAL_WARN_IF(!bRecordOk, "vcl.wmf", "polypolygon record has more polygons than we can handle"); - bRecordOk &= mpWMF->good(); + bRecordOk &= mpInputStream->good(); if (!bRecordOk) { - mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpInputStream->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } // Polygon points are: - for (sal_uInt16 a = 0; a < nPolyCount && mpWMF->good(); ++a) + for (sal_uInt16 a = 0; a < nPolyCount && mpInputStream->good(); ++a) { const sal_uInt16 nPointCount(pnPoints[a]); - if (nPointCount > mpWMF->remainingSize() / (2 * sizeof(sal_uInt16))) + if (nPointCount > mpInputStream->remainingSize() / (2 * sizeof(sal_uInt16))) { bRecordOk = false; break; @@ -433,7 +430,7 @@ namespace emfio std::unique_ptr<Point[]> xPolygonPoints(new Point[nPointCount]); Point* pPtAry = xPolygonPoints.get(); - for(sal_uInt16 b(0); b < nPointCount && mpWMF->good(); ++b) + for(sal_uInt16 b(0); b < nPointCount && mpInputStream->good(); ++b) { pPtAry[b] = ReadPoint(); } @@ -441,11 +438,11 @@ namespace emfio aPolyPoly.Insert( tools::Polygon(nPointCount, pPtAry) ); } - bRecordOk &= mpWMF->good(); + bRecordOk &= mpInputStream->good(); if (!bRecordOk) { - mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpInputStream->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } @@ -459,27 +456,27 @@ namespace emfio bool bRecordOk = true; sal_uInt16 nPoints(0); - mpWMF->ReadUInt16(nPoints); + mpInputStream->ReadUInt16(nPoints); - if (nPoints > mpWMF->remainingSize() / (2 * sizeof(sal_uInt16))) + if (nPoints > mpInputStream->remainingSize() / (2 * sizeof(sal_uInt16))) { bRecordOk = false; } else { tools::Polygon aPoly(nPoints); - for (sal_uInt16 i(0); i < nPoints && mpWMF->good(); ++i) + for (sal_uInt16 i(0); i < nPoints && mpInputStream->good(); ++i) aPoly[ i ] = ReadPoint(); DrawPolyLine( aPoly ); } SAL_WARN_IF(!bRecordOk, "vcl.wmf", "polyline record has more points than we can handle"); - bRecordOk &= mpWMF->good(); + bRecordOk &= mpInputStream->good(); if (!bRecordOk) { - mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpInputStream->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } } @@ -513,11 +510,11 @@ namespace emfio case W_META_TEXTOUT: { sal_uInt16 nLength = 0; - mpWMF->ReadUInt16( nLength ); + mpInputStream->ReadUInt16( nLength ); if ( nLength ) { std::unique_ptr<char[]> pChar(new char[ ( nLength + 1 ) &~ 1 ]); - mpWMF->ReadBytes(pChar.get(), (nLength + 1) &~ 1); + mpInputStream->ReadBytes(pChar.get(), (nLength + 1) &~ 1); OUString aText( pChar.get(), nLength, GetCharSet() ); pChar.reset(); Point aPosition( ReadYX() ); @@ -528,13 +525,13 @@ namespace emfio case W_META_EXTTEXTOUT: { - mpWMF->SeekRel(-6); - sal_Int32 nRecordPos = mpWMF->Tell(), nRecordSize = 0; - mpWMF->ReadInt32( nRecordSize ); - mpWMF->SeekRel(2); + mpInputStream->SeekRel(-6); + sal_Int32 nRecordPos = mpInputStream->Tell(), nRecordSize = 0; + mpInputStream->ReadInt32( nRecordSize ); + mpInputStream->SeekRel(2); Point aPosition = ReadYX(); sal_uInt16 nLen = 0, nOptions = 0; - mpWMF->ReadUInt16( nLen ).ReadUInt16( nOptions ); + mpInputStream->ReadUInt16( nLen ).ReadUInt16( nOptions ); ComplexTextLayoutFlags nTextLayoutMode = ComplexTextLayoutFlags::Default; if ( nOptions & ETO_RTLREADING ) @@ -555,7 +552,7 @@ namespace emfio aRect = tools::Rectangle( aPt1, aPt2 ); } - auto nRemainingSize = mpWMF->remainingSize(); + auto nRemainingSize = mpInputStream->remainingSize(); if (nRemainingSize < static_cast<sal_uInt32>(nOriginalBlockLen)) { SAL_WARN("vcl.wmf", "exttextout record claimed more data than the stream can provide"); @@ -563,7 +560,7 @@ namespace emfio } std::unique_ptr<char[]> pChar(new char[nOriginalBlockLen]); - mpWMF->ReadBytes(pChar.get(), nOriginalBlockLen); + mpInputStream->ReadBytes(pChar.get(), nOriginalBlockLen); OUString aText(pChar.get(), nOriginalTextLen, GetCharSet()); // after this conversion the text may contain sal_Int32 nNewTextLen = aText.getLength(); // less character (japanese version), so the // dxAry will not fit @@ -571,7 +568,7 @@ namespace emfio { std::unique_ptr<long[]> pDXAry, pDYAry; sal_uInt32 nMaxStreamPos = nRecordPos + ( nRecordSize << 1 ); - sal_Int32 nDxArySize = nMaxStreamPos - mpWMF->Tell(); + sal_Int32 nDxArySize = nMaxStreamPos - mpInputStream->Tell(); sal_Int32 nDxAryEntries = nDxArySize >> 1; bool bUseDXAry = false; @@ -585,7 +582,7 @@ namespace emfio } for (i = 0; i < nNewTextLen; i++ ) { - if ( mpWMF->Tell() >= nMaxStreamPos ) + if ( mpInputStream->Tell() >= nMaxStreamPos ) break; sal_Int32 nDxCount = 1; if ( nNewTextLen != nOriginalTextLen ) @@ -601,17 +598,17 @@ namespace emfio sal_Int16 nDx = 0, nDy = 0; while ( nDxCount-- ) { - if ( ( mpWMF->Tell() + 2 ) > nMaxStreamPos ) + if ( ( mpInputStream->Tell() + 2 ) > nMaxStreamPos ) break; sal_Int16 nDxTmp = 0; - mpWMF->ReadInt16(nDxTmp); + mpInputStream->ReadInt16(nDxTmp); nDx += nDxTmp; if ( nOptions & ETO_PDY ) { - if ( ( mpWMF->Tell() + 2 ) > nMaxStreamPos ) + if ( ( mpInputStream->Tell() + 2 ) > nMaxStreamPos ) break; sal_Int16 nDyTmp = 0; - mpWMF->ReadInt16(nDyTmp); + mpInputStream->ReadInt16(nDyTmp); nDy += nDyTmp; } } @@ -637,7 +634,7 @@ namespace emfio case W_META_SELECTOBJECT: { sal_Int16 nObjIndex = 0; - mpWMF->ReadInt16( nObjIndex ); + mpInputStream->ReadInt16( nObjIndex ); SelectObject( nObjIndex ); } break; @@ -645,7 +642,7 @@ namespace emfio case W_META_SETTEXTALIGN: { sal_uInt16 nAlign = 0; - mpWMF->ReadUInt16( nAlign ); + mpInputStream->ReadUInt16( nAlign ); SetTextAlign( nAlign ); } break; @@ -670,15 +667,15 @@ namespace emfio sal_uInt16 nSx = 0, nSy = 0, nSxe = 0, nSye = 0, nDontKnow = 0, nWidth = 0, nHeight = 0, nBytesPerScan = 0; sal_uInt8 nPlanes, nBitCount; - mpWMF->ReadInt32( nWinROP ) + mpInputStream->ReadInt32( nWinROP ) .ReadUInt16( nSy ).ReadUInt16( nSx ).ReadUInt16( nSye ).ReadUInt16( nSxe ); Point aPoint( ReadYX() ); - mpWMF->ReadUInt16( nDontKnow ).ReadUInt16( nWidth ).ReadUInt16( nHeight ).ReadUInt16( nBytesPerScan ).ReadUChar( nPlanes ).ReadUChar( nBitCount ); + mpInputStream->ReadUInt16( nDontKnow ).ReadUInt16( nWidth ).ReadUInt16( nHeight ).ReadUInt16( nBytesPerScan ).ReadUChar( nPlanes ).ReadUChar( nBitCount ); bool bOk = nWidth && nHeight && nPlanes == 1 && nBitCount == 1; if (bOk) { - bOk = nBytesPerScan <= mpWMF->remainingSize() / nHeight; + bOk = nBytesPerScan <= mpInputStream->remainingSize() / nHeight; } if (bOk) { @@ -686,13 +683,13 @@ namespace emfio Bitmap::ScopedWriteAccess pAcc(aBmp); if ( pAcc ) { - for (sal_uInt16 y = 0; y < nHeight && mpWMF->good(); ++y) + for (sal_uInt16 y = 0; y < nHeight && mpInputStream->good(); ++y) { sal_uInt16 x = 0; for (sal_uInt16 scan = 0; scan < nBytesPerScan; scan++ ) { sal_Int8 nEightPixels = 0; - mpWMF->ReadSChar( nEightPixels ); + mpInputStream->ReadSChar( nEightPixels ); for (sal_Int8 i = 7; i >= 0; i-- ) { if ( x < nWidth ) @@ -727,24 +724,24 @@ namespace emfio sal_uInt16 nSx = 0, nSy = 0, nSxe = 0, nSye = 0, nUsage = 0; Bitmap aBmp; - mpWMF->ReadInt32( nWinROP ); + mpInputStream->ReadInt32( nWinROP ); if( nFunc == W_META_STRETCHDIB ) - mpWMF->ReadUInt16( nUsage ); + mpInputStream->ReadUInt16( nUsage ); // nSye and nSxe is the number of pixels that has to been used // If they are set to zero, it is as indicator not to scale the bitmap later if( nFunc == W_META_STRETCHDIB || nFunc == W_META_STRETCHBLT || nFunc == W_META_DIBSTRETCHBLT ) - mpWMF->ReadUInt16( nSye ).ReadUInt16( nSxe ); + mpInputStream->ReadUInt16( nSye ).ReadUInt16( nSxe ); // nSy and nx is the offset of the first pixel - mpWMF->ReadUInt16( nSy ).ReadUInt16( nSx ); + mpInputStream->ReadUInt16( nSy ).ReadUInt16( nSx ); if( nFunc == W_META_STRETCHDIB || nFunc == W_META_DIBBITBLT || nFunc == W_META_DIBSTRETCHBLT ) { if ( nWinROP == PATCOPY ) - mpWMF->ReadUInt16( nUsage ); // i don't know anything of this parameter, so its called nUsage + mpInputStream->ReadUInt16( nUsage ); // i don't know anything of this parameter, so its called nUsage // DrawRect( Rectangle( ReadYX(), aDestSize ), false ); Size aDestSize( ReadYXExt() ); @@ -752,7 +749,7 @@ namespace emfio { tools::Rectangle aDestRect( ReadYX(), aDestSize ); if ( nWinROP != PATCOPY ) - ReadDIB(aBmp, *mpWMF, false); + ReadDIB(aBmp, *mpInputStream, false); // test if it is sensible to crop if ( nSye && nSxe && @@ -774,9 +771,9 @@ namespace emfio sal_uInt32 nRed = 0, nGreen = 0, nBlue = 0, nCount = 1; sal_uInt16 nFunction = 0; - mpWMF->ReadUInt16( nFunction ).ReadUInt16( nFunction ); + mpInputStream->ReadUInt16( nFunction ).ReadUInt16( nFunction ); - ReadDIB(aBmp, *mpWMF, false); + ReadDIB(aBmp, *mpInputStream, false); Bitmap::ScopedReadAccess pBmp(aBmp); if ( pBmp ) { @@ -804,7 +801,7 @@ namespace emfio case W_META_DELETEOBJECT: { sal_Int16 nIndex = 0; - mpWMF->ReadInt16( nIndex ); + mpInputStream->ReadInt16( nIndex ); DeleteObject( nIndex ); } break; @@ -834,9 +831,9 @@ namespace emfio sal_uInt16 nWidth = 0; sal_uInt16 nHeight = 0; - mpWMF->ReadUInt16(nStyle); - mpWMF->ReadUInt16(nWidth); - mpWMF->ReadUInt16(nHeight); + mpInputStream->ReadUInt16(nStyle); + mpInputStream->ReadUInt16(nWidth); + mpInputStream->ReadUInt16(nHeight); if (nWidth > 0) aLineInfo.SetWidth(nWidth); @@ -907,7 +904,7 @@ namespace emfio case W_META_CREATEBRUSHINDIRECT: { sal_uInt16 nStyle = 0; - mpWMF->ReadUInt16( nStyle ); + mpInputStream->ReadUInt16( nStyle ); CreateObject(o3tl::make_unique<WinMtfFillStyle>( ReadColor(), ( nStyle == BS_HOLLOW ) )); } break; @@ -922,18 +919,18 @@ namespace emfio LOGFONTW aLogFont; aFontSize = ReadYXExt(); - mpWMF->ReadInt16( lfEscapement ); - mpWMF->ReadInt16( lfOrientation ); - mpWMF->ReadInt16( lfWeight ); - mpWMF->ReadUChar( aLogFont.lfItalic ); - mpWMF->ReadUChar( aLogFont.lfUnderline ); - mpWMF->ReadUChar( aLogFont.lfStrikeOut ); - mpWMF->ReadUChar( aLogFont.lfCharSet ); - mpWMF->ReadUChar( aLogFont.lfOutPrecision ); - mpWMF->ReadUChar( aLogFont.lfClipPrecision ); - mpWMF->ReadUChar( aLogFont.lfQuality ); - mpWMF->ReadUChar( aLogFont.lfPitchAndFamily ); - size_t nRet = mpWMF->ReadBytes( lfFaceName, LF_FACESIZE ); + mpInputStream->ReadInt16( lfEscapement ); + mpInputStream->ReadInt16( lfOrientation ); + mpInputStream->ReadInt16( lfWeight ); + mpInputStream->ReadUChar( aLogFont.lfItalic ); + mpInputStream->ReadUChar( aLogFont.lfUnderline ); + mpInputStream->ReadUChar( aLogFont.lfStrikeOut ); + mpInputStream->ReadUChar( aLogFont.lfCharSet ); + mpInputStream->ReadUChar( aLogFont.lfOutPrecision ); + mpInputStream->ReadUChar( aLogFont.lfClipPrecision ); + mpInputStream->ReadUChar( aLogFont.lfQuality ); + mpInputStream->ReadUChar( aLogFont.lfPitchAndFamily ); + size_t nRet = mpInputStream->ReadBytes( lfFaceName, LF_FACESIZE ); lfFaceName[nRet] = 0; aLogFont.lfWidth = aFontSize.Width(); aLogFont.lfHeight = aFontSize.Height(); @@ -984,7 +981,7 @@ namespace emfio { sal_uInt32 nROP = 0; WMFRasterOp nOldROP = WMFRasterOp::NONE; - mpWMF->ReadUInt32( nROP ); + mpInputStream->ReadUInt32( nROP ); Size aSize = ReadYXExt(); nOldROP = SetRasterOp( (WMFRasterOp)nROP ); DrawRect( tools::Rectangle( ReadYX(), aSize ), false ); @@ -995,7 +992,7 @@ namespace emfio case W_META_SELECTCLIPREGION: { sal_Int16 nObjIndex = 0; - mpWMF->ReadInt16( nObjIndex ); + mpInputStream->ReadInt16( nObjIndex ); if ( !nObjIndex ) { tools::PolyPolygon aEmptyPolyPoly; @@ -1008,32 +1005,32 @@ namespace emfio { // mnRecSize has been checked previously to be greater than 3 sal_uInt64 nMetaRecSize = static_cast< sal_uInt64 >(mnRecSize - 2 ) * 2; - sal_uInt64 nMetaRecEndPos = mpWMF->Tell() + nMetaRecSize; + sal_uInt64 nMetaRecEndPos = mpInputStream->Tell() + nMetaRecSize; // taking care that mnRecSize does not exceed the maximal stream position if ( nMetaRecEndPos > mnEndPos ) { - mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpInputStream->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } if (mnRecSize >= 4 ) // minimal escape length { sal_uInt16 nMode = 0, nLen = 0; - mpWMF->ReadUInt16( nMode ) + mpInputStream->ReadUInt16( nMode ) .ReadUInt16( nLen ); if ( ( nMode == W_MFCOMMENT ) && ( nLen >= 4 ) ) { sal_uInt32 nNewMagic = 0; // we have to read int32 for - mpWMF->ReadUInt32( nNewMagic ); // META_ESCAPE_ENHANCED_METAFILE CommentIdentifier + mpInputStream->ReadUInt32( nNewMagic ); // META_ESCAPE_ENHANCED_METAFILE CommentIdentifier if( nNewMagic == 0x2c2a4f4f && nLen >= 14 ) { sal_uInt16 nMagic2 = 0; - mpWMF->ReadUInt16( nMagic2 ); + mpInputStream->ReadUInt16( nMagic2 ); if( nMagic2 == 0x0a ) // 2nd half of magic { // continue with private escape sal_uInt32 nCheck = 0, nEsc = 0; - mpWMF->ReadUInt32( nCheck ) + mpInputStream->ReadUInt32( nCheck ) .ReadUInt32( nEsc ); sal_uInt32 nEscLen = nLen - 14; @@ -1047,15 +1044,15 @@ namespace emfio #endif std::unique_ptr<sal_Int8[]> pData; - if ( ( static_cast< sal_uInt64 >( nEscLen ) + mpWMF->Tell() ) > nMetaRecEndPos ) + if ( ( static_cast< sal_uInt64 >( nEscLen ) + mpInputStream->Tell() ) > nMetaRecEndPos ) { - mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpInputStream->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } if ( nEscLen > 0 ) { pData.reset(new sal_Int8[ nEscLen ]); - mpWMF->ReadBytes(pData.get(), nEscLen); + mpInputStream->ReadBytes(pData.get(), nEscLen); nCheckSum = rtl_crc32( nCheckSum, pData.get(), nEscLen ); } if ( nCheck == nCheckSum ) @@ -1113,7 +1110,7 @@ namespace emfio nCurRecSize = 0, nRemainingSize = 0, nEMFTotalSize = 0; sal_uInt16 nCheck = 0; - mpWMF->ReadUInt32( nComType ).ReadUInt32( nVersion ).ReadUInt16( nCheck ).ReadUInt32( nFlags ) + mpInputStream->ReadUInt32( nComType ).ReadUInt32( nVersion ).ReadUInt16( nCheck ).ReadUInt32( nFlags ) .ReadUInt32( nComRecCount ).ReadUInt32( nCurRecSize ) .ReadUInt32( nRemainingSize ).ReadUInt32( nEMFTotalSize ); // the nRemainingSize is not mentioned in MSDN documentation // but it seems to be required to read in data produced by OLE @@ -1124,7 +1121,7 @@ namespace emfio { // first EMF comment mnEMFRecCount = nComRecCount; mnEMFSize = nEMFTotalSize; - if (mnEMFSize > mpWMF->remainingSize()) + if (mnEMFSize > mpInputStream->remainingSize()) { SAL_WARN("vcl.wmf", "emf size claims to be larger than remaining data"); mpEMFStream.reset(); @@ -1146,7 +1143,7 @@ namespace emfio mpEMFStream.reset(); } - if (mpEMFStream && nCurRecSize > mpWMF->remainingSize()) + if (mpEMFStream && nCurRecSize > mpInputStream->remainingSize()) { SAL_WARN("vcl.wmf", "emf record size claims to be larger than remaining data"); mnEMFRecCount = 0xFFFFFFFF; @@ -1156,7 +1153,7 @@ namespace emfio if (mpEMFStream) { std::vector<sal_Int8> aBuf(nCurRecSize); - sal_uInt32 nCount = mpWMF->ReadBytes(aBuf.data(), nCurRecSize); + sal_uInt32 nCount = mpInputStream->ReadBytes(aBuf.data(), nCurRecSize); if( nCount == nCurRecSize ) mpEMFStream->WriteBytes(aBuf.data(), nCount); } @@ -1200,12 +1197,12 @@ namespace emfio bool WmfReader::ReadHeader() { - sal_uInt64 const nStrmPos = mpWMF->Tell(); + sal_uInt64 const nStrmPos = mpInputStream->Tell(); sal_uInt32 nPlaceableMetaKey(0); // if available read the METAFILEHEADER - mpWMF->ReadUInt32( nPlaceableMetaKey ); - if (!mpWMF->good()) + mpInputStream->ReadUInt32( nPlaceableMetaKey ); + if (!mpInputStream->good()) return false; tools::Rectangle aPlaceableBound; @@ -1220,34 +1217,34 @@ namespace emfio sal_Int16 nVal; // Skip reserved bytes - mpWMF->SeekRel(2); + mpInputStream->SeekRel(2); // BoundRect - mpWMF->ReadInt16( nVal ); + mpInputStream->ReadInt16( nVal ); aPlaceableBound.Left() = nVal; - mpWMF->ReadInt16( nVal ); + mpInputStream->ReadInt16( nVal ); aPlaceableBound.Top() = nVal; - mpWMF->ReadInt16( nVal ); + mpInputStream->ReadInt16( nVal ); aPlaceableBound.Right() = nVal; - mpWMF->ReadInt16( nVal ); + mpInputStream->ReadInt16( nVal ); aPlaceableBound.Bottom() = nVal; // inch - mpWMF->ReadUInt16( mnUnitsPerInch ); + mpInputStream->ReadUInt16( mnUnitsPerInch ); // reserved - mpWMF->SeekRel( 4 ); + mpInputStream->SeekRel( 4 ); // Skip and don't check the checksum - mpWMF->SeekRel( 2 ); + mpInputStream->SeekRel( 2 ); } else { mnUnitsPerInch = 96; - mpWMF->Seek( nStrmPos + 18 ); // set the streampos to the start of the metaactions - GetPlaceableBound( aPlaceableBound, mpWMF ); + mpInputStream->Seek( nStrmPos + 18 ); // set the streampos to the start of the metaactions + GetPlaceableBound( aPlaceableBound, mpInputStream ); // The image size is not known so normalize the calculated bounds so that the // resulting image is not too big @@ -1267,7 +1264,7 @@ namespace emfio << " b: " << aPlaceableBound.Right() << " r: " << aPlaceableBound.Bottom()); } - mpWMF->Seek( nStrmPos ); + mpInputStream->Seek( nStrmPos ); } SetWinOrg( aPlaceableBound.TopLeft() ); @@ -1290,27 +1287,27 @@ namespace emfio // read the METAHEADER sal_uInt32 nMetaKey(0); - mpWMF->ReadUInt32( nMetaKey ); // type and headersize - if (!mpWMF->good()) + mpInputStream->ReadUInt32( nMetaKey ); // type and headersize + if (!mpInputStream->good()) return false; if (nMetaKey != 0x00090001) { sal_uInt16 aNextWord(0); - mpWMF->ReadUInt16( aNextWord ); + mpInputStream->ReadUInt16( aNextWord ); if (nMetaKey != 0x10000 || aNextWord != 0x09) { - mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpInputStream->SetError( SVSTREAM_FILEFORMAT_ERROR ); return false; } } - mpWMF->SeekRel( 2 ); // Version (of Windows) - mpWMF->SeekRel( 4 ); // Size (of file in words) - mpWMF->SeekRel( 2 ); // NoObjects (maximum number of simultaneous objects) - mpWMF->SeekRel( 4 ); // MaxRecord (size of largest record in words) - mpWMF->SeekRel( 2 ); // NoParameters (Unused + mpInputStream->SeekRel( 2 ); // Version (of Windows) + mpInputStream->SeekRel( 4 ); // Size (of file in words) + mpInputStream->SeekRel( 2 ); // NoObjects (maximum number of simultaneous objects) + mpInputStream->SeekRel( 4 ); // MaxRecord (size of largest record in words) + mpInputStream->SeekRel( 2 ); // NoParameters (Unused - return mpWMF->good(); + return mpInputStream->good(); } void WmfReader::ReadWMF() @@ -1331,12 +1328,12 @@ namespace emfio SetWinExt( Size( 1, 1 ) ); SetDevExt( Size( 10000, 10000 ) ); - mnEndPos=mpWMF->Seek( STREAM_SEEK_TO_END ); - mpWMF->Seek( mnStartPos ); + mnEndPos=mpInputStream->Seek( STREAM_SEEK_TO_END ); + mpInputStream->Seek( mnStartPos ); if ( ReadHeader( ) ) { - nPos = mpWMF->Tell(); + nPos = mpInputStream->Tell(); if( mnEndPos - mnStartPos ) { @@ -1344,18 +1341,18 @@ namespace emfio while( true ) { mnCurrentAction++; - mpWMF->ReadUInt32(mnRecSize).ReadUInt16( nFunction ); + mpInputStream->ReadUInt32(mnRecSize).ReadUInt16( nFunction ); - if( mpWMF->GetError() + if( mpInputStream->GetError() || (mnRecSize < 3 ) || (mnRecSize == 3 && nFunction == 0 ) - || mpWMF->IsEof() + || mpInputStream->IsEof() ) { - if( mpWMF->IsEof() ) - mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + if( mpInputStream->IsEof() ) + mpInputStream->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } @@ -1409,20 +1406,20 @@ namespace emfio if (mnRecSize <= nMaxPossibleRecordSize) { nPos += mnRecSize * 2; - mpWMF->Seek(nPos); + mpInputStream->Seek(nPos); } else - mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpInputStream->SetError( SVSTREAM_FILEFORMAT_ERROR ); } } else - mpWMF->SetError( SVSTREAM_GENERALERROR ); + mpInputStream->SetError( SVSTREAM_GENERALERROR ); - if( !mpWMF->GetError() && !maBmpSaveList.empty() ) + if( !mpInputStream->GetError() && !maBmpSaveList.empty() ) ResolveBitmapActions( maBmpSaveList ); } - if ( mpWMF->GetError() ) - mpWMF->Seek( mnStartPos ); + if ( mpInputStream->GetError() ) + mpInputStream->Seek( mnStartPos ); } void WmfReader::GetPlaceableBound( tools::Rectangle& rPlaceableBound, SvStream* pStm ) |