update dev300-m58
[ooovba.git] / applied_patches / 0572-external-apm-header.diff
blob2319c46d56429471a92a4fe28f5a0da84048ed55
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
5 @@ -41,6 +41,7 @@
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,
15 SvStream& rStream,
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,
22 SvStream& rStream,
23 USHORT nFormat,
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
35 @@ -34,7 +34,30 @@
36 #include "svtools/svtdllapi.h"
37 #include <svtools/fltcall.hxx>
39 -BOOL ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem = NULL );
40 +struct WMF_APMFILEHEADER {
41 + sal_uInt32 key;
42 + sal_uInt16 hmf;
43 + sal_uInt16 left;
44 + sal_uInt16 top;
45 + sal_uInt16 right;
46 + sal_uInt16 bottom;
47 + sal_uInt16 inch;
48 + sal_uInt32 reserved;
49 + sal_uInt16 checksum;
51 + WMF_APMFILEHEADER() : key(0x9ac6cdd7L),
52 + hmf(0),
53 + left(0),
54 + top(0),
55 + right(0),
56 + bottom(0),
57 + inch(96),
58 + reserved(0),
59 + checksum(0) {
60 + }
61 +};
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
72 return nRetValue;
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)
91 String aFilterName;
92 ULONG nStmBegin;
93 @@ -1483,7 +1483,7 @@ USHORT GraphicFilter::ImportGraphic( Graphic& rGraphic, const String& rPath, SvS
94 aFilterName.EqualsIgnoreCaseAscii( IMP_EMF ) )
96 GDIMetaFile aMtf;
97 - if( !ConvertWMFToGDIMetaFile( rIStream, aMtf, NULL ) )
98 + if( !ConvertWMFToGDIMetaFile( rIStream, aMtf, NULL, pAPMHeader ) )
99 nStatus = GRFILTER_FORMATERROR;
100 else
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;
108 String alfFaceName;
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
118 - BOOL ReadHeader();
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
127 - void ReadWMF();
128 + void ReadWMF(WMF_APMFILEHEADER *pAPMHeader=NULL);
131 #endif
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
136 @@ -32,6 +32,7 @@
137 #include "precompiled_svtools.hxx"
139 #include "winmtf.hxx"
140 +#include <svtools/wmf.hxx>
141 #include <rtl/crc.h>
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()
155 else
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);
173 + }
175 pOut->SetUnitsPerInch( nUnitsPerInch );
176 pOut->SetWinOrg( aPlaceableBound.TopLeft() );
177 @@ -1010,7 +1018,7 @@ BOOL WMFReader::ReadHeader()
178 return TRUE;
181 -void WMFReader::ReadWMF()
182 +void WMFReader::ReadWMF(WMF_APMFILEHEADER *pAPMHeader)
184 USHORT nFunction;
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 ) )
194 nPos = pWMF->Tell();
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
199 @@ -38,7 +38,7 @@
201 // -----------------------------------------------------------------------------
203 -BOOL ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem )
204 +BOOL ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem, WMF_APMFILEHEADER *pAPMHeader )
206 UINT32 nMetaType;
207 UINT32 nOrgPos = rStreamWMF.Tell();
208 @@ -54,7 +54,7 @@ BOOL ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile,
210 else
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
221 @@ -39,6 +39,7 @@
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 )
232 String sTmpStr;
233 + WMF_APMFILEHEADER aAPMHeader;
234 + aAPMHeader.left=0;
235 + aAPMHeader.top=0;
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,
242 - nImportFilter );
243 + bValidBmp = 0 == pGF->ImportGraphic( rGrf, sTmpStr, *pTmpFile, nImportFilter, NULL, 0, pAPMHeader );
245 delete pTmpFile;