Annotation of Amaya/amaya/HTMLbook.c, revision 1.4
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: */
7:
8: /*
9: * Initialization functions and button functions of Amaya application.
10: *
11: * Authors: V. Quint, I. Vatton
12: */
13:
14:
15: /* Included headerfiles */
16: #define THOT_EXPORT
17: #include "amaya.h"
18: #include "print.h"
19:
20: #define NumFormPrint 1
21: #define NumMenuOptions 2
22: #define NumMenuPaperFormat 3
23: #define NumMenuSupport 4
24: #define NumZonePrinterName 5
25: #define PRINT_MAX_REF 6
26:
27: /* Thot printer variables */
1.2 cvs 28: static int PaperPrint;
29: static int ManualFeed;
30: static int PageSize;
31: static char PSdir[MAX_PATH];
32: static char pPrinter[MAX_PATH];
1.1 cvs 33: static Document docPrint;
34: static boolean numberLinks;
35: static boolean withToC;
36: static int basePrint;
37:
38: #include "init_f.h"
39: #include "HTMLactions_f.h"
40: #include "HTMLbook_f.h"
41: #include "HTMLedit_f.h"
42:
43:
44: /*----------------------------------------------------------------------
45: SetInternalLinks
46: Associate a InternalLink attribute with all anchor (A) elements of the
47: document which designate another anchor in the same document.
48: InternalLink is a Thot reference attribute that links a source and a
49: target anchor and that allows P schemas to display and print cross-references
50: ----------------------------------------------------------------------*/
51: #ifdef __STDC__
1.4 ! cvs 52: void SetInternalLinks (Document document)
1.1 cvs 53: #else
1.4 ! cvs 54: void SetInternalLinks (document)
1.1 cvs 55: Document document;
56: #endif
57: {
58: Element root, el;
59: Element link, target;
60: ElementType elType;
61: Attribute HrefAttr, IntLinkAttr;
62: AttributeType attrType;
63: int length;
1.3 cvs 64: int status;
65: char *text;
1.1 cvs 66:
1.3 cvs 67: /* Memorize the current status of the document */
68: status = TtaIsDocumentModified (document);
1.1 cvs 69: root = TtaGetMainRoot (document);
70: elType = TtaGetElementType (root);
71: elType.ElTypeNum = HTML_EL_BODY;
72: el = TtaSearchTypedElement (elType, SearchForward, root);
73:
74: elType.ElTypeNum = HTML_EL_Anchor;
75: attrType.AttrSSchema = elType.ElSSchema;
76: /* looks for all anchors in the document */
77: link = el;
78: while (link != NULL)
79: {
80: link = TtaSearchTypedElement (elType, SearchForward, link);
81: if (link != NULL)
82: /* an anchor has been found */
83: {
84: attrType.AttrTypeNum = HTML_ATTR_HREF_;
85: HrefAttr = TtaGetAttribute (link, attrType);
86: if (HrefAttr != NULL)
87: /* this anchor has an HREF attribute */
88: {
89: length = TtaGetTextAttributeLength (HrefAttr);
90: text = TtaGetMemory (length + 1);
91: TtaGiveTextAttributeValue (HrefAttr, text, &length);
92: if (text[0] == '#')
93: /* it'a an internal link. Attach an attribute InternalLink to */
94: /* the link, if this attribute does not exist yet */
95: {
96: attrType.AttrTypeNum = HTML_ATTR_InternalLink;
97: IntLinkAttr = TtaGetAttribute (link, attrType);
98: if (IntLinkAttr == NULL)
99: {
100: IntLinkAttr = TtaNewAttribute (attrType);
101: TtaAttachAttribute (link, IntLinkAttr, document);
102: }
103: /* looks for the target element */
104: target = SearchNAMEattribute (document, &text[1], NULL);
105: if (target != NULL)
106: /* set the Thot link */
107: TtaSetAttributeReference (IntLinkAttr, link, document,
108: target, document);
109: }
110: TtaFreeMemory (text);
111: }
112: }
113: }
1.3 cvs 114: /* Reset document status */
115: if (!status)
116: TtaSetDocumentUnmodified (document);
117: }
118:
119: /*----------------------------------------------------------------------
120: CheckPrintingDocument reinitialize printing parameters as soon as
121: the printing document changes.
122: ----------------------------------------------------------------------*/
123: #ifdef __STDC__
124: static void CheckPrintingDocument (Document document)
125: #else
126: static void CheckPrintingDocument (document)
127: Document document;
128: #endif
129: {
130: char docName[MAX_LENGTH];
131: char *ptr, suffix[MAX_LENGTH];
132: int lg;
133:
134: if (docPrint != document)
135: {
136: /* initialize print parameters */
137: docPrint = document;
138:
139: /* define the new default PS file */
140: ptr = TtaGetEnvString ("TMPDIR");
141: if (ptr != NULL && TtaCheckDirectory (ptr))
142: {
143: strcpy(PSdir,ptr);
144: lg = strlen(PSdir);
145: if (PSdir[lg - 1] == DIR_SEP)
146: PSdir[--lg] = '\0';
147: }
148: else
149: {
150: #ifdef _WINDOWS
151: strcpy (PSdir,"C:\\TEMP");
152: #else /* !_WINDOWS */
153: strcpy (PSdir,"/tmp");
154: #endif /* !_WINDOWS */
155: lg = strlen (PSdir);
156: }
157: strcpy (docName, TtaGetDocumentName (document));
158: ExtractSuffix (docName, suffix);
159: sprintf (&PSdir[lg], "/%s.ps", docName);
160: TtaSetPsFile (PSdir);
161: /* define the new default PrintSchema */
162: numberLinks = FALSE;
163: withToC = FALSE;
164: TtaSetPrintSchema ("");
165: /* no manual feed */
166: ManualFeed = PP_OFF;
167: TtaSetPrintParameter (PP_ManualFeed, ManualFeed);
168: }
169: }
170:
171:
172: /*----------------------------------------------------------------------
173: PrintAs prints the document using predefined parameters.
174: ----------------------------------------------------------------------*/
175: #ifdef __STDC__
176: void PrintAs (Document document, View view)
177: #else /* __STDC__ */
178: void PrintAs (document, view)
179: Document document;
180: #endif /* __STDC__ */
181: {
182: PathBuffer viewsToPrint;
183:
184: CheckPrintingDocument (document);
185: strcpy (viewsToPrint, "Formatted_view ");
186: if (withToC)
187: strcat (viewsToPrint, "Table_of_contents ");
188: if (numberLinks)
189: {
190: /* display numbered links */
191: if (PageSize == PP_A4)
192: TtaSetPrintSchema ("HTMLPLP");
193: else
194: TtaSetPrintSchema ("HTMLPLPUS");
195: strcat (viewsToPrint, "Links_view ");
196: }
197: TtaPrint (docPrint, viewsToPrint);
1.1 cvs 198: }
199:
200:
201: /*----------------------------------------------------------------------
202: CallbackImage manage returns of Picture form.
203: ----------------------------------------------------------------------*/
204: #ifdef __STDC__
205: void CallbackPrint (int ref, int typedata, char *data)
206: #else /* __STDC__ */
207: void CallbackPrint (ref, typedata, data)
208: int ref;
209: int typedata;
210: char *data;
211: #endif /* __STDC__ */
212: {
213: int val;
214:
215: val = (int) data;
216: switch (ref - basePrint)
217: {
218: case NumFormPrint:
219: TtaDestroyDialogue (basePrint+NumFormPrint);
220: switch (val)
221: {
222: case 1:
223: /* confirms the paper print option */
224: /* the other options are not taken into account without this
225: confirmation */
1.2 cvs 226: TtaSetPrintParameter (PP_Destination, PaperPrint);
227: TtaSetPrintParameter (PP_ManualFeed, ManualFeed);
228: TtaSetPrintParameter (PP_PaperSize, PageSize);
229: TtaSetPrintCommand (pPrinter);
230: TtaSetPsFile (PSdir);
1.3 cvs 231: PrintAs (docPrint, 1);
1.1 cvs 232: break;
1.2 cvs 233: case 0:
234: PaperPrint = TtaGetPrintParameter (PP_Destination);
235: ManualFeed = TtaGetPrintParameter (PP_ManualFeed);
236: PageSize = TtaGetPrintParameter (PP_PaperSize);
237: TtaGetPrintCommand (pPrinter);
238: TtaGetPsFile (PSdir);
239: break;
1.1 cvs 240: default:
241: break;
242: }
243: break;
244: case NumMenuOptions:
245: switch (val)
246: {
247: case 0:
248: /* Manual feed option */
1.2 cvs 249: if (ManualFeed == PP_ON)
250: ManualFeed = PP_OFF;
251: else
252: ManualFeed = PP_ON;
1.1 cvs 253: break;
254: case 1:
255: /* Toc option */
256: withToC = !withToC;
257: break;
258: case 2:
1.3 cvs 259: /* numberLinks option */
260: if (!numberLinks)
261: SetInternalLinks (docPrint);
1.1 cvs 262: numberLinks = !numberLinks;
263: break;
264: }
265: break;
266: case NumMenuPaperFormat:
267: /* page size submenu */
268: switch (val)
269: {
270: case 0:
1.2 cvs 271: PageSize = PP_A4;
1.1 cvs 272: break;
273: case 1:
1.2 cvs 274: PageSize = PP_US;
1.1 cvs 275: break;
276: }
277: break;
278: case NumMenuSupport:
279: /* paper print/save PostScript submenu */
280: switch (val)
281: {
282: case 0:
1.2 cvs 283: if (PaperPrint == PP_PS)
1.1 cvs 284: {
1.2 cvs 285: PaperPrint = PP_PRINTER;
1.1 cvs 286: TtaSetTextForm (basePrint+NumZonePrinterName, pPrinter);
287: }
288: break;
289: case 1:
1.2 cvs 290: if (PaperPrint == PP_PRINTER)
1.1 cvs 291: {
1.2 cvs 292: PaperPrint = PP_PS;
1.1 cvs 293: TtaSetTextForm (basePrint+NumZonePrinterName, PSdir);
294: }
295: break;
296: }
297: break;
298: case NumZonePrinterName:
299: if (data[0] != '\0')
1.2 cvs 300: if (PaperPrint == PP_PRINTER)
1.1 cvs 301: /* text capture zone for the printer name */
302: strncpy (pPrinter, data, MAX_PATH);
303: else
304: /* text capture zone for the name of the PostScript file */
305: strncpy (PSdir, data, MAX_PATH);
306: break;
307: }
308: }
309:
310: /*----------------------------------------------------------------------
311: ----------------------------------------------------------------------*/
312: #ifdef __STDC__
313: void InitPrint (void)
314: #else /* __STDC__ */
315: void InitPrint ()
316: #endif /* __STDC__ */
317: {
318: char *ptr;
319:
320: basePrint = TtaSetCallback (CallbackPrint, PRINT_MAX_REF);
321: docPrint = 0;
322:
323: /* init printer variables */
324: /* read default printer variable */
325: ptr = TtaGetEnvString ("THOTPRINT");
326: if (ptr == NULL)
327: strcpy (pPrinter, "");
328: else
329: strcpy (pPrinter, ptr);
330:
1.2 cvs 331: PageSize = PP_A4;
332: PaperPrint = PP_PRINTER;
333: TtaSetPrintParameter (PP_Destination, PaperPrint);
334: TtaSetPrintParameter (PP_PaperSize, PageSize);
335: TtaSetPrintCommand (pPrinter);
1.1 cvs 336: }
337:
338: /*----------------------------------------------------------------------
1.3 cvs 339: SetupAndPrint sets printing parameters and starts the printing process
1.1 cvs 340: ----------------------------------------------------------------------*/
341: #ifdef __STDC__
342: void SetupAndPrint (Document document, View view)
343: #else
344: void SetupAndPrint (document, view)
345: Document document;
346: View view;
347: #endif
348: {
1.2 cvs 349: char bufMenu[MAX_LENGTH];
1.3 cvs 350: int i;
1.1 cvs 351:
352: /* Print form */
1.3 cvs 353: CheckPrintingDocument (document);
1.1 cvs 354: TtaNewSheet (basePrint+NumFormPrint, TtaGetViewFrame (document, view),
355: TtaGetMessage (LIB, TMSG_LIB_PRINT),
1.3 cvs 356: 1, TtaGetMessage (AMAYA, AM_BUTTON_PRINT), FALSE, 2, 'L', D_CANCEL);
1.1 cvs 357: i = 0;
358: sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (LIB, TMSG_MANUAL_FEED));
359: i += strlen (&bufMenu[i]) + 1;
360: sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_PRINT_TOC));
361: i += strlen (&bufMenu[i]) + 1;
362: sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_NUMBERED_LINKS));
363: TtaNewToggleMenu (basePrint+NumMenuOptions, basePrint+NumFormPrint,
364: TtaGetMessage (LIB, TMSG_OPTIONS), 3, bufMenu, NULL, FALSE);
1.2 cvs 365: if (ManualFeed == PP_ON)
1.1 cvs 366: TtaSetToggleMenu (basePrint+NumMenuOptions, 0, TRUE);
367: if (withToC)
368: TtaSetToggleMenu (basePrint+NumMenuOptions, 1, TRUE);
369: if (numberLinks)
370: TtaSetToggleMenu (basePrint+NumMenuOptions, 2, TRUE);
371:
372: /* Paper format submenu */
373: i = 0;
374: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_A4));
375: i += strlen (&bufMenu[i]) + 1;
376: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_US));
377: TtaNewSubmenu (basePrint+NumMenuPaperFormat, basePrint+NumFormPrint, 0,
378: TtaGetMessage (LIB, TMSG_PAPER_SIZE), 2, bufMenu, NULL, FALSE);
1.2 cvs 379: if (PageSize == PP_US)
1.1 cvs 380: TtaSetMenuForm (basePrint+NumMenuPaperFormat, 1);
381: else
382: TtaSetMenuForm (basePrint+NumMenuPaperFormat, 0);
383:
384: /* Print to paper/ Print to file submenu */
385: i = 0;
386: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_PRINTER));
387: i += strlen (&bufMenu[i]) + 1;
388: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_PS_FILE));
389: TtaNewSubmenu (basePrint+NumMenuSupport, basePrint+NumFormPrint, 0,
390: TtaGetMessage (LIB, TMSG_OUTPUT), 2, bufMenu, NULL, TRUE);
391: /* text capture zone for the printer name */
392: TtaNewTextForm (basePrint+NumZonePrinterName, basePrint+NumFormPrint, NULL, 30, 1, FALSE);
393:
394: /* initialization of the PaperPrint selector */
1.2 cvs 395: if (PaperPrint == PP_PRINTER)
1.1 cvs 396: {
397: TtaSetMenuForm (basePrint+NumMenuSupport, 0);
398: TtaSetTextForm (basePrint+NumZonePrinterName, pPrinter);
399: }
400: else
401: {
402: TtaSetMenuForm (basePrint+NumMenuSupport, 1);
403: TtaSetTextForm (basePrint+NumZonePrinterName, PSdir);
404: }
405:
406: /* activates the Print form */
407: TtaShowDialogue (basePrint+NumFormPrint, FALSE);
408: }
409:
410: /*----------------------------------------------------------------------
411: SectionNumbering
412: Execute the "Section Numbering" command
413: ----------------------------------------------------------------------*/
414: #ifdef __STDC__
415: void SectionNumbering (Document document, View view)
416: #else
417: void SectionNumbering (document, view)
418: Document document;
419: View view;
420: #endif
421: {
422: ChangeAttrOnRoot (document, HTML_ATTR_SectionNumbering);
423: }
424:
425: /*----------------------------------------------------------------------
426: UpdateURLsInSubtree
427: Update NAMEs and URLs in subtree of el element, to take into account
428: the move from one document to another.
429: If a NAME attribute already exists in the new document, it is changed
430: to avoid duplicate names.
431: Transform the HREF and SRC attribute to make them independent from their
432: former base.
433: ----------------------------------------------------------------------*/
434: #ifdef __STDC__
435: static void UpdateURLsInSubtree (NotifyElement *event, Element el)
436: #else
437: static void UpdateURLsInSubtree (event, el)
438: NotifyElement *event;
439: Element el;
440: #endif
441: {
442: Element nextEl;
443:
444: event->element = el;
445: ElementPasted (event);
446: nextEl = TtaGetFirstChild (el);
447: while (nextEl != NULL)
448: {
449: UpdateURLsInSubtree (event, nextEl);
450: TtaNextSibling (&nextEl);
451: }
452: }
453:
454:
455: /*----------------------------------------------------------------------
456: MoveDocumentBody
457: Copy the elements contained in the BODY of document sourceDoc to the
458: position of element *el in document destDoc.
459: Delete the element containing *el and all its empty ancestors.
460: If deleteTree is TRUE, copied elements are deleted from the source
461: document.
462: ----------------------------------------------------------------------*/
463: #ifdef __STDC__
464: static void MoveDocumentBody (Element *el, Document destDoc,
465: Document sourceDoc, boolean deleteTree)
466: #else
467: static void MoveDocumentBody (el, destDoc, sourceDoc, deleteTree)
468: Element *el;
469: Document destDoc;
470: Document sourceDoc;
471: boolean deleteTree;
472: #endif
473: {
474: Element root, body, ancestor, elem, firstInserted,
475: lastInserted, srce, copy, old, parent, sibling;
476: ElementType elType;
477: NotifyElement event;
478:
479: firstInserted = NULL;
480: /* get the BODY element of source document */
481: root = TtaGetMainRoot (sourceDoc);
482: elType = TtaGetElementType (root);
483: elType.ElTypeNum = HTML_EL_BODY;
484: body = TtaSearchTypedElement (elType, SearchForward, root);
485: if (body != NULL)
486: {
487: /* get elem, the ancestor of *el which is a child of a DIV or BODY
488: element in the destination document. The copied elements will be
489: inserted just before this element. */
490: elem = *el;
491: do
492: {
493: ancestor = TtaGetParent (elem);
494: if (ancestor != NULL);
495: {
496: elType = TtaGetElementType (ancestor);
497: if (elType.ElTypeNum == HTML_EL_BODY ||
498: elType.ElTypeNum == HTML_EL_Division)
499: ancestor = NULL;
500: else
501: elem = ancestor;
502: }
503: }
504: while (ancestor != NULL);
505: parent = TtaGetParent (elem);
506:
507: /* do copy */
508: lastInserted = NULL;
509: srce = TtaGetFirstChild (body);
510: while (srce != NULL)
511: {
512: copy = TtaCopyTree (srce, sourceDoc, destDoc, parent);
513: if (copy != NULL)
514: {
515: if (lastInserted == NULL)
516: /* this is the first copied element. Insert it before elem */
517: {
518: TtaInsertSibling (copy, elem, TRUE, destDoc);
519: firstInserted = copy;
520: }
521: else
522: /* insert the new copied element after the element previously
523: copied */
524: TtaInsertSibling (copy, lastInserted, FALSE, destDoc);
525: lastInserted = copy;
526: /* update the NAMEs and URLs in the copied element */
527: event.document = destDoc;
528: event.position = sourceDoc;
529: UpdateURLsInSubtree(&event, copy);
530: }
531: /* get the next element in the source document */
532: old = srce;
533: TtaNextSibling (&srce);
534: if (deleteTree)
535: TtaDeleteTree (old, sourceDoc);
536: }
537:
538: /* delete the element(s) containing the link to the copied document */
539: /* delete the parent element of *el and all empty ancestors */
540: elem = TtaGetParent (*el);
541: do
542: {
543: sibling = elem;
544: TtaNextSibling (&sibling);
545: if (sibling == NULL)
546: {
547: sibling = elem;
548: TtaPreviousSibling (&sibling);
549: if (sibling == NULL)
550: elem = TtaGetParent (elem);
551: }
552: }
553: while (sibling == NULL);
554: TtaDeleteTree (elem, destDoc);
555: /* return the address of the first copied element */
556: *el = firstInserted;
557: }
558: }
559:
560: /*----------------------------------------------------------------------
561: GetIncludedDocuments
562: Look forward, starting from element el, for a link (A) with attribute
563: REL="chapter" and replace that link by the contents of the target document.
564: ----------------------------------------------------------------------*/
565: #ifdef __STDC__
566: static Element GetIncludedDocuments (Element el, Document document)
567: #else
568: static Element GetIncludedDocuments (el, document)
569: Element el;
570: Document document;
571: #endif
572: {
573: Element link, next;
574: Attribute RelAttr, HrefAttr;
575: AttributeType attrType;
576: int length;
577: char *text, *ptr;
578: Document includedDocument, newdoc;
579:
580: attrType.AttrSSchema = TtaGetDocumentSSchema (document);
581: attrType.AttrTypeNum = HTML_ATTR_REL;
582: link = el;
583: RelAttr = NULL;
584: /* looks for an anchor having an attribute REL="chapter" */
585: while (link != NULL && RelAttr == NULL)
586: {
587: TtaSearchAttribute (attrType, SearchForward, link, &link, &RelAttr);
588: if (link != NULL && RelAttr != NULL)
589: {
590: length = TtaGetTextAttributeLength (RelAttr);
591: text = TtaGetMemory (length + 1);
592: TtaGiveTextAttributeValue (RelAttr, text, &length);
593: if (strcasecmp (text, "chapter"))
594: RelAttr = NULL;
595: TtaFreeMemory (text);
596: }
597: }
598:
599: if (RelAttr != NULL && link != NULL)
600: /* a link with attribute REL="Chapter" has been found */
601: {
602: next = link;
603: attrType.AttrTypeNum = HTML_ATTR_HREF_;
604: HrefAttr = TtaGetAttribute (link, attrType);
605: if (HrefAttr != NULL)
606: /* this link has an attribute HREF */
607: {
608: length = TtaGetTextAttributeLength (HrefAttr);
609: text = TtaGetMemory (length + 1);
610: TtaGiveTextAttributeValue (HrefAttr, text, &length);
611: /* ignore links to a particular position within a document */
612: ptr = strrchr (text, '#');
613: if (ptr == NULL)
614: /* this link designate the whole document */
615: {
616: /* create a new document and loads the target document */
617: includedDocument = TtaNewDocument ("HTML", "tmp");
618: newdoc = GetHTMLDocument (text, NULL, includedDocument,
619: document, DC_TRUE);
620: if (newdoc != 0 && newdoc != document)
621: /* it's not the document itself */
622: /* copy the target document at the position of the link */
623: MoveDocumentBody (&next, document, newdoc,
624: newdoc == includedDocument);
625: FreeDocumentResource (includedDocument);
626: TtaCloseDocument (includedDocument);
627: }
628: TtaFreeMemory (text);
629: }
630: return (next);
631: }
632: return (NULL);
633: }
634:
635:
636: /*----------------------------------------------------------------------
637: MakeBook
638: Replace all links in a document which have an attribute REL="chapter"
639: by the corresponding target document.
640: ----------------------------------------------------------------------*/
641: #ifdef __STDC__
642: void MakeBook (Document document, View view)
643: #else
644: void MakeBook (document, view)
645: Document document;
646: View view;
647: #endif
648: {
649: Element root, body, el;
650: ElementType elType;
651:
652: root = TtaGetMainRoot (document);
653: elType = TtaGetElementType (root);
654: elType.ElTypeNum = HTML_EL_BODY;
655: body = TtaSearchTypedElement (elType, SearchForward, root);
656: TtaSetDocumentModified (document);
657: el = body;
658: while (el != NULL)
659: el = GetIncludedDocuments (el, document);
660: }
661:
662:
663: #ifdef R_HTML
664: /*----------------------------------------------------------------------
665: ----------------------------------------------------------------------*/
666: #ifdef __STDC__
667: static void LoadEntity (Document document, char *text)
668: #else
669: static void LoadEntity (document, text)
670: Document document;
671: char *text;
672: #endif
673: {
674: Document includedDocument;
675: Attribute attr;
676: AttributeType attrType;
677: Element el, includedEl;
678: ElementType elType;
679: int length;
680:
681: /* create the temporary document */
682: includedDocument = TtaNewDocument ("HTML", "tmp");
683: /* read the temporary document */
684: includedDocument = GetHTMLDocument (text, NULL, includedDocument, document, DC_TRUE);
685:
686: if (includedDocument != 0)
687: {
688: /* To do: Seach entity in the table */
689: /* locate the entity in the document */
690: el = TtaGetMainRoot (document);
691: elType = TtaGetElementType (el);
692: elType.ElTypeNum = HTML_EL_Entity;
693: /* TtaSearchElementByLabel (label, el); */
694: el = TtaSearchTypedElement (elType, SearchForward, el);
695: /* keep the entity name to know where to insert the sub-tree */
696: attrType.AttrSSchema = TtaGetDocumentSSchema (document);
697: attrType.AttrTypeNum = HTML_ATTR_entity_name;
698: attr = TtaGetAttribute (el, attrType);
699: if (attr != NULL)
700: {
701: length = TtaGetTextAttributeLength (attr);
702: text = TtaGetMemory (length + 1);
703: TtaGiveTextAttributeValue (attr, text, &length);
704: }
705: /* To do: translate the entity name into element type
706: and search this first element type in included document */
707: includedEl = TtaGetMainRoot (includedDocument);
708: elType = TtaGetElementType (includedEl);
709: elType.ElTypeNum = HTML_EL_TEXT_UNIT;
710: includedEl = TtaSearchTypedElement (elType, SearchForward, includedEl);
711: /* remove Entity */
712: /* To do: insert sub-trees */
713: FreeDocumentResource (includedDocument);
714: TtaCloseDocument (includedDocument);
715: }
716: }
717: #endif /* R_HTML */
718:
719:
720: /*----------------------------------------------------------------------
721: ----------------------------------------------------------------------*/
722: #ifdef __STDC__
723: void RealTimeHTML (Document document, View view)
724: #else
725: void RealTimeHTML (document, view)
726: Document document;
727: View view;
728: #endif
729: {
730: #ifdef R_HTML
731: Element root, el;
732: ElementType elType;
733:
734: root = TtaGetMainRoot (document);
735: elType = TtaGetElementType (root);
736: elType.ElTypeNum = HTML_EL_Entity;
737: el = TtaSearchTypedElement (elType, SearchForward, root);
738: if (el != NULL)
739: {
740: /* document contains entities */
741: /* To do -> build table of entities */
742:
743: /* simulate reception of different entities */
744: LoadEntity (document, "0/0");
745: LoadEntity (document, "0/1");
746: }
747: #endif /* R_HTML */
748: }
Webmaster