1 #ifndef PSTOEDITOPTIONS_H
2 #define PSTOEDITOPTIONS_H
3 
4 /*
5    pstoeditoptions.h : This file is part of pstoedit
6    definition of program options
7 
8    Copyright (C) 1993 - 2014 Wolfgang Glunz, wglunz35_AT_pstoedit.net
9 
10     This program is free software; you can redistribute it and/or modify
11     it under the terms of the GNU General Public License as published by
12     the Free Software Foundation; either version 2 of the License, or
13     (at your option) any later version.
14 
15     This program is distributed in the hope that it will be useful,
16     but WITHOUT ANY WARRANTY; without even the implied warranty of
17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18     GNU General Public License for more details.
19 
20     You should have received a copy of the GNU General Public License
21     along with this program; if not, write to the Free Software
22     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 
24 */
25 
26 
27 #include "miscutil.h"
28 #include "poptions.h"
29 
30 enum advancedTypeIDs { start_ty=char_ty, rsstring_ty, charstring_ty, constcharstring_ty, argv_ty };
31 
32 class DLLEXPORT RSStringValueExtractor {
33 public:
getvalue(const char * optname,const char * instring,unsigned int & currentarg,RSString & result)34 	static bool getvalue(const char *optname, const char *instring, unsigned int &currentarg, RSString &result) {
35 	if (instring) {
36 		result.assign(instring);
37 		currentarg++;
38 		return true;
39 	} else {
40 		cout << "missing string argument for " << optname << " option" << endl;
41 		return false;
42 	}
43 	}
gettypename()44 	static const char *gettypename() { return "string"; }
gettypeID()45 	static unsigned int gettypeID()  { return rsstring_ty; }
46 };
47 #if 0
48 // not really usable - because when using a Dialog, the char * would afterwards point into the data owned by the dialog
49 //
50 class DLLEXPORT charstringValueExtractor {
51 public:
52 	static bool getvalue(const char *optname, const char *instring, unsigned int &currentarg, char* &result) {
53 	if (instring) {
54 		result = cppstrdup(instring);
55 		currentarg++;
56 		return true;
57 	} else {
58 		cout << "missing string argument for " << optname << " option" << endl;
59 		return false;
60 	}
61 	}
62 	static const char *gettypename() { return "string"; }
63 	static unsigned int gettypeID() { return charstring_ty; }
64 };
65 
66 
67 template < >
68 inline ostream & Option< char *, charstringValueExtractor>::writevalue(ostream & out) const {
69 		out << (value ? value : "");
70 		return out;
71 }
72 
73 class DLLEXPORT constcharstringValueExtractor {
74 public:
75 	static bool getvalue(const char *optname, const char *instring, unsigned int &currentarg, const char* &result) {
76 	if (instring) {
77 		result = instring;
78 		currentarg++;
79 		return true;
80 	} else {
81 		cout << "missing string argument for " << optname << " option" << endl;
82 		return false;
83 	}
84 	}
85 	static const char *gettypename() { return "string"; }
86 	static unsigned int gettypeID() { return constcharstring_ty; }
87 };
88 
89 
90 template < >
91 inline ostream & Option< const char *, constcharstringValueExtractor>::writevalue(ostream & out) const {
92 	out << (value ? value : "");
93 		return out;
94 }
95 
96 #endif
97 
98 class DLLEXPORT ArgvExtractor {
99 public:
getvalue(const char * optname,const char * instring,unsigned int & currentarg,Argv & result)100 	static bool getvalue(const char *optname, const char *instring, unsigned int &currentarg, Argv  &result) {
101 	if (instring) {
102 		result.addarg(instring);
103 		currentarg++;
104 		return true;
105 	} else {
106 		cout << "missing string argument for " << optname << " option" << endl;
107 		return false;
108 	}
109 	}
gettypename()110 	static const char *gettypename() { return "string"; }
gettypeID()111 	static unsigned int gettypeID() { return argv_ty; }
112 };
113 
114 static const char * const emptyString = "";
115 static const char * const noArgument = emptyString;
116 static const char * const UseDefaultDoku = emptyString;
117 
118 
119 class  PsToEditOptions : public ProgramOptions {
120 public:
121 	static PsToEditOptions& theOptions(); // singleton
122 	enum PropSheetEnum {g_t=0, t_t, a_t, b_t, d_t, h_t };
123 	// g - general
124 	// t - text
125 	// a - unused
126 	// b - debug
127 	// d - drawing
128 	// h - hidden
129 		// cannot be const  because it needs to be changed on non UNIX systems (convertBackSlashes)
130 	char *nameOfInputFile  ; //= 0;
131 	char *nameOfOutputFile ; //= 0;	// can contain %d for page splitting
132 
133 	OptionT < RSString, RSStringValueExtractor> nameOfIncludeFile ;// = 0;	// name of an option include file
134 	OptionT < RSString, RSStringValueExtractor> replacementfont;// = "Courier";
135  	OptionT < bool, BoolTrueExtractor > nomaptoisolatin1 ;//= false;
136 	OptionT < bool, BoolTrueExtractor > withdisplay ;//= false;
137 	OptionT < RSString, RSStringValueExtractor> pngimage ;
138 	OptionT < bool, BoolTrueExtractor > quiet ;//= false;
139 	OptionT < bool, BoolTrueExtractor > noquit ;//= false;
140 	OptionT < bool, BoolTrueExtractor > nocurves ;//= false;		// normally curves are shown as curves if backend supports
141 //	OptionT < bool, BoolTrueExtractor > nosubpaths ;//= false;	// normally we use subpaths if the backend support them
142 	OptionT < bool, BoolTrueExtractor > mergelines ;//= false;
143 	OptionT < bool, BoolTrueExtractor > convertFilledRectToStroke; //= false;
144 	OptionT < bool, BoolTrueExtractor > mergetext ;//= false;
145 	OptionT < bool, BoolTrueExtractor > drawtext ;//= false;
146 	OptionT < bool, BoolTrueExtractor > autodrawtext ;//= false;
147 	OptionT < bool, BoolTrueExtractor > disabledrawtext ;//= false;
148 	OptionT < bool, BoolTrueExtractor > DrawGlyphBitmaps ;//= false;
149 	OptionT < bool, BoolTrueExtractor > correctdefinefont ;//= false;
150 
151 	OptionT < bool, BoolTrueExtractor > ptioption;
152 	OptionT < bool, BoolTrueExtractor > ptaoption;
153 	unsigned int precisiontext ;//= 0; // derived from the above pti ->1 pta -> 2 otherwise 0
154 
155 	OptionT < double, DoubleValueExtractor > xscale;
156 	OptionT < double, DoubleValueExtractor > yscale;
157 	OptionT < double, DoubleValueExtractor > xshift;
158 	OptionT < double, DoubleValueExtractor > yshift;
159 	OptionT < bool, BoolTrueExtractor > centered ;
160 	OptionT < double, DoubleValueExtractor > minlinewidth;
161 
162 
163 	OptionT < RSString, RSStringValueExtractor> pagenumberformat ;
164 	OptionT < bool, BoolTrueExtractor > splitpages ;//= false;
165 	OptionT < bool, BoolTrueExtractor > verbose ;//= false;
166 	OptionT < bool, BoolTrueExtractor > useBBfrominput; //= false;
167 	OptionT < bool, BoolTrueExtractor > simulateSubPaths ;//= false;
168 	OptionT < bool, BoolTrueExtractor > simulateFill ;//= false;
169 	OptionT < RSString, RSStringValueExtractor> unmappablecharstring ;//= 0;
170 	OptionT < bool, BoolTrueExtractor > dontloadplugins ;//= false;
171 	OptionT < bool, BoolTrueExtractor > nobindversion ;//= false;	// use old NOBIND instead of DELAYBIND
172 	OptionT < int, IntValueExtractor > pagetoextract ;//= 0;		// 0 stands for all pages
173 	OptionT < double, DoubleValueExtractor > flatness ;//= 1.0f;		// used for setflat
174 	OptionT < bool, BoolTrueExtractor > simulateClipping ;//= false;	// simulate clipping most useful in combination with -dt
175 	OptionT < bool, BoolTrueExtractor > usePlainStrings; //= false;
176 	OptionT < bool, BoolTrueExtractor > useRGBcolors ;//= false;
177 	OptionT < bool, BoolTrueExtractor > useAGL ;//= false;
178 	OptionT < bool, BoolTrueExtractor > noclip ;//= false;
179 	OptionT < bool, BoolTrueExtractor > t2fontsast1 ;//= false;	// handle T2 fonts (often come as embedded fonts in PDF files) same as T1
180 	OptionT < bool, BoolTrueExtractor > keepinternalfiles ;//= false;
181 	OptionT < bool, BoolTrueExtractor > fontdebug ;//= false;
182 	OptionT < bool, BoolTrueExtractor > justgstest ;//= false;
183 	OptionT < bool, BoolTrueExtractor > pscover ;//= false;
184 	OptionT < bool, BoolTrueExtractor > nofontreplacement ;//= false;
185 	OptionT < bool, BoolTrueExtractor > passglyphnames;
186 	OptionT < bool, BoolTrueExtractor > useoldnormalization;
187 	OptionT < int, IntValueExtractor > rotation ;//= 0;
188 	OptionT < RSString, RSStringValueExtractor> explicitFontMapFile ;//= 0;
189 	OptionT < RSString, RSStringValueExtractor > outputPageSize;//("");
190 	OptionT < bool, BoolTrueExtractor > fromgui;
191 	OptionT < bool, BoolTrueExtractor > showdialog;
192 	OptionT < RSString, RSStringValueExtractor> GSToUse ;
193 
194 //	OptionT < double, DoubleValueExtractor >  magnification ;//= 1.0f;
195 	OptionT < bool, BoolTrueExtractor > showdrvhelp ;//= false;
196 	OptionT < bool, BoolTrueExtractor > showdocu_long ;//= false;
197 	OptionT < bool, BoolTrueExtractor > showdocu_short ;//= false;
198 	OptionT < bool, BoolTrueExtractor > dumphelp ;//= false;
199 	OptionT < bool, BoolTrueExtractor > listdrivers ;//= false;
200 
201 	OptionT < bool, BoolTrueExtractor > backendonly ;//= false;	// used for easier debugging of backends
202 	// directly read input file by backend
203 	// bypass Ghostscript. The input file
204 	// is assumed to be produced by a
205 	// previous call with -f debug
206 
207 	OptionT < Argv, ArgvExtractor > psArgs;				// Pass through arguments to PostScript interpreter
208 	OptionT < int, IntValueExtractor > psLanguageLevel;
209 	OptionT < RSString, RSStringValueExtractor> drivername ;//= 0; // cannot be const char * because it is changed in pstoedit.cpp
210 	OptionT < RSString, RSStringValueExtractor > gsregbase;
211 
212 private:
PsToEditOptions()213 	PsToEditOptions() :
214 
215 	ProgramOptions(true), // expect additional parameters
216 	nameOfInputFile(0),
217 	nameOfOutputFile(0),	// can contain %d for page splitting
218 
219 	nameOfIncludeFile	(true, "-include","name of a PostScript file to be included",g_t,"name of PostScript file to be included",
220 		"This option allows specifying an additional PostScript file that will be "
221 		"executed just before the normal input is read. This is helpful for "
222 		"including specific page settings or for disabling potentially unsafe "
223 		"PostScript operators, e.g., file, renamefile, or deletefile.",
224 		emptyString),	//
225 	replacementfont		(true, "-df","font name",t_t,"default replacement font for raster fonts",
226 		" Sometimes fonts embedded in a PostScript "
227 		"program do not have a fontname. For example, this happens in PostScript "
228 		"files generated by \\Cmd{dvips}{1}. In such a case \\Prog{pstoedit} uses a "
229 		"replacement font. The default for this is Courier. Another font can be "
230 		"specified using the \\Opt{-df} option. \\Opt{-df Helvetica} causes all "
231 		"unnamed fonts to be replaced by Helvetica.",
232 		(const char *) "Courier"),
233 	nomaptoisolatin1	(true, "-nomaptoisolatin1",noArgument,t_t,"do not map to ISO Latin 1 encoding",
234 		"Normally \\Prog{pstoedit} maps all character "
235 		"codes to the ones defined by the ISO Latin1 encoding. If you specify "
236 		"\\Opt{-nomaptoisolatin1} then the encoding from the input PostScript is "
237 		"passed unchanged to the output. This may result in strange text output but "
238 		"on the other hand may be the only way to get some fonts converted appropriately. "
239 		"Try what fits best to your concrete case.",
240 		false),
241 	withdisplay			(true, "-dis",noArgument,b_t,"let Ghostscript display the file during conversion",
242 		"Open a display during processing by Ghostscript. Some files "
243 		"only work correctly this way.",
244 		false),
245 
246 	pngimage	        (true, "-pngimage","filename",t_t,
247 	                     "for debugging purpose mainly. Write result of processing also to a PNG file",
248 						 UseDefaultDoku,emptyString),
249 
250 	quiet				(true, "-q",noArgument,b_t,"quiet mode - do not write startup message",
251 		UseDefaultDoku,
252 		false),
253 	noquit				(true, "-nq",noArgument,b_t,"do not quit Ghostscript after PostScript processing - for debugging only",
254 		"no exit from the PostScript interpreter. Normally Ghostscript "
255 		"exits after processing the pstoedit input-file. For debugging it can be "
256 		"useful to avoid this. If you do, you will have to type quit at the "
257 		"\\verb+GS>+ prompt to exit from Ghostscript.",
258 		false),
259 	nocurves			(true, "-nc",noArgument,d_t,"normally curves are shown as curves if the output format does support it. This options forces curves to be always converted to line segments.",
260 		"no curves.\n"
261 		"Normally pstoedit tries to keep curves from the input and transfers them to "
262 		"the output if the output format supports curves. If the output format does not "
263 		"support curves, then pstoedit replaces curves by a series of lines (see "
264 		"also \\Opt{-flat} option). However, in some cases the user might wish to "
265 		"have this behavior also for output formats that originally support curves. This "
266 		"can be forced via the \\Opt{-nc} option.",
267 		false),		//
268 /*
269 	nosubpaths			(true, "-nsp",noArgument,d_t,"normally subpaths are used if the output format support them. This option turns off subpaths.",
270 		UseDefaultDoku,
271 		false),	*/
272 	mergelines			(true, "-mergelines",noArgument,d_t,"merge adjacent paths if one is a stroke and the other is a fill. This depends on the capabilities of the selected output format",
273 		"Some output formats permit the representation of filled "
274 		"polygons with edges that are in a different color than the fill color. "
275 		"Since PostScript does not support this by the standard drawing primitives directly, drawing programs typically "
276 		"generate two objects (the outline and the filled polygon) into the "
277 		"PostScript output. \\Prog{pstoedit} is able to recombine these, if they "
278 		"follow each other directly and you specify \\Opt{-mergelines}. "
279 		"However, this merging is not supported by all output formats due to restrictions in the target format.",
280 		false),
281 	convertFilledRectToStroke(true,"-filledrecttostroke",noArgument,d_t,"convert filled rectangles to a stroke",
282 		"Rectangles filled with a solid color can be converted to a stroked line with a width that corresponds to "
283 		"the width of the rectangle. This is of primary interest for output formats which do not "
284 		"support filled polygons at all. But it is restricted to rectangles only, i.e. it is not "
285 		"supported for general polygons",false),
286 	mergetext			(true, "-mergetext",noArgument,d_t,"merge adjacent text pieces",
287 		"In order to produce nice looking text output, programs producing PostScript files "
288 		"often split words into smaller pieces which are then placed individually on adjacent positions. "
289 		"However, such split text is hard to edit later on and hence it is sometime better "
290 		"to recombine these pieces again to form a word (or even sequence of words). "
291 		"For this pstoedit implements some heuristics about what text pieces are to be "
292 		"considered parts of a split word. This is based on the geometrical proximity of the different "
293 		"parts and seems to work quite well so far. But there are certainly cases "
294 		"where this simple heuristic fails. So please check the results carefully.",
295 		false),
296 	drawtext			(true, "-dt",noArgument,t_t,"draw text, i.e. convert text to polygons",
297 		"draw text. Text is drawn as polygons. This might produce a large output file. This option is automatically "
298 		"switched on if the selected output format does not support text, e.g. "
299 		"\\Cmd{gnuplot}{1}.",
300 		false),
301 	autodrawtext		(true, "-adt",noArgument,t_t,"automatic draw text. This draws text only for text that uses fonts with non standard encodings",
302 	"automatic draw text. This option turns on the \\Opt{-dt} option selectively for fonts that seem to be no normal text fonts, e.g. Symbol.",
303 		false),
304 	disabledrawtext		(true, "-ndt",noArgument,t_t,"fully disable any \"intelligence\" for drawing text",
305 		"never draw text. Fully disable the heuristics used by pstoedit to decide when to \"draw\" text "
306 		"instead of showing it as text. This may produce incorrect results, but in some cases it might nevertheless be useful. \"Use at own risk\".",
307 		false),
308 
309 	DrawGlyphBitmaps		(true, "-dgbm",noArgument,t_t,"experimental - draw also bitmaps generated by fonts/glyphs",
310 		UseDefaultDoku,
311 		false),
312 
313 
314 	correctdefinefont	(true, "-correctdefinefont",noArgument,t_t,"apply some \"corrective\" actions to definefont - use this for ChemDraw generated PostScript files",
315 		"Some PostScript files, e.g. such as generated by ChemDraw, "
316 		"use the PostScript definefont operator in a way that is incompatible with "
317 		"pstoedit's assumptions. The new font is defined by copying an old font "
318 		"without changing the FontName of the new font. When this option is applied, "
319 		"some \"patches\" are done after a definefont in order to make it again "
320 		"compatible with pstoedit's assumptions. This option is not enabled by default, "
321 		"since it may break other PostScript files. It is tested only with ChemDraw generated files.",
322 		false),
323 
324 	ptioption			(true, "-pti",noArgument,t_t,"precision text - individual. Places text character by character - but only if non standard chararater widths are used",
325 		"precision text. "
326      	"Normally a text string is drawn as it occurs in the input file. However, in some situations, this might "
327 		"produce wrongly positioned characters. This is due to limitations in most output formats of "
328 		"pstoedit. They cannot represent text with arbitrary inter-letter spacing which is easily "
329 		"possible in PDF and PostScript. "
330 		"With \\Opt{-pta}, each character of a text string is placed "
331 		"separately. With \\Opt{-pti}, this is done only in cases when there is a non zero inter-letter spacing. "
332 		"The downside of \"precision text\" is a bigger file size and hard to edit "
333 		"text.",
334 		false),
335 	ptaoption			(true, "-pta",noArgument,t_t,"precision text - always. Places text character by character",
336 		"see -pti",
337 		false),
338 	precisiontext (0), //= 0; // derived from the above pti ->1 pta -> 2 sonst 0
339 
340 	xscale				(true, "-xscale","number",g_t,"scale by a factor in x-direction",
341 		UseDefaultDoku,
342 		1.0),
343 	yscale				(true, "-yscale","number",g_t,"scale by a factor in y-direction",
344 		UseDefaultDoku,
345 		1.0),
346 
347 	xshift				(true, "-xshift","number",g_t,"shift image in x-direction",
348 		UseDefaultDoku,
349 		0.0f),
350 	yshift				(true, "-yshift","number",g_t,"shift image in y-direction",
351 		UseDefaultDoku,
352 		0.0f),
353 
354 	centered		(true,"-centered","number",g_t,"center image before scaling or shifting",
355 		UseDefaultDoku,
356 		false),
357 
358 	minlinewidth		(true, "-minlinewidth","number",g_t,"minimal line width. All lines thinner than this will be drawn in this line width - especially zero-width lines",
359 		UseDefaultDoku,
360 		0.0f),
361 
362 	pagenumberformat		(true, "-pagenumberformat","page number format specification",g_t,"format specification for page numbers in file name if -split is used. "
363 		"The specification is used to create the page number using sprintf. "
364 		"The specification shall not include the leading \\% nor the trailing d. "
365 		"Default is empty string which results in formatting the page number using \\%d. "
366 		"This results in page numbers like 1, 2, ..., 10. "
367 		"Sometimes you may want to have fixed length with leading 0, "
368 		"so you might want to specify 02 which means 2 digits with leading 0.",
369 		UseDefaultDoku,
370 		emptyString),
371 
372 	splitpages			(true, "-split",noArgument,g_t,"split multipage documents into single pages",
373 		"Create a new file for each page of the input. For this the "
374 		"output filename must contain a \\%d which is replaced with the current page "
375 		"number. This option is automatically switched on for output formats that do not "
376 		"support multiple pages within one file, e.g. fig or gnuplot.",
377 		false),
378 	verbose				(true, "-v",noArgument,b_t,"turns on verbose mode",
379 		"Switch on verbose mode. Some additional information is shown "
380 		"during processing.",
381 		false),
382 	useBBfrominput		(true, "-usebbfrominput",noArgument,g_t,"extract BoundingBox from input file rather than determining it during processing",
383 		"If specified, pstoedit uses the BoundingBox as is (hopefully) found in the input file instead of one that is calculated by its own.",
384 		false),
385 	simulateSubPaths	(true, "-ssp",noArgument,d_t,"simulate subpaths",
386 		"simulate subpaths.\n"
387 		"Several output formats do not support PostScript paths containing subpaths, i.e. "
388 		"paths with intermediate movetos. In the normal case, each subpath is "
389 		"treated as an independent path for such output formats. This can lead to bad "
390 		"looking results. The most common case where this happens is if you use the "
391 		"\\Opt{-dt} option and show some text with letters like e, o, or b, i.e. "
392 		"letters that have a \"hole\". When the \\Opt{-ssp} option is set, pstoedit "
393 		"tries to eliminate these problems. However, this option is CPU time "
394 		"intensive!",
395 		false),
396 	simulateFill	(true, "-sfill",noArgument,d_t,"simulate fill",
397 		"simulate filling by individual strokes.\n"
398 		"",
399 		false),
400 	unmappablecharstring(true, "-uchar","character",t_t,"when a character cannot be mapped to one of the standard encoding vector, use this as replacement",
401 		"Sometimes pstoedit cannot map a character "
402 		"from the encoding used by the PostScript file to the font encoding of the target "
403 		"format. In this case pstoedit replaces the input character by a special character "
404 		"in order to show all the places that could not be mapped correctly. The default "
405 		"for this is a \"\\#\". Using the \\Opt{-uchar} option it is possible to specify another character "
406 		"to be used instead. If you want to use a space, use -uchar \" \".",
407 		emptyString),
408 	dontloadplugins		(true, "-dontloadplugins",noArgument,h_t,"internal option - not relevant for normal user",
409 		UseDefaultDoku,
410 		false),
411 	nobindversion		(true, "-nb",noArgument,b_t,"use old NOBIND instead of DELAYBIND - try this if Ghostscript has problems",
412 		"Since version 3.10 \\Prog{pstoedit} uses the "
413 		"\\texttt{-dDELAYBIND} option when calling Ghostscript. Previously the "
414 		"\\texttt{-dNOBIND} option was used instead but that sometimes caused "
415 		"problems if a user's PostScript file overloaded standard PostScript "
416 		"operator with totally new semantic, e.g. lt for lineto instead of the standard meaning of \"less than\". Using \\Opt{-nb} the "
417 		"old style can be activated again in case the \\texttt{-dDELAYBIND} gives "
418 		"different results as before. In such a case please also contact the "
419 		"author.",
420 		false),	//
421 	pagetoextract		(true, "-page","page number",g_t,"extract a specific page: 0 means all pages",
422 		"Select a single page from a multi-page PostScript or PDF file.",
423 		0),		// 0 stands for all pages
424 	flatness			(true, "-flat","flatness factor",d_t,"the precision used for approximating curves by lines if needed",
425 		"If the output format does not support curves in the way "
426 		"PostScript does or if the \\Opt{-nc} option is specified, all curves are "
427 		"approximated by lines. Using the \\Opt{-flat} option one can control this "
428 		"approximation. This parameter is directly converted to a PostScript "
429 		"\\textbf{setflat} command. Higher numbers, e.g. 10 give rougher, lower "
430 		"numbers, e.g. 0.1, give finer approximations.",
431 		1.0),		// used for setflat
432 	simulateClipping	(true, "-sclip",noArgument,d_t,"simulate clipping - probably you need to set this if you use -dt",
433 		"simulate clipping.\n"
434 		"Most output formats of pstoedit do not have native support for clipping. For that "
435 		"\\Prog{pstoedit} offers an option to perform the clipping of the graphics "
436 		"directly without passing the clippath to the output driver. However, this "
437 		"results in curves being replaced by a lot of line segments and thus larger "
438 		"output files. So use this option only if your output looks different from "
439 		"the input due to clipping. In addition, this \"simulated clipping\" is not "
440 		"exactly the same as defined in PostScript. There might be lines drawn at "
441 		"double size. Also clipping of text is not supported unless you also use "
442 		"the \\Opt{-dt} option.",
443 		false),	// simulate clipping
444 	usePlainStrings		(true, "-ups",noArgument,b_t,"write text as plain string instead of hex string in intermediate format - normally useful for trouble shooting and debugging only.",
445 		UseDefaultDoku,
446 		false),
447 	useRGBcolors		(true, "-rgb",noArgument,g_t,"use RGB colors instead of CMYK",
448 		"Since version 3.30 pstoedit uses the CMYK colors internally. The -rgb option turns on the old behavior to use RGB values.",
449 		false),
450 	useAGL		(true, "-useagl",noArgument,g_t,"use Adobe Glyph List instead of the ISO Latin-1 table (this is experimental)",
451 		UseDefaultDoku,
452 		false),
453 	noclip				(true, "-noclip",noArgument,g_t,"do not use clipping (relevant only if output format supports clipping at all)",
454 		UseDefaultDoku,
455 		false),
456 	t2fontsast1			(true, "-t2fontsast1",noArgument,t_t,"handle T2 fonts (often come as embedded fonts in PDF files) same as T1",
457 		"Handle Type 2 fonts same as Type 1. Type 2 fonts sometimes occur as "
458 		"embedded fonts within PDF files. In the default mode, text using such fonts is drawn as polygons "
459 		"since pstoedit assumes that such a font is not available on the user's machine. If this option "
460 		"is set, pstoedit assumes that the internal encoding follows the same as for a standard font "
461 		"and generates normal text output. This assumption may not be true in all cases. But it "
462 		"is nearly impossible for pstoedit to verify this assumption - it would have to do a sort of OCR.",
463 		false),	// handle T2 fonts (often come as embedded fonts in PDF files) same as T1
464 	keepinternalfiles	(true, "-keep",noArgument,b_t,"keep the intermediate files produced by pstoedit - for debug purposes only",
465 		UseDefaultDoku,
466 		false),
467 	fontdebug	(true, "-debugfonthandling",noArgument,b_t,"writes verbose messages related to internal font processing - for debug purposes only",
468 		UseDefaultDoku,
469 		false),
470 	justgstest			(true, "-gstest",noArgument,b_t,"perform a basic test of the interworking with Ghostscript",
471 		UseDefaultDoku,
472 		false),
473 	pscover				(true, "-pscover",noArgument,h_t,"perform coverage statistics about the pstoedit PostScript proloque - for debug and test only",
474 		UseDefaultDoku,
475 		false),
476 	nofontreplacement	(true, "-nfr",noArgument,t_t,"do not replace non standard encoded fonts with a replacement font",
477 		"In normal mode pstoedit replaces bitmap fonts with a font as defined by the \\Opt{-df} option. This is done, because most output formats cannot handle such fonts. This behavior can be "
478 		"switched off using the \\Opt{-nfr} option but then it strongly depends on the application reading the generated file whether the file is usable and correctly interpreted or not. Any problems are then out of control of pstoedit.",
479 		false),
480 	passglyphnames		(true, "-glyphs",noArgument,t_t,"pass glyph names to output format driver",
481 		"pass glyph names to the output format driver. So far no output format driver really uses the glyph names, so this does not have any effect at the moment. "
482 		"It is a preparation for future work.",
483 		false),
484 	useoldnormalization		(true, "-useoldnormalization",noArgument,t_t,"use legacy (pre 3.50) method for normalizing font encodings",
485 			"Just use this option in case the new heuristic introduced in 3.5 does not produce correct results - however, this normalization of font encoding will always be a best-effort approach since there is no real general solution to it with reasonable effort",
486 		false),
487 	rotation			(true, "-rotate","angle (0-360)",g_t,"rotate the image",
488 		"Rotate image by angle.",
489 		0),
490 	explicitFontMapFile	(true, "-fontmap","name of font map file for pstoedit",t_t,"use a font mapping from a file",
491 		"The font map is a "
492 		"simple text file containing lines in the following format:BREAK\n"
493 		"\n\n"
494 		"\\verb+document_font_name    target_font_name+BREAK\n"
495 		"Lines beginning with \\verb+%+ are considerd comments.BREAK\n"
496 		"For font names with spaces use the "
497 		"\\verb+\"font name with spaces\"+ notation.\n"
498 		"\n"
499 		"If a target\\_font\\_name starts with /, it is regarded as alias to a former entry.\n "
500 		"\n"
501 		"Each font name found in the document is checked against this mapping and if "
502 		"there is a corresponding entry, the new name is used for the output. "
503 		"\n\n"
504 		"If  the \\Opt{-fontmap} option is not specified, \\Prog{pstoedit} "
505 		"automatically looks for the file \\emph{drivername}.fmp in the installation "
506 		"directory and uses that file as a default fontmap file if available. The "
507 		"installation directory is:"
508 		"\n\n"
509 		"\\begin{itemize}\n"
510 		"\n"
511 		"  \\item MS Windows: The same directory where the \\Prog{pstoedit} executable is located\n"
512 		"\n"
513 		"  \\item Unix:BREAK\n"
514 		"  $<$\\emph{The directory where the pstoedit executable is located}$>$\\verb+/../lib/+\n"
515 		"\n"
516 		"\\end{itemize}\n"
517 		"\n"
518 		"The mpost.fmp in the misc directory of the pstoedit distribution is a sample "
519 		"map file with mappings from over 5000 PostScript font names to their \\TeX\\ "
520 		"equivalents. This is useful because MetaPost is frequently used with "
521 		"\\TeX/\\LaTeX\\ and those programs do not use standard font names. This file and "
522 		"the MetaPost output format driver are provided by Scott Pakin "
523 		"(\\Email{scott+ps2ed\\_AT\\_pakin.org})."
524 		"\n"
525 		"Another example is wemf.fmp to be used under Windows. See the misc "
526 		"directory of the pstoedit source distribution."
527 		"\n"
528 		"After loading the implicit (based on driver name) or explicit (based on the -fontmap option) font map file, a system specific "
529 		"map file is searched and loaded from the installation directory (unix.fmp or windows.fmp). "
530 		"This file can be used to redirect certain fonts to system specific names using the /AliasName notation described above."
531 		,
532 		emptyString),
533 	outputPageSize		(true, "-pagesize","page format",g_t,"set page size (e.g. a4) - used by TK and libplot output format driver only",
534 		"set page size for output medium.\n"
535 		"This option sets the page size for the output medium. Currently this "
536 		"is just used by the libplot output format driver, but might be used by other "
537 		"output format drivers in future. The page size is specified in terms of the usual "
538 		"page size names, e.g. letter or a4.",
539 		emptyString),
540 	fromgui				(true, "-fromgui",noArgument,h_t,"internal - not for normal user",
541 		UseDefaultDoku,
542 		false),
543 	showdialog			(true, "-showdialog",noArgument,h_t,"internal - not for normal user",
544 		UseDefaultDoku,
545 		false),
546 	GSToUse				(true, "-gs","path to the Ghostscript executable/DLL",g_t,"tells pstoedit which Ghostscript executable/DLL to use - overwrites the internal search heuristic",
547 	UseDefaultDoku,emptyString),
548 	showdrvhelp			(true, "-help",noArgument,g_t,"show the help information",
549 		UseDefaultDoku,
550 		false) ,
551 	showdocu_long			(true, "-doculong",noArgument,h_t,"show help information in TeX format - long version",
552 		UseDefaultDoku,
553 		false) ,
554 	showdocu_short			(true, "-docushort",noArgument,h_t,"show help information in TeX format - short version",
555 		UseDefaultDoku,
556 		false) ,
557 	dumphelp			(true, "-dumphelp",noArgument,h_t,"show all options of all drivers in TeX format",
558 		UseDefaultDoku,
559 		false),
560 	listdrivers			(true, "-listdrivers",noArgument,h_t,"list all available drivers",
561 		UseDefaultDoku,
562 		false),
563 
564 	backendonly			(true, "-bo",noArgument,g_t,"backend only - This option is not useful for a \"normal\" user. "
565 													"It is useful for programs which use pstoedit as output format generator "
566 													"and can provide an input file which adheres to pstoedit's internal dump format.",
567 		"You can run backend processing only (without the PostScript "
568 		"interpreter frontend) by first running \\textbf{pstoedit} \\Opt{-f dump} "
569 		"\\Arg{infile} \\Arg{dumpfile} and then running \\textbf{pstoedit} "
570 		"\\OptArg{-f}{~format}  \\Opt{-bo} \\Arg{dumpfile} \\Arg{outfile}.",
571 		false),	// used for easier debugging of backends
572 	psArgs				(true, "-psarg","argument string",g_t,"additional arguments to be passed to Ghostscript directly",
573 		"The string given with this option is passed "
574 		"directly to Ghostscript when Ghostscript is called to process the "
575 		"PostScript file for \\Prog{pstoedit}. For example:      "
576 		"\\textbf{-psarg}\\textbf{~\"}\\textbf{-r300x300}\\textbf{\"}. "
577 		"This causes the resolution to be changed to "
578 		"300x300 dpi. (With older versions of Ghostscript, changing the resolution "
579 		"this way has an effect only if the \\Opt{-dis} option is given.) "
580 		"If you want to pass multiple options to Ghostscript you can use multiple "
581 		"-psarg options \\Opt{-psarg opt1} \\Opt{-psarg opt2} \\Opt{-psarg opt2}. "
582 		"See the Ghostscript manual for other possible options."
583 		),
584 
585 	psLanguageLevel		(true, "-pslanguagelevel","PostScript Language Level 1, 2, or 3 to be used.", g_t,
586 		"PostScript Language Level 1, 2, or 3 to be used. "
587 		"You can switch Ghostscript into PostScript Level 1 only mode by "
588 		"\\Opt{-pslanguagelevel 1}. This can be useful for example if the PostScript file to be "
589 		"converted uses some Level 2 specific custom color models that are not supported "
590 		"by pstoedit. However, this requires that the PostScript program checks for the "
591 		"PostScript level supported by the interpreter and \"acts\" accordingly. "
592 		"The default language level is 3.",
593 		UseDefaultDoku,
594 		3),
595 
596 	drivername			(false,"-f","\"format[:options]\"",g_t,"target format identifier",
597 		"target output format recognized by "
598 		"\\Prog{pstoedit}. Since other format drivers can be loaded dynamically, "
599 		"type  \\texttt{pstoedit -help} to get a full list of formats. See "
600 		"\"Available formats and their specific options\" "
601 		"below for an explanation of the \\oArg{:options} to "
602 		"\\Opt{-f} format. If the format option is not given, pstoedit tries to guess the target format "
603 		" from the suffix of the output filename. However, in a lot of cases, this is not a unique "
604 		"mapping and hence pstoedit demands the \\Opt{-f} option.",
605 		emptyString),
606 	gsregbase (true, "-gsregbase", "Ghostscript base registry path", g_t,
607 	  "use this registry key as a subkey to search for Ghostscript",
608 	  "registry path to use as a base path when searching Ghostscript interpreter.\n"
609 	  "This option provides means to specify a registry key under "
610 	  "HKLM/Software where to search for GS interpreter key, version "
611 	  "and \\verb+GS_DLL / GS_LIB+ values. Example: \"-gsregbase MyCompany\" means "
612 	  "that HKLM/Software/MyCompany/GPL Ghostscript would be searched "
613 	  "instead of HKLM/Software/GPL Ghostscript.",
614 	  emptyString)
615 	{
616 
617 	// nameOfInputFile (0);
618 	// nameOfOutputFile (0),	// can contain %d for page splitting
619 
620 #define MAKESTRING(x) #x
621 #define ADD(x) add(&x,MAKESTRING(x))
622 
623 	ADD(nameOfIncludeFile);
624 	ADD(replacementfont);
625 	ADD(nomaptoisolatin1);
626 	ADD(withdisplay);
627 	ADD(pngimage);
628 	ADD(quiet);
629 	ADD(noquit);
630 	ADD(nocurves);
631 //	ADD(nosubpaths);
632 	ADD(mergelines);
633 	ADD(convertFilledRectToStroke);
634 	ADD(mergetext);
635 	ADD(drawtext);
636 	ADD(autodrawtext);
637 	ADD(disabledrawtext);
638 	ADD(DrawGlyphBitmaps);
639 	ADD(correctdefinefont);
640 
641 	ADD(ptioption);
642 	ADD(ptaoption);
643 	// ADD(precisiontext (0); //= 0; // derived from the above pti ->1 pta -> 2 sonst 0
644 
645 	ADD(xscale);
646 	ADD(yscale);
647 	ADD(xshift);
648 	ADD(yshift);
649 	ADD(centered);
650 	ADD(minlinewidth);
651 
652 	ADD(pagenumberformat);
653 	ADD(splitpages);
654 	ADD(verbose );
655 	ADD(useBBfrominput);
656 	ADD(simulateSubPaths);
657 	ADD(simulateFill);
658 	ADD(unmappablecharstring);
659 	ADD(dontloadplugins);
660 	ADD(nobindversion );
661 	ADD(pagetoextract);
662 	ADD(flatness);
663 	ADD(simulateClipping);
664 	ADD(usePlainStrings);
665 	ADD(useRGBcolors);
666 	ADD(useAGL);
667 	ADD(noclip);
668 	ADD(t2fontsast1);
669 	ADD(keepinternalfiles);
670 	ADD(fontdebug);
671 	ADD(justgstest);
672 	ADD(pscover);
673 	ADD(nofontreplacement);
674 	ADD(passglyphnames);
675 	ADD(useoldnormalization);
676 	ADD(rotation );
677 	ADD(explicitFontMapFile);
678 	ADD(outputPageSize);
679 	ADD(fromgui);
680 #ifdef HAVE_DIALOG
681 	ADD(showdialog);
682 #endif
683 //	ADD(magnification);
684 	ADD(showdrvhelp) ;
685 	ADD(showdocu_long) ;
686 	ADD(showdocu_short) ;
687 	ADD(GSToUse);
688 	ADD(dumphelp);
689 	ADD(listdrivers);
690 	ADD(backendonly);
691 	ADD(psArgs);
692 	ADD(psLanguageLevel);
693 
694 	ADD(drivername);
695 	ADD(gsregbase);
696 }
697 
~PsToEditOptions()698 	~PsToEditOptions() {
699 		// delete drivername.value; // this crashes under Windows (heap problem) //lint !e605
700 		delete [] nameOfInputFile ;
701 		delete [] nameOfOutputFile  ;
702 	}
703 
hideFromDoku(const OptionBase & opt)704 	virtual bool hideFromDoku(const OptionBase& opt) const { return opt.propsheet == h_t; }
705 
706 //		AutoDeleter < char >DeleterFordrivername(drivername, true);
707 
708 };
709 
710 #endif
711 
712