1 #   include	"drawMetaConfig.h"
2 
3 #   include	<stddef.h>
4 
5 #   include	"drawMetafilePsList.h"
6 #   include	"drawWinMetaImpl.h"
7 #   include	<utilMatchFont.h>
8 #   include	<bmWmfIo.h>
9 #   include	<bmEmfIo.h>
10 #   include	"drawMacPictImpl.h"
11 #   include	<sioGeneral.h>
12 
13 #   include	<appDebugon.h>
14 
15 # if 0
16 #    define	WMFDEB(x)	(x)
17 # else
18 #    define	WMFDEB(x)	/*nothing*/
19 # endif
20 
21 # if 0
22 #    define	WMFLOG(x)	(x)
23 # else
24 #    define	WMFLOG(x)	/*nothing*/
25 # endif
26 
27 
28 typedef struct ListMetaFonts
29     {
30     PostScriptTypeList *	lmfPstl;
31     const char *		lmfPrefix;
32     } ListMetaFonts;
33 
appDrawMetaBitmapImagePsList(DeviceContext * dc,void * through,const RasterImage * abi,const DocumentRectangle * drSrc,const DocumentRectangle * drDest)34 static int appDrawMetaBitmapImagePsList(
35 				DeviceContext *			dc,
36 				void *				through,
37 				const RasterImage *		abi,
38 				const DocumentRectangle *	drSrc,
39 				const DocumentRectangle *	drDest )
40     { return 0;	}
41 
appMetaSelectPenObjectPsList(DeviceContext * dc,void * through,LogicalPen * lp)42 static int appMetaSelectPenObjectPsList(DeviceContext *		dc,
43 					void *			through,
44 					LogicalPen *		lp )
45     { return 0;	}
46 
appCleanObjectPsList(DeviceContext * dc,void * through,MetaFileObject * mfo)47 static int appCleanObjectPsList(	DeviceContext *		dc,
48 					void *			through,
49 					MetaFileObject *	mfo )
50     { return 0;	}
51 
appMetaSelectBrushObjectPsList(DeviceContext * dc,void * through,LogicalBrush * lb)52 static int appMetaSelectBrushObjectPsList(DeviceContext *		dc,
53 					void *			through,
54 					LogicalBrush *		lb )
55     { return 0;	}
56 
appMetaDrawRoundedRectanglePsList(DeviceContext * dc,void * through,const DocumentRectangle * dr,int wide,int high,int fillInside,int drawBorder)57 static int appMetaDrawRoundedRectanglePsList(
58 				DeviceContext *			dc,
59 				void *				through,
60 				const DocumentRectangle *	dr,
61 				int				wide,
62 				int				high,
63 				int				fillInside,
64 				int				drawBorder )
65     { return 0;	}
66 
appMeta_PolyPolygonPsList(DeviceContext * dc,void * through,int polyCount,const int * pointCounts,const Point2DI * points,int fillInsides,int drawBorders,int closePath)67 static int appMeta_PolyPolygonPsList(DeviceContext *	dc,
68 				void *			through,
69 				int			polyCount,
70 				const int *		pointCounts,
71 				const Point2DI *	points,
72 				int			fillInsides,
73 				int			drawBorders,
74 				int			closePath )
75     { return 0;	}
76 
appMeta_PolyBezierPsList(DeviceContext * dc,void * through,int count,const Point2DI * points,int startPath,int fillInsides,int drawBorders,int closePath)77 static int appMeta_PolyBezierPsList(DeviceContext *	dc,
78 				void *			through,
79 				int			count,
80 				const Point2DI *	points,
81 				int			startPath,
82 				int			fillInsides,
83 				int			drawBorders,
84 				int			closePath )
85     { return 0;	}
86 
appMetaDrawArcPsList(DeviceContext * dc,void * through,const DocumentRectangle * dr,int xs,int ys,int xe,int ye,int fillInside,int drawBorder)87 static int appMetaDrawArcPsList(DeviceContext *			dc,
88 				void *				through,
89 				const DocumentRectangle *	dr,
90 				int				xs,
91 				int				ys,
92 				int				xe,
93 				int				ye,
94 				int				fillInside,
95 				int				drawBorder )
96     { return 0;	}
97 
appMetaSelectFontObjectPsList(DeviceContext * dc,void * through,LogicalFont * lf)98 static int appMetaSelectFontObjectPsList( DeviceContext *	dc,
99 					void *			through,
100 					LogicalFont *		lf )
101     {
102     const MetafilePlayer *	player= dc->dcPlayer;
103     const ListMetaFonts *	lmf= (const ListMetaFonts *)through;
104     DocumentFontList *		dfl= &(dc->dcFontList);
105     const PostScriptFontList *	psfl= player->mpPostScriptFontList;
106     const int			appearsInText= 0;
107 
108     const IndexSet *		unicodesWanted;
109 
110     dc->dcAfi= (*player->mpGetFontForAttribute)( &unicodesWanted,
111 					&(lf->lfTextAttribute), dfl, psfl );
112     if  ( ! dc->dcAfi )
113 	{ XDEB(dc->dcAfi); return -1;	}
114 
115     if  ( psRememberPostsciptFace( lmf->lmfPstl, dc->dcAfi,
116 		    &(lf->lfTextAttribute), lmf->lmfPrefix, appearsInText ) )
117 	{ SDEB(dc->dcAfi->afiFontName); return -1;	}
118 
119     return 0;
120     }
121 
appMetaSelectPatternBrushObjectPsList(DeviceContext * dc,void * through,PatternBrush * pb)122 static int appMetaSelectPatternBrushObjectPsList( DeviceContext *	dc,
123 						void *			through,
124 						PatternBrush *		pb )
125     { return 0;	}
126 
appMetaDrawRectanglePsList(DeviceContext * dc,void * through,const DocumentRectangle * dr,int fillInside,int drawBorder)127 static int appMetaDrawRectanglePsList(
128 				DeviceContext *			dc,
129 				void *				through,
130 				const DocumentRectangle *	dr,
131 				int				fillInside,
132 				int				drawBorder )
133     { return 0;	}
134 
appMetaDrawStringPsList(DeviceContext * dc,void * through,int x0,int y0,const MemoryBuffer * text)135 static int appMetaDrawStringPsList(	DeviceContext *		dc,
136 					void *			through,
137 					int			x0,
138 					int			y0,
139 					const MemoryBuffer *	text )
140     { return 0;	}
141 
appMetaPatBltPsList(DeviceContext * dc,void * through,long rop,const DocumentRectangle * dr)142 static int appMetaPatBltPsList(	DeviceContext *			dc,
143 				void *				through,
144 				long				rop,
145 				const DocumentRectangle *	dr )
146     { return 0;	}
147 
appMetaIgnoreColorPsList(DeviceContext * dc,void * through,int r,int g,int b)148 static int appMetaIgnoreColorPsList(	DeviceContext *		dc,
149 					void *			through,
150 					int			r,
151 					int			g,
152 					int			b )
153     { return 0;	}
154 
appMetaSetPolyFillModePsList(DeviceContext * dc,void * through,int mode)155 static int appMetaSetPolyFillModePsList( DeviceContext *	dc,
156 					void *			through,
157 					int			mode )
158     { return 0;	}
159 
appMetaStartPsList(DeviceContext * dc,int objectCount,const MetafilePlayer * player,const DocumentRectangle * drLogical,int mapMode)160 static int appMetaStartPsList(	DeviceContext *			dc,
161 				int				objectCount,
162 				const MetafilePlayer *		player,
163 				const DocumentRectangle *	drLogical,
164 				int				mapMode )
165     {
166     if  ( appMetaInitDeviceContext( dc, player, objectCount, drLogical, mapMode,
167 				player->mpTwipsWide, player->mpTwipsHigh,
168 				player->mpTwipsWide, player->mpTwipsHigh ) )
169 	{ LDEB(objectCount); return -1;	}
170 
171     dc->dcCleanObject= appCleanObjectPsList;
172     dc->dcDrawRasterImage= appDrawMetaBitmapImagePsList;
173     dc->dcSelectPenObject= appMetaSelectPenObjectPsList;
174     dc->dcSelectBrushObject= appMetaSelectBrushObjectPsList;
175     dc->dcSelectFontObject= appMetaSelectFontObjectPsList;
176     dc->dcSelectPatternBrushObject= appMetaSelectPatternBrushObjectPsList;
177     dc->dcDrawPolyPolygon= appMeta_PolyPolygonPsList;
178     dc->dcDrawPolyBezier= appMeta_PolyBezierPsList;
179     dc->dcDrawString= appMetaDrawStringPsList;
180     dc->dcPatBlt= appMetaPatBltPsList;
181     dc->dcDrawPie= appMetaDrawArcPsList;
182     dc->dcDrawArc= appMetaDrawArcPsList;
183     dc->dcDrawChord= appMetaDrawArcPsList;
184     dc->dcDrawEllipse= appMetaDrawRectanglePsList;
185     dc->dcDrawRoundedRectangle= appMetaDrawRoundedRectanglePsList;
186     dc->dcSetTextColor= appMetaIgnoreColorPsList;
187     dc->dcSetBkColor= appMetaIgnoreColorPsList;
188     dc->dcSetPolyFillMode= appMetaSetPolyFillModePsList;
189 
190     return 0;
191     }
192 
193 /************************************************************************/
194 /*									*/
195 /*  List the fonts in a windows metafile.				*/
196 /*									*/
197 /*  The geometry parameters are absolutely irrelevant, but required by	*/
198 /*  appMetaInitDeviceContext().						*/
199 /*									*/
200 /************************************************************************/
201 
appWmfListFontsPs(PostScriptTypeList * pstl,const MetafilePlayer * player,const char * prefix)202 int appWmfListFontsPs( PostScriptTypeList *		pstl,
203 			const MetafilePlayer *		player,
204 			const char *			prefix )
205     {
206     int			rval= 0;
207 
208     WmfHeader		wh;
209     DeviceContext	dc;
210 
211     ListMetaFonts	lmf;
212 
213     DocumentRectangle	drLogical;
214 
215     drLogical.drX0= 0;
216     drLogical.drY0= 0;
217     drLogical.drX1= player->mpXWinExt;
218     drLogical.drY1= player->mpYWinExt;
219 
220     lmf.lmfPstl= pstl;
221     lmf.lmfPrefix= prefix;
222 
223     if  ( sioInGetByte( player->mpInputStream ) == EOF )
224 	{ return 0;	}
225     sioInUngetLastRead( player->mpInputStream );
226 
227     if  ( bmMetaReadWmfHeader( &wh, player->mpInputStream ) )
228 	{ LDEB(1); return -1;		}
229 
230     if  ( appMetaStartPsList( &dc, wh.wh_objectCount, player,
231 					    &drLogical, player->mpMapMode ) )
232 	{ LDEB(wh.wh_objectCount); return -1;	}
233 
234     WMFDEB(appDebug( "PSFONTS WMF\n" ));
235 
236     if  ( appMetaPlayWmf( &dc, (void *)&lmf ) )
237 	{ rval= -1;	}
238 
239     appMetaCleanDeviceContext( &dc, (void *)&lmf );
240 
241     return rval;
242     }
243 
appEmfListFontsPs(PostScriptTypeList * pstl,const MetafilePlayer * player,const char * prefix)244 int appEmfListFontsPs(	PostScriptTypeList *		pstl,
245 			const MetafilePlayer *		player,
246 			const char *			prefix )
247     {
248     int			rval= 0;
249 
250     int			done;
251     EmfHeader		eh;
252     DeviceContext	dc;
253 
254     ListMetaFonts	lmf;
255 
256     lmf.lmfPstl= pstl;
257     lmf.lmfPrefix= prefix;
258 
259     done= bmMetaReadEmfHeader( &eh, player->mpInputStream );
260     if  ( done < 0 )
261 	{ LDEB(done); return -1;		}
262     while( done < eh.eh_headerSize )
263 	{
264 	if  ( sioInGetByte( player->mpInputStream ) < 0 )
265 	    { LDEB(1); return -1;	}
266 
267 	done++;
268 	}
269 
270     if  ( appMetaStartPsList( &dc, eh.eh_numOfHandles, player,
271 					    &(eh.ehBounds), MM_ANISOTROPIC ) )
272 
273 	{ LDEB(eh.eh_numOfHandles); return -1;	}
274 
275     WMFDEB(appDebug(
276 	"PSFONTS EMF LOGICAL: [%d..%d x %d..%d] TWIPS: [%d x %d]\n",
277 				    eh.ehBounds.drX0, eh.ehBounds.drX1,
278 				    eh.ehBounds.drY0, eh.ehBounds.drY1,
279 				    player->mpTwipsWide, player->mpTwipsHigh ));
280 
281     if  ( appMetaPlayEmf( &dc, (void *)&lmf ) )
282 	{ rval= -1;	}
283 
284     appMetaCleanDeviceContext( &dc, (void *)&lmf );
285 
286     return rval;
287     }
288 
289 
appMacPictListFontsPs(PostScriptTypeList * pstl,const MetafilePlayer * player,const char * prefix)290 int appMacPictListFontsPs(	PostScriptTypeList *		pstl,
291 				const MetafilePlayer *		player,
292 				const char *			prefix )
293     {
294     MacPictHeader	mph;
295     int			rval= 0;
296 
297     int			done;
298     DeviceContext	dc;
299     const int		handleCount= MACPICThandle_COUNT;
300 
301     ListMetaFonts	lmf;
302 
303     lmf.lmfPstl= pstl;
304     lmf.lmfPrefix= prefix;
305 
306     done= appMacPictGetDeviceHeader( &mph, player->mpInputStream );
307     if  ( done < 0 )
308 	{ LDEB(done); return -1;		}
309 
310     if  ( appMetaStartPsList( &dc, handleCount, player, &(mph.mphFrame),
311 							    MM_ANISOTROPIC ) )
312 	{ LDEB(handleCount); return -1;	}
313 
314     dc.dcMacPictVersion= mph.mphVersion;
315 
316     WMFDEB(appDebug( "PSFONTS PICT ...\n" ));
317 
318     if  ( appMacPictPlayPict( &dc, (void *)&lmf ) )
319 	{ rval= -1;	}
320 
321     appMetaCleanDeviceContext( &dc, (void *)&lmf );
322 
323     return rval;
324     }
325 
326