1 #ifndef __drvwmf_h__
2 #define __drvwmf_h__
3 
4 /*
5    drvwmf.h : This file is part of pstoedit
6    Class declaration for the WMF output driver.
7    The implementation can be found in drvwmf.cpp
8 
9    Copyright (C) 1998 Thorsten Behrens and Bjoern Petersen
10    Copyright (C) 2000 Thorsten Behrens
11 
12     This program is free software; you can redistribute it and/or modify
13     it under the terms of the GNU General Public License as published by
14     the Free Software Foundation; either version 2 of the License, or
15     (at your option) any later version.
16 
17     This program is distributed in the hope that it will be useful,
18     but WITHOUT ANY WARRANTY; without even the implied warranty of
19     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20     GNU General Public License for more details.
21 
22     You should have received a copy of the GNU General Public License
23     along with this program; if not, write to the Free Software
24     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 
26 */
27 
28 
29 #ifdef _WIN32
30 
31 #include <windows.h>
32 #undef min		// is declared inline in drvbase... (sigh)
33 #undef max
34 
35 #else
36 
37 // use Allen Barnett's libemf
38 #ifdef OLDLIBEMF
39 #include <emf.h>
40 #else
41 #include <libEMF/emf.h>
42 #endif
43 
44 #endif
45 
46 #include "drvbase.h"
47 
48 
49 class drvWMF : public drvbase {
50 
51 public:
52 
53 	derivedConstructor(drvWMF);		// Constructor
54 
55 	~drvWMF();						// Destructor
56 	class DriverOptions : public ProgramOptions {
57 	public:
58 		OptionT < bool, BoolTrueExtractor> mapToArial;
59 		OptionT < bool, BoolTrueExtractor> emulateNarrowFonts;
60 		OptionT < bool, BoolTrueExtractor> drawBoundingBox;
61 		OptionT < bool, BoolTrueExtractor> pruneLineEnds;
62 		OptionT < bool, BoolTrueExtractor> notforWindows;
63 		OptionT < bool, BoolTrueExtractor> winbb;
64 		OptionT < bool, BoolTrueExtractor> OpenOfficeMode ;
65 
DriverOptions()66 		DriverOptions() :
67 		mapToArial(true,"-m",0,0,"map to Arial",0,false),
68 		emulateNarrowFonts(true,"-nf",0,0,"emulate narrow fonts",0,false),
69 		drawBoundingBox(true,"-drawbb",0,0,"draw bounding box",0,false),
70 		pruneLineEnds(true,"-p",0,0,"prune line ends",0,false),
71 		notforWindows(true,"-nfw",0,0,"not for MS Windows (meaningful under *nix only)",
72 		"Newer versions of MS Windows (2000, XP, Vista, 7, ...) will not accept WMF/EMF files generated when this option is set and the input contains text. "
73 		"But if this option is not set, then the WMF/EMF driver will estimate interletter spacing of text using "
74 		"a very coarse heuristic. This may result in ugly looking output. On the other hand, OpenOffice "
75 		"can still read EMF/WMF files where pstoedit delegates the calculation of the inter letter spacing "
76 		"to the program reading the WMF/EMF file. So if the generated WMF/EMF file shall never be processed "
77 		"under MS Windows, use this option. If WMF/EMF files with high precision text need to be generated under *nix "
78 		"the only option is to use the -pta option of pstoedit. However that causes every text to be split into single characters "
79 		"which makes the text hard to edit afterwards. Hence the -nfw option provides a sort of compromise between "
80 		"portability and nice to edit but still nice looking text. Again - this option has no meaning when pstoedit "
81 		"is executed under MS Windows anyway. In that case the output is portable "
82 		"but nevertheless not split and still looks fine.", false),
83 		winbb(true,"-winbb",0,0,"let the MS Windows API calculate the Bounding Box (MS Windows only)",0,false),
84 		OpenOfficeMode(true,"-OO", 0, 0, "generate OpenOffice compatible EMF file",0,false)
85 
86 		{
87 			ADD(mapToArial);
88 			ADD(emulateNarrowFonts);
89 			ADD(drawBoundingBox);
90 			ADD(pruneLineEnds);
91 			ADD(notforWindows);
92 			ADD(winbb);
93 			ADD(OpenOfficeMode);
94 		}
95 
96 	} * options;
97 
98 #include "drvfuncs.h"
99 	void show_rectangle(const float llx, const float lly, const float urx, const float ury);
100 	void show_text(const TextInfo & textInfo);
101 
102 	virtual void show_image(const PSImage & imageinfo);
103 
104 private:
105 
106 	enum polyType {TYPE_FILL,TYPE_LINES};
107 
108 	void	drawPoly			(polyType type);
109 
110 	void	setDrawAttr			();
111 
112 	int		fetchFont			(const TextInfo & textinfo, short int, short int);
113 
114 	float scale() const;
115 	long transx(float x) const;
116 	long transy(float x) const;
117 
118 	void initMetaDC(HDC hdc);
119 
120 // This contains all private data of drvwmf.
121 
122 	HDC				metaDC;
123 	HDC				desktopDC;
124 
125 	LOGPEN			penData;
126 	HPEN			coloredPen;
127 	HPEN			oldColoredPen;
128 
129 	LOGBRUSH		brushData;
130 	HBRUSH			coloredBrush;
131 	HBRUSH			oldColoredBrush;
132 
133 	HFONT			myFont;
134 	HFONT			oldFont;
135 
136 	int 			maxX, maxY;
137 	int 			minX, minY;
138 	bool			maxStatus, minStatus;
139 
140 	bool			enhanced;
141 
142 	RSString		tempName;
143 	FILE*			outFile;
144 
145 };
146 
147 #endif /* #ifndef __drvwmf_h__ */
148 
149 
150 
151 
152 
153