merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0499-emf+-multipart-objects.diff
blob926b36742e39fd8c6d963bee97b7035f05602d58
1 diff --git cppcanvas/source/inc/implrenderer.hxx cppcanvas/source/inc/implrenderer.hxx
2 index 59d793f..bb6ce2a 100644
3 --- cppcanvas/source/inc/implrenderer.hxx
4 +++ cppcanvas/source/inc/implrenderer.hxx
5 @@ -282,6 +282,7 @@ static float GetSwapFloat( SvStream& rSt )
6 ActionVector::const_iterator& o_rRangeBegin,
7 ActionVector::const_iterator& o_rRangeEnd ) const;
9 + void processObjectRecord(SvMemoryStream& rObjectStream, UINT16 flags);
10 void processEMFPlus( MetaCommentAction* pAct, const ActionFactoryParameters& rFactoryParms, OutDevState& rState, const CanvasSharedPtr& rCanvas );
11 void EMFPPlusFillPolygon (::basegfx::B2DPolyPolygon& polygon, const ActionFactoryParameters& rParms, OutDevState& rState, const CanvasSharedPtr& rCanvas, bool isColor, sal_uInt32 brushIndexOrColor);
13 @@ -306,6 +307,10 @@ static float GetSwapFloat( SvStream& rSt )
14 sal_Int32 nPixY;
15 sal_Int32 nMmX;
16 sal_Int32 nMmY;
17 + /* multipart object data */
18 + bool mbMultipart;
19 + UINT16 mMFlags;
20 + SvMemoryStream mMStream;
24 diff --git cppcanvas/source/mtfrenderer/emfplus.cxx cppcanvas/source/mtfrenderer/emfplus.cxx
25 index 657e867..9088e93 100644
26 --- cppcanvas/source/mtfrenderer/emfplus.cxx
27 +++ cppcanvas/source/mtfrenderer/emfplus.cxx
28 @@ -636,6 +636,8 @@ namespace cppcanvas
30 sal_uInt32 header, unknown;
32 + EMFP_DEBUG (dumpWords(s, 16));
34 s >> header >> type;
36 EMFP_DEBUG (printf ("EMF+\timage\nEMF+\theader: 0x%08x type: 0x%08x\n", header, type));
37 @@ -947,6 +949,72 @@ namespace cppcanvas
41 + void ImplRenderer::processObjectRecord(SvMemoryStream& rObjectStream, UINT16 flags)
42 + {
43 + UINT32 objectLen;
44 + sal_uInt32 index;
46 + EMFP_DEBUG (printf ("EMF+ Object slot: %hd flags: %hx\n", flags & 0xff, flags & 0xff00));
48 + index = flags & 0xff;
49 + if (aObjects [index] != NULL) {
50 + delete aObjects [index];
51 + aObjects [index] = NULL;
52 + }
54 + switch (flags & 0x7f00) {
55 + case EmfPlusObjectTypeBrush:
56 + {
57 + EMFPBrush *brush;
58 + aObjects [index] = brush = new EMFPBrush ();
59 + brush->Read (rObjectStream, *this);
61 + break;
62 + }
63 + case EmfPlusObjectTypePen:
64 + {
65 + EMFPPen *pen;
66 + aObjects [index] = pen = new EMFPPen ();
67 + pen->Read (rObjectStream, *this, nHDPI, nVDPI);
69 + break;
70 + }
71 + case EmfPlusObjectTypePath:
72 + sal_uInt32 header, pathFlags;
73 + sal_Int32 points;
75 + rObjectStream >> header >> points >> pathFlags;
77 + EMFP_DEBUG (printf ("EMF+\tpath\n"));
78 + EMFP_DEBUG (printf ("EMF+\theader: 0x%08x points: %d additional flags: 0x%08x\n", header, points, pathFlags));
80 + EMFPPath *path;
81 + aObjects [index] = path = new EMFPPath (points);
82 + path->Read (rObjectStream, pathFlags, *this);
84 + break;
85 + case EmfPlusObjectTypeRegion: {
86 + EMFPRegion *region;
88 + aObjects [index] = region = new EMFPRegion ();
89 + region->Read (rObjectStream);
91 + break;
92 + }
93 + case EmfPlusObjectTypeImage:
94 + {
95 + EMFPImage *image;
96 + aObjects [index] = image = new EMFPImage ();
97 + image->Read (rObjectStream);
99 + break;
101 + default:
102 + EMFP_DEBUG (printf ("EMF+\tObject unhandled flags: 0x%04x\n", flags & 0xff00));
103 + break;
107 void ImplRenderer::processEMFPlus( MetaCommentAction* pAct, const ActionFactoryParameters& rFactoryParms,
108 OutDevState& rState, const CanvasSharedPtr& rCanvas )
110 @@ -966,6 +1034,26 @@ namespace cppcanvas
112 EMFP_DEBUG (printf ("EMF+ record size: %d type: %04hx flags: %04hx data size: %d\n", size, type, flags, dataSize));
114 + if (type == EmfPlusRecordTypeObject && (mbMultipart && flags & 0x7fff == mMFlags & 0x7fff || flags & 0x8000)) {
115 + if (!mbMultipart) {
116 + mbMultipart = true;
117 + mMFlags = flags;
118 + mMStream.Seek(0);
120 + EMFP_DEBUG (dumpWords(rMF, 16));
121 + // 1st 4 bytes are unknown
122 + mMStream.Write (((const char *)rMF.GetData()) + rMF.Tell() + 4, dataSize - 4);
123 + EMFP_DEBUG (printf ("EMF+ read next object part size: %d type: %04hx flags: %04hx data size: %d\n", size, type, flags, dataSize));
124 + } else {
125 + if (mbMultipart) {
126 + EMFP_DEBUG (printf ("EMF+ multipart record flags: %04hx\n", mMFlags));
127 + mMStream.Seek (0);
128 + processObjectRecord (mMStream, mMFlags);
130 + mbMultipart = false;
133 + if (type != EmfPlusRecordTypeObject || !(flags & 0x8000))
134 switch (type) {
135 case EmfPlusRecordTypeHeader:
136 UINT32 header, version;
137 @@ -984,73 +1072,8 @@ namespace cppcanvas
138 EMFP_DEBUG (printf ("EMF+\talready used in svtools wmf/emf filter parser\n"));
139 break;
140 case EmfPlusRecordTypeObject:
142 - UINT32 objectLen;
143 - sal_uInt32 index;
145 - EMFP_DEBUG (printf ("EMF+ Object slot: %hd flags: %hx\n", flags & 0xff, flags & 0xff00));
147 - index = flags & 0xff;
148 - if (aObjects [index] != NULL) {
149 - delete aObjects [index];
150 - aObjects [index] = NULL;
153 - // not sure yet, what 0x8000 means
154 - switch (flags & 0x7f00) {
155 - case EmfPlusObjectTypeBrush:
157 - EMFPBrush *brush;
158 - aObjects [index] = brush = new EMFPBrush ();
159 - brush->Read (rMF, *this);
161 - break;
163 - case EmfPlusObjectTypePen:
165 - EMFPPen *pen;
166 - aObjects [index] = pen = new EMFPPen ();
167 - pen->Read (rMF, *this, nHDPI, nVDPI);
169 - break;
171 - case EmfPlusObjectTypePath:
172 - sal_uInt32 header, pathFlags;
173 - sal_Int32 points;
175 - rMF >> header >> points >> pathFlags;
177 - EMFP_DEBUG (printf ("EMF+\tpath\n"));
178 - EMFP_DEBUG (printf ("EMF+\theader: 0x%08x points: %d additional flags: 0x%08x\n", header, points, pathFlags));
180 - EMFPPath *path;
181 - aObjects [index] = path = new EMFPPath (points);
182 - path->Read (rMF, pathFlags, *this);
184 - break;
185 - case EmfPlusObjectTypeRegion: {
186 - EMFPRegion *region;
188 - aObjects [index] = region = new EMFPRegion ();
189 - region->Read (rMF);
191 - break;
193 - case EmfPlusObjectTypeImage:
195 - EMFPImage *image;
196 - aObjects [index] = image = new EMFPImage ();
197 - image->Read (rMF);
199 - break;
201 - default:
202 - EMFP_DEBUG (printf ("EMF+\tObject unhandled flags: 0x%04x\n", flags & 0xff00));
203 - break;
206 - break;
208 + processObjectRecord (rMF, flags);
209 + break;
210 case EmfPlusRecordTypeFillPath:
212 sal_uInt32 index = flags & 0xff;
213 diff --git cppcanvas/source/mtfrenderer/implrenderer.cxx cppcanvas/source/mtfrenderer/implrenderer.cxx
214 index 7189004..2d03b8a 100644
215 --- cppcanvas/source/mtfrenderer/implrenderer.cxx
216 +++ cppcanvas/source/mtfrenderer/implrenderer.cxx
217 @@ -3034,6 +3034,7 @@ namespace cppcanvas
219 /* EMF+ */
220 memset (aObjects, 0, sizeof (aObjects));
221 + mbMultipart = false;
223 createActions( const_cast<GDIMetaFile&>(rMtf), // HACK(Q2):
224 // we're