Annotation of Amaya/amaya/HTMLbook.c, revision 1.68
1.1 cvs 1: /*
2: *
3: * (c) COPYRIGHT MIT and INRIA, 1996.
4: * Please first read the full copyright statement in file COPYRIGHT.
5: *
6: */
1.65 cvs 7:
1.1 cvs 8: /*
9: * Initialization functions and button functions of Amaya application.
10: *
11: * Authors: V. Quint, I. Vatton
1.49 cvs 12: * R. Guetari (W3C/INRIA) - Unicode and Windows version.
1.1 cvs 13: */
14:
15:
16: /* Included headerfiles */
17: #define THOT_EXPORT
18: #include "amaya.h"
1.44 cvs 19: #include "AHTURLTools_f.h"
1.1 cvs 20: #include "print.h"
1.51 cvs 21: #include "css.h"
1.1 cvs 22:
1.25 cvs 23: /* structure to register sub-documents in MakeBook function*/
24: typedef struct _SubDoc
25: {
26: struct _SubDoc *SDnext;
27: Element SDel;
1.36 cvs 28: STRING SDname;
1.25 cvs 29: }SubDoc;
30:
1.29 cvs 31: /* the structure used for the GetIncludedDocuments_callback function */
1.58 cvs 32: typedef struct _IncludeCtxt
1.53 cvs 33: {
1.58 cvs 34: Element div; /* enclosing element for the search */
35: Element link; /* current processed link */
36: STRING url; /* called url */
37: STRING name; /* the fragment name */
38: struct _IncludeCtxt *ctxt; /* the previous context */
39: } IncludeCtxt;
1.29 cvs 40:
1.55 cvs 41: /* shared with windialogapi.c */
42: ThotBool PrintURL;
43: ThotBool NumberLinks;
44: ThotBool WithToC;
45: ThotBool IgnoreCSS;
46:
1.25 cvs 47: static struct _SubDoc *SubDocs;
1.62 cvs 48: static CHAR_T PSdir[MAX_PATH];
1.53 cvs 49: static CHAR_T PPrinter[MAX_PATH];
50: static Document DocPrint;
1.2 cvs 51: static int PaperPrint;
52: static int ManualFeed;
53: static int PageSize;
1.1 cvs 54:
55: #include "init_f.h"
56: #include "HTMLactions_f.h"
57: #include "HTMLbook_f.h"
58: #include "HTMLedit_f.h"
1.25 cvs 59: #include "HTMLhistory_f.h"
1.51 cvs 60: #include "UIcss_f.h"
1.1 cvs 61:
1.31 cvs 62: #ifdef _WINDOWS
1.37 cvs 63: #include "wininclude.h"
1.31 cvs 64: #endif /* _WINDOWS */
65:
1.58 cvs 66: static ThotBool GetIncludedDocuments ();
1.1 cvs 67:
68: /*----------------------------------------------------------------------
1.16 cvs 69: RegisterSubDoc adds a new entry in SubDoc table.
70: ----------------------------------------------------------------------*/
71: #ifdef __STDC__
1.36 cvs 72: static void RegisterSubDoc (Element el, STRING url)
1.16 cvs 73: #else
74: static void RegisterSubDoc (el, url)
75: Element el;
1.36 cvs 76: STRING url;
1.16 cvs 77: #endif
78: {
79: struct _SubDoc *entry, *last;
80:
81: if (url == NULL || url[0] == EOS)
82: return;
83:
84: entry = TtaGetMemory (sizeof (struct _SubDoc));
85: entry->SDnext = NULL;
86: entry->SDel = el;
1.62 cvs 87: entry->SDname = TtaWCSdup (url);
1.16 cvs 88:
89: if (SubDocs == NULL)
90: SubDocs = entry;
91: else
92: {
93: last = SubDocs;
94: while (last->SDnext != NULL)
95: last = last->SDnext;
96: last->SDnext = entry;
97: }
98: }
99:
100:
101: /*----------------------------------------------------------------------
102: SearchSubDoc searches whether a document name is registered or not
103: within the SubDoc table.
104: Return the DIV element that correspond to the sub-document or NULL.
105: ----------------------------------------------------------------------*/
106: #ifdef __STDC__
1.36 cvs 107: static Element SearchSubDoc (STRING url)
1.16 cvs 108: #else
109: static Element SearchSubDoc (url)
1.36 cvs 110: STRING url;
1.16 cvs 111: #endif
112: {
113: Element el;
114: struct _SubDoc *entry;
1.47 cvs 115: ThotBool docFound;
1.16 cvs 116:
117: if (url == NULL || url[0] == EOS)
118: return (NULL);
119:
120: entry = SubDocs;
121: docFound = FALSE;
122: el = NULL;
123: while (!docFound && entry != NULL)
124: {
1.36 cvs 125: docFound = (ustrcmp (url, entry->SDname) == 0);
1.16 cvs 126: if (!docFound)
127: entry = entry->SDnext;
128: else
129: /* document found -> return the DIV element */
130: el = entry->SDel;
131: }
132: return (el);
133: }
134:
135: /*----------------------------------------------------------------------
136: FreeSubDocTable frees all entries in SubDoc table.
137: ----------------------------------------------------------------------*/
138: static void FreeSubDocTable ()
139: {
140: struct _SubDoc *entry, *last;
141:
142: entry = SubDocs;
143: while (entry != NULL)
144: {
145: last = entry;
146: entry = entry->SDnext;
147: TtaFreeMemory (last->SDname);
148: TtaFreeMemory (last);
149: }
150: SubDocs = NULL;
151: }
152:
153:
154:
155: /*----------------------------------------------------------------------
1.1 cvs 156: SetInternalLinks
1.8 cvs 157: Associate an InternalLink attribute with all anchor (A) elements of the
158: document which designate an element in the same document.
1.1 cvs 159: InternalLink is a Thot reference attribute that links a source and a
160: target anchor and that allows P schemas to display and print cross-references
161: ----------------------------------------------------------------------*/
162: #ifdef __STDC__
1.4 cvs 163: void SetInternalLinks (Document document)
1.1 cvs 164: #else
1.4 cvs 165: void SetInternalLinks (document)
1.1 cvs 166: Document document;
167: #endif
168: {
1.32 cvs 169: Element el, div, link, target, sibling;
170: ElementType elType, linkType;
1.16 cvs 171: Attribute HrefAttr, IntLinkAttr;
1.17 cvs 172: Attribute attr, ExtLinkAttr;
1.16 cvs 173: AttributeType attrType;
1.36 cvs 174: STRING text, ptr, url;
1.43 cvs 175: CHAR_T number[10];
176: CHAR_T value[MAX_LENGTH];
1.25 cvs 177: int length, i, volume;
178: int status, position;
1.47 cvs 179: ThotBool split;
1.1 cvs 180:
1.16 cvs 181: /* Remember the current status of the document */
182: status = TtaIsDocumentModified (document);
1.32 cvs 183: el = TtaGetMainRoot (document);
184: volume = TtaGetElementVolume (el);
185: elType = TtaGetElementType (el);
186: elType.ElTypeNum = HTML_EL_AnyLink;
1.16 cvs 187: attrType.AttrSSchema = elType.ElSSchema;
1.32 cvs 188: /* looks for all links in the document */
1.16 cvs 189: link = el;
190: while (link != NULL)
191: {
1.25 cvs 192: /* display the progression of the work */
193: el = link;
194: position = 0;
195: while (el != NULL)
196: {
197: sibling = el;
198: do
199: {
200: /* add volume of each previous element */
201: TtaPreviousSibling (&sibling);
202: if (sibling != NULL)
203: position += TtaGetElementVolume (sibling);
204: }
205: while (sibling != NULL);
206: el = TtaGetParent (el);
207: }
1.49 cvs 208: usprintf (number, TEXT("%d"), position*100/volume);
1.25 cvs 209: TtaSetStatus (document, 1, TtaGetMessage (AMAYA, AM_UPDATED_LINK), number);
210: TtaHandlePendingEvents ();
1.16 cvs 211: link = TtaSearchTypedElement (elType, SearchForward, link);
212: if (link != NULL)
1.32 cvs 213: /* a link has been found */
1.16 cvs 214: {
1.32 cvs 215: linkType = TtaGetElementType (link);
216: if (linkType.ElTypeNum == HTML_EL_Anchor)
217: attrType.AttrTypeNum = HTML_ATTR_HREF_;
218: else
219: attrType.AttrTypeNum = HTML_ATTR_cite;
1.16 cvs 220: HrefAttr = TtaGetAttribute (link, attrType);
221: attrType.AttrTypeNum = HTML_ATTR_InternalLink;
222: IntLinkAttr = TtaGetAttribute (link, attrType);
223: attrType.AttrTypeNum = HTML_ATTR_ExternalLink;
224: ExtLinkAttr = TtaGetAttribute (link, attrType);
225: if (HrefAttr == NULL)
1.32 cvs 226: /* this element is not a link (no href or cite attribute) */
1.16 cvs 227: /* remove attributes InternalLink and ExternalLink if they
228: are present */
229: {
1.8 cvs 230: if (IntLinkAttr != NULL)
1.16 cvs 231: TtaRemoveAttribute (link, IntLinkAttr, document);
232: if (ExtLinkAttr != NULL)
233: TtaRemoveAttribute (link, ExtLinkAttr, document);
234: }
235: else
1.32 cvs 236: /* this element has an HREF or cite attribute */
1.16 cvs 237: {
238: length = TtaGetTextAttributeLength (HrefAttr);
1.49 cvs 239: text = TtaAllocString (length + 1);
1.16 cvs 240: TtaGiveTextAttributeValue (HrefAttr, text, &length);
241:
242: /* does an external link become an internal link ? */
1.25 cvs 243: if (document == DocBook && SubDocs != NULL)
1.16 cvs 244: {
1.36 cvs 245: ptr = ustrrchr (text, '#');
1.16 cvs 246: url = text;
1.18 cvs 247: split = FALSE;
1.16 cvs 248: if (ptr == text)
249: /* a local link */
250: url = NULL;
1.17 cvs 251: else if (ptr != NULL)
1.16 cvs 252: {
253: /* split url and name part */
254: ptr[0] = EOS;
255: split = TRUE;
256: }
257:
258: /* Is it a sub-document */
259: div = SearchSubDoc (url);
260: if (split)
261: /* retore the mark */
262: ptr[0] = '#';
263:
264: if (div == NULL)
265: {
266: /* it's not a sub-document */
267: if (url == NULL)
268: /* a local link */
269: ptr = &text[1];
270: else
271: /* still an externa; link */
272: ptr = NULL;
273: }
274: else
275: {
276: /* this link becomes internal */
1.17 cvs 277: if (ptr != NULL)
1.16 cvs 278: {
1.17 cvs 279: /* get the target name */
1.36 cvs 280: ustrcpy (value, ptr);
281: length = ustrlen (value);
1.17 cvs 282: /* check whether the name changed */
283: i = 0;
284: target = SearchNAMEattribute (document, &value[1], NULL);
285: while (target != NULL)
1.16 cvs 286: {
1.17 cvs 287: /* is it the right NAME */
288: if (TtaIsAncestor (target, div))
289: target = NULL;
290: else
291: {
292: /* continue the search */
293: i++;
1.49 cvs 294: usprintf (&value[length], TEXT("%d"), i);
1.32 cvs 295: target = SearchNAMEattribute (document,
296: &value[1], NULL);
1.17 cvs 297: }
1.16 cvs 298: }
299: }
1.17 cvs 300: else
301: {
302: /* get the DIV name */
303: attrType.AttrTypeNum = HTML_ATTR_ID;
304: attr = TtaGetAttribute (div, attrType);
305: length = 200;
306: value[0] = '#';
307: TtaGiveTextAttributeValue (attr, &value[1], &length);
308: }
1.16 cvs 309: ptr = &value[1];
310: TtaSetAttributeText (HrefAttr, value, link, document);
311: }
312: }
313: else if (text[0] == '#')
314: ptr = &text[1];
315: else
316: ptr = NULL;
317:
318: if (ptr != NULL)
319: /* it's an internal link. Attach an attribute InternalLink */
320: /* to the link, if this attribute does not exist yet */
321: {
322: if (IntLinkAttr == NULL)
323: {
324: attrType.AttrTypeNum = HTML_ATTR_InternalLink;
325: IntLinkAttr = TtaNewAttribute (attrType);
326: TtaAttachAttribute (link, IntLinkAttr, document);
327: }
328: /* looks for the target element */
329: target = SearchNAMEattribute (document, ptr, NULL);
330: if (target != NULL)
331: /* set the Thot link */
1.32 cvs 332: TtaSetAttributeReference (IntLinkAttr, link, document,
333: target, document);
1.16 cvs 334: }
335: else
336: /* it's an external link */
337: {
338: /* Remove the InternalLink attribute if it is present */
339: if (IntLinkAttr != NULL)
340: TtaRemoveAttribute (link, IntLinkAttr, document);
341: /* create an ExternalLink attribute if there is none */
342: if (ExtLinkAttr == NULL)
343: {
344: attrType.AttrTypeNum = HTML_ATTR_ExternalLink;
345: ExtLinkAttr = TtaNewAttribute (attrType);
346: TtaAttachAttribute (link, ExtLinkAttr, document);
347: }
348: }
349: TtaFreeMemory (text);
350: }
351: }
352: }
353: /* Reset document status */
354: if (!status)
355: TtaSetDocumentUnmodified (document);
1.3 cvs 356: }
357:
358: /*----------------------------------------------------------------------
359: CheckPrintingDocument reinitialize printing parameters as soon as
360: the printing document changes.
361: ----------------------------------------------------------------------*/
362: #ifdef __STDC__
363: static void CheckPrintingDocument (Document document)
364: #else
365: static void CheckPrintingDocument (document)
366: Document document;
367: #endif
368: {
1.62 cvs 369: CHAR_T docName[MAX_LENGTH];
370: CHAR_T* ptr;
371: CHAR_T suffix[MAX_LENGTH];
1.3 cvs 372: int lg;
373:
1.53 cvs 374: if (DocPrint != document)
1.3 cvs 375: {
376: /* initialize print parameters */
1.53 cvs 377: DocPrint = document;
1.3 cvs 378:
379: /* define the new default PS file */
1.52 cvs 380: ptr = TtaGetEnvString ("APP_TMPDIR");
1.3 cvs 381: if (ptr != NULL && TtaCheckDirectory (ptr))
1.62 cvs 382: ustrcpy (PSdir, ptr);
1.44 cvs 383: else
1.62 cvs 384: ustrcpy (PSdir, TtaGetDefEnvString ("APP_TMPDIR"));
385: lg = ustrlen (PSdir);
386: if (PSdir[lg - 1] == WC_DIR_SEP)
387: PSdir[--lg] = WC_EOS;
1.44 cvs 388:
1.62 cvs 389: ustrcpy (docName, TtaGetDocumentName (document));
1.3 cvs 390: ExtractSuffix (docName, suffix);
1.62 cvs 391: usprintf (&PSdir[lg], TEXT("%c%s.ps"), WC_DIR_SEP, docName);
1.3 cvs 392: TtaSetPsFile (PSdir);
393: /* define the new default PrintSchema */
1.53 cvs 394: NumberLinks = FALSE;
395: WithToC = FALSE;
396: IgnoreCSS = FALSE;
397: PrintURL = TRUE;
1.61 cvs 398: TtaSetPrintSchema (TEXT(""));
1.3 cvs 399: /* no manual feed */
400: ManualFeed = PP_OFF;
401: TtaSetPrintParameter (PP_ManualFeed, ManualFeed);
402: }
403: }
404:
405:
406: /*----------------------------------------------------------------------
407: PrintAs prints the document using predefined parameters.
408: ----------------------------------------------------------------------*/
409: #ifdef __STDC__
1.45 cvs 410: static void PrintDocument (Document doc, View view)
1.3 cvs 411: #else /* __STDC__ */
1.45 cvs 412: static void PrintDocument (doc, view)
1.38 cvs 413: Document doc;
1.3 cvs 414: #endif /* __STDC__ */
415: {
1.34 cvs 416: AttributeType attrType;
417: Attribute attr;
418: Element el;
1.50 cvs 419: STRING files, dir;
420: CHAR_T viewsToPrint[MAX_PATH];
1.47 cvs 421: ThotBool status, textFile;
1.3 cvs 422:
1.38 cvs 423: textFile = (DocumentTypes[doc] == docText ||
424: DocumentTypes[doc] == docTextRO ||
425: DocumentTypes[doc] == docCSS ||
426: DocumentTypes[doc] == docCSSRO);
427:
428: CheckPrintingDocument (doc);
1.49 cvs 429: ustrcpy (viewsToPrint, TEXT("Formatted_view "));
1.53 cvs 430: if (!textFile && WithToC)
1.49 cvs 431: ustrcat (viewsToPrint, TEXT("Table_of_contents "));
1.53 cvs 432: if (!textFile && NumberLinks)
1.8 cvs 433: /* display numbered links */
1.3 cvs 434: {
1.8 cvs 435: /* associate an attribute InternalLink with all anchors refering
436: a target in the same document. This allows P schemas to work
437: properly */
1.53 cvs 438: SetInternalLinks (DocPrint);
1.3 cvs 439: if (PageSize == PP_A4)
1.61 cvs 440: TtaSetPrintSchema (TEXT("HTMLPLP"));
1.3 cvs 441: else
1.61 cvs 442: TtaSetPrintSchema (TEXT("HTMLPLPUS"));
1.49 cvs 443: ustrcat (viewsToPrint, TEXT("Links_view "));
1.32 cvs 444: }
445: else
446: {
447: if (PageSize == PP_A4)
1.38 cvs 448: {
449: if (textFile)
1.61 cvs 450: TtaSetPrintSchema (TEXT("TextFilePP"));
1.38 cvs 451: else
1.61 cvs 452: TtaSetPrintSchema (TEXT("HTMLPP"));
1.38 cvs 453: }
1.32 cvs 454: else
1.38 cvs 455: {
456: if (textFile)
1.61 cvs 457: TtaSetPrintSchema (TEXT("TextFilePPUS"));
1.38 cvs 458: else
1.61 cvs 459: TtaSetPrintSchema (TEXT("HTMLPPUS"));
1.38 cvs 460: }
1.3 cvs 461: }
1.34 cvs 462: /* post or remove the PrintURL attribute */
1.38 cvs 463: el = TtaGetMainRoot (doc);
464: status = TtaIsDocumentModified (doc);
465: attrType.AttrSSchema = TtaGetDocumentSSchema (doc);
466: if (textFile)
467: attrType.AttrTypeNum = TextFile_ATTR_PrintURL;
468: else
469: attrType.AttrTypeNum = HTML_ATTR_PrintURL;
1.34 cvs 470: attr = TtaGetAttribute (el, attrType);
1.53 cvs 471: if (attr == 0 && PrintURL)
1.34 cvs 472: {
473: attr = TtaNewAttribute (attrType);
1.38 cvs 474: TtaAttachAttribute (el, attr, doc);
1.34 cvs 475: }
1.50 cvs 476:
1.53 cvs 477: if (attr != 0 && !PrintURL)
1.38 cvs 478: TtaRemoveAttribute (el, attr, doc);
1.50 cvs 479: /* get the path dir where css files have to be stored */
1.53 cvs 480: if (textFile || IgnoreCSS)
1.50 cvs 481: files = NULL;
482: else
483: {
484: TtaGetPrintNames (&files, &dir);
485: /* store css files and get the list of names */
486: files = CssToPrint (doc, dir);
487: }
1.53 cvs 488: TtaPrint (DocPrint, viewsToPrint, files);
1.50 cvs 489: TtaFreeMemory (files);
1.34 cvs 490: if (!status)
1.38 cvs 491: TtaSetDocumentUnmodified (doc);
1.1 cvs 492: }
493:
1.45 cvs 494: /*----------------------------------------------------------------------
495: PrintAs prints the document using predefined parameters.
496: ----------------------------------------------------------------------*/
497: #ifdef __STDC__
498: void PrintAs (Document doc, View view)
499: #else /* __STDC__ */
500: void PrintAs (doc, view)
501: Document doc;
502: #endif /* __STDC__ */
503: {
504: #ifdef _WINDOWS
505: SetupAndPrint (doc, view);
506: #else /* _WINDOWS */
507: PrintDocument (doc, view);
508: #endif /* _WINDOWS */
509: }
1.1 cvs 510:
511: /*----------------------------------------------------------------------
512: CallbackImage manage returns of Picture form.
513: ----------------------------------------------------------------------*/
514: #ifdef __STDC__
1.36 cvs 515: void CallbackPrint (int ref, int typedata, STRING data)
1.1 cvs 516: #else /* __STDC__ */
517: void CallbackPrint (ref, typedata, data)
518: int ref;
519: int typedata;
1.36 cvs 520: STRING data;
1.1 cvs 521: #endif /* __STDC__ */
522: {
523: int val;
524:
525: val = (int) data;
1.53 cvs 526: switch (ref - BasePrint)
1.1 cvs 527: {
528: case NumFormPrint:
1.53 cvs 529: TtaDestroyDialogue (BasePrint+NumFormPrint);
1.1 cvs 530: switch (val)
531: {
532: case 1:
533: /* confirms the paper print option */
534: /* the other options are not taken into account without this
535: confirmation */
1.2 cvs 536: TtaSetPrintParameter (PP_Destination, PaperPrint);
537: TtaSetPrintParameter (PP_ManualFeed, ManualFeed);
538: TtaSetPrintParameter (PP_PaperSize, PageSize);
1.53 cvs 539: TtaSetPrintCommand (PPrinter);
1.2 cvs 540: TtaSetPsFile (PSdir);
1.40 cvs 541: /* update the environment variable */
1.53 cvs 542: TtaSetEnvString ("THOTPRINT", PPrinter, TRUE);
1.57 cvs 543: TtaSetEnvInt ("PAPERSIZE", PageSize, TRUE);
1.53 cvs 544: PrintDocument (DocPrint, 1);
1.1 cvs 545: break;
1.2 cvs 546: case 0:
1.40 cvs 547: PaperPrint = (TtaGetPrintParameter (PP_Destination)) ? PP_PRINTER : PP_PS;
1.2 cvs 548: ManualFeed = TtaGetPrintParameter (PP_ManualFeed);
549: PageSize = TtaGetPrintParameter (PP_PaperSize);
1.53 cvs 550: TtaGetPrintCommand (PPrinter);
1.2 cvs 551: TtaGetPsFile (PSdir);
552: break;
1.1 cvs 553: default:
554: break;
555: }
556: break;
557: case NumMenuOptions:
558: switch (val)
559: {
560: case 0:
561: /* Manual feed option */
1.2 cvs 562: if (ManualFeed == PP_ON)
563: ManualFeed = PP_OFF;
564: else
565: ManualFeed = PP_ON;
1.1 cvs 566: break;
567: case 1:
568: /* Toc option */
1.53 cvs 569: WithToC = !WithToC;
1.1 cvs 570: break;
571: case 2:
1.53 cvs 572: /* NumberLinks option */
573: NumberLinks = !NumberLinks;
1.34 cvs 574: case 3:
575: /* URL option */
1.53 cvs 576: PrintURL = !PrintURL;
577: break;
578: case 4:
579: /* CSS option */
580: IgnoreCSS = !IgnoreCSS;
1.1 cvs 581: break;
582: }
583: break;
584: case NumMenuPaperFormat:
585: /* page size submenu */
586: switch (val)
587: {
588: case 0:
1.2 cvs 589: PageSize = PP_A4;
1.1 cvs 590: break;
591: case 1:
1.2 cvs 592: PageSize = PP_US;
1.1 cvs 593: break;
594: }
595: break;
596: case NumMenuSupport:
597: /* paper print/save PostScript submenu */
598: switch (val)
599: {
600: case 0:
1.2 cvs 601: if (PaperPrint == PP_PS)
1.1 cvs 602: {
1.2 cvs 603: PaperPrint = PP_PRINTER;
1.54 cvs 604: # ifndef _WINDOWS
1.53 cvs 605: TtaSetTextForm (BasePrint+NumZonePrinterName, PPrinter);
1.54 cvs 606: # endif /* !_WINDOWS */
1.1 cvs 607: }
608: break;
609: case 1:
1.2 cvs 610: if (PaperPrint == PP_PRINTER)
1.1 cvs 611: {
1.2 cvs 612: PaperPrint = PP_PS;
1.54 cvs 613: # ifndef _WINDOWS
1.53 cvs 614: TtaSetTextForm (BasePrint+NumZonePrinterName, PSdir);
1.54 cvs 615: # endif /* !_WINDOWS */
1.1 cvs 616: }
617: break;
618: }
619: break;
620: case NumZonePrinterName:
621: if (data[0] != '\0')
1.2 cvs 622: if (PaperPrint == PP_PRINTER)
1.40 cvs 623: /* text capture zone for the printer name */
1.53 cvs 624: ustrncpy (PPrinter, data, MAX_PATH);
1.1 cvs 625: else
626: /* text capture zone for the name of the PostScript file */
1.36 cvs 627: ustrncpy (PSdir, data, MAX_PATH);
1.1 cvs 628: break;
629: }
630: }
631:
632: /*----------------------------------------------------------------------
633: ----------------------------------------------------------------------*/
634: #ifdef __STDC__
635: void InitPrint (void)
636: #else /* __STDC__ */
637: void InitPrint ()
638: #endif /* __STDC__ */
639: {
1.62 cvs 640: CHAR_T* ptr;
1.1 cvs 641:
1.53 cvs 642: BasePrint = TtaSetCallback (CallbackPrint, PRINT_MAX_REF);
643: DocPrint = 0;
1.1 cvs 644:
645: /* init printer variables */
646: /* read default printer variable */
1.52 cvs 647: ptr = TtaGetEnvString ("THOTPRINT");
1.1 cvs 648: if (ptr == NULL)
1.62 cvs 649: ustrcpy (PPrinter, TEXT(""));
1.1 cvs 650: else
1.62 cvs 651: ustrcpy (PPrinter, ptr);
1.57 cvs 652: TtaGetEnvInt ("PAPERSIZE", &PageSize);
1.2 cvs 653: PaperPrint = PP_PRINTER;
1.53 cvs 654: PrintURL = TRUE;
1.55 cvs 655: IgnoreCSS = FALSE;
1.2 cvs 656: TtaSetPrintParameter (PP_Destination, PaperPrint);
657: TtaSetPrintParameter (PP_PaperSize, PageSize);
1.53 cvs 658: TtaSetPrintCommand (PPrinter);
1.1 cvs 659: }
660:
661: /*----------------------------------------------------------------------
1.3 cvs 662: SetupAndPrint sets printing parameters and starts the printing process
1.1 cvs 663: ----------------------------------------------------------------------*/
664: #ifdef __STDC__
1.38 cvs 665: void SetupAndPrint (Document doc, View view)
1.1 cvs 666: #else
1.38 cvs 667: void SetupAndPrint (doc, view)
668: Document doc;
1.1 cvs 669: View view;
670: #endif
671: {
1.10 cvs 672: # ifndef _WINDOWS
1.43 cvs 673: CHAR_T bufMenu[MAX_LENGTH];
1.3 cvs 674: int i;
1.27 cvs 675: # endif /* !_WINDOWS */
1.47 cvs 676: ThotBool textFile;
1.38 cvs 677:
678: textFile = (DocumentTypes[doc] == docText ||
679: DocumentTypes[doc] == docTextRO ||
680: DocumentTypes[doc] == docCSS ||
681: DocumentTypes[doc] == docCSSRO);
1.1 cvs 682:
683: /* Print form */
1.38 cvs 684: CheckPrintingDocument (doc);
1.40 cvs 685:
686: /* read the values that the user may have changed thru
687: the configuration menu */
1.53 cvs 688: TtaGetPrintCommand (PPrinter);
1.40 cvs 689: PageSize = TtaGetPrintParameter (PP_PaperSize);
1.27 cvs 690:
691: # ifndef _WINDOWS
1.68 ! cvs 692: TtaNewSheet (BasePrint + NumFormPrint, TtaGetViewFrame (doc, view),
1.1 cvs 693: TtaGetMessage (LIB, TMSG_LIB_PRINT),
1.3 cvs 694: 1, TtaGetMessage (AMAYA, AM_BUTTON_PRINT), FALSE, 2, 'L', D_CANCEL);
1.1 cvs 695: i = 0;
696: sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (LIB, TMSG_MANUAL_FEED));
1.36 cvs 697: i += ustrlen (&bufMenu[i]) + 1;
1.1 cvs 698: sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_PRINT_TOC));
1.36 cvs 699: i += ustrlen (&bufMenu[i]) + 1;
1.1 cvs 700: sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_NUMBERED_LINKS));
1.36 cvs 701: i += ustrlen (&bufMenu[i]) + 1;
1.34 cvs 702: sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_PRINT_URL));
1.53 cvs 703: i += ustrlen (&bufMenu[i]) + 1;
704: sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_WITH_CSS));
1.68 ! cvs 705: TtaNewToggleMenu (BasePrint + NumMenuOptions, BasePrint + NumFormPrint,
1.53 cvs 706: TtaGetMessage (LIB, TMSG_OPTIONS), 5, bufMenu, NULL, FALSE);
1.2 cvs 707: if (ManualFeed == PP_ON)
1.68 ! cvs 708: TtaSetToggleMenu (BasePrint + NumMenuOptions, 0, TRUE);
1.55 cvs 709: else
1.68 ! cvs 710: TtaSetToggleMenu (BasePrint + NumMenuOptions, 0, FALSE);
! 711: TtaSetToggleMenu (BasePrint + NumMenuOptions, 1, WithToC);
! 712: TtaSetToggleMenu (BasePrint + NumMenuOptions, 2, NumberLinks);
! 713: TtaSetToggleMenu (BasePrint + NumMenuOptions, 3, PrintURL);
! 714: TtaSetToggleMenu (BasePrint + NumMenuOptions, 4, IgnoreCSS);
1.1 cvs 715:
716: /* Paper format submenu */
717: i = 0;
718: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_A4));
1.36 cvs 719: i += ustrlen (&bufMenu[i]) + 1;
1.1 cvs 720: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_US));
1.68 ! cvs 721: TtaNewSubmenu (BasePrint + NumMenuPaperFormat, BasePrint + NumFormPrint, 0,
1.1 cvs 722: TtaGetMessage (LIB, TMSG_PAPER_SIZE), 2, bufMenu, NULL, FALSE);
1.2 cvs 723: if (PageSize == PP_US)
1.68 ! cvs 724: TtaSetMenuForm (BasePrint + NumMenuPaperFormat, 1);
1.1 cvs 725: else
1.68 ! cvs 726: TtaSetMenuForm (BasePrint + NumMenuPaperFormat, 0);
1.1 cvs 727:
728: /* Print to paper/ Print to file submenu */
729: i = 0;
730: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_PRINTER));
1.36 cvs 731: i += ustrlen (&bufMenu[i]) + 1;
1.1 cvs 732: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_PS_FILE));
1.68 ! cvs 733: TtaNewSubmenu (BasePrint + NumMenuSupport, BasePrint + NumFormPrint, 0,
1.1 cvs 734: TtaGetMessage (LIB, TMSG_OUTPUT), 2, bufMenu, NULL, TRUE);
735: /* text capture zone for the printer name */
1.68 ! cvs 736: TtaNewTextForm (BasePrint + NumZonePrinterName, BasePrint + NumFormPrint, NULL, 30, 1, FALSE);
1.1 cvs 737:
738: /* initialization of the PaperPrint selector */
1.2 cvs 739: if (PaperPrint == PP_PRINTER)
1.1 cvs 740: {
1.68 ! cvs 741: TtaSetMenuForm (BasePrint + NumMenuSupport, 0);
! 742: TtaSetTextForm (BasePrint + NumZonePrinterName, PPrinter);
1.1 cvs 743: }
744: else
745: {
1.68 ! cvs 746: TtaSetMenuForm (BasePrint + NumMenuSupport, 1);
! 747: TtaSetTextForm (BasePrint + NumZonePrinterName, PSdir);
1.1 cvs 748: }
749:
750: /* activates the Print form */
1.53 cvs 751: TtaShowDialogue (BasePrint+NumFormPrint, FALSE);
1.56 cvs 752: if (textFile) {
753: /* invalid dialogue entries */
1.68 ! cvs 754: TtaRedrawMenuEntry (BasePrint + NumMenuOptions, 1, NULL, -1, FALSE);
! 755: TtaRedrawMenuEntry (BasePrint + NumMenuOptions, 2, NULL, -1, FALSE);
1.56 cvs 756: }
1.10 cvs 757: # else /* _WINDOWS */
1.66 cvs 758: CreatePrintDlgWindow (TtaGetViewFrame (doc, view), PSdir, BasePrint, NumMenuSupport, NumMenuOptions, NumMenuPaperFormat, NumZonePrinterName, NumFormPrint);
1.10 cvs 759: # endif /* _WINDOWS */
1.1 cvs 760: }
761:
762: /*----------------------------------------------------------------------
763: SectionNumbering
764: Execute the "Section Numbering" command
765: ----------------------------------------------------------------------*/
766: #ifdef __STDC__
1.38 cvs 767: void SectionNumbering (Document doc, View view)
1.1 cvs 768: #else
1.38 cvs 769: void SectionNumbering (doc, view)
770: Document doc;
1.1 cvs 771: View view;
772: #endif
773: {
1.38 cvs 774: ChangeAttrOnRoot (doc, HTML_ATTR_SectionNumbering);
1.1 cvs 775: }
776:
777: /*----------------------------------------------------------------------
778: UpdateURLsInSubtree
779: Update NAMEs and URLs in subtree of el element, to take into account
780: the move from one document to another.
781: If a NAME attribute already exists in the new document, it is changed
782: to avoid duplicate names.
783: Transform the HREF and SRC attribute to make them independent from their
784: former base.
785: ----------------------------------------------------------------------*/
786: #ifdef __STDC__
787: static void UpdateURLsInSubtree (NotifyElement *event, Element el)
788: #else
789: static void UpdateURLsInSubtree (event, el)
790: NotifyElement *event;
791: Element el;
792: #endif
793: {
794: Element nextEl;
795:
796: nextEl = TtaGetFirstChild (el);
797: while (nextEl != NULL)
798: {
1.58 cvs 799: event->element = nextEl;
800: ElementPasted (event);
1.1 cvs 801: TtaNextSibling (&nextEl);
802: }
803: }
804:
805:
806: /*----------------------------------------------------------------------
807: MoveDocumentBody
1.58 cvs 808: Copy the elements contained in the BODY of the document sourceDoc at the
809: position of the element el in the document destDoc.
810: Delete the element containing el and all its empty ancestors.
1.1 cvs 811: If deleteTree is TRUE, copied elements are deleted from the source
812: document.
1.58 cvs 813: Return the root element that delimits the new inserted part (a div).
1.1 cvs 814: ----------------------------------------------------------------------*/
815: #ifdef __STDC__
1.58 cvs 816: static Element MoveDocumentBody (Element el, Document destDoc, Document sourceDoc, STRING target, STRING url, ThotBool deleteTree)
1.1 cvs 817: #else
1.58 cvs 818: static Element MoveDocumentBody (el, destDoc, sourceDoc, target, url, deleteTree)
819: Element el;
1.12 cvs 820: Document destDoc;
821: Document sourceDoc;
1.36 cvs 822: STRING target;
823: STRING url;
1.47 cvs 824: ThotBool deleteTree;
1.1 cvs 825: #endif
826: {
1.58 cvs 827: Element root, ancestor, elem, firstInserted, div;
1.12 cvs 828: Element lastInserted, srce, copy, old, parent, sibling;
829: ElementType elType;
830: NotifyElement event;
831: int checkingMode;
1.47 cvs 832: ThotBool isID;
1.1 cvs 833:
1.67 cvs 834: div = NULL;
1.13 cvs 835: if (target != NULL)
836: {
837: /* locate the target element within the source document */
838: root = SearchNAMEattribute (sourceDoc, target, NULL);
839: elType = TtaGetElementType (root);
1.58 cvs 840: isID = (elType.ElTypeNum != HTML_EL_Anchor && elType.ElTypeNum != HTML_EL_MAP);
1.13 cvs 841: }
842: else
843: {
844: isID = FALSE;
845: /* get the BODY element of source document */
846: root = TtaGetMainRoot (sourceDoc);
847: elType = TtaGetElementType (root);
848: elType.ElTypeNum = HTML_EL_BODY;
849: root = TtaSearchTypedElement (elType, SearchForward, root);
850: }
851:
852: if (root != NULL)
1.12 cvs 853: {
854: /* don't check the abstract tree against the structure schema */
855: checkingMode = TtaGetStructureChecking (destDoc);
856: TtaSetStructureChecking (0, destDoc);
1.58 cvs 857: /* get elem, the ancestor of el which is a child of a DIV or BODY
1.12 cvs 858: element in the destination document. The copied elements will be
859: inserted just before this element. */
1.58 cvs 860: elem = el;
1.12 cvs 861: do
1.1 cvs 862: {
1.12 cvs 863: ancestor = TtaGetParent (elem);
864: if (ancestor != NULL)
865: {
866: elType = TtaGetElementType (ancestor);
867: if (elType.ElTypeNum == HTML_EL_BODY ||
868: elType.ElTypeNum == HTML_EL_Division)
869: ancestor = NULL;
870: else
871: elem = ancestor;
872: }
1.1 cvs 873: }
1.12 cvs 874: while (ancestor != NULL);
875: parent = TtaGetParent (elem);
1.14 cvs 876:
877: /* insert a DIV element */
1.15 cvs 878: elType.ElTypeNum = HTML_EL_Division;
1.16 cvs 879: lastInserted = TtaNewElement (destDoc, elType);
880: TtaInsertSibling (lastInserted, elem, TRUE, destDoc);
1.58 cvs 881: /* this delimits the new inserted part of the document */
1.16 cvs 882: RegisterSubDoc (lastInserted, url);
1.42 cvs 883: CreateTargetAnchor (destDoc, lastInserted, FALSE);
1.58 cvs 884: div = lastInserted;
1.14 cvs 885:
1.12 cvs 886: /* do copy */
1.16 cvs 887: firstInserted = NULL;
1.17 cvs 888: if (isID)
889: srce = root;
890: else
891: srce = TtaGetFirstChild (root);
1.12 cvs 892: while (srce != NULL)
1.1 cvs 893: {
1.12 cvs 894: copy = TtaCopyTree (srce, sourceDoc, destDoc, parent);
895: if (copy != NULL)
896: {
1.16 cvs 897: if (firstInserted == NULL)
1.12 cvs 898: /* this is the first copied element. Insert it before elem */
899: {
1.16 cvs 900: TtaInsertFirstChild (©, lastInserted, destDoc);
1.12 cvs 901: firstInserted = copy;
902: }
903: else
904: /* insert the new copied element after the element previously
905: copied */
906: TtaInsertSibling (copy, lastInserted, FALSE, destDoc);
907: lastInserted = copy;
908: /* update the NAMEs and URLs in the copied element */
909: event.document = destDoc;
910: event.position = sourceDoc;
911: UpdateURLsInSubtree(&event, copy);
912: }
913: /* get the next element in the source document */
914: old = srce;
915: TtaNextSibling (&srce);
916: if (deleteTree)
917: TtaDeleteTree (old, sourceDoc);
1.13 cvs 918: /* Stop here if the target points to a specific element with an ID */
919: if (isID)
920: srce = NULL;
1.1 cvs 921: }
1.12 cvs 922:
923: /* delete the element(s) containing the link to the copied document */
1.58 cvs 924: /* delete the parent element of el and all empty ancestors */
925: elem = TtaGetParent (el);
1.12 cvs 926: do
1.1 cvs 927: {
1.12 cvs 928: sibling = elem;
929: TtaNextSibling (&sibling);
930: if (sibling == NULL)
931: {
932: sibling = elem;
933: TtaPreviousSibling (&sibling);
934: if (sibling == NULL)
935: elem = TtaGetParent (elem);
936: }
1.1 cvs 937: }
1.12 cvs 938: while (sibling == NULL);
939: TtaDeleteTree (elem, destDoc);
940: /* restore previous chacking mode */
1.47 cvs 941: TtaSetStructureChecking ((ThotBool)checkingMode, destDoc);
1.12 cvs 942: }
1.58 cvs 943: /* return the address of the new division */
944: return (div);
1.1 cvs 945: }
946:
1.29 cvs 947:
1.58 cvs 948: /*----------------------------------------------------------------------
949: CloseMakeBook
950: ----------------------------------------------------------------------*/
1.29 cvs 951: #ifdef __STDC__
1.58 cvs 952: static void CloseMakeBook (Document document)
953: #else
954: static void CloseMakeBook (document)
955: Document document;
956: #endif /* __STDC__ */
957:
958: {
959: ResetStop (document);
960: /* update internal links */
961: SetInternalLinks (document);
962: /* if the document changed force the browser mode */
963: if (SubDocs)
964: SetBrowserEditor (document);
965: /* remove registered sub-documents */
966: FreeSubDocTable ();
967: DocBook = 0;
968: TtaSetStatus (document, 1, TtaGetMessage (AMAYA, AM_DOCUMENT_LOADED), NULL);
969: }
970:
971:
972: /*----------------------------------------------------------------------
973: GetIncludedDocuments_callback finishes the GetIncludedDocuments procedure
974: ----------------------------------------------------------------------*/
975: #ifdef __STDC__
976: void GetIncludedDocuments_callback (int newdoc, int status,
977: STRING urlName,
978: STRING outputfile,
1.63 cvs 979: AHTHeaders *http_headers,
1.58 cvs 980: void * context)
1.29 cvs 981: #else /* __STDC__ */
1.58 cvs 982: void GetIncludedDocuments_callback (newdoc, status, urlName,
1.63 cvs 983: outputfile, http_headers,
1.58 cvs 984: context)
985: int newdoc;
986: int status;
1.36 cvs 987: STRING urlName;
988: STRING outputfile;
1.63 cvs 989: AHTHeaders *http_headers;
1.58 cvs 990: void *context;
1.29 cvs 991: #endif /* __STDC__ */
992: {
1.58 cvs 993: Element link, div;
994: IncludeCtxt *ctx, *prev;
1.57 cvs 995: STRING url, ptr;
1.58 cvs 996: ThotBool found = FALSE;
1.29 cvs 997:
998: /* restore GetIncludedDocuments's context */
1.58 cvs 999: ctx = (IncludeCtxt *) context;
1.29 cvs 1000: if (!ctx)
1001: return;
1002:
1.58 cvs 1003: div = NULL;
1.29 cvs 1004: link = ctx->link;
1.58 cvs 1005: ptr = ctx->name;
1.29 cvs 1006: url = ctx->url;
1.58 cvs 1007: if (url)
1.29 cvs 1008: {
1.58 cvs 1009: if (newdoc && newdoc != DocBook)
1.29 cvs 1010: {
1.58 cvs 1011: /* it's not the DocBook itself */
1012: /* copy the target document at the position of the link */
1013: TtaSetDocumentModified (DocBook);
1014: div = MoveDocumentBody (link, DocBook, newdoc, ptr, url,
1015: (ThotBool)(newdoc == IncludedDocument));
1.29 cvs 1016: }
1.58 cvs 1017: /* global variables */
1018: FreeDocumentResource (IncludedDocument);
1019: TtaCloseDocument (IncludedDocument);
1020: IncludedDocument = 0;
1.29 cvs 1021: }
1.58 cvs 1022:
1023: if (div != NULL)
1.29 cvs 1024: {
1.58 cvs 1025: /* new starting point for the search */
1026: ctx->link = div;
1027: found = GetIncludedDocuments (div, div, DocBook, ctx);
1.29 cvs 1028: }
1.58 cvs 1029: while (!found && ctx)
1030: {
1031: /* this sub-document has no more inclusion, examine the caller */
1032: div = ctx->div;
1033: link = ctx->link;
1034: prev = ctx->ctxt;
1035: TtaFreeMemory (url);
1.64 cvs 1036: url = NULL;
1.58 cvs 1037: TtaFreeMemory (ctx);
1038: ctx = prev;
1039: found = GetIncludedDocuments (div, link, DocBook, ctx);
1040: }
1041: if (!found)
1042: /* all links are now managed */
1043: CloseMakeBook (DocBook);
1.29 cvs 1044: }
1045:
1.1 cvs 1046: /*----------------------------------------------------------------------
1047: GetIncludedDocuments
1.58 cvs 1048: Look forward within the element el, starting from element link, for a
1049: link (A) with attribute rel="chapter" or rel="subdocument" and replace
1050: that link by the contents of the target document.
1051: Return TRUE if one inclusion is launched.
1.1 cvs 1052: ----------------------------------------------------------------------*/
1053: #ifdef __STDC__
1.58 cvs 1054: static ThotBool GetIncludedDocuments (Element el, Element link, Document document, IncludeCtxt *prev)
1.1 cvs 1055: #else
1.58 cvs 1056: static ThotBool GetIncludedDocuments (el, link, document, prev)
1057: Element el;
1058: Element link;
1059: Document document;
1060: IncludeCtxt *prev;
1.1 cvs 1061: #endif
1062: {
1.58 cvs 1063: ElementType elType;
1064: Attribute attr;
1065: AttributeType attrType;
1066: Document newdoc;
1067: IncludeCtxt *ctx = NULL;
1068: STRING text, ptr, url = NULL;
1.29 cvs 1069: int length;
1.58 cvs 1070: ThotBool found = FALSE;
1.29 cvs 1071:
1.58 cvs 1072: /* look for anchors with the attribute rel within the element el */
1073: attr = NULL;
1.61 cvs 1074: attrType.AttrSSchema = TtaGetSSchema (TEXT("HTML"), document);
1.58 cvs 1075: elType.ElSSchema = attrType.AttrSSchema;
1076: elType.ElTypeNum = HTML_EL_Anchor;
1.29 cvs 1077:
1.58 cvs 1078: /* Get only one included file each time */
1079: while (link && attr == NULL)
1.29 cvs 1080: {
1.58 cvs 1081: link = TtaSearchTypedElementInTree (elType, SearchForward, el, link);
1082: if (link)
1.29 cvs 1083: {
1.58 cvs 1084: attrType.AttrTypeNum = HTML_ATTR_REL;
1085: attr = TtaGetAttribute (link, attrType);
1086: }
1087: if (attr)
1088: {
1089: length = TtaGetTextAttributeLength (attr);
1.49 cvs 1090: text = TtaAllocString (length + 1);
1.58 cvs 1091: TtaGiveTextAttributeValue (attr, text, &length);
1092: /* Valid rel values are rel="chapter" or rel="subdocument" */
1093: if (ustrcasecmp (text, TEXT("chapter")) &&
1094: ustrcasecmp (text, TEXT("subdocument")))
1095: attr = NULL;
1.29 cvs 1096: TtaFreeMemory (text);
1097: }
1.58 cvs 1098:
1099: if (attr)
1100: {
1101: /* a link with attribute rel="Chapter" has been found */
1102: attrType.AttrTypeNum = HTML_ATTR_HREF_;
1103: attr = TtaGetAttribute (link, attrType);
1104: }
1105: if (attr)
1106: /* this link has an attribute HREF */
1107: {
1108: length = TtaGetTextAttributeLength (attr);
1109: text = TtaAllocString (length + 1);
1110: TtaGiveTextAttributeValue (attr, text, &length);
1111: ptr = ustrrchr (text, '#');
1112: url = text;
1113: if (ptr != NULL)
1114: {
1115: if (ptr == text)
1116: url = NULL;
1117: /* link to a particular position within a remote document */
1118: ptr[0] = EOS;
1119: ptr = &ptr[1];
1120: }
1121:
1122: if (url != NULL)
1123: /* this link designates an external document */
1124: {
1125: /* create a new document and loads the target document */
1.62 cvs 1126: IncludedDocument = TtaNewDocument (TEXT("HTML"), TEXT("tmp"));
1.58 cvs 1127: if (IncludedDocument != 0)
1128: {
1129: TtaSetStatus (document, 1, TtaGetMessage (AMAYA, AM_FETCHING), url);
1130: ctx = TtaGetMemory (sizeof (IncludeCtxt));
1131: ctx->div = el;
1132: ctx->link = link;
1133: ctx->url = url; /* the URL of the document */
1134: ctx->name = ptr;
1135: ctx->ctxt = prev; /* previous context */
1136: /* Get the reference of the calling document */
1137: SetStopButton (document);
1138: newdoc = GetHTMLDocument (url, NULL, IncludedDocument,
1139: document, CE_MAKEBOOK, FALSE,
1140: (void *) GetIncludedDocuments_callback,
1141: (void *) ctx);
1142: found = TRUE;
1143: }
1144: }
1145: else
1146: TtaFreeMemory (text);
1147: }
1.29 cvs 1148: }
1.58 cvs 1149: return (found);
1.1 cvs 1150: }
1151:
1152:
1153: /*----------------------------------------------------------------------
1154: MakeBook
1155: Replace all links in a document which have an attribute REL="chapter"
1.5 cvs 1156: or REL="subdocument" by the corresponding target document.
1.1 cvs 1157: ----------------------------------------------------------------------*/
1158: #ifdef __STDC__
1159: void MakeBook (Document document, View view)
1160: #else
1161: void MakeBook (document, view)
1162: Document document;
1163: View view;
1164: #endif
1165: {
1.58 cvs 1166: Element root, body;
1167: ElementType elType;
1.1 cvs 1168:
1.58 cvs 1169: /* stops all current transfers on this document */
1170: StopTransfer (document, 1);
1171: /* simulate a transfert in the main document */
1172: DocBook = document;
1173: IncludedDocument = 0;
1174: root = TtaGetMainRoot (document);
1175: elType = TtaGetElementType (root);
1176: elType.ElTypeNum = HTML_EL_BODY;
1177: body = TtaSearchTypedElement (elType, SearchForward, root);
1.29 cvs 1178:
1.58 cvs 1179: if (body)
1180: GetIncludedDocuments (body, body, document, NULL);
1.1 cvs 1181: }
Webmaster