diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-06-16 09:23:08 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-07-15 11:01:30 +0200 |
commit | a3f09ab5b0ad192d62a1df6126726e4c3ffa3e0a (patch) | |
tree | 5a8861c86be3edb405eba9297f6841a880d12eb8 | |
parent | c7470f5be441d8fe80155ff29605d74d5838be26 (diff) |
emfplus: reorganized some old filter aspects
Change-Id: I1949e851c560a81a461ec42a992f3b2cb0d019f8
-rw-r--r-- | emfio/inc/emfreader.hxx | 13 | ||||
-rw-r--r-- | emfio/inc/mtftools.hxx | 112 | ||||
-rw-r--r-- | emfio/inc/wmfreader.hxx | 55 | ||||
-rw-r--r-- | emfio/source/emfuno/xemfparser.cxx | 4 | ||||
-rw-r--r-- | emfio/source/reader/emfreader.cxx | 555 | ||||
-rw-r--r-- | emfio/source/reader/mtftools.cxx | 388 | ||||
-rw-r--r-- | emfio/source/reader/wmfreader.cxx | 584 |
7 files changed, 814 insertions, 897 deletions
diff --git a/emfio/inc/emfreader.hxx b/emfio/inc/emfreader.hxx index c4f7e17e574d..c926ee0a317e 100644 --- a/emfio/inc/emfreader.hxx +++ b/emfio/inc/emfreader.hxx @@ -26,24 +26,27 @@ namespace emfio { class EmfReader : public MtfTools { - bool bRecordPath; - sal_Int32 nRecordCount; - bool bEMFPlus; + private: + sal_Int32 mnRecordCount; + + bool mbRecordPath : 1; + bool mbEMFPlus : 1; bool ReadHeader(); // reads and converts the rectangle static tools::Rectangle ReadRectangle(sal_Int32, sal_Int32, sal_Int32, sal_Int32); public: - EmfReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile, FilterConfigItem* pConfigItem = nullptr); + EmfReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile); ~EmfReader(); bool ReadEnhWMF(); + private: template <class T> void ReadAndDrawPolyPolygon(); template <class T> void ReadAndDrawPolyLine(); template <class T> tools::Polygon ReadPolygon(sal_uInt32 nStartIndex, sal_uInt32 nPoints); - template <class T, class Drawer> void ReadAndDrawPolygon(Drawer drawer, const bool skipFirst); + template <class T> tools::Polygon ReadPolygonWithSkip(const bool skipFirst); tools::Rectangle ReadRectangle(); void ReadEMFPlusComment(sal_uInt32 length, bool& bHaveDC); diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx index f20925f5a147..9565df89cfe1 100644 --- a/emfio/inc/mtftools.hxx +++ b/emfio/inc/mtftools.hxx @@ -134,7 +134,6 @@ namespace emfio sal_uInt8 lfPitchAndFamily; OUString alfFaceName; }; - struct WMF_EXTERNALHEADER; } #define TA_NOUPDATECP 0x0000 @@ -423,8 +422,8 @@ namespace emfio RasterOp eRasterOp; Point aActPos; - WinMtfPathObj aPathObj; - WinMtfClipPath aClipPath; + WinMtfPathObj maPathObj; + WinMtfClipPath maClipPath; XForm aXForm; bool bFillStyleSelected; @@ -432,9 +431,9 @@ namespace emfio struct BSaveStruct { - BitmapEx aBmpEx; - tools::Rectangle aOutRect; - sal_uInt32 nWinRop; + BitmapEx aBmpEx; + tools::Rectangle aOutRect; + sal_uInt32 nWinRop; BSaveStruct(const Bitmap& rBmp, const tools::Rectangle& rOutRect, sal_uInt32 nRop) : aBmpEx(rBmp) @@ -449,17 +448,19 @@ namespace emfio {} }; - class MtfToolsWriter final + class MtfTools { - WinMtfPathObj aPathObj; - WinMtfClipPath aClipPath; + protected: + WinMtfPathObj maPathObj; + WinMtfClipPath maClipPath; WinMtfLineStyle maLatestLineStyle; WinMtfLineStyle maLineStyle; - WinMtfLineStyle m_NopLineStyle; + WinMtfLineStyle maNopLineStyle; WinMtfFillStyle maLatestFillStyle; WinMtfFillStyle maFillStyle; - WinMtfFillStyle m_NopFillStyle; + WinMtfFillStyle maNopFillStyle; + vcl::Font maLatestFont; vcl::Font maFont; sal_uInt32 mnLatestTextAlign; @@ -475,43 +476,52 @@ namespace emfio RasterOp meLatestRasterOp; RasterOp meRasterOp; - std::vector< std::unique_ptr<GDIObj> > vGDIObj; - + std::vector< std::unique_ptr<GDIObj> > mvGDIObj; Point maActPos; - WMFRasterOp mnRop; - bool mbNopMode; - bool mbFillStyleSelected; - bool mbClipNeedsUpdate; - bool mbComplexClip; - - std::vector< std::shared_ptr<SaveStruct> > vSaveStack; + std::vector< std::shared_ptr<SaveStruct> > mvSaveStack; sal_uInt32 mnGfxMode; sal_uInt32 mnMapMode; XForm maXForm; - sal_Int32 mnDevOrgX, mnDevOrgY; - sal_Int32 mnDevWidth, mnDevHeight; - sal_Int32 mnWinOrgX, mnWinOrgY; // aktuel window origin - sal_Int32 mnWinExtX, mnWinExtY; // aktuel window extend - bool mbIsMapWinSet; - bool mbIsMapDevSet; - - sal_Int32 mnPixX, mnPixY; // Reference Device in pixel - sal_Int32 mnMillX, mnMillY; // Reference Device in Mill - tools::Rectangle mrclFrame; // rectangle in logical units 1/100th mm - tools::Rectangle mrclBounds; + sal_Int32 mnDevOrgX; + sal_Int32 mnDevOrgY; + sal_Int32 mnDevWidth; + sal_Int32 mnDevHeight; + sal_Int32 mnWinOrgX; + sal_Int32 mnWinOrgY; + sal_Int32 mnWinExtX; + sal_Int32 mnWinExtY; + + sal_Int32 mnPixX; // Reference Device in pixel + sal_Int32 mnPixY; // Reference Device in pixel + sal_Int32 mnMillX; // Reference Device in Mill + sal_Int32 mnMillY; // Reference Device in Mill + tools::Rectangle mrclFrame; + tools::Rectangle mrclBounds; GDIMetaFile* mpGDIMetaFile; + SvStream* mpWMF; // the WMF/EMF file to be read + sal_uInt32 mnStartPos; + sal_uInt32 mnEndPos; + std::vector<std::unique_ptr<BSaveStruct>> maBmpSaveList; + + bool mbNopMode : 1; + bool mbFillStyleSelected : 1; + bool mbClipNeedsUpdate : 1; + bool mbComplexClip : 1; + bool mbIsMapWinSet : 1; + bool mbIsMapDevSet : 1; + void UpdateLineStyle(); void UpdateFillStyle(); Point ImplMap(const Point& rPt); Point ImplScale(const Point& rPt); Size ImplMap(const Size& rSize, bool bDoWorldTransform = true); - tools::Rectangle ImplMap(const tools::Rectangle& rRectangle); + tools::Rectangle ImplMap(const tools::Rectangle& rRectangle); void ImplMap(vcl::Font& rFont); tools::Polygon& ImplMap(tools::Polygon& rPolygon); tools::PolyPolygon& ImplMap(tools::PolyPolygon& rPolyPolygon); @@ -559,11 +569,7 @@ namespace emfio void CreateObject(std::unique_ptr<GDIObj> pObject); void CreateObjectIndexed(sal_Int32 nIndex, std::unique_ptr<GDIObj> pObject); - - void CreateObject() - { - CreateObject(o3tl::make_unique<GDIObj>()); - } + void CreateObject(); void DeleteObject(sal_Int32 nIndex); void SelectObject(sal_Int32 nIndex); @@ -571,9 +577,9 @@ namespace emfio const vcl::Font& GetFont() const { return maFont; } void SetTextLayoutMode(ComplexTextLayoutFlags nLayoutMode); - void ClearPath() { aPathObj.Init(); }; - void ClosePath() { aPathObj.ClosePath(); }; - const tools::PolyPolygon& GetPathObj() { return aPathObj; }; + void ClearPath() { maPathObj.Init(); }; + void ClosePath() { maPathObj.ClosePath(); }; + const tools::PolyPolygon& GetPathObj() { return maPathObj; }; void MoveTo(const Point& rPoint, bool bRecordPath = false); void LineTo(const Point& rPoint, bool bRecordPath = false); @@ -631,33 +637,9 @@ namespace emfio void PassEMFPlus(void* pBuffer, sal_uInt32 nLength); void PassEMFPlusHeaderInfo(); - explicit MtfToolsWriter(GDIMetaFile& rGDIMetaFile); - ~MtfToolsWriter(); - }; - - class MtfTools - { - protected: - std::unique_ptr<MtfToolsWriter> pOut; - SvStream* pWMF; // the WMF/EMF file to be read - - sal_uInt32 nStartPos, nEndPos; - std::vector<std::unique_ptr<BSaveStruct>> aBmpSaveList; - - FilterConfigItem* pFilterConfigItem; - - css::uno::Reference< css::task::XStatusIndicator > xStatusIndicator; - - // assures aSampledBrush is the actual brush of the GDIMetaFile - Color ReadColor(); - void Callback(sal_uInt16 nPercent); - MtfTools( - GDIMetaFile& rGDIMetaFile, - SvStream& rStreamWMF, - FilterConfigItem* pConfigItem - ); + explicit MtfTools(GDIMetaFile& rGDIMetaFile, SvStream& rStreamWMF); ~MtfTools(); }; } diff --git a/emfio/inc/wmfreader.hxx b/emfio/inc/wmfreader.hxx index 734becbb5886..e0566bb95cfb 100644 --- a/emfio/inc/wmfreader.hxx +++ b/emfio/inc/wmfreader.hxx @@ -25,61 +25,29 @@ namespace emfio { - struct WMF_EXTERNALHEADER - { - sal_uInt16 xExt; - sal_uInt16 yExt; - - /** One of the following values: - <ul> - <li>MM_TEXT</li> - <li>MM_LOMETRIC</li> - <li>MM_HIMETRIC</li> - <li>MM_LOENGLISH</li> - <li>MM_HIENGLISH</li> - <li>MM_TWIPS</li> - <li>MM_ISOTROPIC</li> - <li>MM_ANISOTROPIC</li> - </ul> - If this value is 0, then no external mapmode has been defined, - the internal one should then be used. - */ - sal_uInt16 mapMode; - - WMF_EXTERNALHEADER() : - xExt(0), - yExt(0), - mapMode(0) - { - } - }; - class WmfReader : public MtfTools { private: - - sal_uInt16 nUnitsPerInch; - sal_uInt32 nRecSize; + sal_uInt16 mnUnitsPerInch; + sal_uInt32 mnRecSize; // embedded EMF data - std::unique_ptr<SvMemoryStream> pEMFStream; + std::unique_ptr<SvMemoryStream> mpEMFStream; // total number of comment records containing EMF data - sal_uInt32 nEMFRecCount; + sal_uInt32 mnEMFRecCount; // number of EMF records read - sal_uInt32 nEMFRec; + sal_uInt32 mnEMFRec; // total size of embedded EMF data - sal_uInt32 nEMFSize; + sal_uInt32 mnEMFSize; - sal_uInt32 nSkipActions; - sal_uInt32 nCurrentAction; - - WMF_EXTERNALHEADER* pExternalHeader; + sal_uInt32 mnSkipActions; + sal_uInt32 mnCurrentAction; // reads header of the WMF-Datei - bool ReadHeader(); + bool ReadHeader(); // reads parameters of the record with the functionnumber nFunction. void ReadRecordParams(sal_uInt16 nFunction); @@ -91,10 +59,7 @@ namespace emfio void GetPlaceableBound(tools::Rectangle& rSize, SvStream* pStrm); public: - - WmfReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile, - FilterConfigItem* pConfigItem, - WMF_EXTERNALHEADER* pExtHeader = nullptr); + WmfReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile); // read WMF file from stream and fill the GDIMetaFile void ReadWMF(); diff --git a/emfio/source/emfuno/xemfparser.cxx b/emfio/source/emfuno/xemfparser.cxx index e532d903e047..89d34dff1521 100644 --- a/emfio/source/emfuno/xemfparser.cxx +++ b/emfio/source/emfuno/xemfparser.cxx @@ -186,11 +186,11 @@ namespace emfio if (nMetaType == 0x464d4520) { - emfio::EmfReader(*pStream, aMtf, nullptr).ReadEnhWMF(); + emfio::EmfReader(*pStream, aMtf).ReadEnhWMF(); } else { - emfio::WmfReader(*pStream, aMtf, nullptr).ReadWMF(); + emfio::WmfReader(*pStream, aMtf).ReadWMF(); } pStream->SetEndian(nOrigNumberFormat); diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 9fd005578ab3..ada03d278e03 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -380,42 +380,45 @@ bool ImplReadRegion( tools::PolyPolygon& rPolyPoly, SvStream& rStream, sal_uInt3 namespace emfio { - EmfReader::EmfReader(SvStream& rStream,GDIMetaFile& rGDIMetaFile,FilterConfigItem* pConfigItem) - : MtfTools(rGDIMetaFile, rStream , pConfigItem) - , bRecordPath(false) - , nRecordCount(0) - , bEMFPlus(false) - {} + EmfReader::EmfReader(SvStream& rStream,GDIMetaFile& rGDIMetaFile) + : MtfTools(rGDIMetaFile, rStream) + , mnRecordCount(0) + , mbRecordPath(false) + , mbEMFPlus(false) + { + } EmfReader::~EmfReader() - {} + { + } void EmfReader::ReadEMFPlusComment(sal_uInt32 length, bool& bHaveDC) { - if (!bEMFPlus) { - pOut->PassEMFPlusHeaderInfo(); + if (!mbEMFPlus) + { + PassEMFPlusHeaderInfo(); #if OSL_DEBUG_LEVEL > 1 // debug code - write the stream to debug file /tmp/emf-stream.emf - sal_uInt64 const pos = pWMF->Tell(); - pWMF->Seek(0); + sal_uInt64 const pos = mpWMF->Tell(); + mpWMF->Seek(0); SvFileStream file( OUString( "/tmp/emf-stream.emf" ), StreamMode::WRITE | StreamMode::TRUNC ); - pWMF->WriteStream(file); + mpWMF->WriteStream(file); file.Flush(); file.Close(); - pWMF->Seek( pos ); + mpWMF->Seek( pos ); #endif } - bEMFPlus = true; - sal_uInt64 const pos = pWMF->Tell(); + mbEMFPlus = true; + sal_uInt64 const pos = mpWMF->Tell(); void *buffer = malloc( length ); - pOut->PassEMFPlus( buffer, pWMF->ReadBytes(buffer, length) ); + PassEMFPlus( buffer, mpWMF->ReadBytes(buffer, length) ); free( buffer ); - pWMF->Seek( pos ); + mpWMF->Seek( pos ); bHaveDC = false; @@ -428,7 +431,7 @@ namespace emfio sal_uInt16 type(0), flags(0); sal_uInt32 size(0), dataSize(0); - pWMF->ReadUInt16( type ).ReadUInt16( flags ).ReadUInt32( size ).ReadUInt32( dataSize ); + mpWMF->ReadUInt16( type ).ReadUInt16( flags ).ReadUInt32( size ).ReadUInt32( dataSize ); nRemainder -= nRequiredHeaderSize; SAL_INFO ("vcl.emf", "\t\tEMF+ record type: " << std::hex << type << std::dec); @@ -447,32 +450,30 @@ namespace emfio size-nRequiredHeaderSize : 0; // clip to available size nRemainingRecordData = std::min(nRemainingRecordData, nRemainder); - pWMF->SeekRel(nRemainingRecordData); + mpWMF->SeekRel(nRemainingRecordData); nRemainder -= nRemainingRecordData; } - pWMF->SeekRel(nRemainder); + mpWMF->SeekRel(nRemainder); } /** * Reads polygons from the stream. * The \<class T> parameter is for the type of the points (sal_uInt32 or sal_uInt16). - * The \<class Drawer> parameter is a c++11 lambda for the method that will draw the polygon. * skipFirst: if the first point read is the 0th point or the 1st point in the array. * */ - template <class T, class Drawer> - void EmfReader::ReadAndDrawPolygon(Drawer drawer, const bool skipFirst) + template <class T> + tools::Polygon EmfReader::ReadPolygonWithSkip(const bool skipFirst) { sal_uInt32 nPoints(0), nStartIndex(0); - pWMF->SeekRel( 16 ); - pWMF->ReadUInt32( nPoints ); + mpWMF->SeekRel( 16 ); + mpWMF->ReadUInt32( nPoints ); if (skipFirst) { nPoints ++; nStartIndex ++; } - tools::Polygon aPolygon = ReadPolygon<T>(nStartIndex, nPoints); - drawer(pOut, aPolygon, skipFirst, bRecordPath); + return ReadPolygon<T>(nStartIndex, nPoints); } /** @@ -480,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 - * pWMF: the stream containing the polygons + * mpWMF: the stream containing the polygons * */ template <class T> tools::Polygon EmfReader::ReadPolygon(sal_uInt32 nStartIndex, sal_uInt32 nPoints) @@ -491,11 +492,11 @@ namespace emfio return tools::Polygon(); tools::Polygon aPolygon(nPoints); - for (sal_uInt32 i = nStartIndex ; i < nPoints && pWMF->good(); i++ ) + for (sal_uInt32 i = nStartIndex ; i < nPoints && mpWMF->good(); i++ ) { T nX, nY; - *pWMF >> nX >> nY; - if (!pWMF->good()) + *mpWMF >> nX >> nY; + if (!mpWMF->good()) { SAL_WARN("vcl.emf", "short read on polygon, truncating"); aPolygon.SetSize(i); @@ -516,29 +517,29 @@ namespace emfio { sal_uInt32 nPoints; sal_uInt32 i, nNumberOfPolylines( 0 ), nCount( 0 ); - pWMF->SeekRel( 0x10 ); // TODO Skipping Bounds. A 128-bit WMF RectL object (specifies the bounding rectangle in device units.) - pWMF->ReadUInt32( nNumberOfPolylines ); - pWMF->ReadUInt32( nCount ); // total number of points in all polylines - if (pWMF->Tell() >= nEndPos) + 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) return; // taking the amount of points of each polygon, retrieving the total number of points - if ( pWMF->good() && + if ( mpWMF->good() && ( nNumberOfPolylines < SAL_MAX_UINT32 / sizeof( sal_uInt16 ) ) && - ( nNumberOfPolylines * sizeof( sal_uInt16 ) ) <= ( nEndPos - pWMF->Tell() ) + ( nNumberOfPolylines * sizeof( sal_uInt16 ) ) <= ( mnEndPos - mpWMF->Tell() ) ) { std::unique_ptr< sal_uInt32[] > pnPolylinePointCount( new sal_uInt32[ nNumberOfPolylines ] ); - for ( i = 0; i < nNumberOfPolylines && pWMF->good(); i++ ) + for ( i = 0; i < nNumberOfPolylines && mpWMF->good(); i++ ) { - pWMF->ReadUInt32( nPoints ); + mpWMF->ReadUInt32( nPoints ); pnPolylinePointCount[ i ] = nPoints; } // Get polyline points: - for ( i = 0; ( i < nNumberOfPolylines ) && pWMF->good(); i++ ) + for ( i = 0; ( i < nNumberOfPolylines ) && mpWMF->good(); i++ ) { tools::Polygon aPolygon = ReadPolygon< T >( 0, pnPolylinePointCount[ i ] ); - pOut->DrawPolyLine( aPolygon, false, bRecordPath ); + DrawPolyLine( aPolygon, false, mbRecordPath); } } } @@ -563,41 +564,41 @@ namespace emfio void EmfReader::ReadAndDrawPolyPolygon() { sal_uInt32 nPoly(0), nGesPoints(0), nReadPoints(0); - pWMF->SeekRel( 0x10 ); + mpWMF->SeekRel( 0x10 ); // Number of polygons - pWMF->ReadUInt32( nPoly ).ReadUInt32( nGesPoints ); - if (pWMF->Tell() >= nEndPos) + mpWMF->ReadUInt32( nPoly ).ReadUInt32( nGesPoints ); + if (mpWMF->Tell() >= mnEndPos) return; - if (!pWMF->good()) + if (!mpWMF->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) > nEndPos - pWMF->Tell()) + if (nPoly * sizeof(sal_uInt16) > mnEndPos - mpWMF->Tell()) return; // Get number of points in each polygon std::vector<sal_uInt16> aPoints(nPoly); - for (sal_uInt32 i = 0; i < nPoly && pWMF->good(); ++i) + for (sal_uInt32 i = 0; i < nPoly && mpWMF->good(); ++i) { sal_uInt32 nPoints(0); - pWMF->ReadUInt32( nPoints ); + mpWMF->ReadUInt32( nPoints ); aPoints[i] = (sal_uInt16)nPoints; } - if ( pWMF->good() && ( nGesPoints * (sizeof(T)+sizeof(T)) ) <= ( nEndPos - pWMF->Tell() ) ) + if ( mpWMF->good() && ( nGesPoints * (sizeof(T)+sizeof(T)) ) <= ( mnEndPos - mpWMF->Tell() ) ) { // Get polygon points tools::PolyPolygon aPolyPoly(nPoly, nPoly); - for (sal_uInt32 i = 0; i < nPoly && pWMF->good(); ++i) + for (sal_uInt32 i = 0; i < nPoly && mpWMF->good(); ++i) { const sal_uInt16 nPointCount(aPoints[i]); std::vector<Point> aPtAry(nPointCount); - for (sal_uInt16 j = 0; j < nPointCount && pWMF->good(); ++j) + for (sal_uInt16 j = 0; j < nPointCount && mpWMF->good(); ++j) { T nX(0), nY(0); - *pWMF >> nX >> nY; + *mpWMF >> nX >> nY; aPtAry[j] = Point( nX, nY ); ++nReadPoints; } @@ -605,7 +606,7 @@ namespace emfio aPolyPoly.Insert(tools::Polygon(aPtAry.size(), aPtAry.data())); } - pOut->DrawPolyPolygon(aPolyPoly, bRecordPath); + DrawPolyPolygon(aPolyPoly, mbRecordPath); } OSL_ENSURE(nReadPoints == nGesPoints, "The number Points processed from EMR_POLYPOLYGON is unequal imported number (!)"); @@ -624,26 +625,26 @@ namespace emfio static bool bEnableEMFPlus = ( getenv( "EMF_PLUS_DISABLE" ) == nullptr ); - while( bStatus && nRecordCount-- && pWMF->good()) + while( bStatus && mnRecordCount-- && mpWMF->good()) { sal_uInt32 nRecType(0), nRecSize(0); - pWMF->ReadUInt32(nRecType).ReadUInt32(nRecSize); + mpWMF->ReadUInt32(nRecType).ReadUInt32(nRecSize); - if ( !pWMF->good() || ( nRecSize < 8 ) || ( nRecSize & 3 ) ) // Parameters are always divisible by 4 + if ( !mpWMF->good() || ( nRecSize < 8 ) || ( nRecSize & 3 ) ) // Parameters are always divisible by 4 { bStatus = false; break; } - auto nCurPos = pWMF->Tell(); + auto nCurPos = mpWMF->Tell(); - if (nEndPos < nCurPos - 8) + if (mnEndPos < nCurPos - 8) { bStatus = false; break; } - const sal_uInt32 nMaxPossibleRecSize = nEndPos - (nCurPos - 8); + const sal_uInt32 nMaxPossibleRecSize = mnEndPos - (nCurPos - 8); if (nRecSize > nMaxPossibleRecSize) { bStatus = false; @@ -652,11 +653,11 @@ namespace emfio nNextPos = nCurPos + (nRecSize - 8); - if( !aBmpSaveList.empty() + if( !maBmpSaveList.empty() && ( nRecType != EMR_STRETCHBLT ) && ( nRecType != EMR_STRETCHDIBITS ) ) { - pOut->ResolveBitmapActions( aBmpSaveList ); + ResolveBitmapActions( maBmpSaveList ); } bool bFlag = false; @@ -666,14 +667,14 @@ namespace emfio if( bEnableEMFPlus && nRecType == EMR_COMMENT ) { sal_uInt32 length; - pWMF->ReadUInt32( length ); + mpWMF->ReadUInt32( length ); SAL_INFO("vcl.emf", "\tGDI comment, length: " << length); - if( pWMF->good() && length >= 4 && length <= pWMF->remainingSize() ) { + if( mpWMF->good() && length >= 4 && length <= mpWMF->remainingSize() ) { sal_uInt32 nCommentId; - pWMF->ReadUInt32( nCommentId ); + mpWMF->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); @@ -698,32 +699,27 @@ namespace emfio } } } - else if( !bEMFPlus || bHaveDC || nRecType == EMR_EOF ) + else if( !mbEMFPlus || bHaveDC || nRecType == EMR_EOF ) { switch( nRecType ) { case EMR_POLYBEZIERTO : - ReadAndDrawPolygon<sal_Int32>( [] ( std::unique_ptr<MtfToolsWriter> &pWinMtfOutput, tools::Polygon& rPolygon, bool aTo, bool aRecordPath ) - { pWinMtfOutput->DrawPolyBezier( rPolygon, aTo, aRecordPath ); }, true ); + DrawPolyBezier(ReadPolygonWithSkip<sal_Int32>(true), true, mbRecordPath); break; case EMR_POLYBEZIER : - ReadAndDrawPolygon<sal_Int32>( [] ( std::unique_ptr<MtfToolsWriter> &pWinMtfOutput, tools::Polygon& rPolygon, bool aTo, bool aRecordPath ) - { pWinMtfOutput->DrawPolyBezier( rPolygon, aTo, aRecordPath ); }, false ); + DrawPolyBezier(ReadPolygonWithSkip<sal_Int32>(false), false, mbRecordPath); break; case EMR_POLYGON : - ReadAndDrawPolygon<sal_Int32>( [] ( std::unique_ptr<MtfToolsWriter> &pWinMtfOutput, tools::Polygon& rPolygon, bool /*aTo*/, bool aRecordPath ) - { pWinMtfOutput->DrawPolygon( rPolygon, aRecordPath ); }, false ); + DrawPolygon(ReadPolygonWithSkip<sal_Int32>(false), mbRecordPath); break; case EMR_POLYLINETO : - ReadAndDrawPolygon<sal_Int32>( [] ( std::unique_ptr<MtfToolsWriter> &pWinMtfOutput, tools::Polygon& rPolygon, bool aTo, bool aRecordPath ) - { pWinMtfOutput->DrawPolyLine( rPolygon, aTo, aRecordPath ); }, true ); + DrawPolyLine(ReadPolygonWithSkip<sal_Int32>(true), true, mbRecordPath); break; case EMR_POLYLINE : - ReadAndDrawPolygon<sal_Int32>( [] ( std::unique_ptr<MtfToolsWriter> &pWinMtfOutput, tools::Polygon& rPolygon, bool aTo, bool aRecordPath ) - { pWinMtfOutput->DrawPolyLine( rPolygon, aTo, aRecordPath ); }, false ); + DrawPolyLine(ReadPolygonWithSkip<sal_Int32>(false), false, mbRecordPath); break; case EMR_POLYPOLYLINE : @@ -736,69 +732,69 @@ namespace emfio case EMR_SETWINDOWEXTEX : { - pWMF->ReadUInt32( nW ).ReadUInt32( nH ); - pOut->SetWinExt( Size( nW, nH ), true); + mpWMF->ReadUInt32( nW ).ReadUInt32( nH ); + SetWinExt( Size( nW, nH ), true); } break; case EMR_SETWINDOWORGEX : { - pWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); - pOut->SetWinOrg( Point( nX32, nY32 ), true); + mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); + SetWinOrg( Point( nX32, nY32 ), true); } break; case EMR_SCALEWINDOWEXTEX : { - pWMF->ReadUInt32( nNom1 ).ReadUInt32( nDen1 ).ReadUInt32( nNom2 ).ReadUInt32( nDen2 ); - pOut->ScaleWinExt( (double)nNom1 / nDen1, (double)nNom2 / nDen2 ); + mpWMF->ReadUInt32( nNom1 ).ReadUInt32( nDen1 ).ReadUInt32( nNom2 ).ReadUInt32( nDen2 ); + ScaleWinExt( (double)nNom1 / nDen1, (double)nNom2 / nDen2 ); } break; case EMR_SETVIEWPORTORGEX : { - pWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); - pOut->SetDevOrg( Point( nX32, nY32 ) ); + mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); + SetDevOrg( Point( nX32, nY32 ) ); } break; case EMR_SCALEVIEWPORTEXTEX : { - pWMF->ReadUInt32( nNom1 ).ReadUInt32( nDen1 ).ReadUInt32( nNom2 ).ReadUInt32( nDen2 ); - pOut->ScaleDevExt( (double)nNom1 / nDen1, (double)nNom2 / nDen2 ); + mpWMF->ReadUInt32( nNom1 ).ReadUInt32( nDen1 ).ReadUInt32( nNom2 ).ReadUInt32( nDen2 ); + ScaleDevExt( (double)nNom1 / nDen1, (double)nNom2 / nDen2 ); } break; case EMR_SETVIEWPORTEXTEX : { - pWMF->ReadUInt32( nW ).ReadUInt32( nH ); - pOut->SetDevExt( Size( nW, nH ) ); + mpWMF->ReadUInt32( nW ).ReadUInt32( nH ); + SetDevExt( Size( nW, nH ) ); } break; case EMR_EOF : - nRecordCount = 0; + mnRecordCount = 0; break; case EMR_SETPIXELV : { - pWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); - pOut->DrawPixel( Point( nX32, nY32 ), ReadColor() ); + mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); + DrawPixel( Point( nX32, nY32 ), ReadColor() ); } break; case EMR_SETMAPMODE : { sal_uInt32 nMapMode; - pWMF->ReadUInt32( nMapMode ); - pOut->SetMapMode( nMapMode ); + mpWMF->ReadUInt32( nMapMode ); + SetMapMode( nMapMode ); } break; case EMR_SETBKMODE : { - pWMF->ReadUInt32( nDat32 ); - pOut->SetBkMode( static_cast<BkMode>(nDat32) ); + mpWMF->ReadUInt32( nDat32 ); + SetBkMode( static_cast<BkMode>(nDat32) ); } break; @@ -807,74 +803,74 @@ namespace emfio case EMR_SETROP2 : { - pWMF->ReadUInt32( nDat32 ); - pOut->SetRasterOp( (WMFRasterOp)nDat32 ); + mpWMF->ReadUInt32( nDat32 ); + SetRasterOp( (WMFRasterOp)nDat32 ); } break; case EMR_SETSTRETCHBLTMODE : { - pWMF->ReadUInt32( nStretchBltMode ); + mpWMF->ReadUInt32( nStretchBltMode ); } break; case EMR_SETTEXTALIGN : { - pWMF->ReadUInt32( nDat32 ); - pOut->SetTextAlign( nDat32 ); + mpWMF->ReadUInt32( nDat32 ); + SetTextAlign( nDat32 ); } break; case EMR_SETTEXTCOLOR : { - pOut->SetTextColor( ReadColor() ); + SetTextColor( ReadColor() ); } break; case EMR_SETBKCOLOR : { - pOut->SetBkColor( ReadColor() ); + SetBkColor( ReadColor() ); } break; case EMR_OFFSETCLIPRGN : { - pWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); - pOut->MoveClipRegion( Size( nX32, nY32 ) ); + mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); + MoveClipRegion( Size( nX32, nY32 ) ); } break; case EMR_MOVETOEX : { - pWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); - pOut->MoveTo( Point( nX32, nY32 ), bRecordPath ); + mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); + MoveTo( Point( nX32, nY32 ), mbRecordPath); } break; case EMR_INTERSECTCLIPRECT : { - pWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ); - pOut->IntersectClipRect( ReadRectangle( nX32, nY32, nx32, ny32 ) ); + mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ); + IntersectClipRect( ReadRectangle( nX32, nY32, nx32, ny32 ) ); } break; case EMR_SAVEDC : { - pOut->Push(); + Push(); } break; case EMR_RESTOREDC : { - pOut->Pop(); + Pop(); } break; case EMR_SETWORLDTRANSFORM : { XForm aTempXForm; - *pWMF >> aTempXForm; - pOut->SetWorldTransform( aTempXForm ); + *mpWMF >> aTempXForm; + SetWorldTransform( aTempXForm ); } break; @@ -882,22 +878,22 @@ namespace emfio { sal_uInt32 nMode; XForm aTempXForm; - *pWMF >> aTempXForm; - pWMF->ReadUInt32( nMode ); - pOut->ModifyWorldTransform( aTempXForm, nMode ); + *mpWMF >> aTempXForm; + mpWMF->ReadUInt32( nMode ); + ModifyWorldTransform( aTempXForm, nMode ); } break; case EMR_SELECTOBJECT : { - pWMF->ReadUInt32( nIndex ); - pOut->SelectObject( nIndex ); + mpWMF->ReadUInt32( nIndex ); + SelectObject( nIndex ); } break; case EMR_CREATEPEN : { - pWMF->ReadUInt32( nIndex ); + mpWMF->ReadUInt32( nIndex ); if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) { @@ -907,7 +903,7 @@ namespace emfio // #fdo39428 Remove SvStream operator>>(long&) sal_Int32 nTmpW(0), nTmpH(0); - pWMF->ReadUInt32( nStyle ).ReadInt32( nTmpW ).ReadInt32( nTmpH ); + mpWMF->ReadUInt32( nStyle ).ReadInt32( nTmpW ).ReadInt32( nTmpH ); aSize.Width() = nTmpW; aSize.Height() = nTmpH; @@ -980,7 +976,7 @@ namespace emfio default : aLineInfo.SetLineJoin ( basegfx::B2DLineJoin::NONE ); } - pOut->CreateObjectIndexed(nIndex, o3tl::make_unique<WinMtfLineStyle>( ReadColor(), aLineInfo, bTransparent )); + CreateObjectIndexed(nIndex, o3tl::make_unique<WinMtfLineStyle>( ReadColor(), aLineInfo, bTransparent )); } } break; @@ -991,12 +987,12 @@ namespace emfio sal_uInt32 offBmi, cbBmi, offBits, cbBits, nStyle, nWidth, nBrushStyle, elpNumEntries; Color aColorRef; - pWMF->ReadUInt32( nIndex ); + mpWMF->ReadUInt32( nIndex ); if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) { - pWMF->ReadUInt32( offBmi ).ReadUInt32( cbBmi ).ReadUInt32( offBits ).ReadUInt32( cbBits ). ReadUInt32( nStyle ).ReadUInt32( nWidth ).ReadUInt32( nBrushStyle ); + mpWMF->ReadUInt32( offBmi ).ReadUInt32( cbBmi ).ReadUInt32( offBits ).ReadUInt32( cbBits ). ReadUInt32( nStyle ).ReadUInt32( nWidth ).ReadUInt32( nBrushStyle ); aColorRef = ReadColor(); - pWMF->ReadInt32( elpHatch ).ReadUInt32( elpNumEntries ); + mpWMF->ReadInt32( elpHatch ).ReadUInt32( elpNumEntries ); LineInfo aLineInfo; if ( nWidth ) @@ -1070,7 +1066,7 @@ namespace emfio default : aLineInfo.SetLineJoin ( basegfx::B2DLineJoin::NONE ); } - pOut->CreateObjectIndexed(nIndex, o3tl::make_unique<WinMtfLineStyle>( aColorRef, aLineInfo, bTransparent )); + CreateObjectIndexed(nIndex, o3tl::make_unique<WinMtfLineStyle>( aColorRef, aLineInfo, bTransparent )); } } break; @@ -1078,147 +1074,147 @@ namespace emfio case EMR_CREATEBRUSHINDIRECT : { sal_uInt32 nStyle; - pWMF->ReadUInt32( nIndex ); + mpWMF->ReadUInt32( nIndex ); if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) { - pWMF->ReadUInt32( nStyle ); - pOut->CreateObjectIndexed(nIndex, o3tl::make_unique<WinMtfFillStyle>( ReadColor(), ( nStyle == BS_HOLLOW ) )); + mpWMF->ReadUInt32( nStyle ); + CreateObjectIndexed(nIndex, o3tl::make_unique<WinMtfFillStyle>( ReadColor(), ( nStyle == BS_HOLLOW ) )); } } break; case EMR_DELETEOBJECT : { - pWMF->ReadUInt32( nIndex ); + mpWMF->ReadUInt32( nIndex ); if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) - pOut->DeleteObject( nIndex ); + DeleteObject( nIndex ); } break; case EMR_ELLIPSE : { - pWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ); - pOut->DrawEllipse( ReadRectangle( nX32, nY32, nx32, ny32 ) ); + mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ); + DrawEllipse( ReadRectangle( nX32, nY32, nx32, ny32 ) ); } break; case EMR_RECTANGLE : { - pWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ); - pOut->DrawRect( ReadRectangle( nX32, nY32, nx32, ny32 ) ); + mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ); + DrawRect( ReadRectangle( nX32, nY32, nx32, ny32 ) ); } break; case EMR_ROUNDRECT : { - pWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nW ).ReadUInt32( nH ); + mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nW ).ReadUInt32( nH ); Size aSize( Size( nW, nH ) ); - pOut->DrawRoundRect( ReadRectangle( nX32, nY32, nx32, ny32 ), aSize ); + DrawRoundRect( ReadRectangle( nX32, nY32, nx32, ny32 ), aSize ); } break; case EMR_ARC : { sal_uInt32 nStartX, nStartY, nEndX, nEndY; - pWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); - pOut->DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) ); + mpWMF->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; case EMR_CHORD : { sal_uInt32 nStartX, nStartY, nEndX, nEndY; - pWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); - pOut->DrawChord( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ) ); + mpWMF->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; case EMR_PIE : { sal_uInt32 nStartX, nStartY, nEndX, nEndY; - pWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); + mpWMF->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 // semantics. start==end means full ellipse here. if( nStartX == nEndX && nStartY == nEndY ) - pOut->DrawEllipse( aRect ); + DrawEllipse( aRect ); else - pOut->DrawPie( aRect, Point( nStartX, nStartY ), Point( nEndX, nEndY ) ); + DrawPie( aRect, Point( nStartX, nStartY ), Point( nEndX, nEndY ) ); } break; case EMR_LINETO : { - pWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); - pOut->LineTo( Point( nX32, nY32 ), bRecordPath ); + mpWMF->ReadInt32( nX32 ).ReadInt32( nY32 ); + LineTo( Point( nX32, nY32 ), mbRecordPath); } break; case EMR_ARCTO : { sal_uInt32 nStartX, nStartY, nEndX, nEndY; - pWMF->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY ).ReadUInt32( nEndX ).ReadUInt32( nEndY ); - pOut->DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ), true ); + mpWMF->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; case EMR_BEGINPATH : { - pOut->ClearPath(); - bRecordPath = true; + ClearPath(); + mbRecordPath = true; } break; case EMR_ABORTPATH : - pOut->ClearPath(); + ClearPath(); SAL_FALLTHROUGH; case EMR_ENDPATH : - bRecordPath = false; + mbRecordPath = false; break; case EMR_CLOSEFIGURE : - pOut->ClosePath(); + ClosePath(); break; case EMR_FILLPATH : - pOut->StrokeAndFillPath( false, true ); + StrokeAndFillPath( false, true ); break; case EMR_STROKEANDFILLPATH : - pOut->StrokeAndFillPath( true, true ); + StrokeAndFillPath( true, true ); break; case EMR_STROKEPATH : - pOut->StrokeAndFillPath( true, false ); + StrokeAndFillPath( true, false ); break; case EMR_SELECTCLIPPATH : { sal_Int32 nClippingMode; - pWMF->ReadInt32(nClippingMode); - pOut->SetClipPath(pOut->GetPathObj(), nClippingMode, true); + mpWMF->ReadInt32(nClippingMode); + SetClipPath(GetPathObj(), nClippingMode, true); } break; case EMR_EXTSELECTCLIPRGN : { sal_Int32 nClippingMode, cbRgnData; - pWMF->ReadInt32(cbRgnData); - pWMF->ReadInt32(nClippingMode); + mpWMF->ReadInt32(cbRgnData); + mpWMF->ReadInt32(nClippingMode); // This record's region data should be ignored if mode // is RGN_COPY - see EMF spec section 2.3.2.2 if (nClippingMode == RGN_COPY) { - pOut->SetDefaultClipPath(); + SetDefaultClipPath(); } else { tools::PolyPolygon aPolyPoly; if (cbRgnData) - ImplReadRegion(aPolyPoly, *pWMF, nRecSize); - pOut->SetClipPath(aPolyPoly, nClippingMode, false); + ImplReadRegion(aPolyPoly, *mpWMF, nRecSize); + SetClipPath(aPolyPoly, nClippingMode, false); } } @@ -1234,14 +1230,14 @@ namespace emfio sal_uInt32 BkColorSrc(0), iUsageSrc(0), offBmiSrc(0); sal_uInt32 cbBmiSrc(0), offBitsSrc(0), cbBitsSrc(0); - sal_uInt32 nStart = pWMF->Tell() - 8; - pWMF->SeekRel( 0x10 ); + sal_uInt32 nStart = mpWMF->Tell() - 8; + mpWMF->SeekRel( 0x10 ); - pWMF->ReadInt32( xDest ).ReadInt32( yDest ).ReadInt32( cxDest ).ReadInt32( cyDest ); - *pWMF >> aFunc; - pWMF->ReadInt32( xSrc ).ReadInt32( ySrc ); - *pWMF >> xformSrc; - pWMF->ReadUInt32( BkColorSrc ).ReadUInt32( iUsageSrc ).ReadUInt32( offBmiSrc ).ReadUInt32( cbBmiSrc ) + 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 ) .ReadUInt32( offBitsSrc ).ReadUInt32( cbBitsSrc ).ReadInt32( cxSrc ).ReadInt32( cySrc ) ; tools::Rectangle aRect( Point( xDest, yDest ), Size( cxDest+1, cyDest+1 ) ); @@ -1251,7 +1247,7 @@ namespace emfio else { const sal_uInt32 nSourceSize = cbBmiSrc + cbBitsSrc + 14; - bool bSafeRead = nSourceSize <= (nEndPos - nStartPos); + bool bSafeRead = nSourceSize <= (mnEndPos - mnStartPos); sal_uInt32 nDeltaToDIB5HeaderSize(0); const bool bReadAlpha(0x01 == aFunc.aAlphaFormat); if (bSafeRead && bReadAlpha) @@ -1282,8 +1278,8 @@ namespace emfio .WriteUInt32( cbBmiSrc + nDeltaToDIB5HeaderSize + 14 ); // copy DIBInfoHeader from source (cbBmiSrc bytes) - pWMF->Seek( nStart + offBmiSrc ); - pWMF->ReadBytes(pBuf + 14, cbBmiSrc); + mpWMF->Seek( nStart + offBmiSrc ); + mpWMF->ReadBytes(pBuf + 14, cbBmiSrc); if (bReadAlpha) { @@ -1294,8 +1290,8 @@ namespace emfio } // copy bitmap data from source (offBitsSrc bytes) - pWMF->Seek( nStart + offBitsSrc ); - pWMF->ReadBytes(pBuf + 14 + nDeltaToDIB5HeaderSize + cbBmiSrc, cbBitsSrc); + mpWMF->Seek( nStart + offBitsSrc ); + mpWMF->ReadBytes(pBuf + 14 + nDeltaToDIB5HeaderSize + cbBmiSrc, cbBitsSrc); aTmp.Seek( 0 ); // prepare to read and fill BitmapEx @@ -1369,16 +1365,16 @@ namespace emfio sal_uInt32 dwRop, iUsageSrc, offBmiSrc, cbBmiSrc, offBitsSrc, cbBitsSrc; XForm xformSrc; - sal_uInt32 nStart = pWMF->Tell() - 8; + sal_uInt32 nStart = mpWMF->Tell() - 8; - pWMF->SeekRel( 0x10 ); - pWMF->ReadInt32( xDest ).ReadInt32( yDest ).ReadInt32( cxDest ).ReadInt32( cyDest ).ReadUInt32( dwRop ).ReadInt32( xSrc ).ReadInt32( ySrc ) + mpWMF->SeekRel( 0x10 ); + mpWMF->ReadInt32( xDest ).ReadInt32( yDest ).ReadInt32( cxDest ).ReadInt32( cyDest ).ReadUInt32( dwRop ).ReadInt32( xSrc ).ReadInt32( ySrc ) >> xformSrc; - pWMF->ReadUInt32( nColor ).ReadUInt32( iUsageSrc ).ReadUInt32( offBmiSrc ).ReadUInt32( cbBmiSrc ) + mpWMF->ReadUInt32( nColor ).ReadUInt32( iUsageSrc ).ReadUInt32( offBmiSrc ).ReadUInt32( cbBmiSrc ) .ReadUInt32( offBitsSrc ).ReadUInt32( cbBitsSrc ); if ( nRecType == EMR_STRETCHBLT ) - pWMF->ReadInt32( cxSrc ).ReadInt32( cySrc ); + mpWMF->ReadInt32( cxSrc ).ReadInt32( cySrc ); else cxSrc = cySrc = 0; @@ -1390,7 +1386,7 @@ namespace emfio else { sal_uInt32 nSize = cbBmiSrc + cbBitsSrc + 14; - if ( nSize <= ( nEndPos - nStartPos ) ) + if ( nSize <= ( mnEndPos - mnStartPos ) ) { char* pBuf = new char[ nSize ]; SvMemoryStream aTmp( pBuf, nSize, StreamMode::READ | StreamMode::WRITE ); @@ -1401,10 +1397,10 @@ namespace emfio .WriteUInt16( 0 ) .WriteUInt16( 0 ) .WriteUInt32( cbBmiSrc + 14 ); - pWMF->Seek( nStart + offBmiSrc ); - pWMF->ReadBytes(pBuf + 14, cbBmiSrc); - pWMF->Seek( nStart + offBitsSrc ); - pWMF->ReadBytes(pBuf + 14 + cbBmiSrc, cbBitsSrc); + mpWMF->Seek( nStart + offBmiSrc ); + mpWMF->ReadBytes(pBuf + 14, cbBmiSrc); + mpWMF->Seek( nStart + offBitsSrc ); + mpWMF->ReadBytes(pBuf + 14 + cbBmiSrc, cbBitsSrc); aTmp.Seek( 0 ); ReadDIB(aBitmap, aTmp, true); @@ -1417,7 +1413,7 @@ namespace emfio tools::Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) ); aBitmap.Crop( aCropRect ); } - aBmpSaveList.emplace_back(new BSaveStruct(aBitmap, aRect, dwRop)); + maBmpSaveList.emplace_back(new BSaveStruct(aBitmap, aRect, dwRop)); } } } @@ -1427,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 = pWMF->Tell() - 8; + sal_uInt32 nStart = mpWMF->Tell() - 8; - pWMF->SeekRel( 0x10 ); - pWMF->ReadInt32( xDest ) + mpWMF->SeekRel( 0x10 ); + mpWMF->ReadInt32( xDest ) .ReadInt32( yDest ) .ReadInt32( xSrc ) .ReadInt32( ySrc ) @@ -1457,7 +1453,7 @@ namespace emfio else { sal_uInt32 nSize = cbBmiSrc + cbBitsSrc + 14; - if ( nSize <= ( nEndPos - nStartPos ) ) + if ( nSize <= ( mnEndPos - mnStartPos ) ) { char* pBuf = new char[ nSize ]; SvMemoryStream aTmp( pBuf, nSize, StreamMode::READ | StreamMode::WRITE ); @@ -1468,10 +1464,10 @@ namespace emfio .WriteUInt16( 0 ) .WriteUInt16( 0 ) .WriteUInt32( cbBmiSrc + 14 ); - pWMF->Seek( nStart + offBmiSrc ); - pWMF->ReadBytes(pBuf + 14, cbBmiSrc); - pWMF->Seek( nStart + offBitsSrc ); - pWMF->ReadBytes(pBuf + 14 + cbBmiSrc, cbBitsSrc); + mpWMF->Seek( nStart + offBmiSrc ); + mpWMF->ReadBytes(pBuf + 14, cbBmiSrc); + mpWMF->Seek( nStart + offBitsSrc ); + mpWMF->ReadBytes(pBuf + 14 + cbBmiSrc, cbBitsSrc); aTmp.Seek( 0 ); ReadDIB(aBitmap, aTmp, true); @@ -1484,7 +1480,7 @@ namespace emfio tools::Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) ); aBitmap.Crop( aCropRect ); } - aBmpSaveList.emplace_back(new BSaveStruct(aBitmap, aRect, dwRop)); + maBmpSaveList.emplace_back(new BSaveStruct(aBitmap, aRect, dwRop)); } } } @@ -1492,11 +1488,11 @@ namespace emfio case EMR_EXTCREATEFONTINDIRECTW : { - pWMF->ReadUInt32( nIndex ); + mpWMF->ReadUInt32( nIndex ); if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) { LOGFONTW aLogFont; - pWMF->ReadInt32( aLogFont.lfHeight ) + mpWMF->ReadInt32( aLogFont.lfHeight ) .ReadInt32( aLogFont.lfWidth ) .ReadInt32( aLogFont.lfEscapement ) .ReadInt32( aLogFont.lfOrientation ) @@ -1515,7 +1511,7 @@ namespace emfio for (int i = 0; i < LF_FACESIZE; ++i) { sal_uInt16 nChar(0); - pWMF->ReadUInt16(nChar); + mpWMF->ReadUInt16(nChar); lfFaceName[i] = nChar; } aLogFont.alfFaceName = OUString( lfFaceName ); @@ -1527,13 +1523,13 @@ namespace emfio // // #i121382# Need to apply WorldTransform to FontHeight/Width; this should be completely // // changed to basegfx::B2DHomMatrix instead of 'struct XForm', but not now due to time // // constraints and dangers - // const XForm& rXF = pOut->GetWorldTransform(); + // const XForm& rXF = GetWorldTransform(); // const basegfx::B2DHomMatrix aWT(rXF.eM11, rXF.eM21, rXF.eDx, rXF.eM12, rXF.eM22, rXF.eDy); // const basegfx::B2DVector aTransVec(aWT * basegfx::B2DVector(aLogFont.lfWidth, aLogFont.lfHeight)); // aLogFont.lfWidth = aTransVec.getX(); // aLogFont.lfHeight = aTransVec.getY(); - pOut->CreateObjectIndexed(nIndex, o3tl::make_unique<WinMtfFontStyle>( aLogFont )); + CreateObjectIndexed(nIndex, o3tl::make_unique<WinMtfFontStyle>( aLogFont )); } } break; @@ -1547,42 +1543,42 @@ namespace emfio sal_uInt32 nOffString, nOptions, offDx; sal_Int32 nLen; - nCurPos = pWMF->Tell() - 8; + nCurPos = mpWMF->Tell() - 8; - pWMF->ReadInt32( nLeft ).ReadInt32( nTop ).ReadInt32( nRight ).ReadInt32( nBottom ).ReadInt32( nGfxMode ).ReadInt32( nXScale ).ReadInt32( nYScale ) + mpWMF->ReadInt32( nLeft ).ReadInt32( nTop ).ReadInt32( nRight ).ReadInt32( nBottom ).ReadInt32( nGfxMode ).ReadInt32( nXScale ).ReadInt32( nYScale ) .ReadInt32( ptlReferenceX ).ReadInt32( ptlReferenceY ).ReadInt32( nLen ).ReadUInt32( nOffString ).ReadUInt32( nOptions ); - pWMF->SeekRel( 0x10 ); - pWMF->ReadUInt32( offDx ); + mpWMF->SeekRel( 0x10 ); + mpWMF->ReadUInt32( offDx ); ComplexTextLayoutFlags nTextLayoutMode = ComplexTextLayoutFlags::Default; if ( nOptions & ETO_RTLREADING ) nTextLayoutMode = ComplexTextLayoutFlags::BiDiRtl | ComplexTextLayoutFlags::TextOriginLeft; - pOut->SetTextLayoutMode( nTextLayoutMode ); + SetTextLayoutMode( nTextLayoutMode ); SAL_WARN_IF( ( nOptions & ( ETO_PDY | ETO_GLYPH_INDEX ) ) != 0, "vcl.emf", "SJ: ETO_PDY || ETO_GLYPH_INDEX in EMF" ); Point aPos( ptlReferenceX, ptlReferenceY ); bool bLenSane = nLen > 0 && nLen < static_cast<sal_Int32>( SAL_MAX_UINT32 / sizeof(sal_Int32) ); - bool bOffStringSane = nOffString <= nEndPos - nCurPos; + bool bOffStringSane = nOffString <= mnEndPos - nCurPos; if (bLenSane && bOffStringSane) { - pWMF->Seek( nCurPos + nOffString ); + mpWMF->Seek( nCurPos + nOffString ); OUString aText; if ( bFlag ) { - if ( nLen <= static_cast<sal_Int32>( nEndPos - pWMF->Tell() ) ) + if ( nLen <= static_cast<sal_Int32>( mnEndPos - mpWMF->Tell() ) ) { std::unique_ptr<sal_Char[]> pBuf(new sal_Char[ nLen ]); - pWMF->ReadBytes(pBuf.get(), nLen); - aText = OUString(pBuf.get(), nLen, pOut->GetCharSet()); + mpWMF->ReadBytes(pBuf.get(), nLen); + aText = OUString(pBuf.get(), nLen, GetCharSet()); } } else { - if ( ( nLen * sizeof(sal_Unicode) ) <= ( nEndPos - pWMF->Tell() ) ) + if ( ( nLen * sizeof(sal_Unicode) ) <= ( mnEndPos - mpWMF->Tell() ) ) { std::unique_ptr<sal_Unicode[]> pBuf(new sal_Unicode[ nLen ]); - pWMF->ReadBytes(pBuf.get(), nLen << 1); + mpWMF->ReadBytes(pBuf.get(), nLen << 1); #ifdef OSL_BIGENDIAN sal_Char nTmp, *pTmp = (sal_Char*)( pBuf.get() + nLen ); while ( pTmp-- != (sal_Char*)pBuf.get() ) @@ -1598,9 +1594,9 @@ namespace emfio std::unique_ptr<long[]> pDXAry, pDYAry; sal_Int32 nDxSize = nLen * ((nOptions & ETO_PDY) ? 8 : 4); - if ( offDx && (( nCurPos + offDx + nDxSize ) <= nNextPos ) && nNextPos <= nEndPos ) + if ( offDx && (( nCurPos + offDx + nDxSize ) <= nNextPos ) && nNextPos <= mnEndPos ) { - pWMF->Seek( nCurPos + offDx ); + mpWMF->Seek( nCurPos + offDx ); pDXAry.reset( new long[aText.getLength()] ); if (nOptions & ETO_PDY) { @@ -1613,7 +1609,7 @@ namespace emfio if (aText.getLength() != nLen) { sal_Unicode cUniChar = aText[i]; - OString aTmp(&cUniChar, 1, pOut->GetCharSet()); + OString aTmp(&cUniChar, 1, GetCharSet()); if (aTmp.getLength() > 1) { nDxCount = aTmp.getLength(); @@ -1624,12 +1620,12 @@ namespace emfio while (nDxCount--) { sal_Int32 nDxTmp = 0; - pWMF->ReadInt32(nDxTmp); + mpWMF->ReadInt32(nDxTmp); nDx += nDxTmp; if (nOptions & ETO_PDY) { sal_Int32 nDyTmp = 0; - pWMF->ReadInt32(nDyTmp); + mpWMF->ReadInt32(nDyTmp); nDy += nDyTmp; } } @@ -1641,34 +1637,29 @@ namespace emfio } } } - pOut->DrawText(aPos, aText, pDXAry.get(), pDYAry.get(), bRecordPath, nGfxMode); + DrawText(aPos, aText, pDXAry.get(), pDYAry.get(), mbRecordPath, nGfxMode); } } break; case EMR_POLYBEZIERTO16 : - ReadAndDrawPolygon<sal_Int16>( [] ( std::unique_ptr<MtfToolsWriter> &pWinMtfOutput, tools::Polygon& rPolygon, bool aTo, bool aRecordPath ) - { pWinMtfOutput->DrawPolyBezier( rPolygon, aTo, aRecordPath ); }, true ); + DrawPolyBezier(ReadPolygonWithSkip<sal_Int16>(true), true, mbRecordPath); break; case EMR_POLYBEZIER16 : - ReadAndDrawPolygon<sal_Int16>( [] ( std::unique_ptr<MtfToolsWriter> &pWinMtfOutput, tools::Polygon& rPolygon, bool aTo, bool aRecordPath ) - { pWinMtfOutput->DrawPolyBezier( rPolygon, aTo, aRecordPath ); }, false ); + DrawPolyBezier(ReadPolygonWithSkip<sal_Int16>(false), false, mbRecordPath); break; case EMR_POLYGON16 : - ReadAndDrawPolygon<sal_Int16>( [] ( std::unique_ptr<MtfToolsWriter> &pWinMtfOutput, tools::Polygon& rPolygon, bool /*aTo*/, bool aRecordPath ) - { pWinMtfOutput->DrawPolygon( rPolygon, aRecordPath ); }, false ); + DrawPolygon(ReadPolygonWithSkip<sal_Int16>(false), mbRecordPath); break; case EMR_POLYLINETO16 : - ReadAndDrawPolygon<sal_Int16>( [] ( std::unique_ptr<MtfToolsWriter> &pWinMtfOutput, tools::Polygon& rPolygon, bool aTo, bool aRecordPath ) - { pWinMtfOutput->DrawPolyLine( rPolygon, aTo, aRecordPath ); }, true ); + DrawPolyLine(ReadPolygonWithSkip<sal_Int16>(true), true, mbRecordPath); break; case EMR_POLYLINE16 : - ReadAndDrawPolygon<sal_Int16>( [] ( std::unique_ptr<MtfToolsWriter> &pWinMtfOutput, tools::Polygon& rPolygon, bool aTo, bool aRecordPath ) - { pWinMtfOutput->DrawPolyLine( rPolygon, aTo, aRecordPath ); }, false ); + DrawPolyLine(ReadPolygonWithSkip<sal_Int16>(false), false, mbRecordPath); break; case EMR_POLYPOLYLINE16 : @@ -1683,42 +1674,42 @@ namespace emfio { sal_uInt32 nLen; tools::PolyPolygon aPolyPoly; - pWMF->SeekRel( 0x10 ); - pWMF->ReadUInt32( nLen ).ReadUInt32( nIndex ); + mpWMF->SeekRel( 0x10 ); + mpWMF->ReadUInt32( nLen ).ReadUInt32( nIndex ); - if ( ImplReadRegion( aPolyPoly, *pWMF, nRecSize ) ) + if ( ImplReadRegion( aPolyPoly, *mpWMF, nRecSize ) ) { - pOut->Push(); - pOut->SelectObject( nIndex ); - pOut->DrawPolyPolygon( aPolyPoly ); - pOut->Pop(); + Push(); + SelectObject( nIndex ); + DrawPolyPolygon( aPolyPoly ); + Pop(); } } break; case EMR_CREATEDIBPATTERNBRUSHPT : { - sal_uInt32 nStart = pWMF->Tell() - 8; + sal_uInt32 nStart = mpWMF->Tell() - 8; Bitmap aBitmap; - pWMF->ReadUInt32( nIndex ); + mpWMF->ReadUInt32( nIndex ); if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) { sal_uInt32 usage, offBmi, cbBmi, offBits, cbBits; - pWMF->ReadUInt32( usage ); - pWMF->ReadUInt32( offBmi ); - pWMF->ReadUInt32( cbBmi ); - pWMF->ReadUInt32( offBits ); - pWMF->ReadUInt32( cbBits ); + mpWMF->ReadUInt32( usage ); + mpWMF->ReadUInt32( offBmi ); + mpWMF->ReadUInt32( cbBmi ); + mpWMF->ReadUInt32( offBits ); + mpWMF->ReadUInt32( cbBits ); if ( (cbBits > (SAL_MAX_UINT32 - 14)) || ((SAL_MAX_UINT32 - 14) - cbBits < cbBmi) ) bStatus = false; else if ( offBmi ) { sal_uInt32 nSize = cbBmi + cbBits + 14; - if ( nSize <= ( nEndPos - nStartPos ) ) + if ( nSize <= ( mnEndPos - mnStartPos ) ) { char* pBuf = new char[ nSize ]; @@ -1730,17 +1721,17 @@ namespace emfio .WriteUInt16( 0 ) .WriteUInt16( 0 ) .WriteUInt32( cbBmi + 14 ); - pWMF->Seek( nStart + offBmi ); - pWMF->ReadBytes(pBuf + 14, cbBmi); - pWMF->Seek( nStart + offBits ); - pWMF->ReadBytes(pBuf + 14 + cbBmi, cbBits); + mpWMF->Seek( nStart + offBmi ); + mpWMF->ReadBytes(pBuf + 14, cbBmi); + mpWMF->Seek( nStart + offBits ); + mpWMF->ReadBytes(pBuf + 14 + cbBmi, cbBits); aTmp.Seek( 0 ); ReadDIB(aBitmap, aTmp, true); } } } - pOut->CreateObjectIndexed(nIndex, o3tl::make_unique<WinMtfFillStyle>( aBitmap )); + CreateObjectIndexed(nIndex, o3tl::make_unique<WinMtfFillStyle>( aBitmap )); } break; @@ -1802,13 +1793,13 @@ namespace emfio default : SAL_INFO("vcl.emf", "Unknown Meta Action"); break; } } - pWMF->Seek( nNextPos ); + mpWMF->Seek( nNextPos ); } - if( !aBmpSaveList.empty() ) - pOut->ResolveBitmapActions( aBmpSaveList ); + if( !maBmpSaveList.empty() ) + ResolveBitmapActions( maBmpSaveList ); if ( bStatus ) - pWMF->Seek(nEndPos); + mpWMF->Seek(mnEndPos); return bStatus; }; @@ -1820,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) - pWMF->ReadUInt32( nType ).ReadUInt32( nHeaderSize ); + mpWMF->ReadUInt32( nType ).ReadUInt32( nHeaderSize ); if (nType != 0x00000001) { // per [MS-EMF] 2.3.4.2 EMF Header Record Types, type MUST be 0x00000001 @@ -1836,7 +1827,7 @@ namespace emfio // picture frame size (RectL object) tools::Rectangle rclFrame = ReadRectangle(); // rectangle in device units 1/100th mm - pWMF->ReadUInt32( nSignature ); + mpWMF->ReadUInt32( nSignature ); // nSignature MUST be the ASCII characters "FME", see [WS-EMF] 2.2.9 Header Object // and 2.1.14 FormatSignature Enumeration @@ -1846,32 +1837,32 @@ namespace emfio return false; } - pWMF->ReadUInt32(nVersion); // according to [WS-EMF] 2.2.9, this SHOULD be 0x0001000, however + mpWMF->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..."); } - pWMF->ReadUInt32(nEndPos); // size of metafile - nEndPos += nStartPos; + mpWMF->ReadUInt32(mnEndPos); // size of metafile + mnEndPos += mnStartPos; - sal_uInt32 nStrmPos = pWMF->Tell(); // checking if nEndPos is valid - pWMF->Seek(STREAM_SEEK_TO_END); - sal_uInt32 nActualFileSize = pWMF->Tell(); + sal_uInt32 nStrmPos = mpWMF->Tell(); // checking if mnEndPos is valid + mpWMF->Seek(STREAM_SEEK_TO_END); + sal_uInt32 nActualFileSize = mpWMF->Tell(); - if ( nActualFileSize < nEndPos ) + if ( nActualFileSize < mnEndPos ) { - SAL_WARN("vcl.emf", "EMF\t\tEMF Header object records number of bytes as " << nEndPos + SAL_WARN("vcl.emf", "EMF\t\tEMF Header object records number of bytes as " << mnEndPos << ", however the file size is actually " << nActualFileSize << " bytes. Possible file corruption?"); - nEndPos = nActualFileSize; + mnEndPos = nActualFileSize; } - pWMF->Seek(nStrmPos); + mpWMF->Seek(nStrmPos); - pWMF->ReadInt32(nRecordCount); + mpWMF->ReadInt32(mnRecordCount); - if (nRecordCount <= 0) + if (mnRecordCount <= 0) { SAL_WARN("vcl.emf", "EMF\t\tEMF Header object shows record counter as <= 0! This shouldn't " "be possible... indicator of possible file corruption?"); @@ -1881,14 +1872,14 @@ namespace emfio // the number of "handles", or graphics objects used in the metafile sal_uInt16 nHandlesCount; - pWMF->ReadUInt16(nHandlesCount); + mpWMF->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; - pWMF->ReadUInt16(nReserved); + mpWMF->ReadUInt16(nReserved); if ( nReserved != 0x0000 ) { @@ -1901,31 +1892,31 @@ namespace emfio // metafile description... zero means no description string. // For now, we ignore it. - pWMF->SeekRel(0x8); + mpWMF->SeekRel(0x8); sal_Int32 nPixX, nPixY, nMillX, nMillY; - pWMF->ReadUInt32(nPalEntries); - pWMF->ReadInt32(nPixX); - pWMF->ReadInt32(nPixY); - pWMF->ReadInt32(nMillX); - pWMF->ReadInt32(nMillY); - - pOut->SetrclFrame(rclFrame); - pOut->SetrclBounds(rclBounds); - pOut->SetRefPix(Size( nPixX, nPixY ) ); - pOut->SetRefMill(Size( nMillX, nMillY ) ); - - pWMF->Seek(nStartPos + nHeaderSize); + mpWMF->ReadUInt32(nPalEntries); + mpWMF->ReadInt32(nPixX); + mpWMF->ReadInt32(nPixY); + mpWMF->ReadInt32(nMillX); + mpWMF->ReadInt32(nMillY); + + SetrclFrame(rclFrame); + SetrclBounds(rclBounds); + SetRefPix(Size( nPixX, nPixY ) ); + SetRefMill(Size( nMillX, nMillY ) ); + + mpWMF->Seek(mnStartPos + nHeaderSize); return true; } tools::Rectangle EmfReader::ReadRectangle() { sal_Int32 nLeft, nTop, nRight, nBottom; - pWMF->ReadInt32(nLeft); - pWMF->ReadInt32(nTop); - pWMF->ReadInt32(nRight); - pWMF->ReadInt32(nBottom); + mpWMF->ReadInt32(nLeft); + mpWMF->ReadInt32(nTop); + mpWMF->ReadInt32(nRight); + mpWMF->ReadInt32(nBottom); return tools::Rectangle(nLeft, nTop, nRight, nBottom); } diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index e48398522669..37dfc76d0fd3 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -307,50 +307,15 @@ namespace emfio aFont.SetFontSize(aFontSize); }; - MtfTools::MtfTools( GDIMetaFile& rGDIMetaFile, SvStream& rStreamWMF, FilterConfigItem* pConfigItem ) - : pOut( o3tl::make_unique<MtfToolsWriter>(rGDIMetaFile) ) - , pWMF( &rStreamWMF ) - , nEndPos( 0 ) - , pFilterConfigItem( pConfigItem ) - { - SvLockBytes *pLB = pWMF->GetLockBytes(); - if ( pLB ) - pLB->SetSynchronMode(); - - nStartPos = pWMF->Tell(); - - pOut->SetDevOrg( Point() ); - if ( pFilterConfigItem ) - { - xStatusIndicator = pFilterConfigItem->GetStatusIndicator(); - if ( xStatusIndicator.is() ) - { - OUString aMsg; - xStatusIndicator->start( aMsg, 100 ); - } - } - } - - MtfTools::~MtfTools() - { - if ( xStatusIndicator.is() ) - xStatusIndicator->end(); - } - - void MtfTools::Callback( sal_uInt16 nPercent ) - { - if ( xStatusIndicator.is() ) - xStatusIndicator->setValue( nPercent ); - } - Color MtfTools::ReadColor() { sal_uInt32 nColor; - pWMF->ReadUInt32( nColor ); + + mpWMF->ReadUInt32( nColor ); return Color( (sal_uInt8)nColor, (sal_uInt8)( nColor >> 8 ), (sal_uInt8)( nColor >> 16 ) ); }; - Point MtfToolsWriter::ImplScale(const Point& rPoint) // Hack to set varying defaults for incompletely defined files. + Point MtfTools::ImplScale(const Point& rPoint) // Hack to set varying defaults for incompletely defined files. { if (!mbIsMapDevSet) return Point(rPoint.X() * UNDOCUMENTED_WIN_RCL_RELATION - mrclFrame.Left(), @@ -359,7 +324,7 @@ namespace emfio return rPoint; } - Point MtfToolsWriter::ImplMap( const Point& rPt ) + Point MtfTools::ImplMap( const Point& rPt ) { if ( mnWinExtX && mnWinExtY ) { @@ -445,7 +410,7 @@ namespace emfio return Point(); }; - Size MtfToolsWriter::ImplMap(const Size& rSz, bool bDoWorldTransform) + Size MtfTools::ImplMap(const Size& rSz, bool bDoWorldTransform) { if ( mnWinExtX && mnWinExtY ) { @@ -523,12 +488,12 @@ namespace emfio return Size(); } - tools::Rectangle MtfToolsWriter::ImplMap( const tools::Rectangle& rRect ) + tools::Rectangle MtfTools::ImplMap( const tools::Rectangle& rRect ) { return tools::Rectangle( ImplMap( rRect.TopLeft() ), ImplMap( rRect.GetSize() ) ); } - void MtfToolsWriter::ImplMap( vcl::Font& rFont ) + void MtfTools::ImplMap( vcl::Font& rFont ) { // !!! HACK: we now always set the width to zero because the OS width is interpreted differently; // must later be made portable in SV (KA 1996-02-08) @@ -543,7 +508,7 @@ namespace emfio rFont.SetOrientation( 3600 - rFont.GetOrientation() ); } - tools::Polygon& MtfToolsWriter::ImplMap( tools::Polygon& rPolygon ) + tools::Polygon& MtfTools::ImplMap( tools::Polygon& rPolygon ) { sal_uInt16 nPoints = rPolygon.GetSize(); for ( sal_uInt16 i = 0; i < nPoints; i++ ) @@ -553,7 +518,7 @@ namespace emfio return rPolygon; } - void MtfToolsWriter::ImplScale( tools::Polygon& rPolygon ) + void MtfTools::ImplScale( tools::Polygon& rPolygon ) { sal_uInt16 nPoints = rPolygon.GetSize(); for ( sal_uInt16 i = 0; i < nPoints; i++ ) @@ -562,7 +527,7 @@ namespace emfio } } - tools::PolyPolygon& MtfToolsWriter::ImplScale( tools::PolyPolygon& rPolyPolygon ) + tools::PolyPolygon& MtfTools::ImplScale( tools::PolyPolygon& rPolyPolygon ) { sal_uInt16 nPolys = rPolyPolygon.Count(); for (sal_uInt16 i = 0; i < nPolys; ++i) @@ -572,14 +537,14 @@ namespace emfio return rPolyPolygon; } - tools::PolyPolygon& MtfToolsWriter::ImplMap( tools::PolyPolygon& rPolyPolygon ) + tools::PolyPolygon& MtfTools::ImplMap( tools::PolyPolygon& rPolyPolygon ) { sal_uInt16 nPolys = rPolyPolygon.Count(); for ( sal_uInt16 i = 0; i < nPolys; ImplMap( rPolyPolygon[ i++ ] ) ) ; return rPolyPolygon; } - void MtfToolsWriter::SelectObject( sal_Int32 nIndex ) + void MtfTools::SelectObject( sal_Int32 nIndex ) { if ( nIndex & ENHMETA_STOCK_OBJECT ) { @@ -642,8 +607,8 @@ namespace emfio GDIObj *pGDIObj = nullptr; - if ( (sal_uInt32)nIndex < vGDIObj.size() ) - pGDIObj = vGDIObj[ nIndex ].get(); + if ( (sal_uInt32)nIndex < mvGDIObj.size() ) + pGDIObj = mvGDIObj[ nIndex ].get(); if ( pGDIObj ) { @@ -665,37 +630,37 @@ namespace emfio } } - void MtfToolsWriter::SetTextLayoutMode( ComplexTextLayoutFlags nTextLayoutMode ) + void MtfTools::SetTextLayoutMode( ComplexTextLayoutFlags nTextLayoutMode ) { mnTextLayoutMode = nTextLayoutMode; } - void MtfToolsWriter::SetBkMode( BkMode nMode ) + void MtfTools::SetBkMode( BkMode nMode ) { mnBkMode = nMode; } - void MtfToolsWriter::SetBkColor( const Color& rColor ) + void MtfTools::SetBkColor( const Color& rColor ) { maBkColor = rColor; } - void MtfToolsWriter::SetTextColor( const Color& rColor ) + void MtfTools::SetTextColor( const Color& rColor ) { maTextColor = rColor; } - void MtfToolsWriter::SetTextAlign( sal_uInt32 nAlign ) + void MtfTools::SetTextAlign( sal_uInt32 nAlign ) { mnTextAlign = nAlign; } - void MtfToolsWriter::ImplResizeObjectArry( sal_uInt32 nNewEntrys ) + void MtfTools::ImplResizeObjectArry( sal_uInt32 nNewEntrys ) { - vGDIObj.resize(nNewEntrys); + mvGDIObj.resize(nNewEntrys); } - void MtfToolsWriter::ImplDrawClippedPolyPolygon( const tools::PolyPolygon& rPolyPoly ) + void MtfTools::ImplDrawClippedPolyPolygon( const tools::PolyPolygon& rPolyPoly ) { if ( rPolyPoly.Count() ) { @@ -724,7 +689,7 @@ namespace emfio } } - void MtfToolsWriter::CreateObject( std::unique_ptr<GDIObj> pObject ) + void MtfTools::CreateObject( std::unique_ptr<GDIObj> pObject ) { if ( pObject ) { @@ -745,18 +710,18 @@ namespace emfio } } std::vector<std::unique_ptr<GDIObj>>::size_type nIndex; - for ( nIndex = 0; nIndex < vGDIObj.size(); nIndex++ ) + for ( nIndex = 0; nIndex < mvGDIObj.size(); nIndex++ ) { - if ( !vGDIObj[ nIndex ] ) + if ( !mvGDIObj[ nIndex ] ) break; } - if ( nIndex == vGDIObj.size() ) - ImplResizeObjectArry( vGDIObj.size() + 16 ); + if ( nIndex == mvGDIObj.size() ) + ImplResizeObjectArry( mvGDIObj.size() + 16 ); - vGDIObj[ nIndex ] = std::move(pObject); + mvGDIObj[ nIndex ] = std::move(pObject); } - void MtfToolsWriter::CreateObjectIndexed( sal_Int32 nIndex, std::unique_ptr<GDIObj> pObject ) + void MtfTools::CreateObjectIndexed( sal_Int32 nIndex, std::unique_ptr<GDIObj> pObject ) { if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) { @@ -786,47 +751,52 @@ namespace emfio } } } - if ( (sal_uInt32)nIndex >= vGDIObj.size() ) + if ( (sal_uInt32)nIndex >= mvGDIObj.size() ) ImplResizeObjectArry( nIndex + 16 ); - vGDIObj[ nIndex ] = std::move(pObject); + mvGDIObj[ nIndex ] = std::move(pObject); } } - void MtfToolsWriter::DeleteObject( sal_Int32 nIndex ) + void MtfTools::CreateObject() + { + CreateObject(o3tl::make_unique<GDIObj>()); + } + + void MtfTools::DeleteObject( sal_Int32 nIndex ) { if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 ) { - if ( (sal_uInt32)nIndex < vGDIObj.size() ) + if ( (sal_uInt32)nIndex < mvGDIObj.size() ) { - vGDIObj[ nIndex ].reset(); + mvGDIObj[ nIndex ].reset(); } } } - void MtfToolsWriter::IntersectClipRect( const tools::Rectangle& rRect ) + void MtfTools::IntersectClipRect( const tools::Rectangle& rRect ) { mbClipNeedsUpdate=true; if ((rRect.Left()-rRect.Right()==0) && (rRect.Top()-rRect.Bottom()==0)) { return; // empty rectangles cause trouble } - aClipPath.intersectClipRect( ImplMap( rRect ) ); + maClipPath.intersectClipRect( ImplMap( rRect ) ); } - void MtfToolsWriter::ExcludeClipRect( const tools::Rectangle& rRect ) + void MtfTools::ExcludeClipRect( const tools::Rectangle& rRect ) { mbClipNeedsUpdate=true; - aClipPath.excludeClipRect( ImplMap( rRect ) ); + maClipPath.excludeClipRect( ImplMap( rRect ) ); } - void MtfToolsWriter::MoveClipRegion( const Size& rSize ) + void MtfTools::MoveClipRegion( const Size& rSize ) { mbClipNeedsUpdate=true; - aClipPath.moveClipRegion( ImplMap( rSize ) ); + maClipPath.moveClipRegion( ImplMap( rSize ) ); } - void MtfToolsWriter::SetClipPath( const tools::PolyPolygon& rPolyPolygon, sal_Int32 nClippingMode, bool bIsMapped ) + void MtfTools::SetClipPath( const tools::PolyPolygon& rPolyPolygon, sal_Int32 nClippingMode, bool bIsMapped ) { mbClipNeedsUpdate = true; tools::PolyPolygon aPolyPolygon(rPolyPolygon); @@ -838,49 +808,81 @@ namespace emfio else aPolyPolygon = ImplMap(aPolyPolygon); } - aClipPath.setClipPath(aPolyPolygon, nClippingMode); + maClipPath.setClipPath(aPolyPolygon, nClippingMode); } - void MtfToolsWriter::SetDefaultClipPath() + void MtfTools::SetDefaultClipPath() { mbClipNeedsUpdate = true; - aClipPath.setDefaultClipPath(); - } - - MtfToolsWriter::MtfToolsWriter( GDIMetaFile& rGDIMetaFile ) : - mnLatestTextAlign ( 0 ), - mnTextAlign ( TA_LEFT | TA_TOP | TA_NOUPDATECP ), - maLatestBkColor ( 0x12345678 ), - maBkColor ( COL_WHITE ), - mnLatestTextLayoutMode( ComplexTextLayoutFlags::Default ), - mnTextLayoutMode ( ComplexTextLayoutFlags::Default ), - mnLatestBkMode ( BkMode::NONE ), - mnBkMode ( BkMode::OPAQUE ), - meLatestRasterOp ( RasterOp::Invert ), - meRasterOp ( RasterOp::OverPaint ), - maActPos ( Point() ), - mbNopMode ( false ), - mbFillStyleSelected ( false ), - mbClipNeedsUpdate ( true ), - mbComplexClip ( false ), - mnGfxMode ( GM_COMPATIBLE ), - mnMapMode ( MM_TEXT ), - mnDevOrgX ( 0 ), - mnDevOrgY ( 0 ), - mnDevWidth ( 1 ), - mnDevHeight ( 1 ), - mnWinOrgX ( 0 ), - mnWinOrgY ( 0 ), - mnWinExtX ( 1 ), - mnWinExtY ( 1 ), - mnPixX ( 100 ), - mnPixY ( 100 ), - mnMillX ( 1 ), - mnMillY ( 1 ), - mpGDIMetaFile ( &rGDIMetaFile ) - { - mbIsMapWinSet = false; - mbIsMapDevSet = false; + maClipPath.setDefaultClipPath(); + } + + MtfTools::MtfTools( GDIMetaFile& rGDIMetaFile, SvStream& rStreamWMF) + : maPathObj(), + maClipPath(), + maLatestLineStyle(), + maLineStyle(), + maNopLineStyle(), + maLatestFillStyle(), + maFillStyle(), + maNopFillStyle(), + maLatestFont(), + maFont(), + mnLatestTextAlign(90), + mnTextAlign(TA_LEFT | TA_TOP | TA_NOUPDATECP), + maLatestTextColor(), + maTextColor(), + maLatestBkColor(0x12345678), + maBkColor(COL_WHITE), + mnLatestTextLayoutMode(ComplexTextLayoutFlags::Default), + mnTextLayoutMode(ComplexTextLayoutFlags::Default), + mnLatestBkMode(BkMode::NONE), + mnBkMode(BkMode::OPAQUE), + meLatestRasterOp(RasterOp::Invert), + meRasterOp(RasterOp::OverPaint), + mvGDIObj(), + maActPos(), + mnRop(), + mvSaveStack(), + mnGfxMode(GM_COMPATIBLE), + mnMapMode(MM_TEXT), + maXForm(), + mnDevOrgX(0), + mnDevOrgY(0), + mnDevWidth(1), + mnDevHeight(1), + mnWinOrgX(0), + mnWinOrgY(0), + mnWinExtX(1), + mnWinExtY(1), + mnPixX(100), + mnPixY(100), + mnMillX(1), + mnMillY(1), + mrclFrame(), + mrclBounds(), + mpGDIMetaFile(&rGDIMetaFile), + mpWMF(&rStreamWMF), + mnStartPos(0), + mnEndPos(0), + maBmpSaveList(), + mbNopMode(false), + mbFillStyleSelected(false), + mbClipNeedsUpdate(true), + mbComplexClip(false), + mbIsMapWinSet(false), + mbIsMapDevSet(false) + { + SvLockBytes *pLB = mpWMF->GetLockBytes(); + + if (pLB) + { + pLB->SetSynchronMode(); + } + + mnStartPos = mpWMF->Tell(); + SetDevOrg(Point()); + mpGDIMetaFile->AddAction( new MetaPushAction( PushFlags::CLIPREGION ) ); // The original clipregion has to be on top // of the stack so it can always be restored // this is necessary to be able to support @@ -898,7 +900,7 @@ namespace emfio mpGDIMetaFile->AddAction( new MetaRasterOpAction( RasterOp::OverPaint ) ); } - MtfToolsWriter::~MtfToolsWriter() + MtfTools::~MtfTools() { mpGDIMetaFile->AddAction( new MetaPopAction() ); mpGDIMetaFile->SetPrefMapMode( MapUnit::Map100thMM ); @@ -908,7 +910,7 @@ namespace emfio mpGDIMetaFile->SetPrefSize( mrclFrame.GetSize() ); } - void MtfToolsWriter::UpdateClipRegion() + void MtfTools::UpdateClipRegion() { if ( mbClipNeedsUpdate ) { @@ -919,9 +921,9 @@ namespace emfio mpGDIMetaFile->AddAction( new MetaPushAction( PushFlags::CLIPREGION ) ); // skip for 'no clipping at all' case - if( !aClipPath.isEmpty() ) + if( !maClipPath.isEmpty() ) { - const basegfx::B2DPolyPolygon& rClipPoly( aClipPath.getClipPath() ); + const basegfx::B2DPolyPolygon& rClipPoly( maClipPath.getClipPath() ); mbComplexClip = rClipPoly.count() > 1 || !basegfx::tools::isRectangle(rClipPoly); @@ -960,7 +962,7 @@ namespace emfio } } - void MtfToolsWriter::ImplSetNonPersistentLineColorTransparenz() + void MtfTools::ImplSetNonPersistentLineColorTransparenz() { Color aColor( COL_TRANSPARENT); WinMtfLineStyle aTransparentLine( aColor, true ); @@ -971,7 +973,7 @@ namespace emfio } } - void MtfToolsWriter::UpdateLineStyle() + void MtfTools::UpdateLineStyle() { if (!( maLatestLineStyle == maLineStyle ) ) { @@ -980,7 +982,7 @@ namespace emfio } } - void MtfToolsWriter::UpdateFillStyle() + void MtfTools::UpdateFillStyle() { if ( !mbFillStyleSelected ) // SJ: #i57205# taking care of bkcolor if no brush is selected maFillStyle = WinMtfFillStyle( maBkColor, mnBkMode == BkMode::Transparent ); @@ -992,7 +994,7 @@ namespace emfio } } - WMFRasterOp MtfToolsWriter::SetRasterOp( WMFRasterOp nRasterOp ) + WMFRasterOp MtfTools::SetRasterOp( WMFRasterOp nRasterOp ) { WMFRasterOp nRetROP = mnRop; if ( nRasterOp != mnRop ) @@ -1001,8 +1003,8 @@ namespace emfio if ( mbNopMode && ( nRasterOp != WMFRasterOp::Nop ) ) { // changing modes from WMFRasterOp::Nop so set pen and brush - maFillStyle = m_NopFillStyle; - maLineStyle = m_NopLineStyle; + maFillStyle = maNopFillStyle; + maLineStyle = maNopLineStyle; mbNopMode = false; } switch( nRasterOp ) @@ -1020,8 +1022,8 @@ namespace emfio meRasterOp = RasterOp::OverPaint; if( !mbNopMode ) { - m_NopFillStyle = maFillStyle; - m_NopLineStyle = maLineStyle; + maNopFillStyle = maFillStyle; + maNopLineStyle = maLineStyle; maFillStyle = WinMtfFillStyle( Color( COL_TRANSPARENT ), true ); maLineStyle = WinMtfLineStyle( Color( COL_TRANSPARENT ), true ); mbNopMode = true; @@ -1039,9 +1041,9 @@ namespace emfio return nRetROP; }; - void MtfToolsWriter::StrokeAndFillPath( bool bStroke, bool bFill ) + void MtfTools::StrokeAndFillPath( bool bStroke, bool bFill ) { - if ( aPathObj.Count() ) + if ( maPathObj.Count() ) { UpdateClipRegion(); UpdateLineStyle(); @@ -1053,49 +1055,49 @@ namespace emfio mpGDIMetaFile->AddAction( new MetaPushAction( PushFlags::LINECOLOR ) ); mpGDIMetaFile->AddAction( new MetaLineColorAction( Color(), false ) ); } - if ( aPathObj.Count() == 1 ) - mpGDIMetaFile->AddAction( new MetaPolygonAction( aPathObj.GetObject( 0 ) ) ); + if ( maPathObj.Count() == 1 ) + mpGDIMetaFile->AddAction( new MetaPolygonAction( maPathObj.GetObject( 0 ) ) ); else - mpGDIMetaFile->AddAction( new MetaPolyPolygonAction( aPathObj ) ); + mpGDIMetaFile->AddAction( new MetaPolyPolygonAction( maPathObj ) ); if ( !bStroke ) mpGDIMetaFile->AddAction( new MetaPopAction() ); } else { - sal_uInt16 i, nCount = aPathObj.Count(); + sal_uInt16 i, nCount = maPathObj.Count(); for ( i = 0; i < nCount; i++ ) - mpGDIMetaFile->AddAction( new MetaPolyLineAction( aPathObj[ i ], maLineStyle.aLineInfo ) ); + mpGDIMetaFile->AddAction( new MetaPolyLineAction( maPathObj[ i ], maLineStyle.aLineInfo ) ); } ClearPath(); } } - void MtfToolsWriter::DrawPixel( const Point& rSource, const Color& rColor ) + void MtfTools::DrawPixel( const Point& rSource, const Color& rColor ) { mpGDIMetaFile->AddAction( new MetaPixelAction( ImplMap( rSource), rColor ) ); } - void MtfToolsWriter::MoveTo( const Point& rPoint, bool bRecordPath ) + void MtfTools::MoveTo( const Point& rPoint, bool bRecordPath ) { Point aDest( ImplMap( rPoint ) ); if ( bRecordPath ) { // fdo#57353 create new subpath for subsequent moves - if ( aPathObj.Count() ) - if ( aPathObj[ aPathObj.Count() - 1 ].GetSize() ) - aPathObj.Insert( tools::Polygon() ); - aPathObj.AddPoint( aDest ); + if ( maPathObj.Count() ) + if ( maPathObj[ maPathObj.Count() - 1 ].GetSize() ) + maPathObj.Insert( tools::Polygon() ); + maPathObj.AddPoint( aDest ); } maActPos = aDest; } - void MtfToolsWriter::LineTo( const Point& rPoint, bool bRecordPath ) + void MtfTools::LineTo( const Point& rPoint, bool bRecordPath ) { UpdateClipRegion(); Point aDest( ImplMap( rPoint ) ); if ( bRecordPath ) - aPathObj.AddPoint( aDest ); + maPathObj.AddPoint( aDest ); else { UpdateLineStyle(); @@ -1104,7 +1106,7 @@ namespace emfio maActPos = aDest; } - void MtfToolsWriter::DrawRect( const tools::Rectangle& rRect, bool bEdge ) + void MtfTools::DrawRect( const tools::Rectangle& rRect, bool bEdge ) { UpdateClipRegion(); UpdateFillStyle(); @@ -1114,7 +1116,7 @@ namespace emfio tools::Polygon aPoly( ImplMap( rRect ) ); tools::PolyPolygon aPolyPolyRect( aPoly ); tools::PolyPolygon aDest; - tools::PolyPolygon(aClipPath.getClipPath()).GetIntersection( aPolyPolyRect, aDest ); + tools::PolyPolygon(maClipPath.getClipPath()).GetIntersection( aPolyPolyRect, aDest ); ImplDrawClippedPolyPolygon( aDest ); } else @@ -1142,7 +1144,7 @@ namespace emfio } } - void MtfToolsWriter::DrawRoundRect( const tools::Rectangle& rRect, const Size& rSize ) + void MtfTools::DrawRoundRect( const tools::Rectangle& rRect, const Size& rSize ) { UpdateClipRegion(); UpdateLineStyle(); @@ -1150,7 +1152,7 @@ namespace emfio mpGDIMetaFile->AddAction( new MetaRoundRectAction( ImplMap( rRect ), labs( ImplMap( rSize ).Width() ), labs( ImplMap( rSize ).Height() ) ) ); } - void MtfToolsWriter::DrawEllipse( const tools::Rectangle& rRect ) + void MtfTools::DrawEllipse( const tools::Rectangle& rRect ) { UpdateClipRegion(); UpdateFillStyle(); @@ -1172,7 +1174,7 @@ namespace emfio } } - void MtfToolsWriter::DrawArc( const tools::Rectangle& rRect, const Point& rStart, const Point& rEnd, bool bTo ) + void MtfTools::DrawArc( const tools::Rectangle& rRect, const Point& rStart, const Point& rEnd, bool bTo ) { UpdateClipRegion(); UpdateLineStyle(); @@ -1201,7 +1203,7 @@ namespace emfio maActPos = aEnd; } - void MtfToolsWriter::DrawPie( const tools::Rectangle& rRect, const Point& rStart, const Point& rEnd ) + void MtfTools::DrawPie( const tools::Rectangle& rRect, const Point& rStart, const Point& rEnd ) { UpdateClipRegion(); UpdateFillStyle(); @@ -1224,7 +1226,7 @@ namespace emfio } } - void MtfToolsWriter::DrawChord( const tools::Rectangle& rRect, const Point& rStart, const Point& rEnd ) + void MtfTools::DrawChord( const tools::Rectangle& rRect, const Point& rStart, const Point& rEnd ) { UpdateClipRegion(); UpdateFillStyle(); @@ -1247,12 +1249,12 @@ namespace emfio } } - void MtfToolsWriter::DrawPolygon( tools::Polygon& rPolygon, bool bRecordPath ) + void MtfTools::DrawPolygon( tools::Polygon& rPolygon, bool bRecordPath ) { UpdateClipRegion(); ImplMap( rPolygon ); if ( bRecordPath ) - aPathObj.AddPolygon( rPolygon ); + maPathObj.AddPolygon( rPolygon ); else { UpdateFillStyle(); @@ -1261,7 +1263,7 @@ namespace emfio { tools::PolyPolygon aPolyPoly( rPolygon ); tools::PolyPolygon aDest; - tools::PolyPolygon(aClipPath.getClipPath()).GetIntersection( aPolyPoly, aDest ); + tools::PolyPolygon(maClipPath.getClipPath()).GetIntersection( aPolyPoly, aDest ); ImplDrawClippedPolyPolygon( aDest ); } else @@ -1319,14 +1321,14 @@ namespace emfio } } - void MtfToolsWriter::DrawPolyPolygon( tools::PolyPolygon& rPolyPolygon, bool bRecordPath ) + void MtfTools::DrawPolyPolygon( tools::PolyPolygon& rPolyPolygon, bool bRecordPath ) { UpdateClipRegion(); ImplMap( rPolyPolygon ); if ( bRecordPath ) - aPathObj.AddPolyPolygon( rPolyPolygon ); + maPathObj.AddPolyPolygon( rPolyPolygon ); else { UpdateFillStyle(); @@ -1334,7 +1336,7 @@ namespace emfio if ( mbComplexClip ) { tools::PolyPolygon aDest; - tools::PolyPolygon(aClipPath.getClipPath()).GetIntersection( rPolyPolygon, aDest ); + tools::PolyPolygon(maClipPath.getClipPath()).GetIntersection( rPolyPolygon, aDest ); ImplDrawClippedPolyPolygon( aDest ); } else @@ -1352,7 +1354,7 @@ namespace emfio } } - void MtfToolsWriter::DrawPolyLine( tools::Polygon& rPolygon, bool bTo, bool bRecordPath ) + void MtfTools::DrawPolyLine( tools::Polygon& rPolygon, bool bTo, bool bRecordPath ) { UpdateClipRegion(); @@ -1366,7 +1368,7 @@ namespace emfio maActPos = rPolygon[ rPolygon.GetSize() - 1 ]; } if ( bRecordPath ) - aPathObj.AddPolyLine( rPolygon ); + maPathObj.AddPolyLine( rPolygon ); else { UpdateLineStyle(); @@ -1375,7 +1377,7 @@ namespace emfio } } - void MtfToolsWriter::DrawPolyBezier( tools::Polygon& rPolygon, bool bTo, bool bRecordPath ) + void MtfTools::DrawPolyBezier( tools::Polygon& rPolygon, bool bTo, bool bRecordPath ) { sal_uInt16 nPoints = rPolygon.GetSize(); if ( ( nPoints >= 4 ) && ( ( ( nPoints - 4 ) % 3 ) == 0 ) ) @@ -1396,7 +1398,7 @@ namespace emfio rPolygon.SetFlags( i++, PolyFlags::Control ); } if ( bRecordPath ) - aPathObj.AddPolyLine( rPolygon ); + maPathObj.AddPolyLine( rPolygon ); else { UpdateLineStyle(); @@ -1405,7 +1407,7 @@ namespace emfio } } - void MtfToolsWriter::DrawText( Point& rPosition, OUString& rText, long* pDXArry, long* pDYArry, bool bRecordPath, sal_Int32 nGfxMode ) + void MtfTools::DrawText( Point& rPosition, OUString& rText, long* pDXArry, long* pDYArry, bool bRecordPath, sal_Int32 nGfxMode ) { UpdateClipRegion(); rPosition = ImplMap( rPosition ); @@ -1599,7 +1601,7 @@ namespace emfio SetGfxMode( nOldGfxMode ); } - void MtfToolsWriter::ImplDrawBitmap( const Point& rPos, const Size& rSize, const BitmapEx& rBitmap ) + void MtfTools::ImplDrawBitmap( const Point& rPos, const Size& rSize, const BitmapEx& rBitmap ) { BitmapEx aBmpEx( rBitmap ); if ( mbComplexClip ) @@ -1617,7 +1619,7 @@ namespace emfio pVDev->SetMapMode( aMapMode ); pVDev->SetOutputSizePixel( aSizePixel ); pVDev->SetFillColor( Color( COL_BLACK ) ); - const tools::PolyPolygon aClip( aClipPath.getClipPath() ); + const tools::PolyPolygon aClip( maClipPath.getClipPath() ); pVDev->DrawPolyPolygon( aClip ); const Point aEmptyPoint; @@ -1691,7 +1693,7 @@ namespace emfio mpGDIMetaFile->AddAction( new MetaBmpScaleAction( rPos, rSize, aBmpEx.GetBitmap() ) ); } - void MtfToolsWriter::ResolveBitmapActions( std::vector<std::unique_ptr<BSaveStruct>>& rSaveList ) + void MtfTools::ResolveBitmapActions( std::vector<std::unique_ptr<BSaveStruct>>& rSaveList ) { UpdateClipRegion(); @@ -1931,19 +1933,19 @@ namespace emfio rSaveList.clear(); } - void MtfToolsWriter::SetDevOrg( const Point& rPoint ) + void MtfTools::SetDevOrg( const Point& rPoint ) { mnDevOrgX = rPoint.X(); mnDevOrgY = rPoint.Y(); } - void MtfToolsWriter::SetDevOrgOffset( sal_Int32 nXAdd, sal_Int32 nYAdd ) + void MtfTools::SetDevOrgOffset( sal_Int32 nXAdd, sal_Int32 nYAdd ) { mnDevOrgX += nXAdd; mnDevOrgY += nYAdd; } - void MtfToolsWriter::SetDevExt( const Size& rSize ,bool regular) + void MtfTools::SetDevExt( const Size& rSize ,bool regular) { if ( rSize.Width() && rSize.Height() ) { @@ -1963,13 +1965,13 @@ namespace emfio } } - void MtfToolsWriter::ScaleDevExt( double fX, double fY ) + void MtfTools::ScaleDevExt( double fX, double fY ) { mnDevWidth = FRound( mnDevWidth * fX ); mnDevHeight = FRound( mnDevHeight * fY ); } - void MtfToolsWriter::SetWinOrg( const Point& rPoint , bool bIsEMF) + void MtfTools::SetWinOrg( const Point& rPoint , bool bIsEMF) { mnWinOrgX = rPoint.X(); mnWinOrgY = rPoint.Y(); @@ -1980,13 +1982,13 @@ namespace emfio mbIsMapWinSet=true; } - void MtfToolsWriter::SetWinOrgOffset( sal_Int32 nXAdd, sal_Int32 nYAdd ) + void MtfTools::SetWinOrgOffset( sal_Int32 nXAdd, sal_Int32 nYAdd ) { mnWinOrgX += nXAdd; mnWinOrgY += nYAdd; } - void MtfToolsWriter::SetDevByWin() //mnWinExt...-stuff has to be assigned before. + void MtfTools::SetDevByWin() //mnWinExt...-stuff has to be assigned before. { if (!mbIsMapDevSet) { @@ -2000,7 +2002,7 @@ namespace emfio } } - void MtfToolsWriter::SetWinExt(const Size& rSize, bool bIsEMF) + void MtfTools::SetWinExt(const Size& rSize, bool bIsEMF) { if (rSize.Width() && rSize.Height()) { @@ -2021,35 +2023,35 @@ namespace emfio } } - void MtfToolsWriter::ScaleWinExt( double fX, double fY ) + void MtfTools::ScaleWinExt( double fX, double fY ) { mnWinExtX = FRound( mnWinExtX * fX ); mnWinExtY = FRound( mnWinExtY * fY ); } - void MtfToolsWriter::SetrclBounds( const tools::Rectangle& rRect ) + void MtfTools::SetrclBounds( const tools::Rectangle& rRect ) { mrclBounds = rRect; } - void MtfToolsWriter::SetrclFrame( const tools::Rectangle& rRect ) + void MtfTools::SetrclFrame( const tools::Rectangle& rRect ) { mrclFrame = rRect; } - void MtfToolsWriter::SetRefPix( const Size& rSize ) + void MtfTools::SetRefPix( const Size& rSize ) { mnPixX = rSize.Width(); mnPixY = rSize.Height(); } - void MtfToolsWriter::SetRefMill( const Size& rSize ) + void MtfTools::SetRefMill( const Size& rSize ) { mnMillX = rSize.Width(); mnMillY = rSize.Height(); } - void MtfToolsWriter::SetMapMode( sal_uInt32 nMapMode ) + void MtfTools::SetMapMode( sal_uInt32 nMapMode ) { mnMapMode = nMapMode; if ( nMapMode == MM_TEXT && !mbIsMapWinSet ) @@ -2064,7 +2066,7 @@ namespace emfio } } - void MtfToolsWriter::SetWorldTransform( const XForm& rXForm ) + void MtfTools::SetWorldTransform( const XForm& rXForm ) { maXForm.eM11 = rXForm.eM11; maXForm.eM12 = rXForm.eM12; @@ -2074,7 +2076,7 @@ namespace emfio maXForm.eDy = rXForm.eDy; } - void MtfToolsWriter::ModifyWorldTransform( const XForm& rXForm, sal_uInt32 nMode ) + void MtfTools::ModifyWorldTransform( const XForm& rXForm, sal_uInt32 nMode ) { switch( nMode ) { @@ -2152,7 +2154,7 @@ namespace emfio } } - void MtfToolsWriter::Push() // !! to be able to access the original ClipRegion it + void MtfTools::Push() // !! to be able to access the original ClipRegion it { // is not allowed to use the MetaPushAction() UpdateClipRegion(); // (the original clip region is on top of the stack) (SJ) std::shared_ptr<SaveStruct> pSave( new SaveStruct ); @@ -2183,19 +2185,19 @@ namespace emfio pSave->nDevWidth = mnDevWidth; pSave->nDevHeight = mnDevHeight; - pSave->aPathObj = aPathObj; - pSave->aClipPath = aClipPath; + pSave->maPathObj = maPathObj; + pSave->maClipPath = maClipPath; - vSaveStack.push_back( pSave ); + mvSaveStack.push_back( pSave ); } - void MtfToolsWriter::Pop() + void MtfTools::Pop() { // Get the latest data from the stack - if( !vSaveStack.empty() ) + if( !mvSaveStack.empty() ) { // Backup the current data on the stack - std::shared_ptr<SaveStruct> pSave( vSaveStack.back() ); + std::shared_ptr<SaveStruct> pSave( mvSaveStack.back() ); maLineStyle = pSave->aLineStyle; maFillStyle = pSave->aFillStyle; @@ -2223,24 +2225,24 @@ namespace emfio mnDevWidth = pSave->nDevWidth; mnDevHeight = pSave->nDevHeight; - aPathObj = pSave->aPathObj; - if ( ! ( aClipPath == pSave->aClipPath ) ) + maPathObj = pSave->maPathObj; + if ( ! ( maClipPath == pSave->maClipPath ) ) { - aClipPath = pSave->aClipPath; + maClipPath = pSave->maClipPath; mbClipNeedsUpdate = true; } if ( meLatestRasterOp != meRasterOp ) mpGDIMetaFile->AddAction( new MetaRasterOpAction( meRasterOp ) ); - vSaveStack.pop_back(); + mvSaveStack.pop_back(); } } - void MtfToolsWriter::AddFromGDIMetaFile( GDIMetaFile& rGDIMetaFile ) + void MtfTools::AddFromGDIMetaFile( GDIMetaFile& rGDIMetaFile ) { rGDIMetaFile.Play( *mpGDIMetaFile ); } - void MtfToolsWriter::PassEMFPlusHeaderInfo() + void MtfTools::PassEMFPlusHeaderInfo() { EMFP_DEBUG(printf ("\t\t\tadd EMF_PLUS header info\n")); @@ -2273,7 +2275,7 @@ namespace emfio mpGDIMetaFile->UseCanvas( true ); } - void MtfToolsWriter::PassEMFPlus( void* pBuffer, sal_uInt32 nLength ) + void MtfTools::PassEMFPlus( void* pBuffer, sal_uInt32 nLength ) { EMFP_DEBUG(printf ("\t\t\tadd EMF_PLUS comment length %04x\n",(unsigned int) nLength)); mpGDIMetaFile->AddAction( new MetaCommentAction( "EMF_PLUS", 0, static_cast<const sal_uInt8*>(pBuffer), nLength ) ); diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 80e134909266..f1a9a1310095 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -145,14 +145,14 @@ namespace emfio inline Point WmfReader::ReadPoint() { short nX = 0, nY = 0; - pWMF->ReadInt16( nX ).ReadInt16( nY ); + mpWMF->ReadInt16( nX ).ReadInt16( nY ); return Point( nX, nY ); } inline Point WmfReader::ReadYX() { short nX = 0, nY = 0; - pWMF->ReadInt16( nY ).ReadInt16( nX ); + mpWMF->ReadInt16( nY ).ReadInt16( nX ); return Point( nX, nY ); } @@ -169,7 +169,7 @@ namespace emfio Size WmfReader::ReadYXExt() { short nW=0, nH=0; - pWMF->ReadInt16( nH ).ReadInt16( nW ); + mpWMF->ReadInt16( nH ).ReadInt16( nW ); return Size( nW, nH ); } @@ -179,15 +179,15 @@ namespace emfio { case W_META_SETBKCOLOR: { - pOut->SetBkColor( ReadColor() ); + SetBkColor( ReadColor() ); } break; case W_META_SETBKMODE: { sal_uInt16 nDat = 0; - pWMF->ReadUInt16( nDat ); - pOut->SetBkMode( static_cast<BkMode>(nDat) ); + mpWMF->ReadUInt16( nDat ); + SetBkMode( static_cast<BkMode>(nDat) ); } break; @@ -195,57 +195,57 @@ namespace emfio case W_META_SETMAPMODE: { sal_Int16 nMapMode = 0; - pWMF->ReadInt16( nMapMode ); - pOut->SetMapMode( nMapMode ); + mpWMF->ReadInt16( nMapMode ); + SetMapMode( nMapMode ); } break; case W_META_SETROP2: { sal_uInt16 nROP2 = 0; - pWMF->ReadUInt16( nROP2 ); - pOut->SetRasterOp( (WMFRasterOp)nROP2 ); + mpWMF->ReadUInt16( nROP2 ); + SetRasterOp( (WMFRasterOp)nROP2 ); } break; case W_META_SETTEXTCOLOR: { - pOut->SetTextColor( ReadColor() ); + SetTextColor( ReadColor() ); } break; case W_META_SETWINDOWORG: { - pOut->SetWinOrg( ReadYX() ); + SetWinOrg( ReadYX() ); } break; case W_META_SETWINDOWEXT: { short nWidth = 0, nHeight = 0; - pWMF->ReadInt16( nHeight ).ReadInt16( nWidth ); - pOut->SetWinExt( Size( nWidth, nHeight ) ); + mpWMF->ReadInt16( nHeight ).ReadInt16( nWidth ); + SetWinExt( Size( nWidth, nHeight ) ); } break; case W_META_OFFSETWINDOWORG: { short nXAdd = 0, nYAdd = 0; - pWMF->ReadInt16( nYAdd ).ReadInt16( nXAdd ); - pOut->SetWinOrgOffset( nXAdd, nYAdd ); + mpWMF->ReadInt16( nYAdd ).ReadInt16( nXAdd ); + SetWinOrgOffset( nXAdd, nYAdd ); } break; case W_META_SCALEWINDOWEXT: { short nXNum = 0, nXDenom = 0, nYNum = 0, nYDenom = 0; - pWMF->ReadInt16( nYDenom ).ReadInt16( nYNum ).ReadInt16( nXDenom ).ReadInt16( nXNum ); + mpWMF->ReadInt16( nYDenom ).ReadInt16( nYNum ).ReadInt16( nXDenom ).ReadInt16( nXNum ); if (!nYDenom || !nXDenom) { - pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } - pOut->ScaleWinExt( (double)nXNum / nXDenom, (double)nYNum / nYDenom ); + ScaleWinExt( (double)nXNum / nXDenom, (double)nYNum / nYDenom ); } break; @@ -256,58 +256,58 @@ namespace emfio case W_META_OFFSETVIEWPORTORG: { short nXAdd = 0, nYAdd = 0; - pWMF->ReadInt16( nYAdd ).ReadInt16( nXAdd ); - pOut->SetDevOrgOffset( nXAdd, nYAdd ); + mpWMF->ReadInt16( nYAdd ).ReadInt16( nXAdd ); + SetDevOrgOffset( nXAdd, nYAdd ); } break; case W_META_SCALEVIEWPORTEXT: { short nXNum = 0, nXDenom = 0, nYNum = 0, nYDenom = 0; - pWMF->ReadInt16( nYDenom ).ReadInt16( nYNum ).ReadInt16( nXDenom ).ReadInt16( nXNum ); + mpWMF->ReadInt16( nYDenom ).ReadInt16( nYNum ).ReadInt16( nXDenom ).ReadInt16( nXNum ); if (!nYDenom || !nXDenom) { - pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } - pOut->ScaleDevExt( (double)nXNum / nXDenom, (double)nYNum / nYDenom ); + ScaleDevExt( (double)nXNum / nXDenom, (double)nYNum / nYDenom ); } break; case W_META_LINETO: { - pOut->LineTo( ReadYX() ); + LineTo( ReadYX() ); } break; case W_META_MOVETO: { - pOut->MoveTo( ReadYX() ); + MoveTo( ReadYX() ); } break; case W_META_INTERSECTCLIPRECT: { - pOut->IntersectClipRect( ReadRectangle() ); + IntersectClipRect( ReadRectangle() ); } break; case W_META_RECTANGLE: { - pOut->DrawRect( ReadRectangle() ); + DrawRect( ReadRectangle() ); } break; case W_META_ROUNDRECT: { Size aSize( ReadYXExt() ); - pOut->DrawRoundRect( ReadRectangle(), Size( aSize.Width() / 2, aSize.Height() / 2 ) ); + DrawRoundRect( ReadRectangle(), Size( aSize.Width() / 2, aSize.Height() / 2 ) ); } break; case W_META_ELLIPSE: { - pOut->DrawEllipse( ReadRectangle() ); + DrawEllipse( ReadRectangle() ); } break; @@ -317,7 +317,7 @@ namespace emfio Point aStart( ReadYX() ); tools::Rectangle aRect( ReadRectangle() ); aRect.Justify(); - pOut->DrawArc( aRect, aStart, aEnd ); + DrawArc( aRect, aStart, aEnd ); } break; @@ -331,9 +331,9 @@ namespace emfio // #i73608# OutputDevice deviates from WMF // semantics. start==end means full ellipse here. if( aStart == aEnd ) - pOut->DrawEllipse( aRect ); + DrawEllipse( aRect ); else - pOut->DrawPie( aRect, aStart, aEnd ); + DrawPie( aRect, aStart, aEnd ); } break; @@ -343,7 +343,7 @@ namespace emfio Point aStart( ReadYX() ); tools::Rectangle aRect( ReadRectangle() ); aRect.Justify(); - pOut->DrawChord( aRect, aStart, aEnd ); + DrawChord( aRect, aStart, aEnd ); } break; @@ -352,27 +352,27 @@ namespace emfio bool bRecordOk = true; sal_uInt16 nPoints(0); - pWMF->ReadUInt16(nPoints); + mpWMF->ReadUInt16(nPoints); - if (nPoints > pWMF->remainingSize() / (2 * sizeof(sal_uInt16))) + if (nPoints > mpWMF->remainingSize() / (2 * sizeof(sal_uInt16))) { bRecordOk = false; } else { tools::Polygon aPoly(nPoints); - for (sal_uInt16 i(0); i < nPoints && pWMF->good(); ++i) + for (sal_uInt16 i(0); i < nPoints && mpWMF->good(); ++i) aPoly[ i ] = ReadPoint(); - pOut->DrawPolygon(aPoly, false/*bRecordPath*/); + DrawPolygon(aPoly, false/*bRecordPath*/); } SAL_WARN_IF(!bRecordOk, "vcl.wmf", "polygon record has more points than we can handle"); - bRecordOk &= pWMF->good(); + bRecordOk &= mpWMF->good(); if (!bRecordOk) { - pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } } @@ -382,11 +382,11 @@ namespace emfio { sal_uInt16 nPolyCount(0); // Number of polygons: - pWMF->ReadUInt16( nPolyCount ); - if (nPolyCount && pWMF->good()) + mpWMF->ReadUInt16( nPolyCount ); + if (nPolyCount && mpWMF->good()) { bool bRecordOk = true; - if (nPolyCount > pWMF->remainingSize() / sizeof(sal_uInt16)) + if (nPolyCount > mpWMF->remainingSize() / sizeof(sal_uInt16)) { break; } @@ -396,9 +396,9 @@ namespace emfio sal_uInt16* pnPoints = xPolygonPointCounts.get(); tools::PolyPolygon aPolyPoly(nPolyCount, nPolyCount); sal_uInt16 nPoints = 0; - for (sal_uInt16 a = 0; a < nPolyCount && pWMF->good(); ++a) + for (sal_uInt16 a = 0; a < nPolyCount && mpWMF->good(); ++a) { - pWMF->ReadUInt16( pnPoints[a] ); + mpWMF->ReadUInt16( pnPoints[a] ); if (pnPoints[a] > SAL_MAX_UINT16 - nPoints) { @@ -411,20 +411,20 @@ namespace emfio SAL_WARN_IF(!bRecordOk, "vcl.wmf", "polypolygon record has more polygons than we can handle"); - bRecordOk &= pWMF->good(); + bRecordOk &= mpWMF->good(); if (!bRecordOk) { - pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } // Polygon points are: - for (sal_uInt16 a = 0; a < nPolyCount && pWMF->good(); ++a) + for (sal_uInt16 a = 0; a < nPolyCount && mpWMF->good(); ++a) { const sal_uInt16 nPointCount(pnPoints[a]); - if (nPointCount > pWMF->remainingSize() / (2 * sizeof(sal_uInt16))) + if (nPointCount > mpWMF->remainingSize() / (2 * sizeof(sal_uInt16))) { bRecordOk = false; break; @@ -433,7 +433,7 @@ namespace emfio std::unique_ptr<Point[]> xPolygonPoints(new Point[nPointCount]); Point* pPtAry = xPolygonPoints.get(); - for(sal_uInt16 b(0); b < nPointCount && pWMF->good(); ++b) + for(sal_uInt16 b(0); b < nPointCount && mpWMF->good(); ++b) { pPtAry[b] = ReadPoint(); } @@ -441,15 +441,15 @@ namespace emfio aPolyPoly.Insert( tools::Polygon(nPointCount, pPtAry) ); } - bRecordOk &= pWMF->good(); + bRecordOk &= mpWMF->good(); if (!bRecordOk) { - pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } - pOut->DrawPolyPolygon( aPolyPoly ); + DrawPolyPolygon( aPolyPoly ); } } break; @@ -459,27 +459,27 @@ namespace emfio bool bRecordOk = true; sal_uInt16 nPoints(0); - pWMF->ReadUInt16(nPoints); + mpWMF->ReadUInt16(nPoints); - if (nPoints > pWMF->remainingSize() / (2 * sizeof(sal_uInt16))) + if (nPoints > mpWMF->remainingSize() / (2 * sizeof(sal_uInt16))) { bRecordOk = false; } else { tools::Polygon aPoly(nPoints); - for (sal_uInt16 i(0); i < nPoints && pWMF->good(); ++i) + for (sal_uInt16 i(0); i < nPoints && mpWMF->good(); ++i) aPoly[ i ] = ReadPoint(); - pOut->DrawPolyLine( aPoly ); + DrawPolyLine( aPoly ); } SAL_WARN_IF(!bRecordOk, "vcl.wmf", "polyline record has more points than we can handle"); - bRecordOk &= pWMF->good(); + bRecordOk &= mpWMF->good(); if (!bRecordOk) { - pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } } @@ -487,59 +487,59 @@ namespace emfio case W_META_SAVEDC: { - pOut->Push(); + Push(); } break; case W_META_RESTOREDC: { - pOut->Pop(); + Pop(); } break; case W_META_SETPIXEL: { const Color aColor = ReadColor(); - pOut->DrawPixel( ReadYX(), aColor ); + DrawPixel( ReadYX(), aColor ); } break; case W_META_OFFSETCLIPRGN: { - pOut->MoveClipRegion( ReadYXExt() ); + MoveClipRegion( ReadYXExt() ); } break; case W_META_TEXTOUT: { sal_uInt16 nLength = 0; - pWMF->ReadUInt16( nLength ); + mpWMF->ReadUInt16( nLength ); if ( nLength ) { std::unique_ptr<char[]> pChar(new char[ ( nLength + 1 ) &~ 1 ]); - pWMF->ReadBytes(pChar.get(), (nLength + 1) &~ 1); - OUString aText( pChar.get(), nLength, pOut->GetCharSet() ); + mpWMF->ReadBytes(pChar.get(), (nLength + 1) &~ 1); + OUString aText( pChar.get(), nLength, GetCharSet() ); pChar.reset(); Point aPosition( ReadYX() ); - pOut->DrawText( aPosition, aText ); + DrawText( aPosition, aText ); } } break; case W_META_EXTTEXTOUT: { - pWMF->SeekRel(-6); - sal_Int32 nRecordPos = pWMF->Tell(), nRecordSize = 0; - pWMF->ReadInt32( nRecordSize ); - pWMF->SeekRel(2); + mpWMF->SeekRel(-6); + sal_Int32 nRecordPos = mpWMF->Tell(), nRecordSize = 0; + mpWMF->ReadInt32( nRecordSize ); + mpWMF->SeekRel(2); Point aPosition = ReadYX(); sal_uInt16 nLen = 0, nOptions = 0; - pWMF->ReadUInt16( nLen ).ReadUInt16( nOptions ); + mpWMF->ReadUInt16( nLen ).ReadUInt16( nOptions ); ComplexTextLayoutFlags nTextLayoutMode = ComplexTextLayoutFlags::Default; if ( nOptions & ETO_RTLREADING ) nTextLayoutMode = ComplexTextLayoutFlags::BiDiRtl | ComplexTextLayoutFlags::TextOriginLeft; - pOut->SetTextLayoutMode( nTextLayoutMode ); + SetTextLayoutMode( nTextLayoutMode ); SAL_WARN_IF( ( nOptions & ( ETO_PDY | ETO_GLYPH_INDEX ) ) != 0, "vcl.wmf", "SJ: ETO_PDY || ETO_GLYPH_INDEX in WMF" ); // output only makes sense if the text contains characters @@ -555,7 +555,7 @@ namespace emfio aRect = tools::Rectangle( aPt1, aPt2 ); } - auto nRemainingSize = pWMF->remainingSize(); + auto nRemainingSize = mpWMF->remainingSize(); if (nRemainingSize < static_cast<sal_uInt32>(nOriginalBlockLen)) { SAL_WARN("vcl.wmf", "exttextout record claimed more data than the stream can provide"); @@ -563,15 +563,15 @@ namespace emfio } std::unique_ptr<char[]> pChar(new char[nOriginalBlockLen]); - pWMF->ReadBytes(pChar.get(), nOriginalBlockLen); - OUString aText(pChar.get(), nOriginalTextLen, pOut->GetCharSet()); // after this conversion the text may contain + mpWMF->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 if ( nNewTextLen ) { std::unique_ptr<long[]> pDXAry, pDYAry; sal_uInt32 nMaxStreamPos = nRecordPos + ( nRecordSize << 1 ); - sal_Int32 nDxArySize = nMaxStreamPos - pWMF->Tell(); + sal_Int32 nDxArySize = nMaxStreamPos - mpWMF->Tell(); sal_Int32 nDxAryEntries = nDxArySize >> 1; bool bUseDXAry = false; @@ -585,13 +585,13 @@ namespace emfio } for (i = 0; i < nNewTextLen; i++ ) { - if ( pWMF->Tell() >= nMaxStreamPos ) + if ( mpWMF->Tell() >= nMaxStreamPos ) break; sal_Int32 nDxCount = 1; if ( nNewTextLen != nOriginalTextLen ) { sal_Unicode cUniChar = aText[i]; - OString aTmp(&cUniChar, 1, pOut->GetCharSet()); + OString aTmp(&cUniChar, 1, GetCharSet()); if ( aTmp.getLength() > 1 ) { nDxCount = aTmp.getLength(); @@ -601,17 +601,17 @@ namespace emfio sal_Int16 nDx = 0, nDy = 0; while ( nDxCount-- ) { - if ( ( pWMF->Tell() + 2 ) > nMaxStreamPos ) + if ( ( mpWMF->Tell() + 2 ) > nMaxStreamPos ) break; sal_Int16 nDxTmp = 0; - pWMF->ReadInt16(nDxTmp); + mpWMF->ReadInt16(nDxTmp); nDx += nDxTmp; if ( nOptions & ETO_PDY ) { - if ( ( pWMF->Tell() + 2 ) > nMaxStreamPos ) + if ( ( mpWMF->Tell() + 2 ) > nMaxStreamPos ) break; sal_Int16 nDyTmp = 0; - pWMF->ReadInt16(nDyTmp); + mpWMF->ReadInt16(nDyTmp); nDy += nDyTmp; } } @@ -626,9 +626,9 @@ namespace emfio bUseDXAry = true; } if ( pDXAry && bUseDXAry ) - pOut->DrawText( aPosition, aText, pDXAry.get(), pDYAry.get() ); + DrawText( aPosition, aText, pDXAry.get(), pDYAry.get() ); else - pOut->DrawText( aPosition, aText ); + DrawText( aPosition, aText ); } } } @@ -637,16 +637,16 @@ namespace emfio case W_META_SELECTOBJECT: { sal_Int16 nObjIndex = 0; - pWMF->ReadInt16( nObjIndex ); - pOut->SelectObject( nObjIndex ); + mpWMF->ReadInt16( nObjIndex ); + SelectObject( nObjIndex ); } break; case W_META_SETTEXTALIGN: { sal_uInt16 nAlign = 0; - pWMF->ReadUInt16( nAlign ); - pOut->SetTextAlign( nAlign ); + mpWMF->ReadUInt16( nAlign ); + SetTextAlign( nAlign ); } break; @@ -670,15 +670,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; - pWMF->ReadInt32( nWinROP ) + mpWMF->ReadInt32( nWinROP ) .ReadUInt16( nSy ).ReadUInt16( nSx ).ReadUInt16( nSye ).ReadUInt16( nSxe ); Point aPoint( ReadYX() ); - pWMF->ReadUInt16( nDontKnow ).ReadUInt16( nWidth ).ReadUInt16( nHeight ).ReadUInt16( nBytesPerScan ).ReadUChar( nPlanes ).ReadUChar( nBitCount ); + mpWMF->ReadUInt16( nDontKnow ).ReadUInt16( nWidth ).ReadUInt16( nHeight ).ReadUInt16( nBytesPerScan ).ReadUChar( nPlanes ).ReadUChar( nBitCount ); bool bOk = nWidth && nHeight && nPlanes == 1 && nBitCount == 1; if (bOk) { - bOk = nBytesPerScan <= pWMF->remainingSize() / nHeight; + bOk = nBytesPerScan <= mpWMF->remainingSize() / nHeight; } if (bOk) { @@ -686,13 +686,13 @@ namespace emfio Bitmap::ScopedWriteAccess pAcc(aBmp); if ( pAcc ) { - for (sal_uInt16 y = 0; y < nHeight && pWMF->good(); ++y) + for (sal_uInt16 y = 0; y < nHeight && mpWMF->good(); ++y) { sal_uInt16 x = 0; for (sal_uInt16 scan = 0; scan < nBytesPerScan; scan++ ) { sal_Int8 nEightPixels = 0; - pWMF->ReadSChar( nEightPixels ); + mpWMF->ReadSChar( nEightPixels ); for (sal_Int8 i = 7; i >= 0; i-- ) { if ( x < nWidth ) @@ -712,7 +712,7 @@ namespace emfio aBmp.Crop( aCropRect ); } tools::Rectangle aDestRect( aPoint, Size( nSxe, nSye ) ); - aBmpSaveList.emplace_back(new BSaveStruct(aBmp, aDestRect, nWinROP)); + maBmpSaveList.emplace_back(new BSaveStruct(aBmp, aDestRect, nWinROP)); } } } @@ -727,32 +727,32 @@ namespace emfio sal_uInt16 nSx = 0, nSy = 0, nSxe = 0, nSye = 0, nUsage = 0; Bitmap aBmp; - pWMF->ReadInt32( nWinROP ); + mpWMF->ReadInt32( nWinROP ); if( nFunc == W_META_STRETCHDIB ) - pWMF->ReadUInt16( nUsage ); + mpWMF->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 ) - pWMF->ReadUInt16( nSye ).ReadUInt16( nSxe ); + mpWMF->ReadUInt16( nSye ).ReadUInt16( nSxe ); // nSy and nx is the offset of the first pixel - pWMF->ReadUInt16( nSy ).ReadUInt16( nSx ); + mpWMF->ReadUInt16( nSy ).ReadUInt16( nSx ); if( nFunc == W_META_STRETCHDIB || nFunc == W_META_DIBBITBLT || nFunc == W_META_DIBSTRETCHBLT ) { if ( nWinROP == PATCOPY ) - pWMF->ReadUInt16( nUsage ); // i don't know anything of this parameter, so its called nUsage - // pOut->DrawRect( Rectangle( ReadYX(), aDestSize ), false ); + mpWMF->ReadUInt16( nUsage ); // i don't know anything of this parameter, so its called nUsage + // DrawRect( Rectangle( ReadYX(), aDestSize ), false ); Size aDestSize( ReadYXExt() ); if ( aDestSize.Width() && aDestSize.Height() ) // #92623# do not try to read buggy bitmaps { tools::Rectangle aDestRect( ReadYX(), aDestSize ); if ( nWinROP != PATCOPY ) - ReadDIB(aBmp, *pWMF, false); + ReadDIB(aBmp, *mpWMF, false); // test if it is sensible to crop if ( nSye && nSxe && @@ -762,7 +762,7 @@ namespace emfio tools::Rectangle aCropRect( Point( nSx, nSy ), Size( nSxe, nSye ) ); aBmp.Crop( aCropRect ); } - aBmpSaveList.emplace_back(new BSaveStruct(aBmp, aDestRect, nWinROP)); + maBmpSaveList.emplace_back(new BSaveStruct(aBmp, aDestRect, nWinROP)); } } } @@ -774,9 +774,9 @@ namespace emfio sal_uInt32 nRed = 0, nGreen = 0, nBlue = 0, nCount = 1; sal_uInt16 nFunction = 0; - pWMF->ReadUInt16( nFunction ).ReadUInt16( nFunction ); + mpWMF->ReadUInt16( nFunction ).ReadUInt16( nFunction ); - ReadDIB(aBmp, *pWMF, false); + ReadDIB(aBmp, *mpWMF, false); Bitmap::ScopedReadAccess pBmp(aBmp); if ( pBmp ) { @@ -797,33 +797,33 @@ namespace emfio pBmp.reset(); } Color aColor( (sal_uInt8)( nRed / nCount ), (sal_uInt8)( nGreen / nCount ), (sal_uInt8)( nBlue / nCount ) ); - pOut->CreateObject(o3tl::make_unique<WinMtfFillStyle>( aColor, false )); + CreateObject(o3tl::make_unique<WinMtfFillStyle>( aColor, false )); } break; case W_META_DELETEOBJECT: { sal_Int16 nIndex = 0; - pWMF->ReadInt16( nIndex ); - pOut->DeleteObject( nIndex ); + mpWMF->ReadInt16( nIndex ); + DeleteObject( nIndex ); } break; case W_META_CREATEPALETTE: { - pOut->CreateObject(); + CreateObject(); } break; case W_META_CREATEBRUSH: { - pOut->CreateObject(o3tl::make_unique<WinMtfFillStyle>( Color( COL_WHITE ), false )); + CreateObject(o3tl::make_unique<WinMtfFillStyle>( Color( COL_WHITE ), false )); } break; case W_META_CREATEPATTERNBRUSH: { - pOut->CreateObject(o3tl::make_unique<WinMtfFillStyle>( Color( COL_WHITE ), false )); + CreateObject(o3tl::make_unique<WinMtfFillStyle>( Color( COL_WHITE ), false )); } break; @@ -834,9 +834,9 @@ namespace emfio sal_uInt16 nWidth = 0; sal_uInt16 nHeight = 0; - pWMF->ReadUInt16(nStyle); - pWMF->ReadUInt16(nWidth); - pWMF->ReadUInt16(nHeight); + mpWMF->ReadUInt16(nStyle); + mpWMF->ReadUInt16(nWidth); + mpWMF->ReadUInt16(nHeight); if (nWidth > 0) aLineInfo.SetWidth(nWidth); @@ -900,15 +900,15 @@ namespace emfio default : aLineInfo.SetLineJoin ( basegfx::B2DLineJoin::NONE ); } - pOut->CreateObject(o3tl::make_unique<WinMtfLineStyle>( ReadColor(), aLineInfo, bTransparent )); + CreateObject(o3tl::make_unique<WinMtfLineStyle>( ReadColor(), aLineInfo, bTransparent )); } break; case W_META_CREATEBRUSHINDIRECT: { sal_uInt16 nStyle = 0; - pWMF->ReadUInt16( nStyle ); - pOut->CreateObject(o3tl::make_unique<WinMtfFillStyle>( ReadColor(), ( nStyle == BS_HOLLOW ) )); + mpWMF->ReadUInt16( nStyle ); + CreateObject(o3tl::make_unique<WinMtfFillStyle>( ReadColor(), ( nStyle == BS_HOLLOW ) )); } break; @@ -922,18 +922,18 @@ namespace emfio LOGFONTW aLogFont; aFontSize = ReadYXExt(); - pWMF->ReadInt16( lfEscapement ); - pWMF->ReadInt16( lfOrientation ); - pWMF->ReadInt16( lfWeight ); - pWMF->ReadUChar( aLogFont.lfItalic ); - pWMF->ReadUChar( aLogFont.lfUnderline ); - pWMF->ReadUChar( aLogFont.lfStrikeOut ); - pWMF->ReadUChar( aLogFont.lfCharSet ); - pWMF->ReadUChar( aLogFont.lfOutPrecision ); - pWMF->ReadUChar( aLogFont.lfClipPrecision ); - pWMF->ReadUChar( aLogFont.lfQuality ); - pWMF->ReadUChar( aLogFont.lfPitchAndFamily ); - size_t nRet = pWMF->ReadBytes( lfFaceName, LF_FACESIZE ); + 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 ); lfFaceName[nRet] = 0; aLogFont.lfWidth = aFontSize.Width(); aLogFont.lfHeight = aFontSize.Height(); @@ -952,31 +952,31 @@ namespace emfio eCharSet = RTL_TEXTENCODING_MS_1252; aLogFont.alfFaceName = OUString( lfFaceName, strlen(lfFaceName), eCharSet ); - pOut->CreateObject(o3tl::make_unique<WinMtfFontStyle>( aLogFont )); + CreateObject(o3tl::make_unique<WinMtfFontStyle>( aLogFont )); } break; case W_META_CREATEBITMAPINDIRECT: { - pOut->CreateObject(); + CreateObject(); } break; case W_META_CREATEBITMAP: { - pOut->CreateObject(); + CreateObject(); } break; case W_META_CREATEREGION: { - pOut->CreateObject(); + CreateObject(); } break; case W_META_EXCLUDECLIPRECT : { - pOut->ExcludeClipRect( ReadRectangle() ); + ExcludeClipRect( ReadRectangle() ); } break; @@ -984,60 +984,60 @@ namespace emfio { sal_uInt32 nROP = 0; WMFRasterOp nOldROP = WMFRasterOp::NONE; - pWMF->ReadUInt32( nROP ); + mpWMF->ReadUInt32( nROP ); Size aSize = ReadYXExt(); - nOldROP = pOut->SetRasterOp( (WMFRasterOp)nROP ); - pOut->DrawRect( tools::Rectangle( ReadYX(), aSize ), false ); - pOut->SetRasterOp( nOldROP ); + nOldROP = SetRasterOp( (WMFRasterOp)nROP ); + DrawRect( tools::Rectangle( ReadYX(), aSize ), false ); + SetRasterOp( nOldROP ); } break; case W_META_SELECTCLIPREGION: { sal_Int16 nObjIndex = 0; - pWMF->ReadInt16( nObjIndex ); + mpWMF->ReadInt16( nObjIndex ); if ( !nObjIndex ) { tools::PolyPolygon aEmptyPolyPoly; - pOut->SetClipPath( aEmptyPolyPoly, RGN_COPY, true ); + SetClipPath( aEmptyPolyPoly, RGN_COPY, true ); } } break; case W_META_ESCAPE : { - // nRecSize has been checked previously to be greater than 3 - sal_uInt64 nMetaRecSize = static_cast< sal_uInt64 >( nRecSize - 2 ) * 2; - sal_uInt64 nMetaRecEndPos = pWMF->Tell() + nMetaRecSize; + // 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; - // taking care that nRecSize does not exceed the maximal stream position - if ( nMetaRecEndPos > nEndPos ) + // taking care that mnRecSize does not exceed the maximal stream position + if ( nMetaRecEndPos > mnEndPos ) { - pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } - if ( nRecSize >= 4 ) // minimal escape length + if (mnRecSize >= 4 ) // minimal escape length { sal_uInt16 nMode = 0, nLen = 0; - pWMF->ReadUInt16( nMode ) + mpWMF->ReadUInt16( nMode ) .ReadUInt16( nLen ); if ( ( nMode == W_MFCOMMENT ) && ( nLen >= 4 ) ) { sal_uInt32 nNewMagic = 0; // we have to read int32 for - pWMF->ReadUInt32( nNewMagic ); // META_ESCAPE_ENHANCED_METAFILE CommentIdentifier + mpWMF->ReadUInt32( nNewMagic ); // META_ESCAPE_ENHANCED_METAFILE CommentIdentifier if( nNewMagic == 0x2c2a4f4f && nLen >= 14 ) { sal_uInt16 nMagic2 = 0; - pWMF->ReadUInt16( nMagic2 ); + mpWMF->ReadUInt16( nMagic2 ); if( nMagic2 == 0x0a ) // 2nd half of magic { // continue with private escape sal_uInt32 nCheck = 0, nEsc = 0; - pWMF->ReadUInt32( nCheck ) + mpWMF->ReadUInt32( nCheck ) .ReadUInt32( nEsc ); sal_uInt32 nEscLen = nLen - 14; - if ( nEscLen <= ( nRecSize * 2 ) ) + if ( nEscLen <= (mnRecSize * 2 ) ) { #ifdef OSL_BIGENDIAN sal_uInt32 nTmp = OSL_SWAPDWORD( nEsc ); @@ -1047,15 +1047,15 @@ namespace emfio #endif std::unique_ptr<sal_Int8[]> pData; - if ( ( static_cast< sal_uInt64 >( nEscLen ) + pWMF->Tell() ) > nMetaRecEndPos ) + if ( ( static_cast< sal_uInt64 >( nEscLen ) + mpWMF->Tell() ) > nMetaRecEndPos ) { - pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } if ( nEscLen > 0 ) { pData.reset(new sal_Int8[ nEscLen ]); - pWMF->ReadBytes(pData.get(), nEscLen); + mpWMF->ReadBytes(pData.get(), nEscLen); nCheckSum = rtl_crc32( nCheckSum, pData.get(), nEscLen ); } if ( nCheck == nCheckSum ) @@ -1065,7 +1065,7 @@ namespace emfio case PRIVATE_ESCAPE_UNICODE : { // we will use text instead of polygons only if we have the correct font - if ( Application::GetDefaultDevice()->IsFontAvailable( pOut->GetFont().GetFamilyName() ) ) + if ( Application::GetDefaultDevice()->IsFontAvailable( GetFont().GetFamilyName() ) ) { Point aPt; OUString aString; @@ -1096,8 +1096,8 @@ namespace emfio aMemoryStream.ReadInt32( val); pDXAry[ i ] = val; } - aMemoryStream.ReadUInt32( nSkipActions ); - pOut->DrawText( aPt, aString, pDXAry.get() ); + aMemoryStream.ReadUInt32(mnSkipActions); + DrawText( aPt, aString, pDXAry.get() ); } } } @@ -1107,58 +1107,58 @@ namespace emfio } } } - else if ( (nNewMagic == static_cast< sal_uInt32 >(0x43464D57)) && (nLen >= 34) && ( (sal_Int32)(nLen + 10) <= (sal_Int32)(nRecSize * 2) )) + else if ( (nNewMagic == static_cast< sal_uInt32 >(0x43464D57)) && (nLen >= 34) && ( (sal_Int32)(nLen + 10) <= (sal_Int32)(mnRecSize * 2) )) { sal_uInt32 nComType = 0, nVersion = 0, nFlags = 0, nComRecCount = 0, nCurRecSize = 0, nRemainingSize = 0, nEMFTotalSize = 0; sal_uInt16 nCheck = 0; - pWMF->ReadUInt32( nComType ).ReadUInt32( nVersion ).ReadUInt16( nCheck ).ReadUInt32( nFlags ) + mpWMF->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 if( nComType == 0x01 && nVersion == 0x10000 && nComRecCount ) { - if( !nEMFRec ) + if( !mnEMFRec) { // first EMF comment - nEMFRecCount = nComRecCount; - nEMFSize = nEMFTotalSize; - if (nEMFSize > pWMF->remainingSize()) + mnEMFRecCount = nComRecCount; + mnEMFSize = nEMFTotalSize; + if (mnEMFSize > mpWMF->remainingSize()) { SAL_WARN("vcl.wmf", "emf size claims to be larger than remaining data"); - pEMFStream.reset(); + mpEMFStream.reset(); } else - pEMFStream = o3tl::make_unique<SvMemoryStream>(nEMFSize, 0); + mpEMFStream = o3tl::make_unique<SvMemoryStream>(mnEMFSize, 0); } - else if( ( nEMFRecCount != nComRecCount ) || ( nEMFSize != nEMFTotalSize ) ) // add additional checks here + else if( (mnEMFRecCount != nComRecCount ) || (mnEMFSize != nEMFTotalSize ) ) // add additional checks here { // total records should be the same as in previous comments - nEMFRecCount = 0xFFFFFFFF; - pEMFStream.reset(); + mnEMFRecCount = 0xFFFFFFFF; + mpEMFStream.reset(); } - nEMFRec++; + mnEMFRec++; - if (pEMFStream && nCurRecSize + 34 > nLen) + if (mpEMFStream && nCurRecSize + 34 > nLen) { - nEMFRecCount = 0xFFFFFFFF; - pEMFStream.reset(); + mnEMFRecCount = 0xFFFFFFFF; + mpEMFStream.reset(); } - if (pEMFStream && nCurRecSize > pWMF->remainingSize()) + if (mpEMFStream && nCurRecSize > mpWMF->remainingSize()) { SAL_WARN("vcl.wmf", "emf record size claims to be larger than remaining data"); - nEMFRecCount = 0xFFFFFFFF; - pEMFStream.reset(); + mnEMFRecCount = 0xFFFFFFFF; + mpEMFStream.reset(); } - if (pEMFStream) + if (mpEMFStream) { std::vector<sal_Int8> aBuf(nCurRecSize); - sal_uInt32 nCount = pWMF->ReadBytes(aBuf.data(), nCurRecSize); + sal_uInt32 nCount = mpWMF->ReadBytes(aBuf.data(), nCurRecSize); if( nCount == nCurRecSize ) - pEMFStream->WriteBytes(aBuf.data(), nCount); + mpEMFStream->WriteBytes(aBuf.data(), nCount); } } } @@ -1200,12 +1200,12 @@ namespace emfio bool WmfReader::ReadHeader() { - sal_uInt64 const nStrmPos = pWMF->Tell(); + sal_uInt64 const nStrmPos = mpWMF->Tell(); sal_uInt32 nPlaceableMetaKey(0); // if available read the METAFILEHEADER - pWMF->ReadUInt32( nPlaceableMetaKey ); - if (!pWMF->good()) + mpWMF->ReadUInt32( nPlaceableMetaKey ); + if (!mpWMF->good()) return false; tools::Rectangle aPlaceableBound; @@ -1220,201 +1220,173 @@ namespace emfio sal_Int16 nVal; // Skip reserved bytes - pWMF->SeekRel(2); + mpWMF->SeekRel(2); // BoundRect - pWMF->ReadInt16( nVal ); + mpWMF->ReadInt16( nVal ); aPlaceableBound.Left() = nVal; - pWMF->ReadInt16( nVal ); + mpWMF->ReadInt16( nVal ); aPlaceableBound.Top() = nVal; - pWMF->ReadInt16( nVal ); + mpWMF->ReadInt16( nVal ); aPlaceableBound.Right() = nVal; - pWMF->ReadInt16( nVal ); + mpWMF->ReadInt16( nVal ); aPlaceableBound.Bottom() = nVal; // inch - pWMF->ReadUInt16( nUnitsPerInch ); + mpWMF->ReadUInt16( mnUnitsPerInch ); // reserved - pWMF->SeekRel( 4 ); + mpWMF->SeekRel( 4 ); // Skip and don't check the checksum - pWMF->SeekRel( 2 ); + mpWMF->SeekRel( 2 ); } else { - nUnitsPerInch = 96; + mnUnitsPerInch = 96; - if ( pExternalHeader != nullptr - && pExternalHeader->xExt > 0 - && pExternalHeader->yExt > 0 - && (pExternalHeader->mapMode == MM_ISOTROPIC || pExternalHeader->mapMode == MM_ANISOTROPIC)) - { - // #n417818#: If we have an external header then overwrite the bounds! - tools::Rectangle aExtRect(0, 0, - (double) pExternalHeader->xExt * 567 * nUnitsPerInch / 1440000, - (double) pExternalHeader->yExt * 567 * nUnitsPerInch / 1440000); - aPlaceableBound = aExtRect; - - SAL_INFO("vcl.wmf", "External header size " - " t: " << aPlaceableBound.Left() << " l: " << aPlaceableBound.Top() - << " b: " << aPlaceableBound.Right() << " r: " << aPlaceableBound.Bottom()); + mpWMF->Seek( nStrmPos + 18 ); // set the streampos to the start of the metaactions + GetPlaceableBound( aPlaceableBound, mpWMF ); - pOut->SetMapMode( pExternalHeader->mapMode ); - } - else + // The image size is not known so normalize the calculated bounds so that the + // resulting image is not too big + const double fMaxWidth = static_cast<double>(aMaxWidth); + if (aPlaceableBound.GetWidth() > aMaxWidth) { - pWMF->Seek( nStrmPos + 18 ); // set the streampos to the start of the metaactions - GetPlaceableBound( aPlaceableBound, pWMF ); + double fRatio = aPlaceableBound.GetWidth() / fMaxWidth; - // The image size is not known so normalize the calculated bounds so that the - // resulting image is not too big - const double fMaxWidth = static_cast<double>(aMaxWidth); - if (aPlaceableBound.GetWidth() > aMaxWidth) - { - double fRatio = aPlaceableBound.GetWidth() / fMaxWidth; - - aPlaceableBound = tools::Rectangle( - aPlaceableBound.Left() / fRatio, - aPlaceableBound.Top() / fRatio, - aPlaceableBound.Right() / fRatio, - aPlaceableBound.Bottom() / fRatio); + aPlaceableBound = tools::Rectangle( + aPlaceableBound.Left() / fRatio, + aPlaceableBound.Top() / fRatio, + aPlaceableBound.Right() / fRatio, + aPlaceableBound.Bottom() / fRatio); - SAL_INFO("vcl.wmf", "Placeable bounds " - " t: " << aPlaceableBound.Left() << " l: " << aPlaceableBound.Top() - << " b: " << aPlaceableBound.Right() << " r: " << aPlaceableBound.Bottom()); - } + SAL_INFO("vcl.wmf", "Placeable bounds " + " t: " << aPlaceableBound.Left() << " l: " << aPlaceableBound.Top() + << " b: " << aPlaceableBound.Right() << " r: " << aPlaceableBound.Bottom()); } - pWMF->Seek( nStrmPos ); + mpWMF->Seek( nStrmPos ); } - pOut->SetWinOrg( aPlaceableBound.TopLeft() ); + SetWinOrg( aPlaceableBound.TopLeft() ); Size aWMFSize( labs( aPlaceableBound.GetWidth() ), labs( aPlaceableBound.GetHeight() ) ); - pOut->SetWinExt( aWMFSize ); + SetWinExt( aWMFSize ); SAL_INFO("vcl.wmf", "WMF size w: " << aWMFSize.Width() << " h: " << aWMFSize.Height()); Size aDevExt( 10000, 10000 ); if( ( labs( aWMFSize.Width() ) > 1 ) && ( labs( aWMFSize.Height() ) > 1 ) ) { - const Fraction aFrac( 1, nUnitsPerInch ); + const Fraction aFrac( 1, mnUnitsPerInch); MapMode aWMFMap( MapUnit::MapInch, Point(), aFrac, aFrac ); Size aSize100( OutputDevice::LogicToLogic( aWMFSize, aWMFMap, MapUnit::Map100thMM ) ); aDevExt = Size( labs( aSize100.Width() ), labs( aSize100.Height() ) ); } - pOut->SetDevExt( aDevExt ); + SetDevExt( aDevExt ); SAL_INFO("vcl.wmf", "Dev size w: " << aDevExt.Width() << " h: " << aDevExt.Height()); // read the METAHEADER sal_uInt32 nMetaKey(0); - pWMF->ReadUInt32( nMetaKey ); // type and headersize - if (!pWMF->good()) + mpWMF->ReadUInt32( nMetaKey ); // type and headersize + if (!mpWMF->good()) return false; if (nMetaKey != 0x00090001) { sal_uInt16 aNextWord(0); - pWMF->ReadUInt16( aNextWord ); + mpWMF->ReadUInt16( aNextWord ); if (nMetaKey != 0x10000 || aNextWord != 0x09) { - pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); return false; } } - pWMF->SeekRel( 2 ); // Version (of Windows) - pWMF->SeekRel( 4 ); // Size (of file in words) - pWMF->SeekRel( 2 ); // NoObjects (maximum number of simultaneous objects) - pWMF->SeekRel( 4 ); // MaxRecord (size of largest record in words) - pWMF->SeekRel( 2 ); // NoParameters (Unused + 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 - return pWMF->good(); + return mpWMF->good(); } void WmfReader::ReadWMF() { sal_uInt16 nFunction; - sal_uLong nPos, nPercent, nLastPercent; + sal_uLong nPos; - nSkipActions = 0; - nCurrentAction = 0; + mnSkipActions = 0; + mnCurrentAction = 0; - pEMFStream.reset(); - nEMFRecCount = 0; - nEMFRec = 0; - nEMFSize = 0; + mpEMFStream.reset(); + mnEMFRecCount = 0; + mnEMFRec = 0; + mnEMFSize = 0; - pOut->SetMapMode( MM_ANISOTROPIC ); - pOut->SetWinOrg( Point() ); - pOut->SetWinExt( Size( 1, 1 ) ); - pOut->SetDevExt( Size( 10000, 10000 ) ); + SetMapMode( MM_ANISOTROPIC ); + SetWinOrg( Point() ); + SetWinExt( Size( 1, 1 ) ); + SetDevExt( Size( 10000, 10000 ) ); - nEndPos=pWMF->Seek( STREAM_SEEK_TO_END ); - pWMF->Seek( nStartPos ); - Callback( (sal_uInt16) ( nLastPercent = 0 ) ); + mnEndPos=mpWMF->Seek( STREAM_SEEK_TO_END ); + mpWMF->Seek( mnStartPos ); if ( ReadHeader( ) ) { - nPos = pWMF->Tell(); + nPos = mpWMF->Tell(); - if( nEndPos - nStartPos ) + if( mnEndPos - mnStartPos ) { bool bEMFAvailable = false; while( true ) { - nCurrentAction++; - nPercent = ( nPos - nStartPos ) * 100 / ( nEndPos - nStartPos ); + mnCurrentAction++; + mpWMF->ReadUInt32(mnRecSize).ReadUInt16( nFunction ); - if( nLastPercent + 4 <= nPercent ) - { - Callback( (sal_uInt16) nPercent ); - nLastPercent = nPercent; - } - pWMF->ReadUInt32( nRecSize ).ReadUInt16( nFunction ); - - if( pWMF->GetError() - || ( nRecSize < 3 ) - || ( nRecSize == 3 + if( mpWMF->GetError() + || (mnRecSize < 3 ) + || (mnRecSize == 3 && nFunction == 0 ) - || pWMF->IsEof() + || mpWMF->IsEof() ) { - if( pWMF->IsEof() ) - pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + if( mpWMF->IsEof() ) + mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); break; } if ( !bEMFAvailable ) { - if( !aBmpSaveList.empty() + if( !maBmpSaveList.empty() && ( nFunction != W_META_STRETCHDIB ) && ( nFunction != W_META_DIBBITBLT ) && ( nFunction != W_META_DIBSTRETCHBLT ) ) { - pOut->ResolveBitmapActions( aBmpSaveList ); + ResolveBitmapActions( maBmpSaveList ); } - if ( !nSkipActions ) + if ( !mnSkipActions) ReadRecordParams( nFunction ); else - nSkipActions--; + mnSkipActions--; - if( pEMFStream && nEMFRecCount == nEMFRec ) + if(mpEMFStream && mnEMFRecCount == mnEMFRec) { GDIMetaFile aMeta; - pEMFStream->Seek( 0 ); - std::unique_ptr<EmfReader> pEMFReader(o3tl::make_unique<EmfReader>( *pEMFStream, aMeta )); + mpEMFStream->Seek( 0 ); + std::unique_ptr<EmfReader> pEMFReader(o3tl::make_unique<EmfReader>( *mpEMFStream, aMeta )); bEMFAvailable = pEMFReader->ReadEnhWMF(); pEMFReader.reset(); // destroy first!!! if( bEMFAvailable ) { - pOut->AddFromGDIMetaFile( aMeta ); - pOut->SetrclFrame( tools::Rectangle( Point(0, 0), aMeta.GetPrefSize())); + AddFromGDIMetaFile( aMeta ); + SetrclFrame( tools::Rectangle( Point(0, 0), aMeta.GetPrefSize())); // the stream needs to be set to the wmf end position, // otherwise the GfxLink that is created will be incorrect @@ -1426,29 +1398,31 @@ namespace emfio { // something went wrong // continue with WMF, don't try this again - pEMFStream.reset(); + mpEMFStream.reset(); } } } - const sal_uInt32 nAvailableBytes = nEndPos - nPos; + + const sal_uInt32 nAvailableBytes = mnEndPos - nPos; const sal_uInt32 nMaxPossibleRecordSize = nAvailableBytes/2; - if (nRecSize <= nMaxPossibleRecordSize) + + if (mnRecSize <= nMaxPossibleRecordSize) { - nPos += nRecSize * 2; - pWMF->Seek(nPos); + nPos += mnRecSize * 2; + mpWMF->Seek(nPos); } else - pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); + mpWMF->SetError( SVSTREAM_FILEFORMAT_ERROR ); } } else - pWMF->SetError( SVSTREAM_GENERALERROR ); + mpWMF->SetError( SVSTREAM_GENERALERROR ); - if( !pWMF->GetError() && !aBmpSaveList.empty() ) - pOut->ResolveBitmapActions( aBmpSaveList ); + if( !mpWMF->GetError() && !maBmpSaveList.empty() ) + ResolveBitmapActions( maBmpSaveList ); } - if ( pWMF->GetError() ) - pWMF->Seek( nStartPos ); + if ( mpWMF->GetError() ) + mpWMF->Seek( mnStartPos ); } void WmfReader::GetPlaceableBound( tools::Rectangle& rPlaceableBound, SvStream* pStm ) @@ -1749,7 +1723,7 @@ namespace emfio { if ( nWinROP == PATCOPY ) pStm->ReadUInt16( nUsage ); // i don't know anything of this parameter, so its called nUsage - // pOut->DrawRect( Rectangle( ReadYX(), aDestSize ), false ); + // DrawRect( Rectangle( ReadYX(), aDestSize ), false ); Size aDestSize( ReadYXExt() ); if ( aDestSize.Width() && aDestSize.Height() ) // #92623# do not try to read buggy bitmaps @@ -1829,18 +1803,18 @@ namespace emfio } } - WmfReader::WmfReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile, - FilterConfigItem* pConfigItem, WMF_EXTERNALHEADER* pExtHeader) - : MtfTools(rGDIMetaFile, rStreamWMF, pConfigItem) - , nUnitsPerInch(96) - , nRecSize(0) - , nEMFRecCount(0) - , nEMFRec(0) - , nEMFSize(0) - , nSkipActions(0) - , nCurrentAction(0) - , pExternalHeader(pExtHeader) - {} + WmfReader::WmfReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile) + : MtfTools(rGDIMetaFile, rStreamWMF) + , mnUnitsPerInch(96) + , mnRecSize(0) + , mpEMFStream() + , mnEMFRecCount(0) + , mnEMFRec(0) + , mnEMFSize(0) + , mnSkipActions(0) + , mnCurrentAction(0) + { + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |