[ooo-build-commit] patches/dev300
Radek DoulÃk
rodo at kemper.freedesktop.org
Tue Dec 8 09:19:47 PST 2009
patches/dev300/apply | 7
patches/dev300/svtools-embedemf.diff | 454 +++++++++++++++++++++++++
patches/dev300/svtools-emf-fix.diff | 217 +++++++++++
patches/dev300/svtools-wmf-clean-warnings.diff | 63 +++
4 files changed, 741 insertions(+)
New commits:
commit 33af798896652226d1bfe37493ddf8de8db78799
Author: Radek Doulik <rodo at novell.com>
Date: Tue Dec 8 18:16:49 2009 +0100
2 upstream patches for wmf/emf + some cleaning to avoid warnings
* patches/dev300/apply:
* patches/dev300/svtools-embedemf.diff:
* patches/dev300/svtools-emf-fix.diff:
* patches/dev300/svtools-wmf-clean-warnings.diff:
diff --git a/patches/dev300/apply b/patches/dev300/apply
index 473d0c0..253328b 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -3490,3 +3490,10 @@ always-save-option-svx.diff, n#556125, i#5226, kohei
[ Speed ]
# don't throw unnecessary exceptions in sfx2
speed-sfx2-dont-throw-too-much.diff, i#107512, jholesov
+
+[ EMFPlus ]
+
+# 2 upstream patches for emf
+svtools-emf-fix.diff, i#105480, rodo
+svtools-wmf-clean-warnings.diff, rodo
+svtools-embedemf.diff, i#107291, rodo
diff --git a/patches/dev300/svtools-embedemf.diff b/patches/dev300/svtools-embedemf.diff
new file mode 100644
index 0000000..400b6bb
--- /dev/null
+++ b/patches/dev300/svtools-embedemf.diff
@@ -0,0 +1,454 @@
+diff -rup svtools-orig-1/source/filter.vcl/wmf/winmtf.cxx svtools/source/filter.vcl/wmf/winmtf.cxx
+--- svtools-orig-1/source/filter.vcl/wmf/winmtf.cxx 2009-12-08 18:01:50.000000000 +0100
++++ svtools/source/filter.vcl/wmf/winmtf.cxx 2009-12-08 18:02:32.000000000 +0100
+@@ -2293,3 +2293,8 @@ void WinMtfOutput::PassEMFPlus( void* pB
+ EMFP_DEBUG(printf ("\t\t\tadd EMF_PLUS comment length %d\n", nLength));
+ mpGDIMetaFile->AddAction( new MetaCommentAction( "EMF_PLUS", 0, static_cast<const BYTE*>(pBuffer), nLength ) );
+ }
++
++void WinMtfOutput::AddFromGDIMetaFile( GDIMetaFile& rGDIMetaFile )
++{
++ rGDIMetaFile.Play( *mpGDIMetaFile, 0xFFFFFFFF );
++}
+diff -rup svtools-orig-1/source/filter.vcl/wmf/winmtf.hxx svtools/source/filter.vcl/wmf/winmtf.hxx
+--- svtools-orig-1/source/filter.vcl/wmf/winmtf.hxx 2009-12-08 18:01:50.000000000 +0100
++++ svtools/source/filter.vcl/wmf/winmtf.hxx 2009-12-08 18:02:03.000000000 +0100
+@@ -692,6 +692,7 @@ class WinMtfOutput
+ void MoveClipRegion( const Size& rSize );
+ void SetClipPath( const PolyPolygon& rPolyPoly, sal_Int32 nClippingMode, sal_Bool bIsMapped );
+ void UpdateClipRegion();
++ void AddFromGDIMetaFile( GDIMetaFile& rGDIMetaFile );
+
+ void PassEMFPlus( void* pBuffer, UINT32 nLength );
+ void PassEMFPlusHeaderInfo();
+@@ -761,6 +762,18 @@ private:
+ UINT16 nUnitsPerInch;
+ sal_uInt32 nRecSize;
+
++ // embedded EMF data
++ SvMemoryStream* pEMFStream;
++
++ // total number of comment records containing EMF data
++ sal_uInt32 nEMFRecCount;
++
++ // number of EMF records read
++ sal_uInt32 nEMFRec;
++
++ // total size of embedded EMF data
++ sal_uInt32 nEMFSize;
++
+ sal_uInt32 nSkipActions;
+ sal_uInt32 nCurrentAction;
+ sal_uInt32 nUnicodeEscapeAction;
+@@ -781,6 +794,8 @@ public:
+
+ WMFReader( SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile, FilterConfigItem* pConfigItem = NULL )
+ : WinMtf( new WinMtfOutput( rGDIMetaFile ), rStreamWMF, pConfigItem ) {};
++
++ ~WMFReader();
+
+ // Liesst aus dem Stream eine WMF-Datei und fuellt das GDIMetaFile
+ void ReadWMF(WMF_APMFILEHEADER *pAPMHeader=NULL);
+diff -rup svtools-orig-1/source/filter.vcl/wmf/winwmf.cxx svtools/source/filter.vcl/wmf/winwmf.cxx
+--- svtools-orig-1/source/filter.vcl/wmf/winwmf.cxx 2009-12-08 18:01:50.000000000 +0100
++++ svtools/source/filter.vcl/wmf/winwmf.cxx 2009-12-08 18:07:59.000000000 +0100
+@@ -32,6 +32,7 @@
+ #include "precompiled_svtools.hxx"
+
+ #include "winmtf.hxx"
++#include <vcl/gdimtf.hxx>
+ #include <svtools/wmf.hxx>
+ #include <rtl/crc.h>
+ #include <rtl/tencinfo.h>
+@@ -832,81 +833,136 @@ void WMFReader::ReadRecordParams( USHORT
+ pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR );
+ break;
+ }
+- if ( nRecSize >= 12 ) // minimal escape lenght
++ if ( nRecSize >= 4 ) // minimal escape lenght
+ {
+- sal_uInt16 nMode, nLen, OO;
+- sal_uInt32 Magic, nCheck,nEsc;
++ sal_uInt16 nMode, nLen;
+ *pWMF >> nMode
+- >> nLen
+- >> OO
+- >> Magic
+- >> nCheck
+- >> nEsc;
+- if ( ( nMode == W_MFCOMMENT ) && ( nLen >= 14 ) && ( OO == 0x4f4f ) && ( Magic == 0xa2c2a ) )
++ >> nLen;
++ if ( ( nMode == W_MFCOMMENT ) && ( nLen >= 4 ) )
+ {
+- sal_uInt32 nEscLen = nLen - 14;
+- if ( nEscLen <= ( nRecSize * 2 ) )
++ sal_uInt32 nNewMagic; // we have to read int32 for
++ *pWMF >> nNewMagic; // META_ESCAPE_ENHANCED_METAFILE CommentIdentifier
++
++ if( nNewMagic == 0x2c2a4f4f && nLen >= 14 )
+ {
++ sal_uInt16 nMagic2;
++ *pWMF >> nMagic2;
++ if( nMagic2 == 0x0a ) // 2nd half of magic
++ { // continue with private escape
++ sal_uInt32 nCheck, nEsc;
++ *pWMF >> nCheck
++ >> nEsc;
++
++ sal_uInt32 nEscLen = nLen - 14;
++ if ( nEscLen <= ( nRecSize * 2 ) )
++ {
+ #ifdef OSL_BIGENDIAN
+- sal_uInt32 nTmp = SWAPLONG( nEsc );
+- sal_uInt32 nCheckSum = rtl_crc32( 0, &nTmp, 4 );
++ sal_uInt32 nTmp = SWAPLONG( nEsc );
++ sal_uInt32 nCheckSum = rtl_crc32( 0, &nTmp, 4 );
+ #else
+- sal_uInt32 nCheckSum = rtl_crc32( 0, &nEsc, 4 );
++ sal_uInt32 nCheckSum = rtl_crc32( 0, &nEsc, 4 );
+ #endif
+- sal_Int8* pData = NULL;
++ sal_Int8* pData = NULL;
+
+- if ( ( static_cast< sal_uInt64 >( nEscLen ) + pWMF->Tell() ) > nMetaRecEndPos )
+- {
+- pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR );
+- break;
+- }
+- if ( nEscLen > 0 )
+- {
+- pData = new sal_Int8[ nEscLen ];
+- pWMF->Read( pData, nEscLen );
+- nCheckSum = rtl_crc32( nCheckSum, pData, nEscLen );
++ if ( ( static_cast< sal_uInt64 >( nEscLen ) + pWMF->Tell() ) > nMetaRecEndPos )
++ {
++ pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR );
++ break;
++ }
++ if ( nEscLen > 0 )
++ {
++ pData = new sal_Int8[ nEscLen ];
++ pWMF->Read( pData, nEscLen );
++ nCheckSum = rtl_crc32( nCheckSum, pData, nEscLen );
++ }
++ if ( nCheck == nCheckSum )
++ {
++ switch( nEsc )
++ {
++ case PRIVATE_ESCAPE_UNICODE :
++ { // we will use text instead of polygons only if we have the correct font
++ if ( aVDev.IsFontAvailable( pOut->GetFont().GetName() ) )
++ {
++ Point aPt;
++ String aString;
++ sal_uInt32 i, nStringLen, nDXCount;
++ sal_Int32* pDXAry = NULL;
++ SvMemoryStream aMemoryStream( nEscLen );
++ aMemoryStream.Write( pData, nEscLen );
++ aMemoryStream.Seek( STREAM_SEEK_TO_BEGIN );
++ aMemoryStream >> aPt.X()
++ >> aPt.Y()
++ >> nStringLen;
++
++ if ( ( static_cast< sal_uInt64 >( nStringLen ) * sizeof( sal_Unicode ) ) < ( nEscLen - aMemoryStream.Tell() ) )
++ {
++ sal_Unicode* pBuf = aString.AllocBuffer( (xub_StrLen)nStringLen );
++ for ( i = 0; i < nStringLen; i++ )
++ aMemoryStream >> pBuf[ i ];
++ aMemoryStream >> nDXCount;
++ if ( ( static_cast< sal_uInt64 >( nDXCount ) * sizeof( sal_Int32 ) ) >= ( nEscLen - aMemoryStream.Tell() ) )
++ nDXCount = 0;
++ if ( nDXCount )
++ pDXAry = new sal_Int32[ nDXCount ];
++ for ( i = 0; i < nDXCount; i++ )
++ aMemoryStream >> pDXAry[ i ];
++ aMemoryStream >> nSkipActions;
++ pOut->DrawText( aPt, aString, pDXAry );
++ delete[] pDXAry;
++ }
++ }
++ }
++ break;
++ }
++ }
++ delete[] pData;
++ }
+ }
+- if ( nCheck == nCheckSum )
++ }
++ else if ( nNewMagic == 0x43464D57 && nLen >= 34 && (((sal_uInt32)nLen) + 10 <= nRecSize * 2 ))
++ {
++ sal_uInt32 nComType, nVersion, nFlags, nComRecCount,
++ nCurRecSize, nRemainingSize, nEMFTotalSize;
++ sal_uInt16 nCheck;
++
++ *pWMF >> nComType >> nVersion >> nCheck >> nFlags
++ >> nComRecCount >> nCurRecSize
++ >> nRemainingSize >> 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 )
+ {
+- switch( nEsc )
++ if( !nEMFRec )
++ { // first EMF comment
++ nEMFRecCount = nComRecCount;
++ nEMFSize = nEMFTotalSize;
++ pEMFStream = new SvMemoryStream( 0x20000 );
++ }
++ else if( nEMFRecCount != nComRecCount ) // add additional checks here
+ {
+- case PRIVATE_ESCAPE_UNICODE :
+- { // we will use text instead of polygons only if we have the correct font
+- if ( aVDev.IsFontAvailable( pOut->GetFont().GetName() ) )
+- {
+- Point aPt;
+- String aString;
+- sal_uInt32 i, nStringLen, nDXCount;
+- sal_Int32* pDXAry = NULL;
+- SvMemoryStream aMemoryStream( nEscLen );
+- aMemoryStream.Write( pData, nEscLen );
+- aMemoryStream.Seek( STREAM_SEEK_TO_BEGIN );
+- aMemoryStream >> aPt.X()
+- >> aPt.Y()
+- >> nStringLen;
+-
+- if ( ( static_cast< sal_uInt64 >( nStringLen ) * sizeof( sal_Unicode ) ) < ( nEscLen - aMemoryStream.Tell() ) )
+- {
+- sal_Unicode* pBuf = aString.AllocBuffer( (xub_StrLen)nStringLen );
+- for ( i = 0; i < nStringLen; i++ )
+- aMemoryStream >> pBuf[ i ];
+- aMemoryStream >> nDXCount;
+- if ( ( static_cast< sal_uInt64 >( nDXCount ) * sizeof( sal_Int32 ) ) >= ( nEscLen - aMemoryStream.Tell() ) )
+- nDXCount = 0;
+- if ( nDXCount )
+- pDXAry = new sal_Int32[ nDXCount ];
+- for ( i = 0; i < nDXCount; i++ )
+- aMemoryStream >> pDXAry[ i ];
+- aMemoryStream >> nSkipActions;
+- pOut->DrawText( aPt, aString, pDXAry );
+- delete[] pDXAry;
+- }
+- }
+- }
+- break;
++ // total records should be the same as in previous comments
++ nEMFRecCount = 0xFFFFFFFF;
++ delete pEMFStream;
++ pEMFStream = NULL;
++ }
++ nEMFRec++;
++
++ if( pEMFStream && nCurRecSize + 34 > nLen )
++ {
++ nEMFRecCount = 0xFFFFFFFF;
++ delete pEMFStream;
++ pEMFStream = NULL;
++ }
++
++ if( pEMFStream )
++ {
++ sal_Int8* pBuf = new sal_Int8[ nCurRecSize ];
++ sal_uInt32 nCount = pWMF->Read( pBuf, nCurRecSize );
++ if( nCount == nCurRecSize )
++ pEMFStream->Write( pBuf, nCount );
++ delete[] pBuf;
+ }
+ }
+- delete[] pData;
+ }
+ }
+ }
+@@ -1032,6 +1088,11 @@ void WMFReader::ReadWMF(WMF_APMFILEHEADE
+ nCurrentAction = 0;
+ nUnicodeEscapeAction = 0;
+
++ pEMFStream = NULL;
++ nEMFRecCount = 0;
++ nEMFRec = 0;
++ nEMFSize = 0;
++
+ pOut->SetMapMode( MM_ANISOTROPIC );
+ pOut->SetWinOrg( Point() );
+ pOut->SetWinExt( Size( 1, 1 ) );
+@@ -1079,6 +1140,33 @@ void WMFReader::ReadWMF(WMF_APMFILEHEADE
+ ReadRecordParams( nFunction );
+ else
+ nSkipActions--;
++
++ if( pEMFStream && nEMFRecCount == nEMFRec )
++ {
++ GDIMetaFile aMeta;
++ pEMFStream->Seek( 0 );
++ EnhWMFReader* pEMFReader = new EnhWMFReader ( *pEMFStream, aMeta );
++ BOOL bRead = pEMFReader->ReadEnhWMF();
++ delete pEMFReader; // destroy first!!!
++
++ if( bRead )
++ {
++ pOut->AddFromGDIMetaFile( aMeta );
++ pOut->SetrclFrame( Rectangle(0, 0, aMeta.GetPrefSize().Width(), aMeta.GetPrefSize().Height() ));
++ // we have successfully read the embedded EMF data
++ // no need to process WMF data further
++ break;
++ }
++ else
++ {
++ // something went wrong
++ // continue with WMF, don't try this again
++ delete pEMFStream;
++ pEMFStream = NULL;
++ }
++
++ }
++
+ nPos += nRecSize * 2;
+ if ( nPos <= nEndPos )
+ pWMF->Seek( nPos );
+@@ -1342,3 +1430,9 @@ sal_Bool WMFReader::GetPlaceableBound( R
+ return bRet;
+ }
+
++WMFReader::~WMFReader()
++{
++ if( pEMFStream )
++ delete pEMFStream;
++}
++
+diff -rup svtools-orig-1/source/filter.vcl/wmf/wmfwr.cxx svtools/source/filter.vcl/wmf/wmfwr.cxx
+--- svtools-orig-1/source/filter.vcl/wmf/wmfwr.cxx 2009-12-08 18:01:50.000000000 +0100
++++ svtools/source/filter.vcl/wmf/wmfwr.cxx 2009-12-08 18:04:25.000000000 +0100
+@@ -33,6 +33,7 @@
+
+ #include <vcl/salbtype.hxx>
+ #include "wmfwr.hxx"
++#include "emfwr.hxx"
+ #include <vcl/fontcvt.hxx>
+ #include <rtl/crc.h>
+ #include <rtl/tencinfo.h>
+@@ -1807,6 +1808,7 @@ BOOL WMFWriter::WriteWMF( const GDIMetaF
+ {
+ WMFWriterAttrStackMember * pAt;
+
++ bEmbedEMF = TRUE;
+ bStatus=TRUE;
+ pConvert = 0;
+ pVirDev = new VirtualDevice;
+@@ -1870,6 +1872,8 @@ BOOL WMFWriter::WriteWMF( const GDIMetaF
+ CountActionsAndBitmaps(rMTF);
+
+ WriteHeader(rMTF,bPlaceable);
++ if( bEmbedEMF )
++ WriteEmbeddedEMF( rMTF );
+ WMFRecord_SetWindowOrg(Point(0,0));
+ WMFRecord_SetWindowExt(rMTF.GetPrefSize());
+ WMFRecord_SetBkMode( TRUE );
+@@ -1948,3 +1952,82 @@ USHORT WMFWriter::CalcSaveTargetMapMode(
+
+ return nDivisor;
+ }
++
++// ------------------------------------------------------------------------
++
++void WMFWriter::WriteEmbeddedEMF( const GDIMetaFile& rMTF )
++{
++ EMFWriter aEMFWriter;
++ SvMemoryStream aStream;
++ if( aEMFWriter.WriteEMF( rMTF, aStream ) )
++ {
++ aStream.Seek( 0 );
++ sal_Size nTotalSize = aStream.GetSize();
++ if( nTotalSize > SAL_MAX_UINT32 )
++ return;
++ sal_uInt32 nRemainingSize = static_cast< sal_uInt32 >( nTotalSize );
++ sal_uInt32 nRecCounts = ( (nTotalSize - 1) / 0x2000 ) + 1;
++ sal_uInt16 nCheckSum = 0, nWord;
++
++ sal_uInt32 nPos = 0;
++
++ while( nPos + 1 < nTotalSize )
++ {
++ aStream >> nWord;
++ nCheckSum ^= nWord;
++ nPos += 2;
++ }
++
++ nCheckSum = static_cast< sal_uInt16 >( nCheckSum * -1 );
++
++ aStream.Seek( 0 );
++ while( nRemainingSize > 0 )
++ {
++ sal_uInt32 nCurSize;
++ if( nRemainingSize > 0x2000 )
++ {
++ nCurSize = 0x2000;
++ nRemainingSize -= 0x2000;
++ }
++ else
++ {
++ nCurSize = nRemainingSize;
++ nRemainingSize = 0;
++ }
++ WriteEMFRecord( aStream,
++ nCurSize,
++ nRemainingSize,
++ nTotalSize,
++ nRecCounts,
++ nCheckSum );
++ nCheckSum = 0;
++ }
++ }
++}
++
++// ------------------------------------------------------------------------
++
++void WMFWriter::WriteEMFRecord( SvStream& rStream, sal_uInt32 nCurSize, sal_uInt32 nRemainingSize,
++ sal_uInt32 nTotalSize, sal_uInt32 nRecCounts, sal_uInt16 nCheckSum )
++{
++ // according to http://msdn.microsoft.com/en-us/library/dd366152%28PROT.13%29.aspx
++ WriteRecordHeader( 0, W_META_ESCAPE );
++ *pWMF << (sal_uInt16)W_MFCOMMENT // same as META_ESCAPE_ENHANCED_METAFILE
++ << (sal_uInt16)( nCurSize + 34 ) // we will always have a 34 byte escape header:
++ << (sal_uInt32) 0x43464D57 // WMFC
++ << (sal_uInt32) 0x00000001 // Comment type
++ << (sal_uInt32) 0x00010000 // version
++ << nCheckSum // check sum
++ << (sal_uInt32) 0 // flags = 0
++ << nRecCounts // total number of records
++ << nCurSize // size of this record's data
++ << nRemainingSize // remaining size of data in following records, missing in MSDN documentation
++ << nTotalSize; // total size of EMF stream
++
++ sal_Int8* pBuf = new sal_Int8[ nCurSize ];
++ sal_uInt32 nCount = rStream.Read( pBuf, nCurSize );
++ if( nCount == nCurSize )
++ pWMF->Write( pBuf, nCount );
++ delete[] pBuf;
++ UpdateRecordHeader();
++}
+diff -rup svtools-orig-1/source/filter.vcl/wmf/wmfwr.hxx svtools/source/filter.vcl/wmf/wmfwr.hxx
+--- svtools-orig-1/source/filter.vcl/wmf/wmfwr.hxx 2009-12-08 18:01:50.000000000 +0100
++++ svtools/source/filter.vcl/wmf/wmfwr.hxx 2009-12-08 18:02:03.000000000 +0100
+@@ -128,6 +128,8 @@ private:
+ ULONG nWrittenBitmaps; // Anzahl der bereits geschriebenen Bitmaps
+ ULONG nActBitmapPercent; // Wieviel Prozent die naechste Bitmap schon geschrieben ist.
+
++ BOOL bEmbedEMF; // optionally embedd EMF data into WMF
++
+ void MayCallback();
+ // Berechnet anhand der obigen 5 Parameter eine Prozentzahl
+ // und macht dann ggf. einen Callback. Setzt bStatus auf FALSE wenn User abbrechen
+@@ -207,6 +209,13 @@ private:
+ void WriteHeader(const GDIMetaFile & rMTF, BOOL bPlaceable);
+ void UpdateHeader();
+
++ void WriteEmbeddedEMF( const GDIMetaFile& rMTF );
++ void WriteEMFRecord( SvStream& rStream, sal_uInt32 nCurSize,
++ sal_uInt32 nRemainingSize,
++ sal_uInt32 nTotalSize,
++ sal_uInt32 nRecCounts,
++ sal_uInt16 nCheckSum );
++
+ USHORT CalcSaveTargetMapMode(MapMode& rMapMode, const Size& rPrefSize);
+
+ public:
diff --git a/patches/dev300/svtools-emf-fix.diff b/patches/dev300/svtools-emf-fix.diff
new file mode 100644
index 0000000..685caed
--- /dev/null
+++ b/patches/dev300/svtools-emf-fix.diff
@@ -0,0 +1,217 @@
+Index: source/filter.vcl/wmf/emfwr.cxx
+===================================================================
+--- svtools/source/filter.vcl/wmf/emfwr.cxx (revision 275398)
++++ svtools/source/filter.vcl/wmf/emfwr.cxx (working copy)
+@@ -162,6 +162,8 @@
+ #define TA_RTLREADING 256
+ #define TA_MASK (TA_BASELINE+TA_CENTER+TA_UPDATECP+TA_RTLREADING)
+
++#define MM_ANISOTROPIC 8
++
+ // -------------
+ // - EMFWriter -
+ // -------------
+@@ -181,21 +183,39 @@
+ maVDev.SetMapMode( rMtf.GetPrefMapMode() );
+ mpFilterConfigItem = pFilterConfigItem;
+
++ // don't work with pixel as destination map mode -> higher resolution preferrable
++ maDestMapMode.SetMapUnit( MAP_100TH_MM );
++
+ const Size aMtfSizePix( maVDev.LogicToPixel( rMtf.GetPrefSize(), rMtf.GetPrefMapMode() ) );
+ const Size aMtfSizeLog( maVDev.LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_100TH_MM ) );
+
+ // seek over header
+- rOStm.SeekRel( 100 );
++ // use [MS-EMF 2.2.11] HeaderExtension2 Object, otherwise resulting EMF cannot be converted with GetWinMetaFileBits()
++ rOStm.SeekRel( 108 );
+
+ // write initial values
+- ImplBeginRecord( WIN_EMR_SETWINDOWORGEX );
+- (*mpStm) << (INT32) 0 << (INT32) 0;
++
++ // set 100th mm map mode in EMF
++ ImplBeginRecord( WIN_EMR_SETMAPMODE );
++ (*mpStm) << (INT32) MM_ANISOTROPIC;
+ ImplEndRecord();
+
++ ImplBeginRecord( WIN_EMR_SETVIEWPORTEXTEX );
++ (*mpStm) << (INT32) maVDev.ImplGetDPIX() << (INT32) maVDev.ImplGetDPIY();
++ ImplEndRecord();
++
+ ImplBeginRecord( WIN_EMR_SETWINDOWEXTEX );
+- (*mpStm) << (INT32) aMtfSizePix.Width() << (INT32) aMtfSizePix.Height();
++ (*mpStm) << (INT32) 2540 << (INT32) 2540;
+ ImplEndRecord();
+
++ ImplBeginRecord( WIN_EMR_SETVIEWPORTORGEX );
++ (*mpStm) << (INT32) 0 << (INT32) 0;
++ ImplEndRecord();
++
++ ImplBeginRecord( WIN_EMR_SETWINDOWORGEX );
++ (*mpStm) << (INT32) 0 << (INT32) 0;
++ ImplEndRecord();
++
+ ImplWriteRasterOp( ROP_OVERPAINT );
+
+ ImplBeginRecord( WIN_EMR_SETBKMODE );
+@@ -207,7 +227,7 @@
+
+ ImplBeginRecord( WIN_EMR_EOF );
+ (*mpStm)<< (sal_uInt32)0 // nPalEntries
+- << (sal_uInt32)0x16 // offPalEntries
++ << (sal_uInt32)0x10 // offPalEntries
+ << (sal_uInt32)0x14; // nSizeLast
+ ImplEndRecord();
+
+@@ -215,7 +235,7 @@
+ // write header
+ const ULONG nEndPos = mpStm->Tell(); mpStm->Seek( nHeaderPos );
+
+- (*mpStm) << (UINT32) 0x00000001 << (UINT32) 100;
++ (*mpStm) << (UINT32) 0x00000001 << (UINT32) 108; //use [MS-EMF 2.2.11] HeaderExtension2 Object
+ (*mpStm) << (INT32) 0 << (INT32) 0 << (INT32) ( aMtfSizePix.Width() - 1 ) << (INT32) ( aMtfSizePix.Height() - 1 );
+ (*mpStm) << (INT32) 0 << (INT32) 0 << (INT32) ( aMtfSizeLog.Width() - 1 ) << (INT32) ( aMtfSizeLog.Height() - 1 );
+ (*mpStm) << (UINT32) 0x464d4520 << (UINT32) 0x10000 << (UINT32) ( nEndPos - nHeaderPos );
+@@ -223,6 +243,7 @@
+ (*mpStm) << (INT32) aMtfSizePix.Width() << (INT32) aMtfSizePix.Height();
+ (*mpStm) << (INT32) ( aMtfSizeLog.Width() / 100 ) << (INT32) ( aMtfSizeLog.Height() / 100 );
+ (*mpStm) << (UINT32) 0 << (UINT32) 0 << (UINT32) 0;
++ (*mpStm) << (INT32) ( aMtfSizeLog.Width() * 10 ) << (INT32) ( aMtfSizeLog.Height() * 10 ); //use [MS-EMF 2.2.11] HeaderExtension2 Object
+
+ mpStm->Seek( nEndPos );
+ delete[] mpHandlesUsed;
+@@ -520,25 +541,24 @@
+
+ void EMFWriter::ImplWriteExtent( long nExtent )
+ {
+- const Size aSize( maVDev.LogicToPixel( Size( nExtent, nExtent ) ) );
+- (*mpStm) << (INT32) aSize.Width();
++ nExtent = maVDev.LogicToLogic( Size( nExtent, 0 ), maVDev.GetMapMode(), maDestMapMode ).Width();
++ (*mpStm) << (INT32) nExtent;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ void EMFWriter::ImplWritePoint( const Point& rPoint )
+ {
+- const Point aPoint( maVDev.LogicToPixel( rPoint ) );
+-
++ const Point aPoint( maVDev.LogicToLogic( rPoint, maVDev.GetMapMode(), maDestMapMode ));
+ (*mpStm) << (INT32) aPoint.X() << (INT32) aPoint.Y();
+ }
+
++
+ // -----------------------------------------------------------------------------
+
+ void EMFWriter::ImplWriteSize( const Size& rSize)
+ {
+- const Size aSize( maVDev.LogicToPixel( rSize ) );
+-
++ const Size aSize( maVDev.LogicToLogic( rSize, maVDev.GetMapMode(), maDestMapMode ));
+ (*mpStm) << (INT32) aSize.Width() << (INT32) aSize.Height();
+ }
+
+@@ -546,8 +566,7 @@
+
+ void EMFWriter::ImplWriteRect( const Rectangle& rRect )
+ {
+- const Rectangle aRect( maVDev.LogicToPixel( rRect ) );
+-
++ const Rectangle aRect( maVDev.LogicToLogic ( rRect, maVDev.GetMapMode(), maDestMapMode ));
+ (*mpStm) << aRect.Left() << aRect.Top() << aRect.Right() << aRect.Bottom();
+ }
+
+@@ -647,12 +666,20 @@
+ const Polygon& rPoly = rPolyPoly[ i ];
+ while ( n < rPoly.GetSize() )
+ {
+- sal_uInt16 nBezPoints = 0;
+- if ( n )
+- {
+- while ( ( ( nBezPoints + n + 2 ) < rPoly.GetSize() ) && ( rPoly.GetFlags( nBezPoints + n ) == POLY_CONTROL ) )
+- nBezPoints += 3;
+- }
++ if( n == 0)
++ {
++ ImplBeginRecord( WIN_EMR_MOVETOEX );
++ ImplWritePoint( rPoly[ 0 ] );
++ ImplEndRecord();
++ n++;
++ continue;
++ }
++
++ sal_uInt16 nBezPoints = 0;
++
++ while ( ( ( nBezPoints + n + 2 ) < rPoly.GetSize() ) && ( rPoly.GetFlags( nBezPoints + n ) == POLY_CONTROL ) )
++ nBezPoints += 3;
++
+ if ( nBezPoints )
+ {
+ ImplBeginRecord( WIN_EMR_POLYBEZIERTO );
+@@ -672,23 +699,27 @@
+ sal_uInt16 nPoints = 1;
+ while( ( nPoints + n ) < rPoly.GetSize() && ( rPoly.GetFlags( nPoints + n ) != POLY_CONTROL ) )
+ nPoints++;
+- ImplBeginRecord( WIN_EMR_MOVETOEX );
+- ImplWritePoint( rPoly[ n ] );
+- ImplEndRecord();
++
+ if ( nPoints > 1 )
+ {
+ ImplBeginRecord( WIN_EMR_POLYLINETO );
+- Polygon aNewPoly( nPoints );
+- aNewPoly[ 0 ] = rPoly[ n ];
+- for ( o = 1; o < nPoints; o++ )
+- aNewPoly[ o ] = rPoly[ n + o ];
++ Polygon aNewPoly( nPoints + 1 );
++ aNewPoly[ 0 ] = rPoly[ n - 1];
++ for ( o = 1; o <= nPoints; o++ )
++ aNewPoly[ o ] = rPoly[ n - 1 + o ];
+ ImplWriteRect( aNewPoly.GetBoundRect() );
+- (*mpStm) << (sal_uInt32)( nPoints - 1 );
++ (*mpStm) << (sal_uInt32)( nPoints );
+ for( o = 1; o < aNewPoly.GetSize(); o++ )
+ ImplWritePoint( aNewPoly[ o ] );
+ ImplEndRecord();
+ }
+- n = n + nPoints;
++ else
++ {
++ ImplBeginRecord( WIN_EMR_LINETO );
++ ImplWritePoint( rPoly[ n ] );
++ ImplEndRecord();
++ }
++ n = n + nPoints;
+ }
+ if ( bClosed && ( n == rPoly.GetSize() ) )
+ {
+@@ -700,6 +731,7 @@
+ ImplBeginRecord( WIN_EMR_ENDPATH );
+ ImplEndRecord();
+ ImplBeginRecord( bClosed ? WIN_EMR_FILLPATH : WIN_EMR_STROKEPATH );
++ ImplWriteRect( rPolyPoly.GetBoundRect() );
+ ImplEndRecord();
+ }
+
+Index: source/filter.vcl/wmf/emfwr.hxx
+===================================================================
+--- svtools/source/filter.vcl/wmf/emfwr.hxx (revision 275398)
++++ svtools/source/filter.vcl/wmf/emfwr.hxx (working copy)
+@@ -47,6 +47,7 @@
+ private:
+
+ VirtualDevice maVDev;
++ MapMode maDestMapMode;
+ FilterConfigItem* mpFilterConfigItem;
+ SvStream* mpStm;
+ BOOL* mpHandlesUsed;
+@@ -73,7 +74,7 @@
+ void ImplCheckLineAttr();
+ void ImplCheckFillAttr();
+ void ImplCheckTextAttr();
+-
++
+ void ImplWriteColor( const Color& rColor );
+ void ImplWriteRasterOp( RasterOp eRop );
+ void ImplWriteExtent( long nExtent );
\ No newline at end of file
diff --git a/patches/dev300/svtools-wmf-clean-warnings.diff b/patches/dev300/svtools-wmf-clean-warnings.diff
new file mode 100644
index 0000000..b068fcd
--- /dev/null
+++ b/patches/dev300/svtools-wmf-clean-warnings.diff
@@ -0,0 +1,63 @@
+diff -rup svtools-orig/source/filter.vcl/wmf/enhwmf.cxx svtools/source/filter.vcl/wmf/enhwmf.cxx
+--- svtools-orig/source/filter.vcl/wmf/enhwmf.cxx 2009-12-08 17:34:50.000000000 +0100
++++ svtools/source/filter.vcl/wmf/enhwmf.cxx 2009-12-08 17:59:03.000000000 +0100
+@@ -265,7 +265,7 @@ void EnhWMFReader::ReadEMFPlusComment(sa
+
+ void *buffer = malloc( length );
+
+- int count = 0, next, pos = pWMF->Tell();
++ int pos = pWMF->Tell();
+ pOut->PassEMFPlus( buffer, pWMF->Read( buffer, length ) );
+ pWMF->Seek( pos );
+
+@@ -321,14 +321,10 @@ void EnhWMFReader::ReadGDIComment()
+ break;
+ }
+ case 3: {
+- sal_uInt32 x, y, w, h;
+-
+ EMFP_DEBUG(printf ("\t\tENDGROUP\n"));
+ break;
+ }
+ case 0x40000004: {
+- sal_uInt32 x, y, w, h;
+-
+ EMFP_DEBUG(printf ("\t\tMULTIFORMATS\n"));
+ break;
+ }
+@@ -400,10 +396,11 @@ BOOL EnhWMFReader::ReadEnhWMF()
+ if( id == 0x2B464D45 && nRecSize >= 12 )
+ ReadEMFPlusComment( length, bHaveDC );
+ // GDIC comment, doesn't do anything useful yet => enabled only for debug
+- else if( id == 0x43494447 && nRecSize >= 12 )
++ else if( id == 0x43494447 && nRecSize >= 12 ) {
+ EMFP_DEBUG(ReadGDIComment());
+- else
++ } else {
+ EMFP_DEBUG(printf ("\t\tunknown id: 0x%x\n", id));
++ }
+ }
+ } else if( !bEMFPlus || bHaveDC || nRecType == EMR_EOF )
+
+@@ -1342,7 +1339,6 @@ BOOL EnhWMFReader::ReadEnhWMF()
+
+ case EMR_CREATEDIBPATTERNBRUSHPT :
+ {
+- static int count = 0;
+ UINT32 nStart = pWMF->Tell() - 8;
+ Bitmap aBitmap;
+
+diff -rup svtools-orig/source/filter.vcl/wmf/winmtf.hxx svtools/source/filter.vcl/wmf/winmtf.hxx
+--- svtools-orig/source/filter.vcl/wmf/winmtf.hxx 2009-12-08 17:34:50.000000000 +0100
++++ svtools/source/filter.vcl/wmf/winmtf.hxx 2009-12-08 17:57:54.000000000 +0100
+@@ -393,8 +393,8 @@ struct WinMtfFillStyle
+ };
+
+ WinMtfFillStyle( Bitmap& rBmp ) :
+- aBmp ( rBmp ),
+- aType( FillStylePattern )
++ aType( FillStylePattern ),
++ aBmp ( rBmp )
+ {
+ };
+
More information about the ooo-build-commit
mailing list