Annotation of Amaya/amaya/HTMLbook.c, revision 1.83
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.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.83 ! cvs 48: static char PSfile[MAX_PATH];
! 49: static char PPrinter[MAX_PATH];
1.81 cvs 50: static STRING 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.36 cvs 74: static void RegisterSubDoc (Element el, STRING 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.36 cvs 103: static Element SearchSubDoc (STRING 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.36 cvs 161: STRING 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:
381: /*----------------------------------------------------------------------
1.72 cvs 382: PrintDocument prints the document using predefined parameters.
1.3 cvs 383: ----------------------------------------------------------------------*/
1.45 cvs 384: static void PrintDocument (Document doc, View view)
1.3 cvs 385: {
1.34 cvs 386: AttributeType attrType;
387: Attribute attr;
388: Element el;
1.50 cvs 389: STRING files, dir;
1.83 ! 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);
471: if (textFile)
472: attrType.AttrTypeNum = TextFile_ATTR_PrintURL;
473: else
474: attrType.AttrTypeNum = HTML_ATTR_PrintURL;
475: el = TtaGetMainRoot (doc);
476: attr = TtaGetAttribute (el, attrType);
477: if (!attr && PrintURL)
478: {
479: attr = TtaNewAttribute (attrType);
480: TtaAttachAttribute (el, attr, doc);
481: }
482: if (attr && !PrintURL)
483: TtaRemoveAttribute (el, attr, doc);
484: }
485:
486: /* get the path dir where css files have to be stored */
1.79 cvs 487: if ((DocumentTypes[doc] == docHTML || DocumentTypes[doc] == docSVG) &&
1.78 cvs 488: !IgnoreCSS)
1.75 cvs 489: {
490: TtaGetPrintNames (&files, &dir);
491: /* store css files and get the list of names */
492: files = CssToPrint (doc, dir);
493: }
494: else
495: files = NULL;
496: TtaPrint (DocPrint, viewsToPrint, files);
497: if (files)
498: TtaFreeMemory (files);
499: if (!status)
500: TtaSetDocumentUnmodified (doc);
1.1 cvs 501: }
502:
1.45 cvs 503: /*----------------------------------------------------------------------
504: PrintAs prints the document using predefined parameters.
505: ----------------------------------------------------------------------*/
506: void PrintAs (Document doc, View view)
507: {
1.72 cvs 508: #ifdef _WINDOWS
509: DocPrint = doc;
510: ReusePrinterDC ();
1.45 cvs 511: #else /* _WINDOWS */
512: PrintDocument (doc, view);
513: #endif /* _WINDOWS */
514: }
1.1 cvs 515:
516: /*----------------------------------------------------------------------
517: CallbackImage manage returns of Picture form.
518: ----------------------------------------------------------------------*/
1.81 cvs 519: void CallbackPrint (int ref, int typedata, STRING data)
1.1 cvs 520: {
521: int val;
522:
523: val = (int) data;
1.53 cvs 524: switch (ref - BasePrint)
1.1 cvs 525: {
1.69 cvs 526: case FormPrint:
527: TtaDestroyDialogue (BasePrint + FormPrint);
1.1 cvs 528: switch (val)
529: {
530: case 1:
1.53 cvs 531: TtaSetPrintCommand (PPrinter);
1.81 cvs 532: TtaSetPsFile (PSfile);
1.40 cvs 533: /* update the environment variable */
1.53 cvs 534: TtaSetEnvString ("THOTPRINT", PPrinter, TRUE);
535: PrintDocument (DocPrint, 1);
1.1 cvs 536: break;
537: default:
538: break;
539: }
540: break;
1.69 cvs 541: case PrintOptions:
1.1 cvs 542: switch (val)
543: {
544: case 0:
545: /* Manual feed option */
1.2 cvs 546: if (ManualFeed == PP_ON)
547: ManualFeed = PP_OFF;
548: else
549: ManualFeed = PP_ON;
1.81 cvs 550: TtaSetPrintParameter (PP_ManualFeed, ManualFeed);
1.1 cvs 551: break;
552: case 1:
553: /* Toc option */
1.53 cvs 554: WithToC = !WithToC;
1.1 cvs 555: break;
556: case 2:
1.53 cvs 557: /* NumberLinks option */
558: NumberLinks = !NumberLinks;
1.34 cvs 559: case 3:
560: /* URL option */
1.53 cvs 561: PrintURL = !PrintURL;
562: break;
563: case 4:
564: /* CSS option */
565: IgnoreCSS = !IgnoreCSS;
1.1 cvs 566: break;
567: }
568: break;
1.69 cvs 569: case PaperFormat:
1.1 cvs 570: /* page size submenu */
571: switch (val)
572: {
573: case 0:
1.2 cvs 574: PageSize = PP_A4;
1.1 cvs 575: break;
576: case 1:
1.2 cvs 577: PageSize = PP_US;
1.1 cvs 578: break;
579: }
1.81 cvs 580: TtaSetPrintParameter (PP_PaperSize, PageSize);
1.1 cvs 581: break;
1.71 cvs 582: case PaperOrientation:
583: /* orientation submenu */
584: Orientation = val;
1.81 cvs 585: TtaSetPrintParameter (PP_Orientation, Orientation);
1.71 cvs 586: break;
587: case PPagesPerSheet:
588: /* pages per sheet submenu */
589: switch (val)
590: {
591: case 0:
592: PagePerSheet = 1;
593: break;
594: case 1:
595: PagePerSheet = 2;
596: break;
597: case 2:
598: PagePerSheet = 4;
599: break;
600: }
1.81 cvs 601: TtaSetPrintParameter (PP_PagesPerSheet, PagePerSheet);
1.71 cvs 602: break;
1.69 cvs 603: case PrintSupport:
1.1 cvs 604: /* paper print/save PostScript submenu */
605: switch (val)
606: {
607: case 0:
1.2 cvs 608: if (PaperPrint == PP_PS)
1.1 cvs 609: {
1.2 cvs 610: PaperPrint = PP_PRINTER;
1.69 cvs 611: #ifndef _WINDOWS
612: TtaSetTextForm (BasePrint + PPrinterName, PPrinter);
613: #endif /* !_WINDOWS */
1.81 cvs 614: TtaSetPrintParameter (PP_Destination, PaperPrint);
1.1 cvs 615: }
616: break;
617: case 1:
1.2 cvs 618: if (PaperPrint == PP_PRINTER)
1.1 cvs 619: {
1.2 cvs 620: PaperPrint = PP_PS;
1.80 cvs 621: #ifndef _WINDOWS
1.81 cvs 622: TtaSetTextForm (BasePrint + PPrinterName, PSfile);
1.80 cvs 623: #endif /* !_WINDOWS */
1.81 cvs 624: TtaSetPrintParameter (PP_Destination, PaperPrint);
1.1 cvs 625: }
626: break;
627: }
628: break;
1.69 cvs 629: case PPrinterName:
1.1 cvs 630: if (data[0] != '\0')
1.80 cvs 631: {
1.2 cvs 632: if (PaperPrint == PP_PRINTER)
1.40 cvs 633: /* text capture zone for the printer name */
1.83 ! cvs 634: strncpy (PPrinter, data, MAX_PATH);
1.1 cvs 635: else
636: /* text capture zone for the name of the PostScript file */
1.83 ! cvs 637: strncpy (PSfile, data, MAX_PATH);
1.80 cvs 638: }
1.1 cvs 639: break;
640: }
641: }
642:
643: /*----------------------------------------------------------------------
644: ----------------------------------------------------------------------*/
645: void InitPrint (void)
646: {
1.83 ! cvs 647: char* ptr;
1.1 cvs 648:
1.53 cvs 649: BasePrint = TtaSetCallback (CallbackPrint, PRINT_MAX_REF);
650: DocPrint = 0;
1.81 cvs 651: DocPrintURL = NULL;
1.1 cvs 652:
653: /* read default printer variable */
1.52 cvs 654: ptr = TtaGetEnvString ("THOTPRINT");
1.1 cvs 655: if (ptr == NULL)
1.83 ! cvs 656: strcpy (PPrinter, "");
1.1 cvs 657: else
1.83 ! cvs 658: strcpy (PPrinter, ptr);
1.81 cvs 659: TtaSetPrintCommand (PPrinter);
1.2 cvs 660: PaperPrint = PP_PRINTER;
1.81 cvs 661: TtaSetPrintParameter (PP_Destination, PaperPrint);
662:
663: /* define the new default PrintSchema */
664: NumberLinks = FALSE;
665: WithToC = FALSE;
666: IgnoreCSS = FALSE;
1.53 cvs 667: PrintURL = TRUE;
1.81 cvs 668: PageSize = TtaGetPrintParameter (PP_PaperSize);
1.82 cvs 669: TtaSetPrintSchema ("");
1.81 cvs 670: /* no manual feed */
671: ManualFeed = PP_OFF;
672: TtaSetPrintParameter (PP_ManualFeed, ManualFeed);
673: PagePerSheet = 1;
674: TtaSetPrintParameter (PP_PagesPerSheet, PagePerSheet);
1.1 cvs 675: }
676:
677: /*----------------------------------------------------------------------
1.3 cvs 678: SetupAndPrint sets printing parameters and starts the printing process
1.1 cvs 679: ----------------------------------------------------------------------*/
1.38 cvs 680: void SetupAndPrint (Document doc, View view)
1.1 cvs 681: {
1.70 cvs 682: #ifndef _WINDOWS
1.83 ! cvs 683: char bufMenu[MAX_LENGTH];
1.81 cvs 684: int i;
1.70 cvs 685: #endif /* !_WINDOWS */
1.81 cvs 686: ThotBool textFile;
1.38 cvs 687:
1.81 cvs 688: textFile = (DocumentTypes[doc] == docText || DocumentTypes[doc] == docCSS);
689: /* Print form */
690: CheckPrintingDocument (doc);
1.27 cvs 691:
1.70 cvs 692: #ifndef _WINDOWS
1.81 cvs 693: TtaNewSheet (BasePrint + FormPrint, TtaGetViewFrame (doc, view),
694: TtaGetMessage (LIB, TMSG_LIB_PRINT), 1,
695: TtaGetMessage (AMAYA, AM_BUTTON_PRINT), FALSE, 3, 'L', D_CANCEL);
696:
697: /* Paper format submenu */
698: i = 0;
699: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_A4));
1.83 ! cvs 700: i += strlen (&bufMenu[i]) + 1;
1.81 cvs 701: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_US));
702: TtaNewSubmenu (BasePrint + PaperFormat, BasePrint + FormPrint, 0,
703: TtaGetMessage (LIB, TMSG_PAPER_SIZE), 2, bufMenu, NULL, TRUE);
704: if (PageSize == PP_US)
705: TtaSetMenuForm (BasePrint + PaperFormat, 1);
706: else
707: TtaSetMenuForm (BasePrint + PaperFormat, 0);
708:
709: /* Orientation submenu */
710: i = 0;
711: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (AMAYA, AM_PORTRAIT));
1.83 ! cvs 712: i += strlen (&bufMenu[i]) + 1;
1.81 cvs 713: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (AMAYA, AM_LANDSCAPE));
714: TtaNewSubmenu (BasePrint + PaperOrientation, BasePrint + FormPrint, 0,
715: TtaGetMessage (AMAYA, AM_ORIENTATION), 2, bufMenu, NULL, TRUE);
716: if (Orientation == PP_Landscape)
717: TtaSetMenuForm (BasePrint + PaperOrientation, 1);
718: else
719: TtaSetMenuForm (BasePrint + PaperOrientation, 0);
720: /* Pages per sheet submenu */
721: i = 0;
722: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_1_PAGE_SHEET));
1.83 ! cvs 723: i += strlen (&bufMenu[i]) + 1;
1.81 cvs 724: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_2_PAGE_SHEET));
1.83 ! cvs 725: i += strlen (&bufMenu[i]) + 1;
1.81 cvs 726: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_4_PAGE_SHEET));
727: TtaNewSubmenu (BasePrint + PPagesPerSheet, BasePrint + FormPrint, 0,
728: TtaGetMessage (LIB, TMSG_REDUCTION), 3, bufMenu, NULL, TRUE);
729: if (PagePerSheet == 1)
730: TtaSetMenuForm (BasePrint + PPagesPerSheet, 0);
731: else if (PagePerSheet == 2)
732: TtaSetMenuForm (BasePrint + PPagesPerSheet, 1);
733: else
734: TtaSetMenuForm (BasePrint + PPagesPerSheet, 2);
735:
736: /* Print to paper/ Print to file submenu */
737: i = 0;
738: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_PRINTER));
1.83 ! cvs 739: i += strlen (&bufMenu[i]) + 1;
1.81 cvs 740: sprintf (&bufMenu[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_PS_FILE));
741: TtaNewSubmenu (BasePrint + PrintSupport, BasePrint + FormPrint, 0,
742: TtaGetMessage (LIB, TMSG_OUTPUT), 2, bufMenu, NULL, TRUE);
743:
744: /* PaperPrint selector */
745: TtaNewTextForm (BasePrint + PPrinterName, BasePrint + FormPrint, NULL, 30, 1, TRUE);
746: if (PaperPrint == PP_PRINTER)
747: {
748: TtaSetMenuForm (BasePrint + PrintSupport, 0);
749: TtaSetTextForm (BasePrint + PPrinterName, PPrinter);
750: }
751: else
752: {
753: TtaSetMenuForm (BasePrint + PrintSupport, 1);
754: TtaSetTextForm (BasePrint + PPrinterName, PSfile);
755: }
1.1 cvs 756:
1.81 cvs 757: /* The toggle */
758: i = 0;
759: sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (LIB, TMSG_MANUAL_FEED));
1.83 ! cvs 760: i += strlen (&bufMenu[i]) + 1;
1.81 cvs 761: sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_PRINT_TOC));
1.83 ! cvs 762: i += strlen (&bufMenu[i]) + 1;
1.81 cvs 763: sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_NUMBERED_LINKS));
1.83 ! cvs 764: i += strlen (&bufMenu[i]) + 1;
1.81 cvs 765: sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_PRINT_URL));
1.83 ! cvs 766: i += strlen (&bufMenu[i]) + 1;
1.81 cvs 767: sprintf (&bufMenu[i], "%s%s", "T", TtaGetMessage (AMAYA, AM_WITH_CSS));
768: TtaNewToggleMenu (BasePrint + PrintOptions, BasePrint + FormPrint,
769: TtaGetMessage (LIB, TMSG_OPTIONS), 5, bufMenu, NULL, FALSE);
770: if (ManualFeed == PP_ON)
771: TtaSetToggleMenu (BasePrint + PrintOptions, 0, TRUE);
772: else
773: TtaSetToggleMenu (BasePrint + PrintOptions, 0, FALSE);
774: TtaSetToggleMenu (BasePrint + PrintOptions, 1, WithToC);
775: TtaSetToggleMenu (BasePrint + PrintOptions, 2, NumberLinks);
776: TtaSetToggleMenu (BasePrint + PrintOptions, 3, PrintURL);
777: TtaSetToggleMenu (BasePrint + PrintOptions, 4, IgnoreCSS);
778:
779: /* activates the Print form */
780: TtaShowDialogue (BasePrint+FormPrint, FALSE);
781: if (textFile)
782: {
783: /* invalid dialogue entries */
784: TtaRedrawMenuEntry (BasePrint + PrintOptions, 1, NULL, -1, FALSE);
785: TtaRedrawMenuEntry (BasePrint + PrintOptions, 2, NULL, -1, FALSE);
786: }
1.70 cvs 787: #else /* _WINDOWS */
1.81 cvs 788: CreatePrintDlgWindow (TtaGetViewFrame (doc, view), PSfile);
1.70 cvs 789: #endif /* _WINDOWS */
1.1 cvs 790: }
791:
792: /*----------------------------------------------------------------------
793: SectionNumbering
794: Execute the "Section Numbering" command
795: ----------------------------------------------------------------------*/
1.38 cvs 796: void SectionNumbering (Document doc, View view)
1.1 cvs 797: {
1.38 cvs 798: ChangeAttrOnRoot (doc, HTML_ATTR_SectionNumbering);
1.1 cvs 799: }
800:
801: /*----------------------------------------------------------------------
802: UpdateURLsInSubtree
803: Update NAMEs and URLs in subtree of el element, to take into account
804: the move from one document to another.
805: If a NAME attribute already exists in the new document, it is changed
806: to avoid duplicate names.
807: Transform the HREF and SRC attribute to make them independent from their
808: former base.
809: ----------------------------------------------------------------------*/
810: static void UpdateURLsInSubtree (NotifyElement *event, Element el)
811: {
1.77 cvs 812: Element nextEl, child;
813: ElementType elType;
814: SSchema HTMLschema;
1.1 cvs 815:
816: nextEl = TtaGetFirstChild (el);
1.82 cvs 817: HTMLschema = TtaGetSSchema ("HTML", event->document);
1.77 cvs 818: elType.ElSSchema = HTMLschema;
1.1 cvs 819: while (nextEl != NULL)
820: {
1.58 cvs 821: event->element = nextEl;
822: ElementPasted (event);
1.77 cvs 823:
824: /* manage included links and anchors */
825: elType.ElTypeNum = HTML_EL_Anchor;
826: child = TtaSearchTypedElement (elType, SearchInTree, nextEl);
827: while (child)
828: {
829: event->element = child;
830: ElementPasted (event);
831: child = TtaSearchTypedElementInTree (elType, SearchForward, nextEl, child);
832: }
833:
834: /* manage included links and anchors */
835: elType.ElTypeNum = HTML_EL_PICTURE_UNIT;
836: child = TtaSearchTypedElement (elType, SearchInTree, nextEl);
837: while (child)
838: {
839: event->element = child;
840: ElementPasted (event);
841: child = TtaSearchTypedElementInTree (elType, SearchForward, nextEl, child);
842: }
1.1 cvs 843: TtaNextSibling (&nextEl);
844: }
845: }
846:
847:
848: /*----------------------------------------------------------------------
849: MoveDocumentBody
1.58 cvs 850: Copy the elements contained in the BODY of the document sourceDoc at the
851: position of the element el in the document destDoc.
852: Delete the element containing el and all its empty ancestors.
1.1 cvs 853: If deleteTree is TRUE, copied elements are deleted from the source
854: document.
1.58 cvs 855: Return the root element that delimits the new inserted part (a div).
1.1 cvs 856: ----------------------------------------------------------------------*/
1.80 cvs 857: static Element MoveDocumentBody (Element el, Document destDoc,
858: Document sourceDoc, STRING target,
859: STRING url, ThotBool deleteTree)
1.1 cvs 860: {
1.58 cvs 861: Element root, ancestor, elem, firstInserted, div;
1.12 cvs 862: Element lastInserted, srce, copy, old, parent, sibling;
863: ElementType elType;
864: NotifyElement event;
865: int checkingMode;
1.47 cvs 866: ThotBool isID;
1.1 cvs 867:
1.67 cvs 868: div = NULL;
1.13 cvs 869: if (target != NULL)
870: {
871: /* locate the target element within the source document */
872: root = SearchNAMEattribute (sourceDoc, target, NULL);
873: elType = TtaGetElementType (root);
1.58 cvs 874: isID = (elType.ElTypeNum != HTML_EL_Anchor && elType.ElTypeNum != HTML_EL_MAP);
1.13 cvs 875: }
876: else
877: {
878: isID = FALSE;
879: /* get the BODY element of source document */
880: root = TtaGetMainRoot (sourceDoc);
881: elType = TtaGetElementType (root);
882: elType.ElTypeNum = HTML_EL_BODY;
883: root = TtaSearchTypedElement (elType, SearchForward, root);
884: }
885:
886: if (root != NULL)
1.12 cvs 887: {
888: /* don't check the abstract tree against the structure schema */
889: checkingMode = TtaGetStructureChecking (destDoc);
890: TtaSetStructureChecking (0, destDoc);
1.58 cvs 891: /* get elem, the ancestor of el which is a child of a DIV or BODY
1.12 cvs 892: element in the destination document. The copied elements will be
893: inserted just before this element. */
1.58 cvs 894: elem = el;
1.12 cvs 895: do
1.1 cvs 896: {
1.12 cvs 897: ancestor = TtaGetParent (elem);
898: if (ancestor != NULL)
899: {
900: elType = TtaGetElementType (ancestor);
901: if (elType.ElTypeNum == HTML_EL_BODY ||
902: elType.ElTypeNum == HTML_EL_Division)
903: ancestor = NULL;
904: else
905: elem = ancestor;
906: }
1.1 cvs 907: }
1.12 cvs 908: while (ancestor != NULL);
909: parent = TtaGetParent (elem);
1.14 cvs 910:
911: /* insert a DIV element */
1.15 cvs 912: elType.ElTypeNum = HTML_EL_Division;
1.16 cvs 913: lastInserted = TtaNewElement (destDoc, elType);
914: TtaInsertSibling (lastInserted, elem, TRUE, destDoc);
1.58 cvs 915: /* this delimits the new inserted part of the document */
1.16 cvs 916: RegisterSubDoc (lastInserted, url);
1.76 kahan 917: CreateTargetAnchor (destDoc, lastInserted, FALSE, FALSE);
1.58 cvs 918: div = lastInserted;
1.14 cvs 919:
1.12 cvs 920: /* do copy */
1.16 cvs 921: firstInserted = NULL;
1.17 cvs 922: if (isID)
923: srce = root;
924: else
925: srce = TtaGetFirstChild (root);
1.12 cvs 926: while (srce != NULL)
1.1 cvs 927: {
1.12 cvs 928: copy = TtaCopyTree (srce, sourceDoc, destDoc, parent);
929: if (copy != NULL)
930: {
1.16 cvs 931: if (firstInserted == NULL)
1.12 cvs 932: /* this is the first copied element. Insert it before elem */
933: {
1.16 cvs 934: TtaInsertFirstChild (©, lastInserted, destDoc);
1.12 cvs 935: firstInserted = copy;
936: }
937: else
938: /* insert the new copied element after the element previously
939: copied */
940: TtaInsertSibling (copy, lastInserted, FALSE, destDoc);
941: lastInserted = copy;
942: /* update the NAMEs and URLs in the copied element */
943: event.document = destDoc;
944: event.position = sourceDoc;
945: UpdateURLsInSubtree(&event, copy);
946: }
947: /* get the next element in the source document */
948: old = srce;
949: TtaNextSibling (&srce);
950: if (deleteTree)
951: TtaDeleteTree (old, sourceDoc);
1.13 cvs 952: /* Stop here if the target points to a specific element with an ID */
953: if (isID)
954: srce = NULL;
1.1 cvs 955: }
1.12 cvs 956:
957: /* delete the element(s) containing the link to the copied document */
1.58 cvs 958: /* delete the parent element of el and all empty ancestors */
959: elem = TtaGetParent (el);
1.12 cvs 960: do
1.1 cvs 961: {
1.12 cvs 962: sibling = elem;
963: TtaNextSibling (&sibling);
964: if (sibling == NULL)
965: {
966: sibling = elem;
967: TtaPreviousSibling (&sibling);
968: if (sibling == NULL)
969: elem = TtaGetParent (elem);
970: }
1.1 cvs 971: }
1.12 cvs 972: while (sibling == NULL);
973: TtaDeleteTree (elem, destDoc);
974: /* restore previous chacking mode */
1.47 cvs 975: TtaSetStructureChecking ((ThotBool)checkingMode, destDoc);
1.12 cvs 976: }
1.58 cvs 977: /* return the address of the new division */
978: return (div);
1.1 cvs 979: }
980:
1.29 cvs 981:
1.58 cvs 982: /*----------------------------------------------------------------------
983: CloseMakeBook
984: ----------------------------------------------------------------------*/
985: static void CloseMakeBook (Document document)
986: {
987: ResetStop (document);
988: /* update internal links */
989: SetInternalLinks (document);
990: /* if the document changed force the browser mode */
991: if (SubDocs)
992: SetBrowserEditor (document);
993: /* remove registered sub-documents */
994: FreeSubDocTable ();
995: DocBook = 0;
996: TtaSetStatus (document, 1, TtaGetMessage (AMAYA, AM_DOCUMENT_LOADED), NULL);
997: }
998:
999:
1000: /*----------------------------------------------------------------------
1001: GetIncludedDocuments_callback finishes the GetIncludedDocuments procedure
1002: ----------------------------------------------------------------------*/
1003: void GetIncludedDocuments_callback (int newdoc, int status,
1004: STRING urlName,
1005: STRING outputfile,
1.63 cvs 1006: AHTHeaders *http_headers,
1.58 cvs 1007: void * context)
1.29 cvs 1008: {
1.58 cvs 1009: Element link, div;
1010: IncludeCtxt *ctx, *prev;
1.57 cvs 1011: STRING url, ptr;
1.58 cvs 1012: ThotBool found = FALSE;
1.29 cvs 1013:
1014: /* restore GetIncludedDocuments's context */
1.58 cvs 1015: ctx = (IncludeCtxt *) context;
1.29 cvs 1016: if (!ctx)
1017: return;
1018:
1.58 cvs 1019: div = NULL;
1.29 cvs 1020: link = ctx->link;
1.58 cvs 1021: ptr = ctx->name;
1.29 cvs 1022: url = ctx->url;
1.58 cvs 1023: if (url)
1.29 cvs 1024: {
1.58 cvs 1025: if (newdoc && newdoc != DocBook)
1.29 cvs 1026: {
1.58 cvs 1027: /* it's not the DocBook itself */
1028: /* copy the target document at the position of the link */
1029: TtaSetDocumentModified (DocBook);
1030: div = MoveDocumentBody (link, DocBook, newdoc, ptr, url,
1031: (ThotBool)(newdoc == IncludedDocument));
1.29 cvs 1032: }
1.58 cvs 1033: /* global variables */
1034: FreeDocumentResource (IncludedDocument);
1035: TtaCloseDocument (IncludedDocument);
1036: IncludedDocument = 0;
1.29 cvs 1037: }
1.58 cvs 1038:
1039: if (div != NULL)
1.29 cvs 1040: {
1.58 cvs 1041: /* new starting point for the search */
1042: ctx->link = div;
1043: found = GetIncludedDocuments (div, div, DocBook, ctx);
1.29 cvs 1044: }
1.58 cvs 1045: while (!found && ctx)
1046: {
1047: /* this sub-document has no more inclusion, examine the caller */
1048: div = ctx->div;
1049: link = ctx->link;
1050: prev = ctx->ctxt;
1051: TtaFreeMemory (url);
1.64 cvs 1052: url = NULL;
1.58 cvs 1053: TtaFreeMemory (ctx);
1054: ctx = prev;
1055: found = GetIncludedDocuments (div, link, DocBook, ctx);
1056: }
1057: if (!found)
1058: /* all links are now managed */
1059: CloseMakeBook (DocBook);
1.29 cvs 1060: }
1061:
1.1 cvs 1062: /*----------------------------------------------------------------------
1063: GetIncludedDocuments
1.58 cvs 1064: Look forward within the element el, starting from element link, for a
1065: link (A) with attribute rel="chapter" or rel="subdocument" and replace
1066: that link by the contents of the target document.
1067: Return TRUE if one inclusion is launched.
1.1 cvs 1068: ----------------------------------------------------------------------*/
1.80 cvs 1069: static ThotBool GetIncludedDocuments (Element el, Element link,
1070: Document document, IncludeCtxt *prev)
1.1 cvs 1071: {
1.58 cvs 1072: ElementType elType;
1073: Attribute attr;
1074: AttributeType attrType;
1075: Document newdoc;
1076: IncludeCtxt *ctx = NULL;
1077: STRING text, ptr, url = NULL;
1.29 cvs 1078: int length;
1.58 cvs 1079: ThotBool found = FALSE;
1.29 cvs 1080:
1.58 cvs 1081: /* look for anchors with the attribute rel within the element el */
1082: attr = NULL;
1.82 cvs 1083: attrType.AttrSSchema = TtaGetSSchema ("HTML", document);
1.58 cvs 1084: elType.ElSSchema = attrType.AttrSSchema;
1085: elType.ElTypeNum = HTML_EL_Anchor;
1.29 cvs 1086:
1.58 cvs 1087: /* Get only one included file each time */
1088: while (link && attr == NULL)
1.29 cvs 1089: {
1.58 cvs 1090: link = TtaSearchTypedElementInTree (elType, SearchForward, el, link);
1091: if (link)
1.29 cvs 1092: {
1.58 cvs 1093: attrType.AttrTypeNum = HTML_ATTR_REL;
1094: attr = TtaGetAttribute (link, attrType);
1095: }
1096: if (attr)
1097: {
1098: length = TtaGetTextAttributeLength (attr);
1.83 ! cvs 1099: text = TtaGetMemory (length + 1);
1.58 cvs 1100: TtaGiveTextAttributeValue (attr, text, &length);
1101: /* Valid rel values are rel="chapter" or rel="subdocument" */
1.83 ! cvs 1102: if (strcasecmp (text, "chapter") &&
! 1103: strcasecmp (text, "subdocument"))
1.58 cvs 1104: attr = NULL;
1.29 cvs 1105: TtaFreeMemory (text);
1106: }
1.58 cvs 1107:
1108: if (attr)
1109: {
1110: /* a link with attribute rel="Chapter" has been found */
1111: attrType.AttrTypeNum = HTML_ATTR_HREF_;
1112: attr = TtaGetAttribute (link, attrType);
1113: }
1114: if (attr)
1115: /* this link has an attribute HREF */
1116: {
1117: length = TtaGetTextAttributeLength (attr);
1.83 ! cvs 1118: text = TtaGetMemory (length + 1);
1.58 cvs 1119: TtaGiveTextAttributeValue (attr, text, &length);
1.83 ! cvs 1120: ptr = strrchr (text, '#');
1.58 cvs 1121: url = text;
1122: if (ptr != NULL)
1123: {
1124: if (ptr == text)
1125: url = NULL;
1126: /* link to a particular position within a remote document */
1127: ptr[0] = EOS;
1128: ptr = &ptr[1];
1129: }
1130:
1131: if (url != NULL)
1132: /* this link designates an external document */
1133: {
1134: /* create a new document and loads the target document */
1.82 cvs 1135: IncludedDocument = TtaNewDocument ("HTML", "tmp");
1.58 cvs 1136: if (IncludedDocument != 0)
1137: {
1138: TtaSetStatus (document, 1, TtaGetMessage (AMAYA, AM_FETCHING), url);
1139: ctx = TtaGetMemory (sizeof (IncludeCtxt));
1140: ctx->div = el;
1141: ctx->link = link;
1142: ctx->url = url; /* the URL of the document */
1143: ctx->name = ptr;
1144: ctx->ctxt = prev; /* previous context */
1145: /* Get the reference of the calling document */
1146: SetStopButton (document);
1147: newdoc = GetHTMLDocument (url, NULL, IncludedDocument,
1148: document, CE_MAKEBOOK, FALSE,
1149: (void *) GetIncludedDocuments_callback,
1150: (void *) ctx);
1151: found = TRUE;
1152: }
1153: }
1154: else
1155: TtaFreeMemory (text);
1156: }
1.29 cvs 1157: }
1.58 cvs 1158: return (found);
1.1 cvs 1159: }
1160:
1161:
1162: /*----------------------------------------------------------------------
1163: MakeBook
1164: Replace all links in a document which have an attribute REL="chapter"
1.5 cvs 1165: or REL="subdocument" by the corresponding target document.
1.1 cvs 1166: ----------------------------------------------------------------------*/
1167: void MakeBook (Document document, View view)
1168: {
1.58 cvs 1169: Element root, body;
1170: ElementType elType;
1.1 cvs 1171:
1.58 cvs 1172: /* stops all current transfers on this document */
1173: StopTransfer (document, 1);
1174: /* simulate a transfert in the main document */
1175: DocBook = document;
1176: IncludedDocument = 0;
1177: root = TtaGetMainRoot (document);
1178: elType = TtaGetElementType (root);
1179: elType.ElTypeNum = HTML_EL_BODY;
1180: body = TtaSearchTypedElement (elType, SearchForward, root);
1.29 cvs 1181:
1.58 cvs 1182: if (body)
1183: GetIncludedDocuments (body, body, document, NULL);
1.1 cvs 1184: }
Webmaster