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