3 * Copyright (C) 2002-2004 A.J. van Os; Released under GNU GPL
6 * Generic output generating functions
11 static conversion_type eConversionType
= conversion_unknown
;
12 static encoding_type eEncoding
= encoding_neutral
;
16 * vPrologue1 - get options and call a specific initialization
19 vPrologue1(diagram_type
*pDiag
, const char *szTask
, const char *szFilename
)
21 options_type tOptions
;
24 fail(szTask
== NULL
|| szTask
[0] == '\0');
26 vGetOptions(&tOptions
);
27 eConversionType
= tOptions
.eConversionType
;
28 eEncoding
= tOptions
.eEncoding
;
30 switch (eConversionType
) {
32 vPrologueTXT(pDiag
, &tOptions
);
34 case conversion_fmt_text
:
35 vPrologueFMT(pDiag
, &tOptions
);
38 vProloguePS(pDiag
, szTask
, szFilename
, &tOptions
);
41 vPrologueXML(pDiag
, &tOptions
);
44 vProloguePDF(pDiag
, szTask
, &tOptions
);
47 DBG_DEC(eConversionType
);
50 } /* end of vPrologue1 */
53 * vEpilogue - clean up after everything is done
56 vEpilogue(diagram_type
*pDiag
)
58 switch (eConversionType
) {
60 case conversion_fmt_text
:
61 vEpilogueTXT(pDiag
->pOutFile
);
73 DBG_DEC(eConversionType
);
76 } /* end of vEpilogue */
79 * vImagePrologue - perform image initialization
82 vImagePrologue(diagram_type
*pDiag
, const imagedata_type
*pImg
)
84 switch (eConversionType
) {
86 case conversion_fmt_text
:
89 vImageProloguePS(pDiag
, pImg
);
94 vImageProloguePDF(pDiag
, pImg
);
97 DBG_DEC(eConversionType
);
100 } /* end of vImagePrologue */
103 * vImageEpilogue - clean up an image
106 vImageEpilogue(diagram_type
*pDiag
)
108 switch (eConversionType
) {
109 case conversion_text
:
110 case conversion_fmt_text
:
113 vImageEpiloguePS(pDiag
);
118 vImageEpiloguePDF(pDiag
);
121 DBG_DEC(eConversionType
);
124 } /* end of vImageEpilogue */
127 * bAddDummyImage - add a dummy image
129 * return TRUE when successful, otherwise FALSE
132 bAddDummyImage(diagram_type
*pDiag
, const imagedata_type
*pImg
)
134 switch (eConversionType
) {
135 case conversion_text
:
136 case conversion_fmt_text
:
139 return bAddDummyImagePS(pDiag
, pImg
);
143 return bAddDummyImagePDF(pDiag
, pImg
);
145 DBG_DEC(eConversionType
);
148 } /* end of bAddDummyImage */
151 * pCreateDiagram - create and initialize a diagram
153 * remark: does not return if the diagram can't be created
156 pCreateDiagram(const char *szTask
, const char *szFilename
)
160 fail(szTask
== NULL
|| szTask
[0] == '\0');
161 DBG_MSG("pCreateDiagram");
163 /* Get the necessary memory */
164 pDiag
= xmalloc(sizeof(diagram_type
));
166 pDiag
->pOutFile
= stdout
;
167 vPrologue1(pDiag
, szTask
, szFilename
);
170 } /* end of pCreateDiagram */
173 * vDestroyDiagram - remove a diagram by freeing the memory it uses
176 vDestroyDiagram(diagram_type
*pDiag
)
178 DBG_MSG("vDestroyDiagram");
186 pDiag
= xfree(pDiag
);
187 } /* end of vDestroyDiagram */
190 * vPrologue2 - call a specific initialization
193 vPrologue2(diagram_type
*pDiag
, int iWordVersion
)
195 switch (eConversionType
) {
196 case conversion_text
:
197 case conversion_fmt_text
:
203 vCreateBookIntro(pDiag
, iWordVersion
);
206 vCreateInfoDictionary(pDiag
, iWordVersion
);
210 DBG_DEC(eConversionType
);
213 } /* end of vPrologue2 */
216 * vMove2NextLine - move to the next line
219 vMove2NextLine(diagram_type
*pDiag
, drawfile_fontref tFontRef
,
223 fail(pDiag
->pOutFile
== NULL
);
224 fail(usFontSize
< MIN_FONT_SIZE
|| usFontSize
> MAX_FONT_SIZE
);
226 switch (eConversionType
) {
227 case conversion_text
:
228 case conversion_fmt_text
:
229 vMove2NextLineTXT(pDiag
);
232 vMove2NextLinePS(pDiag
, usFontSize
);
235 vMove2NextLineXML(pDiag
);
238 vMove2NextLinePDF(pDiag
, usFontSize
);
241 DBG_DEC(eConversionType
);
244 } /* end of vMove2NextLine */
247 * vSubstring2Diagram - put a sub string into a diagram
250 vSubstring2Diagram(diagram_type
*pDiag
,
251 char *szString
, size_t tStringLength
, long lStringWidth
,
252 UCHAR ucFontColor
, USHORT usFontstyle
, drawfile_fontref tFontRef
,
253 USHORT usFontSize
, USHORT usMaxFontSize
)
255 switch (eConversionType
) {
256 case conversion_text
:
257 vSubstringTXT(pDiag
, szString
, tStringLength
, lStringWidth
);
259 case conversion_fmt_text
:
260 vSubstringFMT(pDiag
, szString
, tStringLength
, lStringWidth
,
264 vSubstringPS(pDiag
, szString
, tStringLength
, lStringWidth
,
265 ucFontColor
, usFontstyle
, tFontRef
,
266 usFontSize
, usMaxFontSize
);
269 vSubstringXML(pDiag
, szString
, tStringLength
, lStringWidth
,
273 vSubstringPDF(pDiag
, szString
, tStringLength
, lStringWidth
,
274 ucFontColor
, usFontstyle
, tFontRef
,
275 usFontSize
, usMaxFontSize
);
278 DBG_DEC(eConversionType
);
281 pDiag
->lXleft
+= lStringWidth
;
282 } /* end of vSubstring2Diagram */
285 * Create a start of paragraph (phase 1)
286 * Before indentation, list numbering, bullets etc.
289 vStartOfParagraph1(diagram_type
*pDiag
, long lBeforeIndentation
)
293 switch (eConversionType
) {
294 case conversion_text
:
295 case conversion_fmt_text
:
296 vStartOfParagraphTXT(pDiag
, lBeforeIndentation
);
299 vStartOfParagraphPS(pDiag
, lBeforeIndentation
);
304 vStartOfParagraphPDF(pDiag
, lBeforeIndentation
);
307 DBG_DEC(eConversionType
);
310 } /* end of vStartOfParagraph1 */
313 * Create a start of paragraph (phase 2)
314 * After indentation, list numbering, bullets etc.
317 vStartOfParagraph2(diagram_type
*pDiag
)
321 switch (eConversionType
) {
322 case conversion_text
:
323 case conversion_fmt_text
:
328 vStartOfParagraphXML(pDiag
, 1);
333 DBG_DEC(eConversionType
);
336 } /* end of vStartOfParagraph2 */
339 * Create an end of paragraph
342 vEndOfParagraph(diagram_type
*pDiag
,
343 drawfile_fontref tFontRef
, USHORT usFontSize
, long lAfterIndentation
)
346 fail(pDiag
->pOutFile
== NULL
);
347 fail(usFontSize
< MIN_FONT_SIZE
|| usFontSize
> MAX_FONT_SIZE
);
348 fail(lAfterIndentation
< 0);
350 switch (eConversionType
) {
351 case conversion_text
:
352 case conversion_fmt_text
:
353 vEndOfParagraphTXT(pDiag
, lAfterIndentation
);
356 vEndOfParagraphPS(pDiag
, usFontSize
, lAfterIndentation
);
359 vEndOfParagraphXML(pDiag
, 1);
362 vEndOfParagraphPDF(pDiag
, usFontSize
, lAfterIndentation
);
365 DBG_DEC(eConversionType
);
368 } /* end of vEndOfParagraph */
371 * Create an end of page
374 vEndOfPage(diagram_type
*pDiag
, long lAfterIndentation
, BOOL bNewSection
)
376 switch (eConversionType
) {
377 case conversion_text
:
378 case conversion_fmt_text
:
379 vEndOfPageTXT(pDiag
, lAfterIndentation
);
382 vEndOfPagePS(pDiag
, bNewSection
);
385 vEndOfPageXML(pDiag
);
388 vEndOfPagePDF(pDiag
, bNewSection
);
391 DBG_DEC(eConversionType
);
394 } /* end of vEndOfPage */
397 * vSetHeaders - set the headers
400 vSetHeaders(diagram_type
*pDiag
, USHORT usIstd
)
402 switch (eConversionType
) {
403 case conversion_text
:
404 case conversion_fmt_text
:
409 vSetHeadersXML(pDiag
, usIstd
);
414 DBG_DEC(eConversionType
);
417 } /* end of vSetHeaders */
420 * Create a start of list
423 vStartOfList(diagram_type
*pDiag
, UCHAR ucNFC
, BOOL bIsEndOfTable
)
425 switch (eConversionType
) {
426 case conversion_text
:
427 case conversion_fmt_text
:
432 vStartOfListXML(pDiag
, ucNFC
, bIsEndOfTable
);
437 DBG_DEC(eConversionType
);
440 } /* end of vStartOfList */
443 * Create an end of list
446 vEndOfList(diagram_type
*pDiag
)
448 switch (eConversionType
) {
449 case conversion_text
:
450 case conversion_fmt_text
:
455 vEndOfListXML(pDiag
);
460 DBG_DEC(eConversionType
);
463 } /* end of vEndOfList */
466 * Create a start of a list item
469 vStartOfListItem(diagram_type
*pDiag
, BOOL bNoMarks
)
471 switch (eConversionType
) {
472 case conversion_text
:
473 case conversion_fmt_text
:
478 vStartOfListItemXML(pDiag
, bNoMarks
);
483 DBG_DEC(eConversionType
);
486 } /* end of vStartOfListItem */
489 * Create an end of a table
492 vEndOfTable(diagram_type
*pDiag
)
494 switch (eConversionType
) {
495 case conversion_text
:
496 case conversion_fmt_text
:
501 vEndOfTableXML(pDiag
);
506 DBG_DEC(eConversionType
);
509 } /* end of vEndOfTable */
514 * Returns TRUE when conversion type is XML
517 bAddTableRow(diagram_type
*pDiag
, char **aszColTxt
,
518 int iNbrOfColumns
, const short *asColumnWidth
, UCHAR ucBorderInfo
)
520 switch (eConversionType
) {
521 case conversion_text
:
522 case conversion_fmt_text
:
527 vAddTableRowXML(pDiag
, aszColTxt
,
528 iNbrOfColumns
, asColumnWidth
,
534 DBG_DEC(eConversionType
);
538 } /* end of bAddTableRow */