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