1 diff --git svtools/inc/svtools/filter.hxx svtools/inc/svtools/filter.hxx
2 index 4f33b66..177db61 100644
3 --- svtools/inc/svtools/filter.hxx
4 +++ svtools/inc/svtools/filter.hxx
6 #include <com/sun/star/uno/Sequence.h>
7 #include <com/sun/star/beans/PropertyValue.hpp>
9 +struct WMF_APMFILEHEADER;
10 // -----------------------
11 // - GraphicFilter-Types -
12 // -----------------------
13 @@ -392,13 +393,15 @@ public:
14 USHORT ImportGraphic( Graphic& rGraphic, const String& rPath,
16 USHORT nFormat = GRFILTER_FORMAT_DONTKNOW,
17 - USHORT * pDeterminedFormat = NULL, sal_uInt32 nImportFlags = 0 );
18 + USHORT * pDeterminedFormat = NULL, sal_uInt32 nImportFlags = 0
19 + , WMF_APMFILEHEADER *pAPMHeader = NULL);
21 USHORT ImportGraphic( Graphic& rGraphic, const String& rPath,
24 USHORT * pDeterminedFormat, sal_uInt32 nImportFlags,
25 - com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData );
26 + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData
27 + , WMF_APMFILEHEADER *pAPMHeader = NULL);
29 BOOL Setup( USHORT nFormat );
31 diff --git svtools/inc/svtools/wmf.hxx svtools/inc/svtools/wmf.hxx
32 index 68a4c4f..d3dc61d 100644
33 --- svtools/inc/svtools/wmf.hxx
34 +++ svtools/inc/svtools/wmf.hxx
36 #include "svtools/svtdllapi.h"
37 #include <svtools/fltcall.hxx>
39 -BOOL ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem = NULL );
40 +struct WMF_APMFILEHEADER {
48 + sal_uInt32 reserved;
49 + sal_uInt16 checksum;
51 + WMF_APMFILEHEADER() : key(0x9ac6cdd7L),
63 +BOOL ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem = NULL, WMF_APMFILEHEADER *pAPMHeader = NULL );
65 SVT_DLLPUBLIC BOOL ReadWindowMetafile( SvStream& rStream, GDIMetaFile& rMTF, FilterConfigItem* pConfigItem );
67 diff --git svtools/source/filter.vcl/filter/filter.cxx svtools/source/filter.vcl/filter/filter.cxx
68 index db14402..14c9ea4 100644
69 --- svtools/source/filter.vcl/filter/filter.cxx
70 +++ svtools/source/filter.vcl/filter/filter.cxx
71 @@ -1276,17 +1276,17 @@ USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const INetURLObject& rPa
75 -USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvStream& rIStream,
76 - USHORT nFormat, USHORT* pDeterminedFormat, sal_uInt32 nImportFlags )
77 +USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvStream& rIStream, USHORT nFormat, USHORT* pDeterminedFormat, sal_uInt32 nImportFlags, WMF_APMFILEHEADER *pAPMHeader )
79 - return ImportGraphic( rGraphic, rPath, rIStream, nFormat, pDeterminedFormat, nImportFlags, NULL );
80 + return ImportGraphic( rGraphic, rPath, rIStream, nFormat, pDeterminedFormat, nImportFlags, NULL, pAPMHeader );
83 //-------------------------------------------------------------------------
85 USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvStream& rIStream,
86 USHORT nFormat, USHORT* pDeterminedFormat, sal_uInt32 nImportFlags,
87 - com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData )
88 + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData
89 + , WMF_APMFILEHEADER *pAPMHeader)
93 @@ -1483,7 +1483,7 @@ USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvS
94 aFilterName.EqualsIgnoreCaseAscii( IMP_EMF ) )
97 - if( !ConvertWMFToGDIMetaFile( rIStream, aMtf, NULL ) )
98 + if( !ConvertWMFToGDIMetaFile( rIStream, aMtf, NULL, pAPMHeader ) )
99 nStatus = GRFILTER_FORMATERROR;
102 diff --git svtools/source/filter.vcl/wmf/winmtf.hxx svtools/source/filter.vcl/wmf/winmtf.hxx
103 index f4ac2d4..9253169 100644
104 --- svtools/source/filter.vcl/wmf/winmtf.hxx
105 +++ svtools/source/filter.vcl/wmf/winmtf.hxx
106 @@ -162,6 +162,7 @@ struct LOGFONTW
107 BYTE lfPitchAndFamily;
110 +struct WMF_APMFILEHEADER;
112 #define TA_NOUPDATECP 0x0000
113 #define TA_UPDATECP 0x0001
114 @@ -765,7 +766,7 @@ private:
115 sal_uInt32 nUnicodeEscapeAction;
117 // Liesst den Kopf der WMF-Datei
119 + BOOL ReadHeader(WMF_APMFILEHEADER *pAPMHeader);
121 // Liesst die Parameter des Rocords mit der Funktionsnummer nFunction.
122 void ReadRecordParams( USHORT nFunction );
123 @@ -782,7 +783,7 @@ public:
124 : WinMtf( new WinMtfOutput( rGDIMetaFile ), rStreamWMF, pConfigItem ) {};
126 // Liesst aus dem Stream eine WMF-Datei und fuellt das GDIMetaFile
128 + void ReadWMF(WMF_APMFILEHEADER *pAPMHeader=NULL);
132 diff --git svtools/source/filter.vcl/wmf/winwmf.cxx svtools/source/filter.vcl/wmf/winwmf.cxx
133 index 9db828c..fda0b81 100644
134 --- svtools/source/filter.vcl/wmf/winwmf.cxx
135 +++ svtools/source/filter.vcl/wmf/winwmf.cxx
137 #include "precompiled_svtools.hxx"
139 #include "winmtf.hxx"
140 +#include <svtools/wmf.hxx>
142 #include <rtl/tencinfo.h>
143 #include <osl/endian.h>
144 @@ -938,7 +939,7 @@ void WMFReader::ReadRecordParams( USHORT nFunc )
146 // ------------------------------------------------------------------------
148 -BOOL WMFReader::ReadHeader()
149 +BOOL WMFReader::ReadHeader(WMF_APMFILEHEADER *pAPMHeader)
151 Rectangle aPlaceableBound;
152 sal_uInt32 nl, nStrmPos = pWMF->Tell();
153 @@ -971,11 +972,18 @@ BOOL WMFReader::ReadHeader()
157 - nUnitsPerInch = 96;
158 - pWMF->Seek( nStrmPos + 18 ); // set the streampos to the start of the the metaactions
159 - GetPlaceableBound( aPlaceableBound, pWMF );
160 - pWMF->Seek( nStrmPos );
162 + nUnitsPerInch = (pAPMHeader!=NULL?pAPMHeader->inch:96);
163 + pWMF->Seek( nStrmPos + 18 ); // set the streampos to the start of the the metaactions
164 + GetPlaceableBound( aPlaceableBound, pWMF );
165 + pWMF->Seek( nStrmPos );
166 + if (pAPMHeader!=NULL) {
167 + // #n417818#: If we have an external header then overwrite the bounds!
168 + aPlaceableBound=Rectangle(pAPMHeader->left*567*nUnitsPerInch/1440/1000,
169 + pAPMHeader->top*567*nUnitsPerInch/1440/1000,
170 + pAPMHeader->right*567*nUnitsPerInch/1440/1000,
171 + pAPMHeader->bottom*567*nUnitsPerInch/1440/1000);
175 pOut->SetUnitsPerInch( nUnitsPerInch );
176 pOut->SetWinOrg( aPlaceableBound.TopLeft() );
177 @@ -1010,7 +1018,7 @@ BOOL WMFReader::ReadHeader()
181 -void WMFReader::ReadWMF()
182 +void WMFReader::ReadWMF(WMF_APMFILEHEADER *pAPMHeader)
185 ULONG nPos, nPercent, nLastPercent;
186 @@ -1028,7 +1036,7 @@ void WMFReader::ReadWMF()
187 pWMF->Seek( nStartPos );
188 Callback( (USHORT) ( nLastPercent = 0 ) );
190 - if ( ReadHeader() )
191 + if ( ReadHeader( pAPMHeader ) )
195 diff --git svtools/source/filter.vcl/wmf/wmf.cxx svtools/source/filter.vcl/wmf/wmf.cxx
196 index 4654864..9e3e258 100644
197 --- svtools/source/filter.vcl/wmf/wmf.cxx
198 +++ svtools/source/filter.vcl/wmf/wmf.cxx
201 // -----------------------------------------------------------------------------
203 -BOOL ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem )
204 +BOOL ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem, WMF_APMFILEHEADER *pAPMHeader )
207 UINT32 nOrgPos = rStreamWMF.Tell();
208 @@ -54,7 +54,7 @@ BOOL ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile,
212 - WMFReader( rStreamWMF, rGDIMetaFile, pConfigItem ).ReadWMF();
213 + WMFReader( rStreamWMF, rGDIMetaFile, pConfigItem ).ReadWMF( pAPMHeader );
215 rStreamWMF.SetNumberFormatInt( nOrigNumberFormat );
216 return !rStreamWMF.GetError();
217 diff --git svx/source/svrtf/rtfgrf.cxx svx/source/svrtf/rtfgrf.cxx
218 index ddddab8..587a4ce 100644
219 --- svx/source/svrtf/rtfgrf.cxx
220 +++ svx/source/svrtf/rtfgrf.cxx
222 #include <svtools/rtfkeywd.hxx>
223 #include <svtools/rtftoken.h>
224 #include <svtools/filter.hxx>
225 +#include <svtools/wmf.hxx>
227 #include "impgrf.hxx"
228 #include "svxrtf.hxx"
229 @@ -508,9 +509,15 @@ BOOL SvxRTFParser::ReadBmpData( Graphic& rGrf, SvxRTFPictureType& rPicType )
233 + WMF_APMFILEHEADER aAPMHeader;
236 + aAPMHeader.right=rPicType.nWidth;
237 + aAPMHeader.bottom=rPicType.nHeight;
239 + WMF_APMFILEHEADER *pAPMHeader=(aAPMHeader.right>0 && aAPMHeader.bottom>0?&aAPMHeader:NULL);
240 pTmpFile->Seek( STREAM_SEEK_TO_BEGIN );
241 - bValidBmp = 0 == pGF->ImportGraphic( rGrf, sTmpStr, *pTmpFile,
243 + bValidBmp = 0 == pGF->ImportGraphic( rGrf, sTmpStr, *pTmpFile, nImportFilter, NULL, 0, pAPMHeader );