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