Annotation of Amaya/amaya/init.c, revision 1.933
1.17 cvs 1: /*
2: *
1.924 vatton 3: * (c) COPYRIGHT INRIA and W3C, 1996-2004
1.445 cvs 4: *
1.17 cvs 5: * Please first read the full copyright statement in file COPYRIGHT.
6: *
7: */
1.9 cvs 8:
1.26 cvs 9: /*
10: * Initialization functions and button functions of Amaya application.
11: *
12: * Author: I. Vatton
1.576 cvs 13: * R. Guetari (W3C/INRIA) - Windows version
1.26 cvs 14: */
15:
1.6 cvs 16: /* Included headerfiles */
1.333 cvs 17:
1.926 gully 18: #ifdef _WX
19: #include "wx/wx.h"
20: #endif /* _WX */
21:
1.907 gully 22: #undef THOT_EXPORT
23: #define THOT_EXPORT extern /* defined into css.c */
24: #include "amaya.h"
25:
26: #undef THOT_EXPORT
1.331 cvs 27: #define THOT_EXPORT extern
1.6 cvs 28: #include "css.h"
1.18 cvs 29: #include "trans.h"
1.290 cvs 30: #include "zlib.h"
1.352 cvs 31: #include "profiles.h"
1.592 cvs 32:
33: /*
34: * A VIRER SUREMENT PAR LA SUITE
35: *
36: *
37: *
38: **/
1.337 cvs 39: #ifdef _GTK
1.891 gully 40: #include "gtkdialogapi.h"
41: extern char LostPicturePath [512];
1.337 cvs 42: #endif /* _GTK */
1.919 cvs 43: #ifdef _WINDOWS
44: #include <commctrl.h>
45: #endif /* _WINDOWS */
1.916 cvs 46: #ifdef _WINGUI
1.891 gully 47: #include "resource.h"
1.916 cvs 48: #endif /* _WINGUI */
1.926 gully 49: #ifdef _WX
50: #include "wxdialogapi_f.h"
51: #endif /* _WX */
52:
1.911 gully 53: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.6 cvs 54: #include "stopN.xpm"
55: #include "stopR.xpm"
56: #include "save.xpm"
1.290 cvs 57: #include "saveNo.xpm"
1.6 cvs 58: #include "find.xpm"
1.276 cvs 59: #include "Reload.xpm"
60: #include "Browser.xpm"
61: #include "Editor.xpm"
62: #include "Print.xpm"
1.6 cvs 63: #include "Back.xpm"
1.143 cvs 64: #include "BackNo.xpm"
1.6 cvs 65: #include "Forward.xpm"
1.143 cvs 66: #include "ForwardNo.xpm"
1.6 cvs 67: #include "I.xpm"
1.276 cvs 68: #include "INo.xpm"
1.6 cvs 69: #include "B.xpm"
1.276 cvs 70: #include "BNo.xpm"
1.6 cvs 71: #include "T.xpm"
1.276 cvs 72: #include "TNo.xpm"
1.6 cvs 73: #include "H1.xpm"
1.276 cvs 74: #include "H1No.xpm"
1.6 cvs 75: #include "H2.xpm"
1.276 cvs 76: #include "H2No.xpm"
1.6 cvs 77: #include "H3.xpm"
1.276 cvs 78: #include "H3No.xpm"
1.6 cvs 79: #include "Num.xpm"
1.276 cvs 80: #include "NumNo.xpm"
1.6 cvs 81: #include "Bullet.xpm"
1.276 cvs 82: #include "BulletNo.xpm"
1.6 cvs 83: #include "Image.xpm"
1.276 cvs 84: #include "ImageNo.xpm"
1.6 cvs 85: #include "DL.xpm"
1.276 cvs 86: #include "DLNo.xpm"
1.29 cvs 87: #include "Link.xpm"
1.276 cvs 88: #include "LinkNo.xpm"
1.29 cvs 89: #include "Table.xpm"
1.276 cvs 90: #include "TableNo.xpm"
1.311 cvs 91: #include "home.xpm"
1.911 gully 92: #endif /* #if defined(_MOTIF) || defned(_GTK) || defined(_WX) */
1.124 cvs 93:
1.567 kahan 94: #include "XPointer_f.h"
1.770 pierre 95: #include "anim_f.h"
1.823 cheyroul 96: #include "animbuilder_f.h"
1.765 cvs 97: #include "libmanag_f.h"
1.342 cvs 98: #ifdef ANNOTATIONS
1.442 kahan 99: #include "annotlib.h"
1.342 cvs 100: #include "ANNOTevent_f.h"
1.571 kahan 101: #include "ANNOTfiles_f.h"
1.594 kahan 102: #include "ANNOTtools_f.h"
1.342 cvs 103: #endif /* ANNOTATIONS */
1.859 kahan 104: #ifdef BOOKMARKS
1.858 kahan 105: #include "BMevent_f.h"
106: #endif /* BOOKMARKS */
1.342 cvs 107:
1.916 cvs 108: #ifdef _WINGUI
1.124 cvs 109: /*
1.13 cvs 110: #ifndef __GNUC__
1.6 cvs 111: #include <direct.h>
1.124 cvs 112: #endif
113: */
1.398 cvs 114: int Window_Curs;
1.547 cvs 115: char DocToOpen[MAX_LENGTH];
1.916 cvs 116: #endif /* _WINGUI */
1.66 cvs 117:
1.360 cvs 118:
1.18 cvs 119: static int AmayaInitialized = 0;
1.503 cvs 120: static ThotBool NewFile = FALSE;
121: static int NewDocType = 0;
1.683 cvs 122: static int NewDocProfile = 0;
1.659 vatton 123: static ThotBool ShowErrors;
1.830 vatton 124: static ThotBool BADMimeType = FALSE;
1.904 vatton 125: static ThotBool CriticConfirm = FALSE;
1.678 vatton 126: /* the open document is the Amaya default page */
127: static ThotBool WelcomePage = FALSE;
1.325 cvs 128: /* we have to mark the initial loading status to avoid to re-open the
129: document view twice */
1.445 cvs 130: static int Loading_method = CE_INIT;
1.315 cvs 131:
1.915 gully 132: #if defined(_NOGUI)
1.276 cvs 133: static ThotIcon stopR;
134: static ThotIcon stopN;
135: static ThotIcon iconSave;
1.290 cvs 136: static ThotIcon iconSaveNo;
1.276 cvs 137: static ThotIcon iconFind;
138: static ThotIcon iconReload;
139: static ThotIcon iconI;
140: static ThotIcon iconINo;
141: static ThotIcon iconB;
142: static ThotIcon iconBNo;
143: static ThotIcon iconT;
144: static ThotIcon iconTNo;
145: static ThotIcon iconImage;
146: static ThotIcon iconImageNo;
147: static ThotIcon iconBack;
148: static ThotIcon iconBackNo;
149: static ThotIcon iconForward;
150: static ThotIcon iconForwardNo;
151: static ThotIcon iconH1;
152: static ThotIcon iconH1No;
153: static ThotIcon iconH2;
154: static ThotIcon iconH2No;
155: static ThotIcon iconH3;
156: static ThotIcon iconH3No;
157: static ThotIcon iconPrint;
158: static ThotIcon iconBullet;
159: static ThotIcon iconBulletNo;
160: static ThotIcon iconNum;
161: static ThotIcon iconNumNo;
162: static ThotIcon iconDL;
163: static ThotIcon iconDLNo;
164: static ThotIcon iconLink;
165: static ThotIcon iconLinkNo;
166: static ThotIcon iconTable;
167: static ThotIcon iconTableNo;
168: static ThotIcon iconBrowser;
169: static ThotIcon iconEditor;
1.311 cvs 170: static ThotIcon iconHome;
1.891 gully 171: #endif /* #ifdef _NOGUI */
172:
1.911 gully 173: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.891 gully 174: static ThotIcon stopR;
175: static ThotIcon stopN;
176: static ThotIcon iconSave;
177: static ThotIcon iconSaveNo;
178: static ThotIcon iconFind;
179: static ThotIcon iconReload;
180: static ThotIcon iconI;
181: static ThotIcon iconINo;
182: static ThotIcon iconB;
183: static ThotIcon iconBNo;
184: static ThotIcon iconT;
185: static ThotIcon iconTNo;
186: static ThotIcon iconImage;
187: static ThotIcon iconImageNo;
188: static ThotIcon iconBack;
189: static ThotIcon iconBackNo;
190: static ThotIcon iconForward;
191: static ThotIcon iconForwardNo;
192: static ThotIcon iconH1;
193: static ThotIcon iconH1No;
194: static ThotIcon iconH2;
195: static ThotIcon iconH2No;
196: static ThotIcon iconH3;
197: static ThotIcon iconH3No;
198: static ThotIcon iconPrint;
199: static ThotIcon iconBullet;
200: static ThotIcon iconBulletNo;
201: static ThotIcon iconNum;
202: static ThotIcon iconNumNo;
203: static ThotIcon iconDL;
204: static ThotIcon iconDLNo;
205: static ThotIcon iconLink;
206: static ThotIcon iconLinkNo;
207: static ThotIcon iconTable;
208: static ThotIcon iconTableNo;
209: static ThotIcon iconBrowser;
210: static ThotIcon iconEditor;
211: static ThotIcon iconHome;
1.911 gully 212: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.124 cvs 213:
1.916 cvs 214: #ifdef _WINGUI
1.168 cvs 215: #define stopR 0
1.276 cvs 216: #define stopN 0
1.168 cvs 217: #define iconBack 1
1.276 cvs 218: #define iconBackNo 1
1.168 cvs 219: #define iconForward 2
1.276 cvs 220: #define iconForwardNo 2
221: #define iconReload 3
222: #define iconSave 4
1.290 cvs 223: #define iconSaveNo 4
1.168 cvs 224: #define iconPrint 5
225: #define iconFind 6
1.276 cvs 226: #define iconI 7
227: #define iconINo 7
228: #define iconB 8
229: #define iconBNo 8
1.168 cvs 230: #define iconT 9
1.276 cvs 231: #define iconTNo 9
232: #define iconImage 11
233: #define iconImageNo 11
1.214 cvs 234: #define iconH1 12
1.276 cvs 235: #define iconH1No 12
236: #define iconH2 13
1.279 cvs 237: #define iconH2No 13
1.214 cvs 238: #define iconH3 14
1.279 cvs 239: #define iconH3No 14
1.214 cvs 240: #define iconBullet 15
1.279 cvs 241: #define iconBulletNo 15
1.214 cvs 242: #define iconNum 16
1.276 cvs 243: #define iconNumNo 16
1.214 cvs 244: #define iconDL 17
1.276 cvs 245: #define iconDLNo 17
1.214 cvs 246: #define iconLink 18
1.276 cvs 247: #define iconLinkNo 18
1.214 cvs 248: #define iconTable 19
1.276 cvs 249: #define iconTableNo 19
1.279 cvs 250: #define iconBrowser 23
1.649 cvs 251: #define iconEditor 26
1.311 cvs 252: #define iconHome 10
1.315 cvs 253:
254: extern int menu_item;
1.547 cvs 255: extern char LostPicturePath [512];
1.273 cvs 256:
257: #include "wininclude.h"
1.916 cvs 258: #endif /* _WINGUI */
1.568 cvs 259: #include "AHTURLTools_f.h"
1.18 cvs 260: #include "css_f.h"
261: #include "EDITORactions_f.h"
262: #include "EDITimage_f.h"
1.27 cvs 263: #include "EDITstyle_f.h"
1.565 cvs 264: #include "fetchXMLname_f.h"
1.652 vatton 265: #ifdef _SVG
1.653 vatton 266: #include "SVGedit_f.h"
1.652 vatton 267: #endif /* _SVG */
1.18 cvs 268: #include "HTMLactions_f.h"
1.66 cvs 269: #include "HTMLbook_f.h"
1.29 cvs 270: #include "HTMLedit_f.h"
1.57 cvs 271: #include "HTMLhistory_f.h"
1.43 cvs 272: #include "HTMLimage_f.h"
1.18 cvs 273: #include "HTMLsave_f.h"
1.920 vatton 274: #include "HTMLtable_f.h"
1.568 cvs 275: #include "html2thot_f.h"
276: #include "Mathedit_f.h"
1.304 cvs 277: #include "MENUconf_f.h"
1.568 cvs 278: #include "init_f.h"
279: #include "query_f.h"
1.289 cvs 280: #include "styleparser_f.h"
1.313 cvs 281: #include "templates_f.h"
1.568 cvs 282: #include "trans_f.h"
1.421 cvs 283: #include "transparse_f.h"
1.568 cvs 284: #include "UIcss_f.h"
1.575 cvs 285: #include "string.h"
1.477 cvs 286: #include "Xml2thot_f.h"
1.749 kirschpi 287: #ifdef DAV
1.909 gully 288: #define WEBDAV_EXPORT extern
1.749 kirschpi 289: #include "davlib.h"
290: #include "davlib_f.h"
291: #include "davlibRequests_f.h"
292: #include "davlibUI_f.h"
293: #endif /* DAV */
294:
1.273 cvs 295: extern void InitMathML ();
296:
1.222 cvs 297: /* the structure used for storing the context of the
1.751 vatton 298: GetAmayaDoc_callback function */
1.924 vatton 299: typedef struct _AmayaDoc_context
1.547 cvs 300: {
1.398 cvs 301: Document doc;
302: Document baseDoc;
303: ThotBool history;
304: ThotBool local_link;
1.547 cvs 305: char *target;
1.924 vatton 306: char *documentname; /* the document name */
307: char *initial_url; /* initial loaded URL */
1.547 cvs 308: char *form_data;
1.398 cvs 309: ClickEvent method;
1.824 vatton 310: ThotBool inNewWindow;
1.547 cvs 311: TTcbf *cbf;
312: void *ctx_cbf;
1.924 vatton 313: } AmayaDoc_context;
1.177 cvs 314:
1.222 cvs 315: /* the structure used for storing the context of the
316: Reload_callback function */
1.547 cvs 317: typedef struct _RELOAD_context
318: {
1.222 cvs 319: Document newdoc;
1.547 cvs 320: char *documentname;
321: char *form_data;
1.222 cvs 322: ClickEvent method;
1.245 cvs 323: int position; /* volume preceding the the first element to be shown */
324: int distance; /* distance from the top of the window to the top of this
325: element (% of the window height) */
1.222 cvs 326: } RELOAD_context;
1.96 cvs 327:
1.507 cvs 328: typedef enum
329: {
330: OpenDocBrowser,
331: HrefAttrBrowser,
1.626 vatton 332: DocSaveBrowser
1.507 cvs 333: } TypeBrowserFile;
334: TypeBrowserFile WidgetParent;
335:
1.626 vatton 336:
1.9 cvs 337: /*----------------------------------------------------------------------
1.552 kahan 338: DocumentMetaDataAlloc
339: Creates a DocumentMeta element and initializes it to its default
340: values.
341: ----------------------------------------------------------------------*/
1.586 cvs 342: DocumentMetaDataElement *DocumentMetaDataAlloc (void)
1.552 kahan 343: {
344: DocumentMetaDataElement *me;
345:
346: me = (DocumentMetaDataElement *) TtaGetMemory (sizeof (DocumentMetaDataElement));
347: memset ((void *) me, 0, sizeof (DocumentMetaDataElement));
348: me->method = CE_ABSOLUTE;
349: return (me);
350: }
351:
352: /*----------------------------------------------------------------------
1.471 kahan 353: DocumentMetaClear
354: Clears the dynamically allocated memory associated to a metadata
355: element. Doesn't free the element or clears any of its other elements.
356: ----------------------------------------------------------------------*/
1.586 cvs 357: void DocumentMetaClear (DocumentMetaDataElement *me)
1.471 kahan 358: {
1.602 kahan 359: if (!me)
360: return;
361:
1.471 kahan 362: if (me->form_data)
363: {
364: TtaFreeMemory (me->form_data);
365: me->form_data = NULL;
366: }
1.472 kahan 367: if (me->initial_url)
1.471 kahan 368: {
1.472 kahan 369: TtaFreeMemory (me->initial_url);
370: me->initial_url = NULL;
1.471 kahan 371: }
1.551 kahan 372: if (me->content_type)
373: {
374: TtaFreeMemory (me->content_type);
375: me->content_type = NULL;
376: }
377: if (me->charset)
378: {
379: TtaFreeMemory (me->charset);
380: me->charset = NULL;
381: }
1.562 kahan 382: if (me->content_length)
383: {
384: TtaFreeMemory (me->content_length);
385: me->content_length = NULL;
386: }
1.647 kahan 387: if (me->content_location)
388: {
389: TtaFreeMemory (me->content_location);
390: me->content_location = NULL;
391: }
1.781 kahan 392: if (me->full_content_location)
393: {
394: TtaFreeMemory (me->full_content_location);
395: me->full_content_location = NULL;
396: }
1.471 kahan 397: }
398:
1.549 cvs 399: /*----------------------------------------------------------------------
1.694 kahan 400: DocumentTypeString
401: Returns a string that represents the document type or the current
402: profile.
403: ----------------------------------------------------------------------*/
404: char * DocumentTypeString (Document document)
405: {
406: char *result;
1.695 kahan 407: ThotBool isXml;
1.694 kahan 408:
409: result = NULL;
410: switch (DocumentTypes[document])
411: {
412: case docText:
413: result = "Text file";
414: break;
415: case docImage:
416: result = "Image";
417: case docCSS:
1.695 kahan 418: result = "CSS style sheet";
1.694 kahan 419: break;
420: case docSource:
421: result = "Document source";
422: break;
423: case docAnnot:
424: result = "Annotation";
425: break;
426: case docLog:
1.695 kahan 427: result = "Log file";
1.694 kahan 428: break;
429: case docSVG:
430: result = "SVG";
431: break;
432: case docXml:
1.695 kahan 433: result = "XML";
1.694 kahan 434: break;
1.765 cvs 435: case docLibrary:
436: result = "HTML";
437: break;
1.694 kahan 438: default:
439: break;
440: }
441:
1.709 quint 442: if (!result && DocumentMeta[document]) /* try the profiles */
1.694 kahan 443: {
1.695 kahan 444: isXml = DocumentMeta[document]->xmlformat;
1.694 kahan 445: switch (TtaGetDocumentProfile (document))
446: {
1.695 kahan 447: case L_Other:
448: result = "Unknown";
449: break;
1.694 kahan 450: case L_Xhtml11:
451: result = "XHTML 1.1";
452: break;
453: case L_Basic:
454: result = "XHTML 1.0 Basic";
455: break;
456: case L_Strict:
1.695 kahan 457: if (isXml)
458: result = "XHTML 1.0 Strict";
459: else
1.696 cvs 460: result = "HTML Strict";
1.694 kahan 461: break;
462: case L_Transitional:
1.695 kahan 463: if (isXml)
464: result = "XHTML 1.0 Transitional";
465: else
1.696 cvs 466: result = "HTML Transitional";
1.694 kahan 467: break;
468: case L_MathML:
1.695 kahan 469: result = "MathML";
1.694 kahan 470: break;
471: }
472: }
473:
474: return (result);
475: }
476:
477: /*----------------------------------------------------------------------
1.549 cvs 478: DocumentInfo
479: Displays the document informations given by the header
480: ----------------------------------------------------------------------*/
1.574 cvs 481: void DocumentInfo (Document document, View view)
1.549 cvs 482: {
1.915 gully 483: #if defined(_MOTIF) || defined(_GTK)
1.575 cvs 484: char *content;
1.562 kahan 485:
1.554 cvs 486: /* Main form */
1.550 cvs 487: TtaNewSheet (BaseDialog + DocInfoForm, TtaGetViewFrame (document, 1),
1.574 cvs 488: "Document Information",
1.694 kahan 489: 0, NULL, FALSE, 8, 'L', D_DONE);
1.553 kahan 490:
1.554 cvs 491: /* Document information labels */
492: TtaNewLabel (BaseDialog + DocInfoTitle1,
1.553 kahan 493: BaseDialog + DocInfoForm,
1.554 cvs 494: "________________");
1.553 kahan 495:
1.554 cvs 496: /* Document URL */
1.648 kahan 497: TtaNewLabel (BaseDialog + DocInfoURLTitle,
1.553 kahan 498: BaseDialog + DocInfoForm,
1.849 vatton 499: TtaGetMessage (AMAYA, AM_HREF_VALUE));
1.553 kahan 500:
1.694 kahan 501: /* Document type */
502: TtaNewLabel (BaseDialog + DocInfoDocTypeTitle,
503: BaseDialog + DocInfoForm,
1.697 kahan 504: "Document Type");
1.694 kahan 505:
1.554 cvs 506: /* Mime Type */
1.550 cvs 507: TtaNewLabel (BaseDialog + DocInfoMimeTypeTitle,
508: BaseDialog + DocInfoForm,
1.697 kahan 509: "MIME Type");
1.554 cvs 510: /* Charset */
511: TtaNewLabel (BaseDialog + DocInfoCharsetTitle,
512: BaseDialog + DocInfoForm,
1.697 kahan 513: "Charset");
1.554 cvs 514:
515: /* Content Length */
516: TtaNewLabel (BaseDialog + DocInfoContentTitle,
517: BaseDialog + DocInfoForm,
1.697 kahan 518: "Content Length");
1.554 cvs 519:
1.647 kahan 520: /* Content Location */
1.648 kahan 521: TtaNewLabel (BaseDialog + DocInfoLocationTitle,
1.647 kahan 522: BaseDialog + DocInfoForm,
1.697 kahan 523: "Content Location");
1.647 kahan 524:
1.554 cvs 525: TtaNewLabel (BaseDialog + DocInfoTitle2,
526: BaseDialog + DocInfoForm,
527: "________________");
528:
529: /* Document information contents */
530: TtaNewLabel (BaseDialog + DocInfoContent1,
531: BaseDialog + DocInfoForm,
1.559 cvs 532: "___________________________________________");
1.554 cvs 533: /* Document URL */
534: if (DocumentURLs[document] != NULL)
1.574 cvs 535: content = DocumentURLs[document];
1.554 cvs 536: else
1.633 kahan 537: content = TtaGetMessage (AMAYA, AM_UNKNOWN);
1.648 kahan 538: TtaNewLabel (BaseDialog + DocInfoURL,
1.694 kahan 539: BaseDialog + DocInfoForm, content);
540:
541: /* Document Type */
542: content = DocumentTypeString (document);
543: if (!content)
544: content = TtaGetMessage (AMAYA, AM_UNKNOWN);
545: TtaNewLabel (BaseDialog + DocInfoDocType,
1.554 cvs 546: BaseDialog + DocInfoForm, content);
547:
548: /* Mime Type */
1.602 kahan 549: if (DocumentMeta[document] && DocumentMeta[document]->content_type != NULL)
1.574 cvs 550: content = DocumentMeta[document]->content_type;
1.554 cvs 551: else
1.633 kahan 552: content = TtaGetMessage (AMAYA, AM_UNKNOWN);
1.550 cvs 553: TtaNewLabel (BaseDialog + DocInfoMimeType,
1.554 cvs 554: BaseDialog + DocInfoForm, content);
1.550 cvs 555:
1.554 cvs 556: /* Charset */
1.602 kahan 557: if (DocumentMeta[document] && DocumentMeta[document]->charset != NULL)
1.562 kahan 558: content = DocumentMeta[document]->charset;
1.554 cvs 559: else
1.633 kahan 560: content = TtaGetMessage (AMAYA, AM_UNKNOWN);
1.554 cvs 561: TtaNewLabel (BaseDialog + DocInfoCharset,
562: BaseDialog + DocInfoForm, content);
563:
564: /* Content Length */
1.602 kahan 565: if (DocumentMeta[document] && DocumentMeta[document]->content_length != NULL)
1.562 kahan 566: content = DocumentMeta[document]->content_length;
567: else
1.633 kahan 568: content = TtaGetMessage (AMAYA, AM_UNKNOWN);
1.554 cvs 569: TtaNewLabel (BaseDialog + DocInfoContent,
570: BaseDialog + DocInfoForm, content);
571:
1.647 kahan 572: /* Content Location */
1.648 kahan 573: if (DocumentMeta[document]
1.781 kahan 574: && DocumentMeta[document]->full_content_location != NULL)
575: content = DocumentMeta[document]->full_content_location;
1.647 kahan 576: else
577: content = TtaGetMessage (AMAYA, AM_UNKNOWN);
1.648 kahan 578: TtaNewLabel (BaseDialog + DocInfoLocation,
1.647 kahan 579: BaseDialog + DocInfoForm, content);
580:
1.562 kahan 581: /* end of dialogue */
1.554 cvs 582: TtaNewLabel (BaseDialog + DocInfoContent2,
1.550 cvs 583: BaseDialog + DocInfoForm,
1.559 cvs 584: "___________________________________________");
1.551 kahan 585:
1.550 cvs 586: TtaSetDialoguePosition ();
1.554 cvs 587: TtaShowDialogue (BaseDialog + DocInfoForm, TRUE);
1.553 kahan 588:
1.915 gully 589: #endif /* #if defined(_MOTIF) || defined(_GTK) */
1.891 gully 590:
1.916 cvs 591: #ifdef _WINGUI
1.553 kahan 592: CreateDocumentInfoDlgWindow (TtaGetViewFrame (document, view),
593: document);
1.916 cvs 594: #endif /* _WINGUI */
1.549 cvs 595: }
1.471 kahan 596:
597: /*----------------------------------------------------------------------
1.9 cvs 598: IsDocumentLoaded returns the document identification if the
599: corresponding document is already loaded or 0.
600: ----------------------------------------------------------------------*/
1.586 cvs 601: Document IsDocumentLoaded (char *documentURL, char *form_data)
1.6 cvs 602: {
1.398 cvs 603: int i;
604: ThotBool found;
1.293 cvs 605:
606: if (!documentURL)
607: return ((Document) None);
1.222 cvs 608:
1.293 cvs 609: i = 1;
610: found = FALSE;
611: /* look for the URL into the list of downloaded documents */
612: while (!found && i < DocumentTableLength)
613: {
614: if (DocumentURLs[i])
615: {
616: /* compare the url */
1.547 cvs 617: found = (!strcmp (documentURL, DocumentURLs[i]) ||
1.799 vatton 618: (DocumentMeta[i]->initial_url &&
619: !strcmp (documentURL, DocumentMeta[i]->initial_url)));
1.293 cvs 620: /* compare the form_data */
1.398 cvs 621: if (found && (!((!form_data && !DocumentMeta[i]->form_data) ||
1.293 cvs 622: (form_data && DocumentMeta[i]->form_data &&
1.547 cvs 623: !strcmp (form_data, DocumentMeta[i]->form_data)))))
1.293 cvs 624: found = FALSE;
625: }
626: if (!found)
627: i++;
628: }
629:
630: if (found)
631: /* document is found */
632: return ((Document) i);
633: else
1.405 cvs 634: /* document is not found */
1.293 cvs 635: return ((Document) None);
1.6 cvs 636: }
637:
1.146 cvs 638: /*----------------------------------------------------------------------
639: CanReplaceCurrentDocument
1.892 cvs 640: Return TRUE if the document has not been modified
641: and if the user agrees to loose the changes he/she has made.
1.146 cvs 642: ----------------------------------------------------------------------*/
1.586 cvs 643: ThotBool CanReplaceCurrentDocument (Document doc, View view)
1.146 cvs 644: {
1.309 cvs 645: ThotBool ret;
1.146 cvs 646:
647: ret = TRUE;
1.558 cvs 648: if (TtaIsDocumentModified (doc) ||
1.882 vatton 649: (!Synchronizing &&
650: DocumentTypes[doc] != docLog && DocumentSource[doc] &&
1.558 cvs 651: TtaIsDocumentModified (DocumentSource[doc])))
652: {
653: InitConfirm (doc, view, TtaGetMessage (AMAYA, AM_DOC_MODIFIED));
654: if (UserAnswer)
655: {
656: TtaSetDocumentUnmodified (doc);
657: if (DocumentSource[doc])
658: TtaSetDocumentUnmodified (DocumentSource[doc]);
1.892 cvs 659: /* remove the corrsponding auto saved doc */
1.900 vatton 660: RemoveAutoSavedDoc (doc);
1.558 cvs 661: }
662: else
663: ret = FALSE;
1.146 cvs 664: }
665: return ret;
666: }
1.6 cvs 667:
1.9 cvs 668: /*----------------------------------------------------------------------
669: ExtractParameters extract parameters from document nane.
670: ----------------------------------------------------------------------*/
1.878 vatton 671: void ExtractParameters (char *aName, char *parameters)
1.6 cvs 672: {
1.878 vatton 673: int lg, i;
674: char *ptr;
675: char *oldptr;
1.6 cvs 676:
1.10 cvs 677: if (!parameters || !aName)
1.137 cvs 678: /* bad parameters */
679: return;
1.6 cvs 680:
1.547 cvs 681: parameters[0] = EOS;
682: lg = strlen (aName);
1.10 cvs 683: if (lg)
684: {
685: /* the name is not empty */
686: oldptr = ptr = &aName[0];
687: do
688: {
1.547 cvs 689: ptr = strrchr (oldptr, '?');
1.10 cvs 690: if (ptr)
691: oldptr = &ptr[1];
692: }
693: while (ptr);
1.6 cvs 694:
1.10 cvs 695: i = (int) (oldptr) - (int) (aName); /* name length */
696: if (i > 1)
697: {
1.547 cvs 698: aName[i - 1] = EOS;
1.10 cvs 699: if (i != lg)
1.547 cvs 700: strcpy (parameters, oldptr);
1.10 cvs 701: }
702: }
1.6 cvs 703: }
704:
1.451 kahan 705: /*----------------------------------------------------------------------
706: FileExistTarget
707: Removes the URL target separator ('#') before verifying if a file
708: exists.
709: ----------------------------------------------------------------------*/
1.547 cvs 710: static ThotBool FileExistTarget (char *filename)
1.451 kahan 711: {
1.547 cvs 712: char *ptr;
1.451 kahan 713: ThotBool result;
714:
1.547 cvs 715: ptr = strrchr (filename, '#');
1.451 kahan 716: if (ptr)
1.547 cvs 717: *ptr = EOS;
1.451 kahan 718: result = TtaFileExist (filename);
719: if (ptr)
1.547 cvs 720: *ptr = '#';
1.451 kahan 721: return result;
722: }
1.6 cvs 723:
1.9 cvs 724: /*----------------------------------------------------------------------
1.143 cvs 725: SetArrowButton
726: Change the appearance of the Back (if back == TRUE) or Forward button
727: for a given document.
728: ----------------------------------------------------------------------*/
1.692 vatton 729: void SetArrowButton (Document document, ThotBool back, ThotBool on)
1.143 cvs 730: {
1.171 cvs 731: int index;
1.309 cvs 732: ThotBool state;
1.276 cvs 733: ThotIcon picture;
1.143 cvs 734:
1.171 cvs 735: if (back)
736: {
1.143 cvs 737: index = 2;
1.171 cvs 738: if (on)
739: {
740: state = TRUE;
1.269 cvs 741: picture = iconBack;
742: TtaSetItemOn (document, 1, File, BBack);
1.171 cvs 743: }
744: else
745: {
1.169 cvs 746: state = FALSE;
1.171 cvs 747: picture = iconBackNo;
1.269 cvs 748: TtaSetItemOff (document, 1, File, BBack);
1.171 cvs 749: }
750: }
751: else
752: {
753: index = 3;
754: if (on)
755: {
756: state = TRUE;
757: picture = iconForward;
1.269 cvs 758: TtaSetItemOn (document, 1, File, BForward);
1.171 cvs 759: }
760: else
761: {
762: state = FALSE;
763: picture = iconForwardNo;
1.269 cvs 764: TtaSetItemOff (document, 1, File, BForward);
1.171 cvs 765: }
766: }
1.276 cvs 767: TtaChangeButton (document, 1, index, picture, state);
1.171 cvs 768: }
769:
770: /*----------------------------------------------------------------------
771: ResetStop resets the stop button state
772: ----------------------------------------------------------------------*/
1.692 vatton 773: void ResetStop (Document document)
1.171 cvs 774: {
1.836 vatton 775: if (document)
1.171 cvs 776: {
1.836 vatton 777: if (FilesLoading[document] != 0)
778: FilesLoading[document]--;
779: if (FilesLoading[document] == 0)
780: /* The last object associated to the document has been loaded */
1.171 cvs 781: {
1.836 vatton 782: if (TtaGetViewFrame (document, 1) != 0)
783: /* this document is displayed */
784: {
785: if(!(DocNetworkStatus[document] & AMAYA_NET_ERROR) &&
786: (DocNetworkStatus[document] & AMAYA_NET_ACTIVE))
787: /* if there was no error message, display the LOADED message */
788: TtaSetStatus (document, 1,
789: TtaGetMessage (AMAYA, AM_DOCUMENT_LOADED), NULL);
790: TtaChangeButton (document, 1, iStop, stopN, FALSE);
1.851 cheyroul 791: #ifdef _GL
792: TtaPlay (document, 1);
793: #endif /* _GL */
1.836 vatton 794: }
795: DocNetworkStatus[document] = AMAYA_NET_INACTIVE;
1.171 cvs 796: }
797: }
1.143 cvs 798: }
799:
800: /*----------------------------------------------------------------------
1.9 cvs 801: ActiveTransfer initialize the current transfer
802: ----------------------------------------------------------------------*/
1.836 vatton 803: void ActiveTransfer (Document document)
1.6 cvs 804: {
1.836 vatton 805: if (document)
806: {
807: DocNetworkStatus[document] = AMAYA_NET_ACTIVE;
808: FilesLoading[document] = 1;
809: if (TtaGetViewFrame (document, 1) != 0)
810: /* this document is displayed */
811: TtaChangeButton (document, 1, iStop, stopR, TRUE);
812: }
1.6 cvs 813: }
814:
1.73 cvs 815: /*----------------------------------------------------------------------
1.192 cvs 816: SetStopButton Activates the stop button if it's turned off
817: ----------------------------------------------------------------------*/
1.836 vatton 818: void SetStopButton (Document document)
1.192 cvs 819: {
1.836 vatton 820: if (document)
1.396 cvs 821: {
1.836 vatton 822: if (document != DocBook)
823: {
824: if (DocNetworkStatus[document] != AMAYA_NET_ACTIVE)
825: DocNetworkStatus[document] = AMAYA_NET_ACTIVE;
826: if (FilesLoading[document] == 0)
827: FilesLoading[document] = 1;
828: }
829:
830: if (TtaGetViewFrame (document, 1) != 0)
831: /* this document is displayed */
832: TtaChangeButton (document, 1, iStop, stopR, TRUE);
1.396 cvs 833: }
1.192 cvs 834: }
1.249 cvs 835:
836:
837: /*----------------------------------------------------------------------
838: SetFormReadWrite
839: Set ReadWrite access to input elements
840: ----------------------------------------------------------------------*/
1.836 vatton 841: static void SetFormReadWrite (Element el, Document doc)
1.249 cvs 842: {
1.545 cvs 843: ElementType elType;
844: Element child, next;
1.249 cvs 845:
1.836 vatton 846: while (el)
1.249 cvs 847: {
848: /* look at all elements within this form */
849: elType = TtaGetElementType (el);
850: child = TtaGetFirstChild (el);
851: next = el;
852: TtaNextSibling (&next);
853: switch (elType.ElTypeNum)
854: {
855: case HTML_EL_Input:
856: case HTML_EL_Text_Input:
857: case HTML_EL_Password_Input:
858: case HTML_EL_File_Input:
1.351 cvs 859: case HTML_EL_Option:
1.249 cvs 860: case HTML_EL_Text_Area: /* it's a Text_Area */
861: TtaSetAccessRight (child, ReadWrite, doc);
862: child = NULL;
863: break;
864: default:
865: break;
866: }
867: if (child != NULL)
868: SetFormReadWrite (child, doc);
869: el = next;
870: }
871: }
872:
873:
874: /*----------------------------------------------------------------------
1.349 cvs 875: SetDocumentReadOnly
1.249 cvs 876: Set the whole document in ReadOnly mode except input elements
877: ----------------------------------------------------------------------*/
1.792 vatton 878: static void SetDocumentReadOnly (Document doc)
1.249 cvs 879: {
1.545 cvs 880: ElementType elType;
881: Element el, elForm;
1.249 cvs 882:
883: TtaSetDocumentAccessMode (doc, 0);
884: el = TtaGetMainRoot (doc);
885: elType = TtaGetElementType (el);
1.547 cvs 886: if (!strcmp (TtaGetSSchemaName (elType.ElSSchema), "HTML"))
1.249 cvs 887: {
1.291 cvs 888: elType.ElTypeNum = HTML_EL_Form;
889: elForm = TtaSearchTypedElement (elType, SearchForward, el);
890: while (elForm != NULL)
891: {
892: /* there is a form */
893: el = TtaGetFirstChild (elForm);
894: if (el != NULL)
895: SetFormReadWrite (el, doc);
896: elForm = TtaSearchTypedElement (elType, SearchForward, elForm);
897: }
1.249 cvs 898: }
899: }
1.407 cvs 900:
1.310 cvs 901: /*----------------------------------------------------------------------
1.407 cvs 902: Update the save button and corresponding menu entry according to the
903: document status.
1.310 cvs 904: ----------------------------------------------------------------------*/
1.791 vatton 905: void DocStatusUpdate (Document doc, ThotBool modified)
1.310 cvs 906: {
1.352 cvs 907: Document otherDoc;
908:
1.791 vatton 909: if (modified && TtaGetDocumentAccessMode (doc))
1.479 cvs 910: /* the document has been modified and is not in Read-Only mode */
1.310 cvs 911: {
1.791 vatton 912: TtaSetItemOn (doc, 1, File, BSave);
913: TtaChangeButton (doc, 1, iSave, iconSave, TRUE);
1.479 cvs 914: /* if we have a pair source/structured document allow synchronization */
1.791 vatton 915: otherDoc = DocumentSource[doc];
1.352 cvs 916: if (!otherDoc)
1.791 vatton 917: otherDoc = GetDocFromSource (doc);
1.352 cvs 918: if (otherDoc)
919: {
1.791 vatton 920: TtaSetItemOn (doc, 1, File, BSynchro);
1.352 cvs 921: TtaSetItemOn (otherDoc, 1, File, BSynchro);
922: }
1.791 vatton 923: else if (DocumentTypes[doc] == docCSS)
924: TtaSetItemOn (doc, 1, File, BSynchro);
1.310 cvs 925: }
926: else
1.880 quint 927: /* the document is no longer modified */
1.310 cvs 928: {
1.880 quint 929: TtaSetItemOff (doc, 1, File, BSave);
930: TtaChangeButton (doc, 1, iSave, iconSaveNo, FALSE);
1.791 vatton 931: if (TtaIsDocumentUpdated (doc))
932: {
933: /* if we have a pair source/structured document allow synchronization */
934: otherDoc = DocumentSource[doc];
935: if (!otherDoc)
936: otherDoc = GetDocFromSource (doc);
937: if (otherDoc)
938: {
939: TtaSetItemOff (doc, 1, File, BSynchro);
940: TtaSetItemOff (otherDoc, 1, File, BSynchro);
941: }
942: else if (DocumentTypes[doc] == docCSS)
943: TtaSetItemOff (doc, 1, File, BSynchro);
944: }
1.310 cvs 945: }
946: }
1.249 cvs 947:
948: /*----------------------------------------------------------------------
1.518 cvs 949: UpdateBrowserMenus
1.598 cvs 950: Update windows menus for the Browser mode
1.518 cvs 951: ----------------------------------------------------------------------*/
1.791 vatton 952: static void UpdateBrowserMenus (Document doc)
1.518 cvs 953: {
1.545 cvs 954: View view;
1.518 cvs 955:
1.598 cvs 956: TtaChangeButton (doc, 1, iEditor, iconBrowser, TRUE);
957: TtaSetToggleItem (doc, 1, Edit_, TEditMode, FALSE);
1.518 cvs 958:
1.598 cvs 959: TtaSetItemOff (doc, 1, Edit_, BUndo);
960: TtaSetItemOff (doc, 1, Edit_, BRedo);
961: TtaSetItemOff (doc, 1, Edit_, BCut);
962: TtaSetItemOff (doc, 1, Edit_, BPaste);
963: TtaSetItemOff (doc, 1, Edit_, BClear);
1.518 cvs 964:
1.598 cvs 965: if (DocumentTypes[doc] == docHTML ||
966: DocumentTypes[doc] == docSVG ||
967: DocumentTypes[doc] == docMath ||
968: DocumentTypes[doc] == docXml ||
969: DocumentTypes[doc] == docImage)
1.518 cvs 970: {
1.735 cvs 971: TtaSetItemOn (doc, 1, Views, TShowMapAreas);
972: TtaSetItemOn (doc, 1, Views, TShowTargets);
973: TtaSetItemOn (doc, 1, Views, BShowAlternate);
974: TtaSetItemOn (doc, 1, Views, BShowToC);
975: TtaSetItemOn (doc, 1, Views, BShowStructure);
976: TtaSetItemOn (doc, 1, Views, BShowLinks);
977: TtaSetItemOn (doc, 1, Views, BShowSource);
978: if (DocumentTypes[doc] == docXml)
979: {
980: TtaSetMenuOff (doc, 1, Annotations_);
981: TtaSetItemOff (doc, 1, Views, TShowMapAreas);
982: TtaSetItemOff (doc, 1, Views, TShowTargets);
983: TtaSetItemOff (doc, 1, Views, BShowAlternate);
984: TtaSetItemOff (doc, 1, Views, BShowToC);
985: }
1.598 cvs 986: TtaChangeButton (doc, 1, iI, iconINo, FALSE);
987: TtaChangeButton (doc, 1, iB, iconBNo, FALSE);
988: TtaChangeButton (doc, 1, iT, iconTNo, FALSE);
989: TtaChangeButton (doc, 1, iImage, iconImageNo, FALSE);
990: TtaChangeButton (doc, 1, iH1, iconH1No, FALSE);
991: TtaChangeButton (doc, 1, iH2, iconH2No, FALSE);
992: TtaChangeButton (doc, 1, iH3, iconH3No, FALSE);
993: TtaChangeButton (doc, 1,iBullet, iconBulletNo, FALSE);
994: TtaChangeButton (doc, 1,iNum, iconNumNo, FALSE);
995: TtaChangeButton (doc, 1,iDL, iconDLNo, FALSE);
996: TtaChangeButton (doc, 1, iLink, iconLinkNo, FALSE);
997: TtaChangeButton (doc, 1, iTable, iconTableNo, FALSE);
998: SwitchIconMath (doc, 1, FALSE);
1.652 vatton 999: #ifdef _SVG
1.598 cvs 1000: SwitchIconGraph (doc, 1, FALSE);
1.799 vatton 1001: SwitchIconLibrary (doc, 1, FALSE);
1.847 cheyroul 1002: #ifdef _GL
1.846 cheyroul 1003: SwitchIconAnim (doc, 1, FALSE);
1.847 cheyroul 1004: #endif /*_GL*/
1.930 vatton 1005: #endif /* _SVG */
1.598 cvs 1006: TtaSetItemOff (doc, 1, Edit_, BSpellCheck);
1007: TtaSetItemOff (doc, 1, Edit_, BTransform);
1008: TtaSetMenuOff (doc, 1, Types);
1.808 vatton 1009: TtaSetMenuOff (doc, 1, XMLTypes);
1.598 cvs 1010: TtaSetMenuOff (doc, 1, Links);
1011: TtaSetMenuOff (doc, 1, Style);
1012: TtaSetItemOff (doc, 1, Special, BMakeBook);
1.518 cvs 1013:
1.598 cvs 1014: view = TtaGetViewFromName (doc, "Structure_view");
1015: if (view != 0 && TtaIsViewOpen (doc, view))
1.518 cvs 1016: {
1.598 cvs 1017: TtaSetItemOff (doc, view, Edit_, BCut);
1018: TtaSetItemOff (doc, view, Edit_, BPaste);
1019: TtaSetItemOff (doc, view, Edit_, BClear);
1020: TtaSetItemOff (doc, view, Edit_, BSpellCheck);
1021: TtaSetItemOff (doc, view, Edit_, BTransform);
1022: TtaSetMenuOff (doc, view, StructTypes);
1023: TtaSetMenuOff (doc, view, Types);
1.808 vatton 1024: TtaSetMenuOff (doc, view, XMLTypes);
1.518 cvs 1025: }
1.598 cvs 1026: view = TtaGetViewFromName (doc, "Alternate_view");
1027: if (view != 0 && TtaIsViewOpen (doc, view))
1.518 cvs 1028: {
1.598 cvs 1029: TtaSetItemOff (doc, view, Edit_, BCut);
1030: TtaSetItemOff (doc, view, Edit_, BPaste);
1031: TtaSetItemOff (doc, view, Edit_, BClear);
1032: TtaSetItemOff (doc, view, Edit_, BSpellCheck);
1033: TtaSetMenuOff (doc, view, StructTypes);
1034: TtaSetMenuOff (doc, view, Types);
1.808 vatton 1035: TtaSetMenuOff (doc, view, XMLTypes);
1.518 cvs 1036: }
1.598 cvs 1037: view = TtaGetViewFromName (doc, "Links_view");
1038: if (view != 0 && TtaIsViewOpen (doc, view))
1.518 cvs 1039: {
1.598 cvs 1040: TtaSetItemOff (doc, view, Edit_, BCut);
1041: TtaSetItemOff (doc, view, Edit_, BPaste);
1042: TtaSetItemOff (doc, view, Edit_, BClear);
1043: TtaSetItemOff (doc, view, Edit_, BSpellCheck);
1044: TtaSetItemOff (doc, view, Edit_, BTransform);
1045: TtaSetMenuOff (doc, view, Types);
1.808 vatton 1046: TtaSetMenuOff (doc, view, XMLTypes);
1.518 cvs 1047: }
1.598 cvs 1048: view = TtaGetViewFromName (doc, "Table_of_contents");
1049: if (view != 0 && TtaIsViewOpen (doc, view))
1.518 cvs 1050: {
1.598 cvs 1051: TtaSetItemOff (doc, view, Edit_, BCut);
1052: TtaSetItemOff (doc, view, Edit_, BPaste);
1053: TtaSetItemOff (doc, view, Edit_, BClear);
1054: TtaSetItemOff (doc, view, Edit_, BSpellCheck);
1055: TtaSetItemOff (doc, view, Edit_, BTransform);
1056: TtaSetMenuOff (doc, view, Types);
1.808 vatton 1057: TtaSetMenuOff (doc, view, XMLTypes);
1.518 cvs 1058: }
1059: }
1060: }
1061:
1062: /*----------------------------------------------------------------------
1063: UpdateEditorMenus
1064: Update windows menus for the Editor mode
1065: ----------------------------------------------------------------------*/
1.808 vatton 1066: static void UpdateEditorMenus (Document doc)
1.518 cvs 1067: {
1.545 cvs 1068: View view;
1.932 vatton 1069: int profile;
1070: ThotBool isXhtml11;
1.527 cvs 1071:
1.932 vatton 1072: profile = TtaGetDocumentProfile (doc);
1073: isXhtml11 = (DocumentMeta[doc] && DocumentMeta[doc]->xmlformat &&
1074: profile != L_Strict && profile != L_Basic);
1.689 cvs 1075: TtaUpdateMenus (doc, 1, ReadOnlyDocument[doc]);
1.598 cvs 1076: TtaChangeButton (doc, 1, iEditor, iconEditor, TRUE);
1077: TtaSetToggleItem (doc, 1, Edit_, TEditMode, TRUE);
1078: TtaSetItemOn (doc, 1, Edit_, BUndo);
1079: TtaSetItemOn (doc, 1, Edit_, BRedo);
1080: TtaSetItemOn (doc, 1, Edit_, BCut);
1081: TtaSetItemOn (doc, 1, Edit_, BPaste);
1082: TtaSetItemOn (doc, 1, Edit_, BClear);
1.791 vatton 1083:
1.598 cvs 1084: if (DocumentTypes[doc] == docHTML ||
1085: DocumentTypes[doc] == docSVG ||
1086: DocumentTypes[doc] == docMath ||
1.735 cvs 1087: DocumentTypes[doc] == docXml ||
1.598 cvs 1088: DocumentTypes[doc] == docImage)
1.518 cvs 1089: {
1.598 cvs 1090: TtaSetItemOn (doc, 1, Edit_, BSpellCheck);
1091: TtaSetMenuOn (doc, 1, Style);
1.932 vatton 1092: if (DocumentTypes[doc] == docMath)
1093: {
1094: SwitchIconMath (doc, 1, TRUE);
1095: TtaSetMenuOn (doc, 1, XMLTypes);
1096: TtaSetItemOn (doc, 1, Edit_, BTransform);
1097: }
1098: else
1.598 cvs 1099: {
1.932 vatton 1100: if (DocumentTypes[doc] == docHTML)
1101: {
1102: if (isXhtml11)
1103: TtaSetMenuOn (doc, 1, XMLTypes);
1104: TtaSetItemOn (doc, 1, Special, TSectionNumber);
1105: TtaSetItemOn (doc, 1, Special, BMakeBook);
1106: TtaSetItemOn (doc, 1, Edit_, BTransform);
1107: }
1108: else if (DocumentTypes[doc] != docImage)
1.808 vatton 1109: TtaSetMenuOn (doc, 1, XMLTypes);
1.932 vatton 1110: TtaSetMenuOn (doc, 1, Types);
1111: TtaSetMenuOn (doc, 1, Links);
1.598 cvs 1112: TtaChangeButton (doc, 1, iI, iconI, TRUE);
1113: TtaChangeButton (doc, 1, iB, iconB, TRUE);
1114: TtaChangeButton (doc, 1, iT, iconT, TRUE);
1115: TtaChangeButton (doc, 1, iImage, iconImage, TRUE);
1116: TtaChangeButton (doc, 1, iH1, iconH1, TRUE);
1117: TtaChangeButton (doc, 1, iH2, iconH2, TRUE);
1118: TtaChangeButton (doc, 1, iH3, iconH3, TRUE);
1119: TtaChangeButton (doc, 1, iBullet, iconBullet, TRUE);
1120: TtaChangeButton (doc, 1, iNum, iconNum, TRUE);
1121: TtaChangeButton (doc, 1, iDL, iconDL, TRUE);
1122: TtaChangeButton (doc, 1, iTable, iconTable, TRUE);
1.932 vatton 1123: TtaChangeButton (doc, 1, iLink, iconLink, TRUE);
1.808 vatton 1124: SwitchIconMath (doc, 1, TRUE);
1.652 vatton 1125: #ifdef _SVG
1.598 cvs 1126: SwitchIconGraph (doc, 1, TRUE);
1.799 vatton 1127: SwitchIconLibrary (doc, 1, TRUE);
1.884 vatton 1128: SwitchIconAnim (doc, 1, TRUE);
1.847 cheyroul 1129: #ifdef _GL
1.884 vatton 1130: SwitchIconAnimPlay (doc, 1, TRUE);
1.847 cheyroul 1131: #endif /*_GL*/
1.799 vatton 1132: #endif /* _SVG */
1.598 cvs 1133: }
1.518 cvs 1134:
1.598 cvs 1135: view = TtaGetViewFromName (doc, "Structure_view");
1136: if (view != 0 && TtaIsViewOpen (doc, view))
1.518 cvs 1137: {
1.598 cvs 1138: TtaSetItemOn (doc, view, Edit_, BCut);
1139: TtaSetItemOn (doc, view, Edit_, BPaste);
1140: TtaSetItemOn (doc, view, Edit_, BClear);
1141: TtaSetItemOn (doc, view, Edit_, BSpellCheck);
1142: TtaSetItemOn (doc, view, Edit_, BTransform);
1.932 vatton 1143: if (DocumentTypes[doc] != docMath)
1.735 cvs 1144: {
1.808 vatton 1145: TtaSetMenuOn (doc, view, StructTypes);
1146: TtaSetMenuOn (doc, view, Types);
1.932 vatton 1147: if (DocumentTypes[doc] != docHTML || isXhtml11)
1148: TtaSetMenuOn (doc, view, XMLTypes);
1.735 cvs 1149: }
1.518 cvs 1150: }
1.598 cvs 1151: view = TtaGetViewFromName (doc, "Alternate_view");
1152: if (view != 0 && TtaIsViewOpen (doc, view))
1.518 cvs 1153: {
1.598 cvs 1154: TtaSetItemOn (doc, view, Edit_, BCut);
1155: TtaSetItemOn (doc, view, Edit_, BPaste);
1156: TtaSetItemOn (doc, view, Edit_, BClear);
1157: TtaSetItemOn (doc, view, Edit_, BSpellCheck);
1158: TtaSetMenuOn (doc, view, StructTypes);
1.932 vatton 1159: if (isXhtml11)
1.808 vatton 1160: TtaSetMenuOn (doc, view, XMLTypes);
1.518 cvs 1161: }
1.598 cvs 1162: view = TtaGetViewFromName (doc, "Links_view");
1163: if (view != 0 && TtaIsViewOpen (doc, view))
1.518 cvs 1164: {
1.598 cvs 1165: TtaSetItemOn (doc, view, Edit_, BCut);
1166: TtaSetItemOn (doc, view, Edit_, BPaste);
1167: TtaSetItemOn (doc, view, Edit_, BClear);
1168: TtaSetItemOn (doc, view, Edit_, BSpellCheck);
1169: TtaSetItemOn (doc, view, Edit_, BTransform);
1.932 vatton 1170: if (DocumentTypes[doc] != docMath)
1171: {
1172: TtaSetMenuOn (doc, view, StructTypes);
1173: TtaSetMenuOn (doc, view, Types);
1174: if (DocumentTypes[doc] != docHTML || isXhtml11)
1175: TtaSetMenuOn (doc, view, XMLTypes);
1176: }
1.518 cvs 1177: }
1.598 cvs 1178: view = TtaGetViewFromName (doc, "Table_of_contents");
1179: if (view != 0 && TtaIsViewOpen (doc, view))
1.518 cvs 1180: {
1.598 cvs 1181: TtaSetItemOn (doc, view, Edit_, BCut);
1182: TtaSetItemOn (doc, view, Edit_, BPaste);
1183: TtaSetItemOn (doc, view, Edit_, BClear);
1184: TtaSetItemOn (doc, view, Edit_, BSpellCheck);
1185: TtaSetItemOn (doc, view, Edit_, BTransform);
1.932 vatton 1186: if (isXhtml11)
1.808 vatton 1187: TtaSetMenuOn (doc, view, XMLTypes);
1.518 cvs 1188: }
1189: }
1190: }
1191:
1192: /*----------------------------------------------------------------------
1.538 cvs 1193: ChangeToEdotirMode
1194: Similar to Editor mode except for the variable ReadOnlyDocument
1195: ----------------------------------------------------------------------*/
1.598 cvs 1196: void ChangeToEditorMode (Document doc)
1.538 cvs 1197: {
1198: Document docSel;
1199:
1.666 vatton 1200: if (DocumentTypes[doc] == docXml)
1201: /* don't allow editing mode for XML document today */
1202: return;
1.538 cvs 1203: docSel = TtaGetSelectedDocument ();
1.598 cvs 1204: if (docSel == doc)
1205: TtaUnselect (doc);
1.538 cvs 1206:
1207: /* =============> The document is in Read-Write mode now */
1208: /* change the document status */
1.598 cvs 1209: if (TtaIsDocumentModified (doc))
1210: DocStatusUpdate (doc, TRUE);
1.538 cvs 1211: /* change the document status */
1.598 cvs 1212: TtaSetDocumentAccessMode (doc, 1);
1.538 cvs 1213: /* update windows menus */
1.598 cvs 1214: UpdateEditorMenus (doc);
1.538 cvs 1215: }
1216:
1217: /*----------------------------------------------------------------------
1.519 cvs 1218: ChangeToBrowserMode
1.538 cvs 1219: Similar to Browser mode except for the variable ReadOnlyDocument
1.518 cvs 1220: ----------------------------------------------------------------------*/
1.598 cvs 1221: void ChangeToBrowserMode (Document doc)
1.518 cvs 1222: {
1223: Document docSel;
1224:
1225: docSel = TtaGetSelectedDocument ();
1.598 cvs 1226: if (docSel == doc)
1227: TtaUnselect (doc);
1.518 cvs 1228:
1229: /* =============> The document is in Read-Only mode now */
1230: /* change the document status */
1.598 cvs 1231: SetDocumentReadOnly (doc);
1.518 cvs 1232: /* update windows menus */
1.598 cvs 1233: UpdateBrowserMenus (doc);
1.518 cvs 1234: }
1235:
1236: /*----------------------------------------------------------------------
1.479 cvs 1237: Change the Browser/Editor mode
1.249 cvs 1238: ----------------------------------------------------------------------*/
1.907 gully 1239: void SetBrowserEditor (Document doc, View view)
1.249 cvs 1240: {
1.518 cvs 1241: Document docSel;
1.249 cvs 1242:
1.251 cvs 1243: docSel = TtaGetSelectedDocument ();
1.598 cvs 1244: if (docSel == doc)
1245: TtaUnselect (doc);
1.518 cvs 1246:
1.598 cvs 1247: if (TtaGetDocumentAccessMode (doc))
1.249 cvs 1248: {
1.349 cvs 1249: /* =============> The document is in Read-Only mode now */
1.249 cvs 1250: /* change the document status */
1.598 cvs 1251: SetDocumentReadOnly (doc);
1252: ReadOnlyDocument[doc] = TRUE;
1.249 cvs 1253: /* update windows menus */
1.598 cvs 1254: UpdateBrowserMenus (doc);
1.249 cvs 1255: }
1256: else
1257: {
1.349 cvs 1258: /* =============> The document is in Read-Write mode now */
1.518 cvs 1259: /* change the document status */
1.598 cvs 1260: ReadOnlyDocument[doc] = FALSE;
1261: TtaSetDocumentAccessMode (doc, 1);
1.576 cvs 1262: /* change the document status */
1.598 cvs 1263: if (TtaIsDocumentModified (doc))
1264: DocStatusUpdate (doc, TRUE);
1.249 cvs 1265: /* update windows menus */
1.598 cvs 1266: UpdateEditorMenus (doc);
1.249 cvs 1267: }
1268: }
1.171 cvs 1269:
1270: /*----------------------------------------------------------------------
1.617 cvs 1271: ShowLogFile
1272: Show error messages generated by the parser.
1273: -----------------------------------------------------------------------*/
1.659 vatton 1274: void ShowLogFile (Document doc, View view)
1.617 cvs 1275: {
1276: char fileName [100];
1277: int newdoc;
1278:
1279: sprintf (fileName, "%s%c%d%cPARSING.ERR",
1280: TempFileDirectory, DIR_SEP, doc, DIR_SEP);
1.924 vatton 1281: newdoc = GetAmayaDoc (fileName, NULL, 0, doc, (ClickEvent)CE_LOG, FALSE,
1282: NULL, NULL);
1.617 cvs 1283: /* store the relation with the original document */
1284: if (newdoc)
1.863 vatton 1285: {
1286: DocumentSource[newdoc] = doc;
1287: TtaSetStatus (newdoc, 1, " ", NULL);
1288: }
1.617 cvs 1289: }
1290:
1291: /*----------------------------------------------------------------------
1292: OpenParsingErrors
1293: ----------------------------------------------------------------------*/
1.659 vatton 1294: ThotBool OpenParsingErrors (Document document)
1.617 cvs 1295: {
1296: char fileName [100];
1297:
1298: sprintf (fileName, "%s%c%d%cPARSING.ERR",
1299: TempFileDirectory, DIR_SEP, document, DIR_SEP);
1300: if ((ErrFile = fopen (fileName, "w")) == NULL)
1301: return FALSE;
1302: else
1.883 vatton 1303: fprintf (ErrFile, TtaGetMessage (AMAYA, AM_LINK_LINE));
1304: return TRUE;
1.617 cvs 1305: }
1306:
1307: /*----------------------------------------------------------------------
1308: RemoveParsingErrors
1309: ----------------------------------------------------------------------*/
1.659 vatton 1310: void RemoveParsingErrors (Document document)
1.617 cvs 1311: {
1312: char htmlErrFile [100];
1313:
1314: sprintf (htmlErrFile, "%s%c%d%cPARSING.ERR",
1315: TempFileDirectory, DIR_SEP, document, DIR_SEP);
1316: if (TtaFileExist (htmlErrFile))
1317: TtaFileUnlink (htmlErrFile);
1318: }
1319:
1320: /*----------------------------------------------------------------------
1321: CleanUpParsingErrors
1322: Initialize the 'PARSING.ERR' file and the related global variables
1323: ----------------------------------------------------------------------*/
1.659 vatton 1324: void CleanUpParsingErrors ()
1.617 cvs 1325: {
1326: HTMLErrorsFound = FALSE;
1327: XMLErrorsFound = FALSE;
1328: CSSErrorsFound = FALSE;
1329: XMLErrorsFoundInProfile = FALSE;
1330: XMLNotWellFormed = FALSE;
1331: XMLUnknownEncoding = FALSE;
1332: XMLCharacterNotSupported = FALSE;
1333: /* close the error file */
1334: if (ErrFile)
1335: {
1336: fclose (ErrFile);
1337: ErrFile = NULL;
1338: }
1339: }
1340:
1341: /*----------------------------------------------------------------------
1342: CheckParsingErrors
1343: Checks the errors during the parsing of the document and active
1344: (or not) the Show Log File menu entry
1345: ----------------------------------------------------------------------*/
1.659 vatton 1346: void CheckParsingErrors (Document doc)
1.617 cvs 1347: {
1.680 cvs 1348: char *ptr, *reload;
1.757 cheyroul 1349: #ifndef _PARSING
1.702 vatton 1350: char profile [200];
1351: int prof;
1.757 cheyroul 1352: #endif /*_PARSING*/
1.680 cvs 1353:
1.830 vatton 1354: if (BADMimeType)
1355: {
1356: /* the mime type doesn't match the doctype */
1357: InitConfirm (doc, 1, TtaGetMessage (AMAYA, AM_INVALID_MIMETYPE));
1358: BADMimeType = FALSE;
1359: }
1.659 vatton 1360: if (ErrFile)
1.617 cvs 1361: {
1362: /* Active the menu entry */
1.659 vatton 1363: TtaSetItemOn (doc, 1, Views, BShowLogFile);
1364: if (XMLNotWellFormed || XMLCharacterNotSupported)
1.617 cvs 1365: {
1.659 vatton 1366: /* Raise a popup message */
1367: if (DocumentTypes[doc] == docHTML)
1368: /* when propose a reload */
1369: reload = TtaGetMessage (AMAYA, AM_BUTTON_RELOAD);
1370: else
1371: reload = NULL;
1372: if (XMLCharacterNotSupported)
1.617 cvs 1373: {
1.659 vatton 1374: /* Some elements or attributes are not supported */
1375: if (reload)
1376: ptr = TtaGetMessage (AMAYA, AM_XML_CHARACTER_RETRY);
1377: else
1378: ptr = TtaGetMessage (AMAYA, AM_XML_CHARACTER_ERROR);
1.617 cvs 1379: }
1.659 vatton 1380: else
1.617 cvs 1381: {
1.659 vatton 1382: /* The document is not well-formed */
1.720 cvs 1383: if (reload)
1.659 vatton 1384: ptr = TtaGetMessage (AMAYA, AM_XML_RETRY);
1385: else
1386: ptr = TtaGetMessage (AMAYA, AM_XML_ERROR);
1.617 cvs 1387: }
1.720 cvs 1388: ConfirmError (doc, 1, ptr, reload,
1389: TtaGetMessage (AMAYA, AM_AFILTER_SHOW));
1.830 vatton 1390: CleanUpParsingErrors ();
1.659 vatton 1391: if (UserAnswer && reload)
1392: ParseAsHTML (doc, 1);
1393: else
1.617 cvs 1394: {
1.659 vatton 1395: ChangeToBrowserMode (doc);
1396: if (ShowErrors || UserAnswer)
1.663 vatton 1397: {
1398: ShowLogFile (doc, 1);
1399: ShowSource (doc, 1);
1400: }
1.617 cvs 1401: }
1402: }
1.757 cheyroul 1403: #ifndef _PARSING
1.659 vatton 1404: else if (XMLErrorsFoundInProfile)
1405: {
1.757 cheyroul 1406:
1.659 vatton 1407: /* Some elements or attributes are not supported */
1.680 cvs 1408: /* in the current document profile */
1.702 vatton 1409: prof = TtaGetDocumentProfile (doc);
1410: if (prof == L_Basic)
1411: {
1412: strcpy (profile, TtaGetMessage (AMAYA, AM_XML_PROFILE));
1413: strcat (profile, " XHTML Basic");
1414: }
1415: else if (prof == L_Strict)
1416: {
1417: strcpy (profile, TtaGetMessage (AMAYA, AM_XML_PROFILE));
1418: if (DocumentMeta[doc]->xmlformat)
1419: strcat (profile, " XHTML 1.0 Strict");
1420: else
1421: strcat (profile, " HTML 4.0 Strict");
1422: }
1423: else if (prof == L_Xhtml11)
1424: {
1425: strcpy (profile, TtaGetMessage (AMAYA, AM_XML_PROFILE));
1426: strcat (profile, " XHTML 1.1");
1427: }
1428: else if (prof == L_Transitional)
1429: strcpy (profile, "");
1430:
1431: InitConfirm3L (doc, 1, profile, NULL,
1432: TtaGetMessage (AMAYA, AM_XML_WARNING), FALSE);
1.659 vatton 1433: CleanUpParsingErrors ();
1434: if (UserAnswer)
1.702 vatton 1435: {
1436: ShowLogFile (doc, 1);
1437: ShowSource (doc, 1);
1438: }
1.659 vatton 1439: }
1.740 cvs 1440: else if (XMLErrorsFound)
1441: {
1442: /* Some elements or attributes are not supported */
1443: strcpy (profile, "");
1444: InitConfirm (doc, 1, TtaGetMessage (AMAYA, AM_XML_WARNING));
1445: CleanUpParsingErrors ();
1446: if (UserAnswer)
1447: {
1448: ShowLogFile (doc, 1);
1449: ShowSource (doc, 1);
1450: }
1451: }
1.757 cheyroul 1452: #endif /*_PARSING*/
1.659 vatton 1453: CleanUpParsingErrors ();
1.617 cvs 1454: }
1455: else
1.662 cvs 1456: TtaSetItemOff (doc, 1, Views, BShowLogFile);
1.617 cvs 1457: }
1458:
1459:
1460: /*----------------------------------------------------------------------
1.73 cvs 1461: UpdateTransfer updates the status of the current transfer
1462: ----------------------------------------------------------------------*/
1.659 vatton 1463: void UpdateTransfer (Document document)
1.73 cvs 1464: {
1.836 vatton 1465: if (document)
1466: FilesLoading[document]++;
1.73 cvs 1467: }
1.6 cvs 1468:
1.9 cvs 1469: /*----------------------------------------------------------------------
1470: StopTransfer stops the current transfer
1471: ----------------------------------------------------------------------*/
1.659 vatton 1472: void StopTransfer (Document document, View view)
1.6 cvs 1473: {
1.171 cvs 1474: if (document == 0)
1475: return;
1476: else if (document == DocBook)
1.136 cvs 1477: {
1.171 cvs 1478: /* Make Book function stopped */
1479: DocBook = 0;
1480: /* stop transfer of the sub-document */
1.136 cvs 1481: StopRequest (document);
1.171 cvs 1482: StopRequest (IncludedDocument);
1483: FilesLoading[document] = 0;
1484: DocNetworkStatus[document] = AMAYA_NET_INACTIVE;
1.136 cvs 1485: }
1.171 cvs 1486: else if (DocNetworkStatus[document] & AMAYA_NET_ACTIVE)
1487: {
1488: if (TtaGetViewFrame (document, 1) != 0)
1.276 cvs 1489: TtaChangeButton (document, 1, 1, stopN, FALSE);
1.118 cvs 1490: StopRequest (document);
1491: FilesLoading[document] = 0;
1492: DocNetworkStatus[document] = AMAYA_NET_INACTIVE;
1.375 cvs 1493: TtaSetStatus (document, 1,
1494: TtaGetMessage (AMAYA, AM_LOAD_ABORT),
1495: NULL);
1.118 cvs 1496: }
1.6 cvs 1497: }
1.680 cvs 1498:
1.756 vatton 1499: /*----------------------------------------------------------------------
1.810 vatton 1500: CompleteUrl
1501: In case of a user typed url without protocol specification
1502: and filepath like url (the ~ or / url beginning),
1503: we add the http:// (more conveniant when you often type urls)
1504: so that you can now enter w3.org directly in the url bar.
1505: Return TRUE if the URL changed.
1.756 vatton 1506: ----------------------------------------------------------------------*/
1.810 vatton 1507: static ThotBool CompleteUrl(char **url)
1.673 cheyroul 1508: {
1509: char *s;
1510:
1511: if (**url != DIR_SEP
1512: && **url != '~'
1.916 cvs 1513: #ifdef _WINGUI
1.674 cvs 1514: && (*(url))[1] != ':'
1.916 cvs 1515: #endif /* _WINGUI */
1.673 cheyroul 1516: && !IsW3Path (*url)
1517: && !IsFilePath (*url)
1518: && (strlen (*url) + 8) < MAX_LENGTH)
1519: {
1520: if (TtaFileExist (*url) == 0)
1521: {
1.907 gully 1522: s = (char *)TtaGetMemory (MAX_LENGTH);
1.673 cheyroul 1523: strcpy (s, "http://");
1524: strcat (s, *url);
1525: *url = s;
1.810 vatton 1526: return TRUE;
1.673 cheyroul 1527: }
1528: }
1.810 vatton 1529: return FALSE;
1.673 cheyroul 1530: }
1531:
1.6 cvs 1532:
1.9 cvs 1533: /*----------------------------------------------------------------------
1.146 cvs 1534: TextURL
1535: The Address text field in a document window has been modified by the user
1536: Load the corresponding document in that window.
1.9 cvs 1537: ----------------------------------------------------------------------*/
1.798 vatton 1538: static void TextURL (Document doc, View view, char *text)
1.6 cvs 1539: {
1.547 cvs 1540: char *s = NULL;
1541: char *url;
1.810 vatton 1542: ThotBool change, updated;
1.6 cvs 1543:
1.810 vatton 1544: updated = FALSE;
1.123 cvs 1545: if (text)
1546: {
1.422 cvs 1547: /* remove any trailing '\n' chars that may have gotten there
1548: after a cut and pase */
1549: change = RemoveNewLines (text);
1.558 cvs 1550: if (IsW3Path (text))
1551: url = text;
1552: else
1.123 cvs 1553: {
1.907 gully 1554: s = (char *)TtaGetMemory (MAX_LENGTH);
1.810 vatton 1555: updated = CompleteUrl(&text);
1.429 cvs 1556: change = NormalizeFile (text, s, AM_CONV_NONE);
1.810 vatton 1557: if (updated)
1558: /* free the allocated string */
1559: TtaFreeMemory (text);
1.426 cvs 1560: url = s;
1.123 cvs 1561: }
1.810 vatton 1562: if (!InNewWindow && !CanReplaceCurrentDocument (doc, view))
1.123 cvs 1563: {
1.222 cvs 1564: /* restore the previous value @@ */
1.839 kahan 1565: AddURLInCombobox (DocumentURLs[doc], NULL, FALSE);
1.799 vatton 1566: TtaSetTextZone (doc, view, URL_list);
1.558 cvs 1567: /* cannot load the new document */
1568: TtaSetStatus (doc, 1, TtaGetMessage (AMAYA, AM_CANNOT_LOAD), text);
1.146 cvs 1569: /* abort the command */
1.810 vatton 1570: TtaFreeMemory (s);
1.146 cvs 1571: return;
1.123 cvs 1572: }
1573: else
1.810 vatton 1574: /* do the same thing as a callback form open document form */
1.426 cvs 1575: CallbackDialogue (BaseDialog + URLName, STRING_DATA, url);
1.799 vatton 1576: TtaFreeMemory (s);
1.123 cvs 1577: InNewWindow = FALSE;
1.558 cvs 1578: CurrentDocument = doc;
1.547 cvs 1579: CallbackDialogue (BaseDialog + OpenForm, INTEGER_DATA, (char *) 1);
1.123 cvs 1580: }
1.6 cvs 1581: }
1582:
1.9 cvs 1583: /*----------------------------------------------------------------------
1.376 cvs 1584: SetWindowTitle
1585: Change the title of all windows (if view == 0) of document targetDoc
1586: or only the title of the window associated with the specified view.
1587: if it's not 0.
1588: The new title is the content of the TITLE element of document sourceDoc.
1589: If document sourceDoc does not have any TITLE element, nothing happen.
1590: ----------------------------------------------------------------------*/
1.568 cvs 1591: void SetWindowTitle (Document sourceDoc, Document targetDoc, View view)
1.376 cvs 1592: {
1593: ElementType elType;
1.568 cvs 1594: Element el;
1.376 cvs 1595:
1596: el = TtaGetMainRoot (sourceDoc);
1597: elType.ElSSchema = TtaGetDocumentSSchema (sourceDoc);
1.547 cvs 1598: if (!strcmp (TtaGetSSchemaName (elType.ElSSchema), "HTML"))
1.376 cvs 1599: /* sourceDoc is a HTML document */
1600: {
1601: /* search the Title element in sourceDoc */
1602: elType.ElTypeNum = HTML_EL_TITLE;
1603: el = TtaSearchTypedElement (elType, SearchForward, el);
1604: if (el)
1.568 cvs 1605: UpdateTitle (el, sourceDoc);
1.376 cvs 1606: }
1607: }
1608:
1609: /*----------------------------------------------------------------------
1.370 cvs 1610: InitFormAnswer
1611: Dialogue form for answering text, user name and password
1.9 cvs 1612: ----------------------------------------------------------------------*/
1.710 vatton 1613: void InitFormAnswer (Document document, View view, const char *auth_realm,
1614: char *server)
1.6 cvs 1615: {
1.915 gully 1616: #if defined(_MOTIF) || defined(_GTK)
1.547 cvs 1617: char *label;
1.370 cvs 1618:
1.38 cvs 1619: TtaNewForm (BaseDialog + FormAnswer, TtaGetViewFrame (document, view),
1.370 cvs 1620: TtaGetMessage (AMAYA, AM_GET_AUTHENTICATION),
1621: TRUE, 1, 'L', D_CANCEL);
1622:
1.907 gully 1623: label = (char *)TtaGetMemory (((server) ? strlen (server) : 0)
1.547 cvs 1624: + strlen (TtaGetMessage (AMAYA,
1.502 kahan 1625: AM_AUTHENTICATION_REALM_SERVER))
1.547 cvs 1626: + ((auth_realm) ? strlen (auth_realm) : 0)
1.370 cvs 1627: + 20); /*a bit more than enough memory */
1.547 cvs 1628: sprintf (label, TtaGetMessage (AMAYA, AM_AUTHENTICATION_REALM_SERVER),
1629: ((auth_realm) ? auth_realm : ""),
1630: ((server) ? server : ""));
1.369 cvs 1631: TtaNewLabel (BaseDialog + RealmText, BaseDialog + FormAnswer,
1.370 cvs 1632: label);
1633: TtaFreeMemory (label);
1634:
1.25 cvs 1635: TtaNewTextForm (BaseDialog + NameText, BaseDialog + FormAnswer,
1.10 cvs 1636: TtaGetMessage (AMAYA, AM_NAME), NAME_LENGTH, 1, FALSE);
1.891 gully 1637:
1638: #ifdef _MOTIF
1.25 cvs 1639: TtaNewTextForm (BaseDialog + PasswordText, BaseDialog + FormAnswer,
1.10 cvs 1640: TtaGetMessage (AMAYA, AM_PASSWORD), NAME_LENGTH, 1, TRUE);
1.891 gully 1641: #endif /* _MOTIF */
1642:
1643: #ifdef _GTK
1.623 cvs 1644: TtaNewPwdForm (BaseDialog + PasswordText, BaseDialog + FormAnswer,
1.654 cvs 1645: TtaGetMessage (AMAYA, AM_PASSWORD), NAME_LENGTH, 1, TRUE);
1.891 gully 1646: #endif /* _GTK */
1647:
1.258 cvs 1648: TtaSetTextForm (BaseDialog + NameText, Answer_name);
1.256 cvs 1649: TtaSetTextForm (BaseDialog + PasswordText, Answer_password);
1.10 cvs 1650: TtaSetDialoguePosition ();
1651: TtaShowDialogue (BaseDialog + FormAnswer, FALSE);
1652: TtaWaitShowDialogue ();
1.433 cvs 1653: if (UserAnswer &&
1.547 cvs 1654: (Answer_name[0] == EOS || Answer_password[0] == EOS))
1.256 cvs 1655: {
1.413 cvs 1656: /* no login name or password, retry */
1.258 cvs 1657: TtaSetTextForm (BaseDialog + NameText, Answer_name);
1.256 cvs 1658: TtaSetTextForm (BaseDialog + PasswordText, Answer_password);
1.413 cvs 1659: TtaSetDialoguePosition ();
1.256 cvs 1660: TtaShowDialogue (BaseDialog + FormAnswer, FALSE);
1661: TtaWaitShowDialogue ();
1662: }
1.915 gully 1663: #endif /* #if defined(_MOTIF) || defined(_GTK) */
1.891 gully 1664:
1.916 cvs 1665: #ifdef _WINGUI
1.547 cvs 1666: CreateAuthenticationDlgWindow (TtaGetViewFrame (document, view),
1667: (char *)auth_realm, server);
1.916 cvs 1668: #endif /* _WINGUI */
1.891 gully 1669:
1.369 cvs 1670: }
1671:
1.659 vatton 1672:
1.369 cvs 1673: /*----------------------------------------------------------------------
1674: InitInfo
1675: Displays a message box with the given info text
1676: ----------------------------------------------------------------------*/
1.605 cvs 1677: void InitInfo (char *label, char *info)
1.369 cvs 1678: {
1.547 cvs 1679: if (!info || *info == EOS)
1.369 cvs 1680: return;
1.916 cvs 1681: #ifdef _WINGUI
1.369 cvs 1682: MessageBox (NULL, info, label, MB_OK);
1.916 cvs 1683: #endif /* !_WINGUI */
1.891 gully 1684:
1.911 gully 1685: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.369 cvs 1686: TtaDisplayMessage (CONFIRM, info, NULL);
1.911 gully 1687: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.6 cvs 1688: }
1689:
1.9 cvs 1690: /*----------------------------------------------------------------------
1691: ----------------------------------------------------------------------*/
1.720 cvs 1692: void ConfirmError (Document document, View view, char *label,
1693: char *extrabutton, char *confirmbutton)
1.659 vatton 1694: {
1.915 gully 1695: #if defined(_MOTIF) || defined(_GTK)
1.659 vatton 1696: char s[MAX_LENGTH];
1697: int i, n;
1698:
1699: i = 0;
1700: n = 1;
1701: if (extrabutton)
1702: {
1703: /* display 3 buttons: extrabutton - show - cancel */
1704: strcpy (&s[i], extrabutton);
1705: n++;
1706: i += strlen (&s[i]) + 1;
1707: }
1.720 cvs 1708: strcpy (&s[i], confirmbutton);
1.659 vatton 1709: TtaNewSheet (BaseDialog + ConfirmForm, TtaGetViewFrame (document, view),
1710: TtaGetMessage (LIB, TMSG_LIB_CONFIRM),
1711: n, s, TRUE, 2, 'L', D_CANCEL);
1712: TtaNewLabel (BaseDialog + ConfirmText, BaseDialog + ConfirmForm, label);
1713: TtaSetDialoguePosition ();
1714: TtaShowDialogue (BaseDialog + ConfirmForm, FALSE);
1715: /* wait for an answer */
1716: TtaWaitShowDialogue ();
1.904 vatton 1717: /* remove the critic section */
1718: CriticConfirm = FALSE;
1.891 gully 1719: #endif /* #if defined(_MOTIF) || defined(_GTK) */
1720:
1.916 cvs 1721: #ifdef _WINGUI
1.659 vatton 1722: CreateInitConfirmDlgWindow (TtaGetViewFrame (document, view),
1723: extrabutton, label);
1.916 cvs 1724: #endif /* _WINGUI */
1.659 vatton 1725: }
1726:
1727: /*----------------------------------------------------------------------
1728: ----------------------------------------------------------------------*/
1.605 cvs 1729: void InitConfirm3L (Document document, View view, char *label1, char *label2,
1730: char *label3, ThotBool withCancel)
1.430 cvs 1731: {
1.891 gully 1732: #if defined(_MOTIF) || defined(_GTK)
1.904 vatton 1733: /* IV: This widget can't be called twice, but it happens when downloading a
1734: document with protected images. This is a quick silution to avoid the
1735: sigsev, although it doesn't fix the problem */
1736: if (CriticConfirm)
1737: return;
1738: else
1739: CriticConfirm = TRUE;
1740:
1.467 cvs 1741: /* Confirm form */
1742: if (withCancel)
1743: TtaNewForm (BaseDialog + ConfirmForm, TtaGetViewFrame (document, view),
1744: TtaGetMessage (LIB, TMSG_LIB_CONFIRM), FALSE, 3, 'L', D_CANCEL);
1745: else
1746: TtaNewDialogSheet (BaseDialog + ConfirmForm, TtaGetViewFrame (document, view),
1747: TtaGetMessage(LIB, TMSG_LIB_CONFIRM),
1748: 1, TtaGetMessage(LIB, TMSG_LIB_CONFIRM),
1749: FALSE, 3, 'L');
1.430 cvs 1750: /* open as many label widgets as \n we find in the label */
1.547 cvs 1751: if (label1 && *label1 != EOS)
1.430 cvs 1752: TtaNewLabel (BaseDialog + Label1, BaseDialog + ConfirmForm, label1);
1.837 kahan 1753: else
1754: TtaNewLabel (BaseDialog + Label1, BaseDialog + ConfirmForm, "");
1.430 cvs 1755: /* open as many label widgets as \n we find in the label */
1.547 cvs 1756: if (label2 && *label2 != EOS)
1.430 cvs 1757: TtaNewLabel (BaseDialog + Label2, BaseDialog + ConfirmForm, label2);
1.837 kahan 1758: else
1759: TtaNewLabel (BaseDialog + Label2, BaseDialog + ConfirmForm, "");
1.547 cvs 1760: if (label3 && *label3 != EOS)
1.430 cvs 1761: TtaNewLabel (BaseDialog + Label3, BaseDialog + ConfirmForm, label3);
1.837 kahan 1762: else
1763: TtaNewLabel (BaseDialog + Label3, BaseDialog + ConfirmForm, "");
1.430 cvs 1764: TtaSetDialoguePosition ();
1765: TtaShowDialogue (BaseDialog + ConfirmForm, FALSE);
1766: /* wait for an answer */
1767: TtaWaitShowDialogue ();
1.915 gully 1768: #endif /* #if defined(_MOTIF) || defined(_GTK) */
1.891 gully 1769:
1.916 cvs 1770: #ifdef _WINGUI
1.445 cvs 1771: CreateInitConfirm3LDlgWindow (TtaGetViewFrame (document, view),
1772: TtaGetMessage (LIB, TMSG_LIB_CONFIRM), label1,
1.467 cvs 1773: label2, label3, withCancel);
1.916 cvs 1774: #endif /* _WINGUI */
1.891 gully 1775:
1.430 cvs 1776: }
1777:
1778: /*----------------------------------------------------------------------
1779: ----------------------------------------------------------------------*/
1.655 vatton 1780: void InitConfirm (Document document, View view, char *label)
1.6 cvs 1781: {
1.915 gully 1782: #if defined(_MOTIF) || defined(_GTK)
1.10 cvs 1783: /* Confirm form */
1.443 kahan 1784:
1785: /* JK: This widget can't be called twice, but it happens when downloading a
1786: document with protected images. This is a quick silution to avoid the
1787: sigsev, although it doesn't fix the problem */
1.904 vatton 1788: if (CriticConfirm)
1.443 kahan 1789: return;
1.659 vatton 1790: else
1.904 vatton 1791: CriticConfirm = TRUE;
1.659 vatton 1792:
1.445 cvs 1793: TtaNewForm (BaseDialog + ConfirmForm, TtaGetViewFrame (document, view),
1.659 vatton 1794: TtaGetMessage (LIB, TMSG_LIB_CONFIRM), TRUE, 2, 'L', D_CANCEL);
1.25 cvs 1795: TtaNewLabel (BaseDialog + ConfirmText, BaseDialog + ConfirmForm, label);
1.10 cvs 1796: TtaSetDialoguePosition ();
1.25 cvs 1797: TtaShowDialogue (BaseDialog + ConfirmForm, FALSE);
1.10 cvs 1798: /* wait for an answer */
1799: TtaWaitShowDialogue ();
1.443 kahan 1800: /* remove the critic section */
1.904 vatton 1801: CriticConfirm = FALSE;
1.891 gully 1802: #endif /* #if defined(_MOTIF) || defined(_GTK) */
1803:
1.916 cvs 1804: #ifdef _WINGUI
1.661 cvs 1805: CreateInitConfirmDlgWindow (TtaGetViewFrame (document, view), NULL, label);
1.916 cvs 1806: #endif /* _WINGUI */
1.891 gully 1807:
1.926 gully 1808: #ifdef _WX
1809: CreateInitConfirmDlgWX (TtaGetViewFrame (document, view), NULL, label);
1810: #endif /* _WX */
1.6 cvs 1811: }
1812:
1.618 kahan 1813: /*----------------------------------------------------------------------
1814: InitCharset
1815: Asks the user for the charset of a given URL. Used when saving a
1816: document with an unknown charset.
1817: ----------------------------------------------------------------------*/
1818: void InitCharset (Document document, View view, char *url)
1819: {
1.915 gully 1820: #if defined(_MOTIF) || defined(_GTK)
1.626 vatton 1821: char s[MAX_LENGTH]; /* general purpose buffer */
1822: int i;
1.618 kahan 1823:
1.626 vatton 1824: i = 0;
1825: strcpy (&s[i], "Bus-ascii");
1826: i += strlen (&s[i]) + 1;
1827: strcpy (&s[i], "BUTF-8");
1828: i += strlen (&s[i]) + 1;
1829: strcpy (&s[i], "Biso-8859-1");
1830: i += strlen (&s[i]) + 1;
1831: if (!strcmp (UserCharset, "us-ascii"))
1832: i = 0;
1.628 vatton 1833: else if (!strcmp (UserCharset, "iso-8859-1"))
1834: i = 2;
1835: else
1.626 vatton 1836: i = 1;
1837:
1838: TtaNewForm (BaseDialog + CharsetForm, TtaGetViewFrame (document, view),
1.633 kahan 1839: TtaGetMessage (AMAYA, AM_SELECT_CHARSET), TRUE, 1, 'L', D_CANCEL);
1.626 vatton 1840: /* radio buttons */
1841: TtaNewSubmenu (BaseDialog + CharsetSel, BaseDialog + CharsetForm, 0,
1842: NULL, 3, s, NULL, FALSE);
1843: TtaSetMenuForm (BaseDialog + CharsetSel, i);
1844:
1845: TtaSetDialoguePosition ();
1846: TtaShowDialogue (BaseDialog + CharsetForm, FALSE);
1847: /* wait for an answer */
1848: TtaWaitShowDialogue ();
1.915 gully 1849: #endif /* #if defined(_MOTIF) || defined(_GTK) */
1.891 gully 1850:
1.916 cvs 1851: #ifdef _WINGUI
1.626 vatton 1852: CreateCharsetDlgWindow (TtaGetViewFrame (document, view));
1.916 cvs 1853: #endif /* _WINGUI */
1.891 gully 1854:
1.618 kahan 1855: }
1856:
1857: /*----------------------------------------------------------------------
1858: InitMimeType
1859: Asks the user for the MIME type of a given URL. Used when saving a
1860: document with an unknown MIME type.
1861: ----------------------------------------------------------------------*/
1.634 kahan 1862: void InitMimeType (Document document, View view, char *url, char *status)
1.618 kahan 1863: {
1.626 vatton 1864: char *mimetypes_list;
1865: int nbmimetypes;
1866:
1867: if (DocumentTypes[document] == docImage)
1868: {
1869: mimetypes_list = "image/png\0"
1870: "image/jpeg\0"
1871: "image/gif\0"
1.635 kahan 1872: "image/x-bitmap\0"
1873: "image/x-xpicmap\0";
1874: nbmimetypes = 5;
1.626 vatton 1875: }
1876: else if (DocumentTypes[document] == docSVG)
1877: {
1.734 kahan 1878: mimetypes_list = AM_SVG_MIME_TYPE"\0"
1.729 kahan 1879: "application/xml\0"
1.635 kahan 1880: "text/xml\0";
1.729 kahan 1881: nbmimetypes = 4;
1.626 vatton 1882: }
1.729 kahan 1883: else if (DocumentTypes[document] == docMath)
1884: {
1.734 kahan 1885: mimetypes_list = AM_MATHML_MIME_TYPE"\0"
1.729 kahan 1886: "application/xml\0"
1887: "text/xml\0";
1888: nbmimetypes = 3;
1889: }
1890: else if (DocumentTypes[document] == docHTML && DocumentMeta[document] &&
1891: DocumentMeta[document]->xmlformat)
1892: {
1.734 kahan 1893: mimetypes_list = AM_XHTML_MIME_TYPE"\0"
1.729 kahan 1894: "text/html\0"
1895: "application/xml\0"
1896: "text/xml\0";
1897: nbmimetypes = 4;
1898: }
1899: else
1.626 vatton 1900: {
1901: mimetypes_list = "text/html\0"
1.734 kahan 1902: AM_XHTML_MIME_TYPE"\0"
1.729 kahan 1903: "application/xml\0"
1.626 vatton 1904: "text/xml\0"
1905: "text/plain\0"
1.779 kahan 1906: "text/css\0"
1907: "application/smil\0";
1908: nbmimetypes = 7;
1.626 vatton 1909: }
1.618 kahan 1910:
1.915 gully 1911: #if defined(_MOTIF) || defined(_GTK)
1.618 kahan 1912: TtaNewForm (BaseDialog + MimeTypeForm, TtaGetViewFrame (document, view),
1.633 kahan 1913: TtaGetMessage (AMAYA, AM_SELECT_MIMETYPE), TRUE, 1, 'L', D_CANCEL);
1.618 kahan 1914: /* selector */
1915: TtaNewSelector (BaseDialog + MimeTypeSel, BaseDialog + MimeTypeForm, NULL,
1916: nbmimetypes, mimetypes_list, 4, NULL, TRUE, FALSE);
1917: /* status */
1.634 kahan 1918: if (status && *status)
1919: TtaNewLabel (BaseDialog + MimeFormStatus, BaseDialog + MimeTypeForm, status);
1920: else
1921: TtaNewLabel (BaseDialog + MimeFormStatus, BaseDialog + MimeTypeForm,
1922: " ");
1.626 vatton 1923: TtaSetSelector (BaseDialog + MimeTypeSel, -1, UserMimeType);
1.618 kahan 1924:
1925: TtaSetDialoguePosition ();
1926: TtaShowDialogue (BaseDialog + MimeTypeForm, FALSE);
1927: /* wait for an answer */
1928: TtaWaitShowDialogue ();
1.915 gully 1929: #endif /* #if defined(_MOTIF) || defined(_GTK) */
1.891 gully 1930:
1.916 cvs 1931: #ifdef _WINGUI
1.619 cvs 1932: CreateMimeTypeDlgWindow (TtaGetViewFrame (document, view), nbmimetypes,
1933: mimetypes_list);
1.916 cvs 1934: #endif /* _WINGUI */
1.618 kahan 1935: }
1.501 cvs 1936:
1.500 cvs 1937: /*-------------------------------------------------------------------------
1.501 cvs 1938: BrowserForm
1.500 cvs 1939: Initializes a form that ask the URI of the opened or new created document.
1940: -------------------------------------------------------------------------*/
1.678 vatton 1941: static void BrowserForm (Document doc, View view, char *urlname)
1.500 cvs 1942: {
1.915 gully 1943: #if defined(_MOTIF) || defined(_GTK)
1.547 cvs 1944: char s[MAX_LENGTH];
1.500 cvs 1945: int i;
1.547 cvs 1946: char tempfile[MAX_LENGTH];
1.500 cvs 1947:
1948: /* Dialogue form for open URL or local */
1949: i = 0;
1.547 cvs 1950: strcpy (&s[i], TtaGetMessage (LIB, TMSG_LIB_CONFIRM));
1951: i += strlen (&s[i]) + 1;
1952: strcpy (&s[i], TtaGetMessage (AMAYA, AM_CLEAR));
1953: i += strlen (&s[i]) + 1;
1954: strcpy (&s[i], TtaGetMessage (AMAYA, AM_PARSE));
1.500 cvs 1955:
1956: TtaNewSheet (BaseDialog + FileBrowserForm, TtaGetViewFrame (doc, 1),
1.509 cvs 1957: TtaGetMessage (AMAYA, AM_FILE_BROWSER), 3, s,
1.500 cvs 1958: TRUE, 2, 'L', D_CANCEL);
1959: TtaNewTextForm (BaseDialog + FileBrowserText, BaseDialog + FileBrowserForm,
1.509 cvs 1960: TtaGetMessage (AMAYA, AM_SELECTION), 50, 1, TRUE);
1.500 cvs 1961: TtaNewLabel (BaseDialog + FileBrowserLocalName,
1962: BaseDialog + FileBrowserForm, " ");
1.507 cvs 1963:
1964: /* initialise the text fields in the dialogue box */
1.547 cvs 1965: tempfile[0] = EOS;
1966: if (urlname[0] != EOS)
1.507 cvs 1967: NormalizeFile (urlname, tempfile, AM_CONV_NONE);
1968:
1.547 cvs 1969: if (tempfile[0] != EOS && !IsW3Path (tempfile))
1.507 cvs 1970: {
1971: if (TtaCheckDirectory (tempfile))
1972: {
1.547 cvs 1973: strcpy (DirectoryName, tempfile);
1974: DocumentName[0] = EOS;
1.507 cvs 1975: }
1976: else
1977: TtaExtractName (tempfile, DirectoryName, DocumentName);
1.547 cvs 1978: if (DirectoryName[0] == EOS)
1.507 cvs 1979: {
1.607 cvs 1980: getcwd (DirectoryName, MAX_LENGTH);
1.547 cvs 1981: DocumentName[0] = EOS;
1.507 cvs 1982: }
1.547 cvs 1983: strcpy (s, DirectoryName);
1984: strcat (s, DIR_STR);
1985: strcat (s, DocumentName);
1.507 cvs 1986: }
1987: else
1988: {
1.547 cvs 1989: if (tempfile[0] != EOS && IsW3Path (tempfile))
1.507 cvs 1990: {
1.607 cvs 1991: getcwd (DirectoryName, MAX_LENGTH);
1.547 cvs 1992: DocumentName[0] = EOS;
1.507 cvs 1993: }
1994: else
1995: {
1.547 cvs 1996: if (DirectoryName[0] == EOS)
1.507 cvs 1997: {
1.607 cvs 1998: getcwd (DirectoryName, MAX_LENGTH);
1.547 cvs 1999: DocumentName[0] = EOS;
1.507 cvs 2000: }
2001: }
1.547 cvs 2002: strcpy (s, DirectoryName);
2003: strcat (s, DIR_STR);
2004: strcat (s, DocumentName);
1.507 cvs 2005: }
1.790 cvs 2006:
1.500 cvs 2007: TtaListDirectory (DirectoryName, BaseDialog + FileBrowserForm,
2008: TtaGetMessage (LIB, TMSG_DOC_DIR),
2009: BaseDialog + BrowserDirSelect, ScanFilter,
2010: TtaGetMessage (AMAYA, AM_FILES),
2011: BaseDialog + BrowserDocSelect);
2012: TtaNewTextForm (BaseDialog + FileBrowserFilter,
2013: BaseDialog + FileBrowserForm,
2014: TtaGetMessage (AMAYA, AM_PARSE), 10, 1, TRUE);
2015:
2016: TtaSetTextForm (BaseDialog + FileBrowserText, s);
2017: TtaSetTextForm (BaseDialog + FileBrowserFilter, ScanFilter);
2018: TtaSetDialoguePosition ();
2019: TtaShowDialogue (BaseDialog + FileBrowserForm, FALSE);
1.915 gully 2020: #endif /* #if defined(_MOTIF) || defined(_GTK)*/
1.500 cvs 2021: }
1.6 cvs 2022:
1.9 cvs 2023: /*----------------------------------------------------------------------
1.325 cvs 2024: InitOpenDocForm initializes a form that ask the URI of the opened or
2025: new created document.
1.564 cvs 2026: The parameter name gives a proposed document name.
2027: The parameter title gives the title of the the form.
1.9 cvs 2028: ----------------------------------------------------------------------*/
1.760 cvs 2029: static void InitOpenDocForm (Document doc, View view, char *name, char *title,
1.819 vatton 2030: DocumentType docType)
1.6 cvs 2031: {
1.558 cvs 2032: char s[MAX_LENGTH];
1.564 cvs 2033: ThotBool remote;
1.915 gully 2034: #if defined(_MOTIF) || defined(_GTK)
1.558 cvs 2035: int i;
1.6 cvs 2036:
1.558 cvs 2037: /* Dialogue form for open URL or local */
2038: i = 0;
2039: strcpy (&s[i], TtaGetMessage (AMAYA, AM_OPEN_URL));
2040: i += strlen (&s[i]) + 1;
2041: strcpy (&s[i], TtaGetMessage (AMAYA, AM_BROWSE));
2042: i += strlen (&s[i]) + 1;
2043: strcpy (&s[i], TtaGetMessage (AMAYA, AM_CLEAR));
1.10 cvs 2044:
1.558 cvs 2045: TtaNewSheet (BaseDialog + OpenForm, TtaGetViewFrame (doc, view),
2046: title, 3, s, TRUE, 2, 'L', D_CANCEL);
2047: TtaNewTextForm (BaseDialog + URLName, BaseDialog + OpenForm,
2048: TtaGetMessage (AMAYA, AM_LOCATION), 50, 1, TRUE);
2049: TtaNewLabel (BaseDialog + LocalName, BaseDialog + OpenForm, " ");
1.915 gully 2050: #endif /* #if defined(_MOTIF) || defined(_GTK) */
1.564 cvs 2051:
2052: CurrentDocument = doc;
2053: /* generate the right name and URI */
2054: TtaExtractName (DocumentURLs[doc], s, DocumentName);
2055: remote = IsW3Path (DocumentURLs[doc]);
2056: if (remote)
1.558 cvs 2057: {
1.564 cvs 2058: if (name[0] != EOS)
2059: {
2060: strcpy (LastURLName, s);
2061: strcat (LastURLName, URL_STR);
2062: strcat (LastURLName, name);
2063: }
2064: else
2065: strcpy (LastURLName, DocumentURLs[doc]);
2066: strcpy (s, LastURLName);
1.558 cvs 2067: }
2068: else
2069: {
1.678 vatton 2070: /* check if it's the default Welcome page */
1.911 gully 2071: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.765 cvs 2072: if (WelcomePage)
2073: {
2074: getcwd (s, MAX_LENGTH);
2075: if (name[0] != EOS)
1.761 vatton 2076: {
1.765 cvs 2077: strcat (s, DIR_STR);
2078: strcat (s, name);
1.761 vatton 2079: }
1.765 cvs 2080: }
2081: else
1.911 gully 2082: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 2083:
1.760 cvs 2084: if (name[0] == EOS)
1.885 quint 2085: {
2086: if (DocumentURLs[doc])
2087: strcpy (s, DocumentURLs[doc]);
2088: else
2089: s[0] = EOS;
2090: }
1.760 cvs 2091: else
2092: {
1.678 vatton 2093: strcpy (DirectoryName, s);
1.760 cvs 2094: strcpy (DocumentName, name);
2095: strcat (s, DIR_STR);
2096: strcat (s, name);
1.564 cvs 2097: }
1.587 cvs 2098: strcpy (LastURLName, s);
1.558 cvs 2099: }
1.564 cvs 2100:
1.916 cvs 2101: #ifdef _WINGUI
1.766 cheyroul 2102: CreateOpenDocDlgWindow (TtaGetViewFrame (doc, view), title, s, name,
1.760 cvs 2103: DocSelect, DirSelect, docType);
1.891 gully 2104: #endif /* WINDOWS */
2105:
1.915 gully 2106: #if defined(_MOTIF) || defined(_GTK)
1.564 cvs 2107: TtaSetTextForm (BaseDialog + URLName, s);
1.558 cvs 2108: TtaSetDialoguePosition ();
2109: TtaShowDialogue (BaseDialog + OpenForm, TRUE);
1.915 gully 2110: #endif /* #if defined(_MOTIF) || defined(_GTK) */
1.891 gully 2111:
1.6 cvs 2112: }
2113:
1.9 cvs 2114: /*----------------------------------------------------------------------
2115: ----------------------------------------------------------------------*/
1.564 cvs 2116: void OpenDoc (Document doc, View view)
1.485 cvs 2117: {
1.558 cvs 2118: if (CanReplaceCurrentDocument (doc, view))
1.485 cvs 2119: {
2120: /* load the new document */
2121: InNewWindow = FALSE;
1.765 cvs 2122: /* no specific type requested */
1.905 vatton 2123: InitOpenDocForm (doc, view, "",
2124: TtaGetMessage (AMAYA, AM_OPEN_DOCUMENT), docText);
1.485 cvs 2125: }
2126: }
2127:
2128: /*----------------------------------------------------------------------
2129: ----------------------------------------------------------------------*/
1.564 cvs 2130: void OpenDocInNewWindow (Document document, View view)
1.6 cvs 2131: {
1.10 cvs 2132: InNewWindow = TRUE;
1.760 cvs 2133: /* no specific type requested */
1.905 vatton 2134: InitOpenDocForm (document, view, "",
2135: TtaGetMessage (AMAYA, AM_OPEN_IN_NEW_WINDOW),
1.760 cvs 2136: docText);
1.6 cvs 2137: }
2138:
2139:
1.9 cvs 2140: /*----------------------------------------------------------------------
1.445 cvs 2141: OpenNew: create a new document
1.9 cvs 2142: ----------------------------------------------------------------------*/
1.683 cvs 2143: void OpenNew (Document document, View view, int docType, int docProfile)
1.315 cvs 2144: {
2145: /* create a new document */
2146: InNewWindow = TRUE;
1.503 cvs 2147: NewFile = TRUE;
2148: NewDocType = docType;
1.683 cvs 2149: NewDocProfile = docProfile;
1.503 cvs 2150:
2151: if (NewDocType == docHTML)
1.683 cvs 2152: {
1.819 vatton 2153: /* will scan html documents */
2154: strcpy (ScanFilter, "*.*htm*");
1.683 cvs 2155: if (docProfile == L_Basic)
1.850 cvs 2156: InitOpenDocForm (document, view, "New.html", TtaGetMessage (AMAYA, AM_NEW_HTML_BASIC), docHTML);
1.683 cvs 2157: else if (docProfile == L_Strict)
1.850 cvs 2158: InitOpenDocForm (document, view, "New.html", TtaGetMessage (AMAYA, AM_NEW_HTML_STRICT), docHTML);
1.683 cvs 2159: else if (docProfile == L_Xhtml11)
1.850 cvs 2160: InitOpenDocForm (document, view, "New.html", TtaGetMessage (AMAYA, AM_NEW_HTML11), docHTML);
1.683 cvs 2161: else
1.850 cvs 2162: InitOpenDocForm (document, view, "New.html", TtaGetMessage (AMAYA, AM_NEW_HTML_TRANSITIONAL), docHTML);
1.683 cvs 2163: }
1.503 cvs 2164: else if (NewDocType == docMath)
1.819 vatton 2165: {
2166: /* will scan html documents */
2167: strcpy (ScanFilter, "*.mml");
1.850 cvs 2168: InitOpenDocForm (document, view, "New.mml", TtaGetMessage (AMAYA, AM_NEW_MATHML), docMath);
1.819 vatton 2169: }
1.503 cvs 2170: else if (NewDocType == docSVG)
1.819 vatton 2171: {
2172: /* will scan html documents */
2173: strcpy (ScanFilter, "*.svg");
1.850 cvs 2174: InitOpenDocForm (document, view, "New.svg", TtaGetMessage (AMAYA, AM_NEW_SVG), docSVG);
1.819 vatton 2175: }
1.315 cvs 2176: else
1.819 vatton 2177: {
2178: /* will scan html documents */
2179: strcpy (ScanFilter, "*.css");
1.850 cvs 2180: InitOpenDocForm (document, view, "New.css", TtaGetMessage (AMAYA, AM_NEW_CSS), docCSS);
1.819 vatton 2181: }
1.315 cvs 2182: }
2183:
2184: /*----------------------------------------------------------------------
1.311 cvs 2185: Load the Home page
2186: ----------------------------------------------------------------------*/
1.593 cvs 2187: void GoToHome (Document doc, View view)
1.311 cvs 2188: {
1.547 cvs 2189: char *s, *lang;
1.311 cvs 2190:
1.339 cvs 2191: s = TtaGetEnvString ("HOME_PAGE");
1.492 cvs 2192: lang = TtaGetVarLANG ();
1.589 cvs 2193:
1.492 cvs 2194: if (s == NULL)
2195: {
1.678 vatton 2196: /* the open document is the Amaya default page */
2197: WelcomePage = TRUE;
1.492 cvs 2198: s = TtaGetEnvString ("THOTDIR");
1.589 cvs 2199: sprintf (LastURLName, "%s%camaya%c%s.%s",
2200: s, DIR_SEP, DIR_SEP, AMAYA_PAGE, lang);
1.492 cvs 2201: if (!TtaFileExist (LastURLName))
1.589 cvs 2202: sprintf (LastURLName, "%s%camaya%c%s",
2203: s, DIR_SEP, DIR_SEP, AMAYA_PAGE);
1.492 cvs 2204: }
2205: else
1.547 cvs 2206: strcpy (LastURLName, s);
1.678 vatton 2207:
1.625 cvs 2208: if (doc == 0 || CanReplaceCurrentDocument (doc, view))
1.589 cvs 2209: {
2210: /* load the HOME document */
2211: InNewWindow = FALSE;
2212: CurrentDocument = doc;
2213: CallbackDialogue (BaseDialog + OpenForm, INTEGER_DATA, (char *) 1);
2214: }
1.311 cvs 2215: }
2216:
1.714 cvs 2217: /*----------------------------------------------------------------------
2218: UpdateDoctypeMenu
2219: ----------------------------------------------------------------------*/
2220: void UpdateDoctypeMenu (Document doc)
2221: {
1.717 cvs 2222: DocumentType docType;
2223: SSchema nature;
2224: char *ptr;
1.914 cvs 2225: ThotBool useMathML, useSVG;
1.717 cvs 2226:
1.714 cvs 2227: docType = DocumentTypes[doc];
2228:
2229: TtaSetItemOn (doc, 1, File, Doctype1);
2230: TtaSetItemOn (doc, 1, File, BRemoveDoctype);
1.933 ! cvs 2231: TtaSetItemOff (doc, 1, File, BAddDoctype);
1.714 cvs 2232: TtaSetItemOff (doc, 1, File, BDoctypeXhtml11);
2233: TtaSetItemOff (doc, 1, File, BDoctypeXhtmlTransitional);
2234: TtaSetItemOff (doc, 1, File, BDoctypeXhtmlStrict);
2235: TtaSetItemOff (doc, 1, File, BDoctypeXhtmlBasic);
2236: TtaSetItemOff (doc, 1, File, BDoctypeHtmlTransitional);
2237: TtaSetItemOff (doc, 1, File, BDoctypeHtmlStrict);
1.745 cvs 2238:
2239:
2240: if (docType == docText || docType == docCSS ||
2241: docType == docSource || docType == docLog)
2242: {
2243: /* Don't change the doctype for a text document */
2244: TtaSetItemOff (doc, 1, File, Doctype1);
2245: TtaSetItemOff (doc, 1, File, BRemoveDoctype);
2246: return;
2247: }
1.714 cvs 2248:
1.933 ! cvs 2249: /* look for a MathML or SVG nature within the document */
1.717 cvs 2250: nature = NULL;
2251: useMathML = FALSE;
1.914 cvs 2252: useSVG = FALSE;
1.717 cvs 2253: do
2254: {
2255: TtaNextNature (doc, &nature);
1.914 cvs 2256: if (nature)
1.717 cvs 2257: {
2258: ptr = TtaGetSSchemaName (nature);
2259: if (!strcmp (ptr, "MathML"))
2260: useMathML = TRUE;
1.914 cvs 2261: if (!strcmp (ptr, "SVG"))
2262: useSVG = TRUE;
1.717 cvs 2263: }
2264: }
2265: while (nature);
1.714 cvs 2266:
2267: switch (TtaGetDocumentProfile (doc))
2268: {
2269: case L_Other:
2270: if (docType == docHTML)
2271: {
1.933 ! cvs 2272: TtaSetItemOff (doc, 1, File, BRemoveDoctype);
! 2273: /* TtaSetItemOn (doc, 1, File, BAddDoctype); */
! 2274: if (!useMathML && !useSVG)
1.928 cvs 2275: {
1.933 ! cvs 2276: if (DocumentMeta[doc]->xmlformat)
! 2277: {
! 2278: TtaSetItemOn (doc, 1, File, BDoctypeXhtml11);
! 2279: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlTransitional);
! 2280: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlStrict);
! 2281: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlBasic);
! 2282: }
! 2283: else
! 2284: {
! 2285: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlTransitional);
! 2286: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlStrict);
! 2287: TtaSetItemOn (doc, 1, File, BDoctypeXhtml11);
! 2288: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlBasic);
! 2289: TtaSetItemOn (doc, 1, File, BDoctypeHtmlTransitional);
! 2290: TtaSetItemOn (doc, 1, File, BDoctypeHtmlStrict);
! 2291: }
1.717 cvs 2292: }
1.714 cvs 2293: }
2294: else if (docType == docMath)
1.933 ! cvs 2295: TtaSetItemOn (doc, 1, File, BAddDoctype);
1.714 cvs 2296: else if (docType == docSVG)
1.933 ! cvs 2297: TtaSetItemOn (doc, 1, File, BAddDoctype);
1.714 cvs 2298: break;
2299: case L_Xhtml11:
1.933 ! cvs 2300: if (!useMathML && !useSVG)
1.717 cvs 2301: {
2302: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlTransitional);
2303: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlStrict);
2304: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlBasic);
2305: }
1.714 cvs 2306: break;
2307: case L_Basic:
2308: TtaSetItemOn (doc, 1, File, BDoctypeXhtml11);
2309: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlTransitional);
2310: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlStrict);
2311: break;
2312: case L_Strict:
2313: if (DocumentMeta[doc]->xmlformat)
2314: {
2315: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlTransitional);
2316: TtaSetItemOn (doc, 1, File, BDoctypeXhtml11);
2317: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlBasic);
2318: }
2319: else
1.759 cvs 2320: {
2321: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlTransitional);
2322: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlStrict);
2323: TtaSetItemOn (doc, 1, File, BDoctypeXhtml11);
2324: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlBasic);
2325: TtaSetItemOn (doc, 1, File, BDoctypeHtmlTransitional);
2326: }
1.714 cvs 2327: break;
2328: case L_Transitional:
2329: if (DocumentMeta[doc]->xmlformat)
2330: {
2331: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlStrict);
2332: TtaSetItemOn (doc, 1, File, BDoctypeXhtml11);
2333: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlBasic);
2334: }
2335: else
1.759 cvs 2336: {
2337: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlTransitional);
2338: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlStrict);
2339: TtaSetItemOn (doc, 1, File, BDoctypeXhtml11);
2340: TtaSetItemOn (doc, 1, File, BDoctypeXhtmlBasic);
2341: TtaSetItemOn (doc, 1, File, BDoctypeHtmlStrict);
2342: }
1.714 cvs 2343: break;
2344: case L_MathML:
1.933 ! cvs 2345: case L_SVG:
1.714 cvs 2346: break;
1.933 ! cvs 2347: /* TtaSetItemOn (doc, 1, File, BAddDoctype); */
1.714 cvs 2348: break;
2349: }
2350: }
1.6 cvs 2351:
1.9 cvs 2352: /*----------------------------------------------------------------------
1.724 kahan 2353: AddDirAttributeToDocEl
2354: Set the HTML attribute dir on the Document element
2355: ----------------------------------------------------------------------*/
2356: void AddDirAttributeToDocEl (Document doc)
2357: {
2358: Element root;
2359: Attribute attr;
2360: AttributeType attrType;
2361:
2362: root = TtaGetMainRoot (doc);
2363: if (root)
2364: {
2365: attrType.AttrSSchema = TtaGetSSchema ("HTML", doc);
2366: if (!attrType.AttrSSchema)
2367: return;
2368: attrType.AttrTypeNum = HTML_ATTR_dir;
2369: attr = TtaNewAttribute (attrType);
2370: TtaAttachAttribute (root, attr, doc);
2371: TtaSetAttributeValue (attr, HTML_ATTR_dir_VAL_ltr_, root, doc);
2372: }
2373: }
2374:
2375: /*----------------------------------------------------------------------
1.690 cvs 2376: InitDocAndView prepares the main view of a new document.
1.247 cvs 2377: logFile is TRUE if the new view is created to display a log file
1.437 cvs 2378: sourceOfDoc is not zero when we're opening the source view of a document.
1.926 gully 2379: params:
2380: + Document oldDoc: the old document id
2381: + ThotBool replaceOldDoc: true if the new doc should replace the old one
2382: + ThotBool inNewWindow: true if the new doc should be created in a new window
2383: + ...
1.9 cvs 2384: ----------------------------------------------------------------------*/
1.926 gully 2385: Document InitDocAndView (Document oldDoc, ThotBool replaceOldDoc, ThotBool inNewWindow,
2386: char *docname, DocumentType docType,
1.838 vatton 2387: Document sourceOfDoc, ThotBool readOnly, int profile,
2388: ClickEvent method)
1.6 cvs 2389: {
1.926 gully 2390: Document doc; /* the new doc */
1.527 cvs 2391: View mainView, structView, altView, linksView, tocView;
2392: Document old_doc;
1.699 cvs 2393: Element root, comment, leaf;
2394: ElementType elType;
1.930 vatton 2395: char *tmp, buffer[MAX_LENGTH];
1.527 cvs 2396: int x, y, w, h;
2397: int requested_doc;
1.699 cvs 2398: Language lang;
1.645 vatton 2399: ThotBool isOpen, reinitialized, show;
1.650 vatton 2400:
1.915 gully 2401: #ifdef _WX
2402: /* this is the window id identifying where the document should be shown
2403: * this window_id is a document attribute and the corresponding
2404: * window widget has been allocated before this function call */
2405: int window_id = -1;
1.926 gully 2406: /* this is the page id identifying where the document should be shown
2407: * into a window (window_id), each page can contain one or more documents */
2408: int page_id = -1;
1.915 gully 2409: #endif /* _WX */
2410:
1.916 cvs 2411: #ifdef _WINGUI
1.276 cvs 2412: Window_Curs = IDC_WINCURSOR;
1.916 cvs 2413: #endif /* _WINGUI */
1.349 cvs 2414:
2415: /* is there any editing function available */
2416: if (!TtaCanEdit ())
1.479 cvs 2417: /* change the document status */
2418: readOnly = TRUE;
1.638 kahan 2419:
1.518 cvs 2420: /* previous document */
1.926 gully 2421: old_doc = oldDoc;
2422: doc = oldDoc;
1.527 cvs 2423: reinitialized = FALSE;
1.518 cvs 2424:
1.926 gully 2425: /* if there is no old doc then force the document to
2426: be created in a new window */
2427: if (oldDoc == 0)
2428: inNewWindow = TRUE;
2429:
2430: if (replaceOldDoc)
1.338 cvs 2431: /* the new document will replace another document in the same window */
1.276 cvs 2432: {
1.915 gully 2433: #ifdef _WX
2434: /* get the old document window */
2435: window_id = TtaGetWindowId( doc );
1.926 gully 2436: /* get the old document page id */
2437: page_id = TtaGetPageId( doc );
1.915 gully 2438: #endif /* _WX */
2439:
1.504 cvs 2440: /* keep in memory if the closed document is in read-only mode */
2441: if (ReadOnlyDocument[doc])
2442: readOnly = TRUE;
1.527 cvs 2443: else
2444: /* if there is a parsing error/warning for the old document */
2445: if (!TtaGetDocumentAccessMode (doc))
2446: reinitialized = TRUE;
2447:
1.505 cvs 2448: if (DocumentTypes[doc] == docHTML ||
2449: DocumentTypes[doc] == docSVG ||
1.545 cvs 2450: DocumentTypes[doc] == docXml ||
1.765 cvs 2451: DocumentTypes[doc] == docMath ||
2452: DocumentTypes[doc] == docLibrary)
1.276 cvs 2453: {
2454: /* close the Alternate view if it is open */
1.408 cvs 2455: altView = TtaGetViewFromName (doc, "Alternate_view");
1.529 cvs 2456: if (altView != 0 && TtaIsViewOpen (doc, altView))
1.276 cvs 2457: TtaCloseView (doc, altView);
2458: /* close the Structure view if it is open */
1.408 cvs 2459: structView = TtaGetViewFromName (doc, "Structure_view");
1.529 cvs 2460: if (structView != 0 && TtaIsViewOpen (doc, structView))
1.276 cvs 2461: TtaCloseView (doc, structView);
2462: /* close the Links view if it is open */
1.408 cvs 2463: linksView = TtaGetViewFromName (doc, "Links_view");
1.529 cvs 2464: if (linksView != 0 && TtaIsViewOpen (doc, linksView))
1.276 cvs 2465: TtaCloseView (doc, linksView);
2466: /* close the Table_of_contents view if it is open */
1.408 cvs 2467: tocView = TtaGetViewFromName (doc, "Table_of_contents");
1.529 cvs 2468: if (tocView != 0 && TtaIsViewOpen (doc, tocView))
1.276 cvs 2469: TtaCloseView (doc, tocView);
2470: }
1.479 cvs 2471: /* remove the current selection */
1.10 cvs 2472: TtaUnselect (doc);
2473: UpdateContextSensitiveMenus (doc);
2474: TtaFreeView (doc, 1);
1.481 cvs 2475: isOpen = TRUE;
1.508 cvs 2476: /* use the same document identifier */
2477: requested_doc = doc;
1.48 cvs 2478: old_doc = 0; /* the previous document doesn't exist any more */
1.325 cvs 2479: /* The toolkit has to do its job now */
2480: TtaHandlePendingEvents ();
1.10 cvs 2481: }
1.926 gully 2482: else if (inNewWindow)
2483: {
2484: /* open the new document in a fresh window */
2485: isOpen = FALSE;
2486: requested_doc = 0;
2487: #ifdef _WX
2488: window_id = TtaMakeWindow();
2489: page_id = TtaGetFreePageId( window_id );
2490: #endif /* _WX */
2491: }
1.10 cvs 2492: else
1.508 cvs 2493: {
1.926 gully 2494: /* open the new document in the same window but in a fresh page */
1.508 cvs 2495: isOpen = FALSE;
2496: requested_doc = 0;
1.915 gully 2497: #ifdef _WX
1.926 gully 2498: window_id = TtaGetWindowId( oldDoc );
2499: page_id = TtaGetFreePageId( window_id );
1.915 gully 2500: #endif /* _WX */
1.508 cvs 2501: }
1.10 cvs 2502:
1.690 cvs 2503: /* Init the new document */
1.587 cvs 2504: if (docType == docText || docType == docCSS ||
2505: docType == docSource || docType == docLog)
1.547 cvs 2506: doc = TtaInitDocument ("TextFile", docname, requested_doc);
1.479 cvs 2507: else if (docType == docAnnot)
1.547 cvs 2508: doc = TtaInitDocument ("Annot", docname, requested_doc);
1.844 kahan 2509: #ifdef BOOKMARKS
2510: else if (docType == docBookmark)
2511: doc = TtaInitDocument ("Topics", docname, requested_doc);
2512: #endif /* BOOKMARKS */
1.479 cvs 2513: else if (docType == docSVG)
1.652 vatton 2514: doc = TtaInitDocument ("SVG", docname, requested_doc);
1.479 cvs 2515: else if (docType == docMath)
1.547 cvs 2516: doc = TtaInitDocument ("MathML", docname, requested_doc);
1.616 cvs 2517: #ifdef XML_GENERIC
1.545 cvs 2518: else if (docType == docXml)
1.547 cvs 2519: doc = TtaInitDocument ("XML", docname, requested_doc);
1.616 cvs 2520: #endif /* XML_GENERIC */
1.276 cvs 2521: else
1.547 cvs 2522: doc = TtaInitDocument ("HTML", docname, requested_doc);
1.197 cvs 2523: if (doc >= DocumentTableLength)
2524: {
2525: TtaCloseDocument (doc);
2526: doc = 0;
2527: }
2528: else if (doc > 0)
1.10 cvs 2529: {
1.338 cvs 2530: /* assign a presentation model to the document */
1.587 cvs 2531: if (docType == docText || docType == docCSS ||
2532: docType == docSource || docType == docLog)
1.547 cvs 2533: TtaSetPSchema (doc, "TextFileP");
1.479 cvs 2534: else if (docType == docAnnot)
1.547 cvs 2535: TtaSetPSchema (doc, "AnnotP");
1.844 kahan 2536: #ifdef BOOKMARKS
2537: else if (docType == docBookmark)
2538: TtaSetPSchema (doc, "TopicsP");
2539: #endif /* BOOKMARKS */
1.479 cvs 2540: else if (docType == docSVG)
1.652 vatton 2541: TtaSetPSchema (doc, "SVGP");
1.479 cvs 2542: else if (docType == docMath)
1.547 cvs 2543: TtaSetPSchema (doc, "MathMLP");
1.616 cvs 2544: #ifdef XML_GENERIC
1.545 cvs 2545: else if (docType == docXml)
1.547 cvs 2546: TtaSetPSchema (doc, "XMLP");
1.616 cvs 2547: #endif /* XML_GENERIC */
1.388 cvs 2548: /* @@ shouldn't we have a Color and BW case for annots too? */
1.276 cvs 2549: else
2550: {
2551: if (TtaGetScreenDepth () > 1)
1.547 cvs 2552: TtaSetPSchema (doc, "HTMLP");
1.276 cvs 2553: else
1.547 cvs 2554: TtaSetPSchema (doc, "HTMLPBW");
1.705 quint 2555: /* set attribute dir on the Document element. */
1.724 kahan 2556: AddDirAttributeToDocEl (doc);
1.276 cvs 2557: }
1.699 cvs 2558: if (docType == docSVG || docType == docMath)
2559: /* add a comment proudly claiming that the document was created by
2560: Amaya */
2561: {
2562: root = TtaGetRootElement (doc);
2563: elType = TtaGetElementType (root);
2564: if (docType == docSVG)
2565: elType.ElTypeNum = SVG_EL_XMLcomment;
2566: else
2567: elType.ElTypeNum = MathML_EL_XMLcomment;
2568: comment = TtaNewTree (doc, elType, "");
1.723 quint 2569: TtaSetStructureChecking (0, doc);
2570: TtaInsertSibling (comment, root, TRUE, doc);
2571: TtaSetStructureChecking (1, doc);
1.699 cvs 2572: strcpy (buffer, " Created by ");
2573: strcat (buffer, HTAppName);
2574: strcat (buffer, " ");
2575: strcat (buffer, HTAppVersion);
2576: strcat (buffer, ", see http://www.w3.org/Amaya/ ");
2577: leaf = TtaGetFirstLeaf (comment);
1.703 vatton 2578: lang = TtaGetLanguageIdFromScript('L');
1.907 gully 2579: TtaSetTextContent (leaf, (unsigned char *)buffer, lang, doc);
1.699 cvs 2580: }
1.917 kahan 2581: if (docType == docBookmark)
2582: TtaSetNotificationMode (doc, 0); /* we don't need notif. in
2583: bookmarks */
2584: else
2585: TtaSetNotificationMode (doc, 1);
1.915 gully 2586:
2587: #ifdef _WX
1.926 gully 2588: /* the document needs to have a window parent and a page id
2589: * (identified by window_id and page_id) */
1.915 gully 2590: TtaSetWindowId( doc, window_id );
1.926 gully 2591: TtaSetPageId( doc, page_id );
1.915 gully 2592: #endif /* _WX */
2593:
1.338 cvs 2594: /* get the geometry of the main view */
1.479 cvs 2595: if (docType == docAnnot)
1.444 kahan 2596: tmp = "Annot_Formatted_view";
1.870 kahan 2597: else if (docType == docBookmark)
2598: tmp = "Topics_Formatted_view";
1.479 cvs 2599: else if (sourceOfDoc && docType == docSource)
1.452 cvs 2600: tmp = "Source_view";
1.444 kahan 2601: else
2602: tmp = "Formatted_view";
1.452 cvs 2603: TtaGetViewGeometry (doc, tmp, &x, &y, &w, &h);
2604: if (docType == docLog)
2605: {
1.512 cvs 2606: x += 100;
2607: y += 60;
1.452 cvs 2608: h = 300;
2609: w = 550;
2610: }
1.483 cvs 2611: else if (docType == docMath)
2612: {
2613: h = 300;
1.699 cvs 2614: w = 580;
1.483 cvs 2615: }
1.879 vatton 2616: else if (method == CE_HELP )
1.765 cvs 2617: {
1.767 cvs 2618: x += 500;
2619: y += 200;
1.765 cvs 2620: h = 500;
1.879 vatton 2621: w = 800;
2622: }
2623: else if (docType == docLibrary && method == CE_RELATIVE)
2624: {
2625: x += 500;
2626: y += 200;
2627: h = 500;
2628: w = 400;
1.765 cvs 2629: }
1.276 cvs 2630: /* change the position slightly to avoid hiding completely the main
2631: view of other documents */
1.452 cvs 2632: x = x + (doc - 1) * 10;
2633: y = y + (doc - 1) * 10;
1.338 cvs 2634: /* open the main view */
1.879 vatton 2635: if (docType == docLog ||
2636: (docType == docLibrary && method == CE_RELATIVE))
1.824 vatton 2637: /* without menu bar */
2638: mainView = TtaOpenMainView (doc, x, y, w, h, FALSE, TRUE);
2639: else
2640: mainView = TtaOpenMainView (doc, x, y, w, h, TRUE, TRUE);
1.276 cvs 2641:
2642: if (mainView == 0)
2643: {
2644: TtaCloseDocument (doc);
2645: return (0);
2646: }
1.690 cvs 2647:
2648: /* store the profile of the new document */
2649: /* and update the menus according to it */
2650: TtaSetDocumentProfile (doc, profile);
1.693 vatton 2651: if (profile != 0)
2652: TtaUpdateMenus (doc, 1, readOnly);
1.458 cvs 2653: /* By default no log file */
1.524 cvs 2654: TtaSetItemOff (doc, 1, Views, BShowLogFile);
1.872 kahan 2655: #ifndef BOOKMARKS
2656: /* if bookmarks are not enabled, disable the menu */
2657: TtaSetMenuOff (doc, 1, Bookmarks_);
2658: #endif /* BOOKMARKS */
2659:
1.930 vatton 2660: if (docType == docSource || docType == docLog ||
2661: docType == docLibrary || docType == docBookmark)
1.791 vatton 2662: {
1.780 cvs 2663: TtaSetItemOff (doc, 1, File, BHtmlBasic);
2664: TtaSetItemOff (doc, 1, File, BHtmlStrict);
2665: TtaSetItemOff (doc, 1, File, BHtml11);
2666: TtaSetItemOff (doc, 1, File, BHtmlTransitional);
2667: TtaSetItemOff (doc, 1, File, BMathml);
2668: TtaSetItemOff (doc, 1, File, BSvg);
2669: TtaSetItemOff (doc, 1, File, BTemplate);
2670: TtaSetItemOff (doc, 1, File, BCss);
2671: TtaSetItemOff (doc, 1, File, BOpenDoc);
2672: TtaSetItemOff (doc, 1, File, BOpenInNewWindow);
2673: TtaSetItemOff (doc, 1, File, BReload);
2674: TtaSetItemOff (doc, 1, File, BBack);
2675: TtaSetItemOff (doc, 1, File, BForward);
2676: TtaSetItemOff (doc, 1, File, BSave);
2677: TtaSetItemOff (doc, 1, File, BSynchro);
1.930 vatton 2678: TtaSetItemOff (doc, 1, File, BDocInfo);
2679: TtaSetItemOff (doc, 1, File, BSetUpandPrint);
2680: TtaSetItemOff (doc, 1, File, BPrint);
1.931 vatton 2681: TtaSetItemOff (doc, 1, Edit_, BTransform);
1.452 cvs 2682: TtaSetMenuOff (doc, 1, Types);
1.808 vatton 2683: TtaSetMenuOff (doc, 1, XMLTypes);
1.452 cvs 2684: TtaSetMenuOff (doc, 1, Links);
2685: TtaSetMenuOff (doc, 1, Views);
2686: TtaSetMenuOff (doc, 1, Style);
2687: TtaSetMenuOff (doc, 1, Special);
2688: TtaSetMenuOff (doc, 1, Attributes_);
2689: #ifdef ANNOTATIONS
2690: TtaSetMenuOff (doc, 1, Annotations_);
2691: #endif /* ANNOTATIONS */
1.869 kahan 2692: #ifdef BOOKMARKS
1.930 vatton 2693: if (docType == docBookmark)
2694: {
2695: TtaSetItemOff (doc, 1, Bookmarks_, BBookmarkFile);
2696: TtaSetMenuOff (doc, 1, Edit_);
2697: }
2698: else
2699: TtaSetMenuOff (doc, 1, Bookmarks_);
1.869 kahan 2700: #endif /* BOOKMARKS */
1.452 cvs 2701: TtaSetMenuOff (doc, 1, Help_);
2702: TtcSwitchButtonBar (doc, 1); /* no button bar */
1.930 vatton 2703: if (docType == docLog || docType == docLibrary)
1.768 vatton 2704: {
1.930 vatton 2705: TtaSetItemOff (doc, 1, File, BExit);
2706: TtaSetMenuOff (doc, 1, Edit_);
2707: /* change the document status */
2708: ReadOnlyDocument[doc] = FALSE;
2709: TtaSetDocumentAccessMode (doc, 1);
2710: if (docType == docLibrary)
2711: {
1.884 vatton 2712: #ifdef _SVG
1.930 vatton 2713: if (InNewWindow == TRUE)
2714: {
2715: /* Initialize SVG Library Buffer string */
2716: TtaAddTextZone (doc, 1, TtaGetMessage (AMAYA, AM_OPEN_URL),
2717: FALSE, (Proc)OpenLibraryCallback, SVGlib_list);
2718: }
2719: #endif /* _SVG */
1.783 cvs 2720: }
1.768 vatton 2721: }
1.930 vatton 2722: if (docType != docLibrary)
1.768 vatton 2723: TtcSwitchCommands (doc, 1); /* no command open */
1.931 vatton 2724: isOpen = TRUE;
1.452 cvs 2725: }
1.481 cvs 2726: else if (!isOpen)
1.276 cvs 2727: {
1.930 vatton 2728: /* use a new window: Create all buttons */
1.907 gully 2729: iStop =TtaAddButton (doc, 1, stopN, (Proc)StopTransfer,"StopTransfer",
1.445 cvs 2730: TtaGetMessage (AMAYA, AM_BUTTON_INTERRUPT),
2731: TBSTYLE_BUTTON, FALSE);
1.907 gully 2732: iBack = TtaAddButton (doc, 1, iconBackNo, (Proc)GotoPreviousHTML,
1.445 cvs 2733: "GotoPreviousHTML",
2734: TtaGetMessage (AMAYA, AM_BUTTON_PREVIOUS),
2735: TBSTYLE_BUTTON, FALSE);
1.907 gully 2736: iForward = TtaAddButton (doc, 1, iconForwardNo, (Proc)GotoNextHTML,
1.445 cvs 2737: "GotoNextHTML",
2738: TtaGetMessage (AMAYA, AM_BUTTON_NEXT),
2739: TBSTYLE_BUTTON, FALSE);
1.907 gully 2740: iReload = TtaAddButton (doc, 1, iconReload, (Proc)Reload, "Reload",
1.445 cvs 2741: TtaGetMessage (AMAYA, AM_BUTTON_RELOAD),
2742: TBSTYLE_BUTTON, TRUE);
1.907 gully 2743: iHome = TtaAddButton (doc, 1, iconHome, (Proc)GoToHome, "GoToHome",
1.445 cvs 2744: TtaGetMessage (AMAYA, AM_BUTTON_HOME),
2745: TBSTYLE_BUTTON, TRUE);
1.891 gully 2746:
1.916 cvs 2747: #ifdef _WINGUI
1.649 cvs 2748: /* cannot change the browser icone -> use active instead of */
1.907 gully 2749: iEditor = TtaAddButton (doc, 1, iconBrowser, (Proc)SetBrowserEditor,
1.649 cvs 2750: "SetBrowserEditor",
2751: TtaGetMessage (AMAYA, AM_BUTTON_BrowseEdit),
2752: TBSTYLE_BUTTON, TRUE);
2753: TtaChangeButton (doc, 1, iEditor, iconEditor, TRUE);
1.916 cvs 2754: #endif /* _WINGUI */
1.891 gully 2755:
1.911 gully 2756: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.907 gully 2757: iEditor = TtaAddButton (doc, 1, iconEditor, (Proc)SetBrowserEditor,
1.445 cvs 2758: "SetBrowserEditor",
2759: TtaGetMessage (AMAYA, AM_BUTTON_BrowseEdit),
2760: TBSTYLE_BUTTON, TRUE);
1.911 gully 2761: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 2762:
1.276 cvs 2763: /* SEPARATOR */
1.340 cvs 2764: TtaAddButton (doc, 1, None, NULL, NULL, NULL, TBSTYLE_SEP, FALSE);
1.907 gully 2765: iSave = TtaAddButton (doc, 1, iconSaveNo, (Proc)SaveDocument,
1.445 cvs 2766: "SaveDocument",
2767: TtaGetMessage (AMAYA, AM_BUTTON_SAVE),
2768: TBSTYLE_BUTTON, FALSE);
1.907 gully 2769: iPrint = TtaAddButton (doc, 1, iconPrint, (Proc)SetupAndPrint, "SetupAndPrint",
1.448 cvs 2770: TtaGetMessage (AMAYA, AM_BUTTON_PRINT),
2771: TBSTYLE_BUTTON, TRUE);
1.907 gully 2772: iFind = TtaAddButton (doc, 1, iconFind, (Proc)TtcSearchText,
1.445 cvs 2773: "TtcSearchText",
2774: TtaGetMessage (AMAYA, AM_BUTTON_SEARCH),
2775: TBSTYLE_BUTTON, TRUE);
1.276 cvs 2776: /* SEPARATOR */
1.340 cvs 2777: TtaAddButton (doc, 1, None, NULL, NULL, NULL, TBSTYLE_SEP, FALSE);
1.907 gully 2778: iI = TtaAddButton (doc, 1, iconI, (Proc)SetOnOffEmphasis,
1.445 cvs 2779: "SetOnOffEmphasis",
2780: TtaGetMessage (AMAYA, AM_BUTTON_ITALICS),
2781: TBSTYLE_CHECK, TRUE);
1.907 gully 2782: iB = TtaAddButton (doc, 1, iconB, (Proc)SetOnOffStrong, "SetOnOffStrong",
1.445 cvs 2783: TtaGetMessage (AMAYA, AM_BUTTON_BOLD),
2784: TBSTYLE_CHECK, TRUE);
1.907 gully 2785: iT = TtaAddButton (doc, 1, iconT, (Proc)SetOnOffCode, "SetOnOffCode",
1.445 cvs 2786: TtaGetMessage (AMAYA, AM_BUTTON_CODE),
2787: TBSTYLE_CHECK, TRUE);
1.276 cvs 2788: /* SEPARATOR */
1.340 cvs 2789: TtaAddButton (doc, 1, None, NULL, NULL, NULL, TBSTYLE_SEP, FALSE);
1.907 gully 2790: iImage = TtaAddButton (doc, 1, iconImage, (Proc)CreateImage,
1.445 cvs 2791: "CreateImage",
2792: TtaGetMessage (AMAYA, AM_BUTTON_IMG),
2793: TBSTYLE_BUTTON, TRUE);
1.907 gully 2794: iH1 = TtaAddButton (doc, 1, iconH1, (Proc)CreateHeading1,
1.445 cvs 2795: "CreateHeading1",
2796: TtaGetMessage (AMAYA, AM_BUTTON_H1),
2797: TBSTYLE_BUTTON, TRUE);
1.907 gully 2798: iH2 = TtaAddButton (doc, 1, iconH2, (Proc)CreateHeading2,
1.445 cvs 2799: "CreateHeading2",
2800: TtaGetMessage (AMAYA, AM_BUTTON_H2),
2801: TBSTYLE_BUTTON, TRUE);
1.907 gully 2802: iH3 = TtaAddButton (doc, 1, iconH3, (Proc)CreateHeading3,
1.445 cvs 2803: "CreateHeading3",
2804: TtaGetMessage (AMAYA, AM_BUTTON_H3),
2805: TBSTYLE_BUTTON, TRUE);
1.907 gully 2806: iBullet = TtaAddButton (doc, 1, iconBullet, (Proc)CreateList,
1.445 cvs 2807: "CreateList",
2808: TtaGetMessage (AMAYA, AM_BUTTON_UL),
2809: TBSTYLE_BUTTON, TRUE);
1.907 gully 2810: iNum = TtaAddButton (doc, 1, iconNum, (Proc)CreateNumberedList,
1.445 cvs 2811: "CreateNumberedList",
2812: TtaGetMessage (AMAYA, AM_BUTTON_OL),
2813: TBSTYLE_BUTTON, TRUE);
1.907 gully 2814: iDL = TtaAddButton (doc, 1, iconDL, (Proc)CreateDefinitionList,
1.445 cvs 2815: "CreateDefinitionList",
2816: TtaGetMessage (AMAYA, AM_BUTTON_DL),
2817: TBSTYLE_BUTTON, TRUE);
1.907 gully 2818: iLink = TtaAddButton (doc, 1, iconLink, (Proc)CreateOrChangeLink,
1.445 cvs 2819: "CreateOrChangeLink",
2820: TtaGetMessage (AMAYA, AM_BUTTON_LINK),
2821: TBSTYLE_BUTTON, TRUE);
1.907 gully 2822: iTable = TtaAddButton (doc, 1, iconTable, (Proc)CreateTable,
1.445 cvs 2823: "CreateTable",
2824: TtaGetMessage (AMAYA, AM_BUTTON_TABLE),
2825: TBSTYLE_BUTTON, TRUE);
1.276 cvs 2826: AddMathButton (doc, 1);
1.652 vatton 2827: #ifdef _SVG
1.276 cvs 2828: AddGraphicsButton (doc, 1);
1.765 cvs 2829: AddLibraryButton (doc, 1);
1.764 pierre 2830: AddAnimButton (doc, 1);
1.847 cheyroul 2831: #ifdef _GL
1.823 cheyroul 2832: AddAnimPlayButton (doc, 1);
1.847 cheyroul 2833: #endif /*_GL*/
1.891 gully 2834:
1.799 vatton 2835: #endif /* _SVG */
1.479 cvs 2836: if (docType == docAnnot)
1.704 kahan 2837: {
2838: /* turn off the menus that don't make sense in the annotation view */
1.739 kahan 2839: TtaAddTextZone (doc, 1, TtaGetMessage (AMAYA, AM_OPEN_URL),
1.907 gully 2840: TRUE, (Proc)TextURL, NULL);
1.704 kahan 2841: TtcSwitchCommands (doc, 1); /* no command open */
2842: TtaSetItemOff (doc, 1, Views, BShowAlternate);
2843: TtaSetItemOff (doc, 1, Views, BShowToC);
2844: TtaSetItemOff (doc, 1, Views, BShowSource);
1.869 kahan 2845: #ifdef BOOKMARKS
2846: TtaSetMenuOff (doc, 1, Bookmarks_);
2847: #endif /* BOOKMARKS */
1.704 kahan 2848: }
1.452 cvs 2849: else
1.571 kahan 2850: {
2851: TtaAddTextZone (doc, 1, TtaGetMessage (AMAYA, AM_OPEN_URL),
1.907 gully 2852: TRUE, (Proc)TextURL, URL_list);
1.571 kahan 2853: /* turn off the assign annotation buttons (should be
2854: contextual */
1.597 kahan 2855: TtaSetItemOff (doc, 1, Annotations_, BReplyToAnnotation);
1.571 kahan 2856: TtaSetItemOff (doc, 1, Annotations_, BMoveAnnotSel);
2857: TtaSetItemOff (doc, 1, Annotations_, BMoveAnnotXPtr);
2858: TtaSetItemOff (doc, 1, Annotations_, BPostAnnot);
2859: }
1.393 cvs 2860:
1.276 cvs 2861: /* initial state for menu entries */
2862: TtaSetItemOff (doc, 1, File, BBack);
2863: TtaSetItemOff (doc, 1, File, BForward);
1.310 cvs 2864: TtaSetItemOff (doc, 1, File, BSave);
1.352 cvs 2865: TtaSetItemOff (doc, 1, File, BSynchro);
1.772 vatton 2866: if (SButtons[doc])
2867: TtaSetToggleItem (doc, 1, Views, TShowButtonbar, TRUE);
2868: else
2869: /* hide buttons */
2870: TtcSwitchButtonBar (doc, 1);
2871: if (SAddress[doc])
2872: TtaSetToggleItem (doc, 1, Views, TShowTextZone, TRUE);
2873: else
2874: /* hide the address */
2875: TtcSwitchCommands (doc, 1);
1.645 vatton 2876: TtaSetToggleItem (doc, 1, Views, TShowMapAreas, MapAreas[doc]);
2877: TtaSetToggleItem (doc, 1, Special, TSectionNumber, SNumbering[doc]);
2878: TtaGetEnvBoolean ("SHOW_TARGET", &show);
2879: if (show)
2880: ShowTargets (doc, 1);
2881: else
2882: TtaSetToggleItem (doc, 1, Views, TShowTargets, FALSE);
1.322 cvs 2883: TtaSetMenuOff (doc, 1, Attributes_);
1.930 vatton 2884: #ifndef DAV /* after all, we active the WebDAV menu in the main view */
2885: TtaSetMenuOff (doc, 1, Cooperation_);
2886: #endif /* DAV */
1.276 cvs 2887:
2888: /* if we open the new document in a new view, control */
2889: /* is transferred from previous document to new document */
2890: if (old_doc != doc && old_doc != 0)
2891: {
2892: ResetStop (old_doc);
2893: /* clear the status line of previous document */
1.547 cvs 2894: TtaSetStatus (old_doc, 1, " ", NULL);
1.276 cvs 2895: ActiveTransfer (doc);
2896: }
1.871 kahan 2897: #ifdef BOOKMARKS
1.930 vatton 2898: /* if there are multiple instances of Amaya, disable the bookmark menu */
2899: if (!GetBookmarksEnabled ())
2900: TtaSetMenuOff (doc, 1, Bookmarks_);
1.871 kahan 2901: #endif /* BOOKMARKS */
1.930 vatton 2902: }
1.931 vatton 2903: else if (!reinitialized)
2904: /* we have to redraw buttons and menus? */
2905: reinitialized = docType != DocumentTypes[doc];
1.276 cvs 2906: }
2907:
1.481 cvs 2908: /* store the new document type */
2909: DocumentTypes[doc] = docType;
2910: if (reinitialized || !isOpen)
1.492 cvs 2911: {
1.930 vatton 2912: /* now update menus and buttons according to the document status */
2913: if (DocumentTypes[doc] == docText ||
2914: DocumentTypes[doc] == docCSS ||
2915: DocumentTypes[doc] == docMath)
2916: {
2917: TtaChangeButton (doc, 1, iI, iconINo, FALSE);
2918: TtaChangeButton (doc, 1, iB, iconBNo, FALSE);
2919: TtaChangeButton (doc, 1, iT, iconTNo, FALSE);
2920: TtaChangeButton (doc, 1, iImage, iconImageNo, FALSE);
2921: TtaChangeButton (doc, 1, iH1, iconH1No, FALSE);
2922: TtaChangeButton (doc, 1, iH2, iconH2No, FALSE);
2923: TtaChangeButton (doc, 1, iH3, iconH3No, FALSE);
2924: TtaChangeButton (doc, 1, iBullet, iconBulletNo, FALSE);
2925: TtaChangeButton (doc, 1, iNum, iconNumNo, FALSE);
2926: TtaChangeButton (doc, 1, iDL, iconDLNo, FALSE);
2927: TtaChangeButton (doc, 1, iTable, iconTableNo, FALSE);
1.932 vatton 2928: TtaChangeButton (doc, 1, iLink, iconLinkNo, FALSE);
2929: TtaSetItemOff (doc, 1, Special, TSectionNumber);
1.930 vatton 2930: TtaSetItemOff (doc, 1, Special, BMakeBook);
2931: TtaSetItemOff (doc, 1, Views, TShowMapAreas);
2932: TtaSetItemOff (doc, 1, Views, TShowTargets);
2933: TtaSetItemOff (doc, 1, Views, BShowAlternate);
2934: TtaSetItemOff (doc, 1, Views, BShowLinks);
2935: TtaSetItemOff (doc, 1, Views, BShowToC);
2936: TtaSetMenuOff (doc, 1, Doctype1);
2937: TtaSetMenuOff (doc, 1, Types);
1.932 vatton 2938: TtaSetMenuOff (doc, 1, Links);
2939: if (DocumentTypes[doc] != docMath)
1.930 vatton 2940: {
1.931 vatton 2941: TtaSetItemOff (doc, 1, Edit_, BTransform);
1.930 vatton 2942: SwitchIconMath (doc, 1, FALSE);
2943: TtaSetMenuOff (doc, 1, XMLTypes);
2944: TtaSetMenuOff (doc, 1, Views);
2945: TtaSetMenuOff (doc, 1, Style);
2946: TtaSetMenuOff (doc, 1, Attributes_);
2947: }
1.652 vatton 2948: #ifdef _SVG
1.930 vatton 2949: SwitchIconGraph (doc, 1, FALSE);
2950: SwitchIconLibrary (doc, 1, FALSE);
2951: SwitchIconAnim (doc, 1, FALSE);
1.799 vatton 2952: #endif /* _SVG */
1.930 vatton 2953: }
2954: else
2955: {
2956: TtaSetMenuOn (doc, 1, Views);
1.932 vatton 2957: TtaSetItemOn (doc, 1, Views, TShowTargets);
2958: if (DocumentTypes[doc] == docHTML)
2959: {
2960: TtaSetItemOn (doc, 1, Views, TShowMapAreas);
2961: TtaSetItemOn (doc, 1, Views, BShowAlternate);
2962: TtaSetItemOn (doc, 1, Views, BShowToC);
2963: if (DocumentMeta[doc] == NULL ||
2964: !DocumentMeta[doc]->xmlformat ||
2965: profile == L_Strict || profile == L_Basic)
2966: TtaSetMenuOff (doc, 1, XMLTypes);
2967: }
2968: else
2969: {
2970: TtaSetItemOff (doc, 1, Views, TShowMapAreas);
2971: TtaSetItemOff (doc, 1, Views, BShowAlternate);
2972: TtaSetItemOff (doc, 1, Views, BShowToC);
2973: TtaSetItemOff (doc, 1, Special, TSectionNumber);
2974: TtaSetItemOff (doc, 1, Special, BMakeBook);
2975: }
1.930 vatton 2976: }
1.492 cvs 2977: }
1.749 kirschpi 2978:
1.930 vatton 2979: /* set the document in Read-Only mode */
2980: if (readOnly)
2981: ReadOnlyDocument[doc] = TRUE;
1.10 cvs 2982: return (doc);
1.6 cvs 2983: }
2984:
1.9 cvs 2985: /*----------------------------------------------------------------------
1.248 cvs 2986: CreateHTMLContainer creates an HTML container for an image
2987: ----------------------------------------------------------------------*/
1.547 cvs 2988: static void CreateHTMLContainer (char *pathname, char *docname,
2989: char *tempfile, ThotBool local)
1.248 cvs 2990: {
2991: FILE *file;
1.547 cvs 2992: char *tempfile_new;
2993: char *ptr;
1.248 cvs 2994:
2995: if (!local)
2996: {
2997: /* Rename the current downloaded file (an image) so that we can
2998: find it easily next time around.
2999: The convention is to change the image's extension to 'html',
3000: and give the HTML's container the image's extension */
1.907 gully 3001: tempfile_new = (char *)TtaGetMemory (strlen (tempfile) + strlen (docname) + 10);
1.547 cvs 3002: strcpy (tempfile_new, tempfile);
3003: ptr = strrchr (tempfile_new, DIR_SEP);
1.248 cvs 3004: ptr++;
1.547 cvs 3005: strcpy (ptr, docname);
1.906 vatton 3006: SetContainerImageName (tempfile_new);
3007: TtaFileUnlink (tempfile_new);
3008: if (TtaFileCopyUncompress (tempfile, tempfile_new))
3009: /* copy done */
3010: TtaFileUnlink (tempfile);
1.248 cvs 3011: else
1.906 vatton 3012: /* change the tempfile name */
3013: sprintf (tempfile_new, "%s", tempfile);
1.248 cvs 3014: TtaFreeMemory (tempfile_new);
3015: }
3016: /* create a temporary file for the container and make Amaya think
3017: that it is the current downloaded file */
1.547 cvs 3018: file = fopen (tempfile, "w");
1.805 vatton 3019: fprintf (file, "<html><head><title>%s</title></head><body>", docname);
1.248 cvs 3020: if (local)
1.638 kahan 3021: fprintf (file, "<img src=\"%s\">", pathname);
1.248 cvs 3022: else
1.638 kahan 3023: fprintf (file, "<img src=\"internal:%s\">", pathname);
3024: fprintf (file, "</body></html>");
1.248 cvs 3025: fclose (file);
3026: }
3027:
3028: /*----------------------------------------------------------------------
1.254 cvs 3029: MoveImageFile moves an image file (related to an HTML container) from
3030: one directory to another
3031: ----------------------------------------------------------------------*/
3032: static void MoveImageFile (Document source_doc, Document dest_doc,
1.547 cvs 3033: char *documentname)
1.254 cvs 3034: {
1.547 cvs 3035: char *source;
3036: char *target;
3037: char *imagefile;
3038: char *ptr;
1.254 cvs 3039:
3040: /* generate the name of the file where is stored the image */
1.907 gully 3041: imagefile = (char *)TtaGetMemory (strlen (documentname) + 6);
1.547 cvs 3042: strcpy (imagefile, documentname);
3043: ptr = strrchr (imagefile, '.');
1.268 cvs 3044: if (!ptr)
1.547 cvs 3045: strcat (imagefile, ".html");
1.268 cvs 3046: else
1.547 cvs 3047: strcpy (&(ptr[1]), "html");
1.268 cvs 3048:
1.254 cvs 3049: /* create the source and dest file names */
1.907 gully 3050: source = (char *)TtaGetMemory (strlen (TempFileDirectory) + strlen (imagefile) + 6);
1.547 cvs 3051: sprintf (source, "%s%c%d%c%s",
3052: TempFileDirectory, DIR_SEP, source_doc, DIR_SEP, imagefile);
1.907 gully 3053: target = (char *)TtaGetMemory (strlen (TempFileDirectory) + strlen (imagefile) + 6);
1.547 cvs 3054: sprintf (target, "%s%c%d%c%s",
3055: TempFileDirectory, DIR_SEP, dest_doc, DIR_SEP, imagefile);
1.254 cvs 3056:
3057: /* move the file */
3058: TtaFileCopy (source, target);
3059: TtaFileUnlink (source);
3060:
3061: TtaFreeMemory (source);
3062: TtaFreeMemory (target);
3063: TtaFreeMemory (imagefile);
3064: }
3065:
3066: /*----------------------------------------------------------------------
1.659 vatton 3067: ParseAsHTML
1.877 vatton 3068: Load current document considering it's a HTML document
1.569 cvs 3069: ----------------------------------------------------------------------*/
1.877 vatton 3070: void ParseAsHTML (Document doc, View view)
1.569 cvs 3071: {
1.600 cvs 3072: char *tempdocument = NULL;
3073: char documentname[MAX_LENGTH];
3074: char tempdir[MAX_LENGTH];
1.659 vatton 3075: int i;
1.569 cvs 3076:
1.877 vatton 3077: if (!DocumentURLs[doc])
1.569 cvs 3078: /* the document is not loaded yet */
3079: return;
1.877 vatton 3080: if (!DocumentMeta[doc]->xmlformat)
1.569 cvs 3081: /* the document is not concerned by this option */
3082: return;
1.877 vatton 3083: if (!CanReplaceCurrentDocument (doc, view))
1.569 cvs 3084: /* abort the command */
3085: return;
3086:
1.877 vatton 3087: tempdocument = GetLocalPath (doc, DocumentURLs[doc]);
1.569 cvs 3088: TtaExtractName (tempdocument, tempdir, documentname);
3089:
1.845 cvs 3090: /* Initialize the LogFile variables */
1.617 cvs 3091: CleanUpParsingErrors ();
1.845 cvs 3092:
1.617 cvs 3093: /* remove the PARSING.ERR file */
1.877 vatton 3094: RemoveParsingErrors (doc);
1.845 cvs 3095: /* Remove the previous namespaces declaration */
1.877 vatton 3096: TtaFreeNamespaceDeclarations (doc);
1.845 cvs 3097:
1.659 vatton 3098: for (i = 1; i < DocumentTableLength; i++)
1.877 vatton 3099: if (DocumentURLs[i] != NULL && DocumentSource[i] == doc)
1.659 vatton 3100: {
3101: DocumentSource[i] = 0;
3102: if (DocumentTypes[i] == docLog)
3103: {
3104: /* close the window of the log file attached to the
3105: current document */
3106: TtaCloseDocument (i);
3107: TtaFreeMemory (DocumentURLs[i]);
3108: DocumentURLs[i] = NULL;
3109: /* switch off the button Show Log file */
1.877 vatton 3110: TtaSetItemOff (doc, 1, Views, BShowLogFile);
1.659 vatton 3111: }
3112: }
1.617 cvs 3113:
1.877 vatton 3114: /* Removes all CSS informations linked with the document */
3115: RemoveDocCSSs (doc);
3116: /* Free access keys table */
3117: TtaRemoveDocAccessKeys (doc);
3118: DocumentMeta[doc]->xmlformat = FALSE;
1.659 vatton 3119: /* parse with the HTML parser */
1.877 vatton 3120: StartParser (doc, tempdocument, documentname, tempdir,
1.744 vatton 3121: tempdocument, FALSE);
1.742 vatton 3122: /* then request to save as XHTML */
1.877 vatton 3123: DocumentMeta[doc]->xmlformat = TRUE;
1.569 cvs 3124: /* fetch and display all images referred by the document */
1.877 vatton 3125: DocNetworkStatus[doc] = AMAYA_NET_ACTIVE;
3126: FetchAndDisplayImages (doc, AMAYA_LOAD_IMAGE, NULL);
3127: DocNetworkStatus[doc] = AMAYA_NET_INACTIVE;
1.572 cvs 3128:
1.617 cvs 3129: /* check parsing errors */
1.877 vatton 3130: CheckParsingErrors (doc);
1.569 cvs 3131: TtaFreeMemory (tempdocument);
3132: }
3133:
3134: /*----------------------------------------------------------------------
1.542 cvs 3135: LoadDocument parses the new document and stores its path (or
1.220 cvs 3136: URL) into the document table.
1.290 cvs 3137: For a local loading, the parameter tempfile must be an empty string.
3138: For a remote loading, the parameter tempfile gives the file name that
3139: contains the current copy of the remote file.
1.9 cvs 3140: ----------------------------------------------------------------------*/
1.585 cvs 3141: static Document LoadDocument (Document doc, char *pathname,
3142: char *form_data, char *initial_url,
3143: int method, char *tempfile,
3144: char *documentname, AHTHeaders *http_headers,
1.824 vatton 3145: ThotBool history, ThotBool *inNewWindow)
1.6 cvs 3146: {
1.293 cvs 3147: CSSInfoPtr css;
1.861 vatton 3148: PInfoPtr pInfo;
1.163 cvs 3149: Document newdoc = 0;
1.276 cvs 3150: DocumentType docType;
1.721 kahan 3151: #ifdef ANNOTATIONS
1.782 vatton 3152: DocumentType annotBodyType = docHTML;
1.721 kahan 3153: #endif /* ANNOTATIONS */
1.518 cvs 3154: CHARSET charset, httpcharset;
3155: CHARSET metacharset = UNDEFINED_CHARSET;
1.924 vatton 3156: char charsetname[MAX_LENGTH];
1.547 cvs 3157: char *charEncoding;
3158: char *tempdir;
1.924 vatton 3159: char *s, *localdoc;
1.547 cvs 3160: char *content_type;
1.551 kahan 3161: char *http_content_type;
1.163 cvs 3162: int i, j;
1.905 vatton 3163: int docProfile;
3164: DocumentType thotType;
3165: char local_content_type[MAX_LENGTH];
1.461 cvs 3166: ThotBool unknown;
1.905 vatton 3167: ThotBool contentImage, contentText, contentApplication;
1.309 cvs 3168: ThotBool plainText;
1.775 cvs 3169: ThotBool xmlDec, withDoctype, isXML, isknown;
1.917 kahan 3170: ThotBool isRDF;
1.248 cvs 3171:
1.917 kahan 3172: isRDF = FALSE;
1.464 cvs 3173: docType = docText;
1.461 cvs 3174: unknown = TRUE;
1.924 vatton 3175: tempdir = localdoc = NULL;
1.557 cvs 3176: charsetname[0] = EOS;
1.621 cvs 3177: local_content_type[0] = EOS;
1.551 kahan 3178: http_content_type = HTTP_headers (http_headers, AM_HTTP_CONTENT_TYPE);
3179: /* make a copy we can modify */
3180: if (http_content_type)
3181: content_type = TtaStrdup (http_content_type);
3182: else
3183: content_type = NULL;
3184:
1.726 cvs 3185: /* Check informations within the document */
1.547 cvs 3186: if (tempfile[0] != EOS)
1.924 vatton 3187: s = tempfile;
1.457 cvs 3188: else
1.924 vatton 3189: s = pathname;
1.922 cvs 3190:
1.924 vatton 3191: CheckDocHeader (s, &xmlDec, &withDoctype, &isXML, &isknown,
3192: &docProfile, &charset, charsetname, &thotType);
1.461 cvs 3193:
1.537 cvs 3194: /* if (charset == UNDEFINED_CHARSET && isXML && thotType == docHTML) */
1.726 cvs 3195: /* Check charset information in a meta */
1.537 cvs 3196: if (charset == UNDEFINED_CHARSET)
1.924 vatton 3197: CheckCharsetInMeta (s, &metacharset, charsetname);
1.922 cvs 3198:
1.542 cvs 3199: if (method == CE_CSS)
3200: {
3201: /* we're loading a CSS file */
3202: docType = docCSS;
3203: unknown = FALSE;
3204: }
1.728 cvs 3205:
1.163 cvs 3206: if (content_type == NULL || content_type[0] == EOS)
1.728 cvs 3207: /* Local document - no content type */
1.163 cvs 3208: {
1.461 cvs 3209: /* check file name extension */
1.534 cvs 3210: if (isXML)
1.290 cvs 3211: {
1.621 cvs 3212: /* it seems to be a XML document */
1.765 cvs 3213: if (DocumentTypes[doc] == docLibrary)
3214: docType = docLibrary;
3215: else
3216: docType = thotType;
1.461 cvs 3217: unknown = FALSE;
1.917 kahan 3218: if (IsRDFName (pathname))
3219: isRDF = TRUE;
3220: }
3221: else if (IsRDFName (pathname))
3222: {
3223: /* it's an RDF document. By default we assume we will
3224: parse it as generic XML */
3225: docType = thotType;
3226: isRDF = TRUE;
3227: unknown = FALSE;
1.290 cvs 3228: }
1.588 cvs 3229: else if (IsCSSName (pathname))
1.478 cvs 3230: {
1.588 cvs 3231: docType = docCSS;
1.905 vatton 3232: docProfile = L_Other;
1.478 cvs 3233: unknown = FALSE;
3234: }
1.588 cvs 3235: else if (IsTextName (pathname))
1.280 cvs 3236: {
1.588 cvs 3237: docType = docText;
1.905 vatton 3238: docProfile = L_Other;
1.461 cvs 3239: unknown = FALSE;
1.276 cvs 3240: }
1.478 cvs 3241: else if (IsImageName (pathname))
3242: {
3243: /* It's a local image file that we can display. We change the
3244: doctype flag so that we can create an HTML container later on */
3245: docType = docImage;
3246: unknown = FALSE;
1.905 vatton 3247: docProfile = L_Transitional;
1.478 cvs 3248: }
1.728 cvs 3249: else if (IsMathMLName (pathname))
3250: {
3251: docType = docMath;
1.905 vatton 3252: docProfile = L_Other;
1.728 cvs 3253: isXML = TRUE;
3254: unknown = FALSE;
3255: }
3256: else if (IsSVGName (pathname))
3257: {
3258: docType = docSVG;
1.905 vatton 3259: docProfile = L_Other;
1.728 cvs 3260: isXML = TRUE;
3261: unknown = FALSE;
3262: }
1.777 cvs 3263: #ifdef XML_GENERIC
3264: else if (IsXMLName (pathname))
3265: {
3266: docType = docXml;
1.905 vatton 3267: docProfile = L_Other;
1.777 cvs 3268: isXML = TRUE;
3269: unknown = FALSE;
3270: }
3271: #endif /* XML_GENERIC */
1.884 vatton 3272: #ifdef _SVG
1.765 cvs 3273: else if (IsLibraryName (pathname))
3274: {
3275: docType = docLibrary;
3276: unknown = FALSE;
3277: }
1.884 vatton 3278: #endif /* _SVG */
1.905 vatton 3279: else if (docProfile != L_Other || IsHTMLName (pathname))
1.588 cvs 3280: {
3281: /* it seems to be an HTML document */
3282: docType = docHTML;
3283: unknown = FALSE;
3284: }
1.621 cvs 3285: /* Assign a content type to that local document */
1.917 kahan 3286: if (isRDF)
3287: strcpy (local_content_type , "application/xml+rdf");
3288: else if (docType == docCSS)
1.747 kahan 3289: strcpy (local_content_type , "text/css");
3290: else if (docType == docMath)
1.734 kahan 3291: strcpy (local_content_type , AM_MATHML_MIME_TYPE);
1.621 cvs 3292: else if (docType == docSVG)
1.734 kahan 3293: strcpy (local_content_type , AM_SVG_MIME_TYPE);
1.621 cvs 3294: else if (docType == docXml)
3295: strcpy (local_content_type , "text/xml");
3296: else if (docType == docText || docType == docCSS ||
3297: docType == docSource || docType == docLog )
3298: strcpy (local_content_type , "text/plain");
1.768 vatton 3299: else if (docType == docHTML || docType == docLibrary)
1.729 kahan 3300: {
1.741 kahan 3301: if (isXML && AM_UseXHTMLMimeType () )
1.734 kahan 3302: strcpy (local_content_type , AM_XHTML_MIME_TYPE);
1.729 kahan 3303: else
3304: strcpy (local_content_type , "text/html");
3305: }
1.621 cvs 3306: }
1.154 cvs 3307: else
1.728 cvs 3308: /* The server returned a content type */
1.163 cvs 3309: {
3310: i = 0;
1.290 cvs 3311: while (content_type[i] != URL_SEP && content_type[i] != EOS)
1.163 cvs 3312: i++;
1.290 cvs 3313: if (content_type[i] == URL_SEP)
1.163 cvs 3314: {
3315: content_type[i] = EOS;
3316: j = i+1;
1.547 cvs 3317: while (content_type[j] != ';' && content_type[j] != EOS)
1.163 cvs 3318: j++;
1.547 cvs 3319: if (content_type[j] == ';')
1.163 cvs 3320: content_type[j] = EOS;
1.905 vatton 3321: contentText = !strcasecmp (content_type, "text");
3322: contentApplication = !strcasecmp (content_type, "application");
3323: contentImage = !strcasecmp (content_type, "image");
3324: if (contentText &&
3325: !strncasecmp (&content_type[i+1], "html", 4))
1.163 cvs 3326: {
1.905 vatton 3327: if (thotType == docSVG)
1.707 cvs 3328: {
1.905 vatton 3329: /* ignore the mime type */
1.707 cvs 3330: isXML = TRUE;
1.905 vatton 3331: docType = thotType;
3332: BADMimeType = TRUE;
1.707 cvs 3333: }
1.905 vatton 3334: else if (thotType == docMath)
1.382 cvs 3335: {
1.905 vatton 3336: /* ignore the mime type */
1.707 cvs 3337: isXML = TRUE;
1.905 vatton 3338: docType = thotType;
3339: BADMimeType = TRUE;
1.478 cvs 3340: }
1.163 cvs 3341: else
1.276 cvs 3342: {
1.905 vatton 3343: /* it's an HTML document */
3344: docType = docHTML;
3345: if (docProfile == L_Other)
3346: docProfile = L_Transitional;
1.276 cvs 3347: }
1.905 vatton 3348: unknown = FALSE;
3349: }
3350: else if (contentApplication &&
3351: !strncasecmp (&content_type[i+1], "html", 4))
3352: {
3353: /* it's an HTML document */
3354: docType = docHTML;
3355: if (docProfile == L_Other)
3356: docProfile = L_Transitional;
3357: unknown = FALSE;
1.163 cvs 3358: }
1.905 vatton 3359: else if ((contentText || contentApplication) &&
3360: (!strncasecmp (&content_type[i+1], "xhtml+xml", 9) ||
3361: !strncasecmp (&content_type[i+1], "xhtml", 5)))
1.478 cvs 3362: {
1.905 vatton 3363: /* it's an xhtml document */
3364: isXML = TRUE;
3365: docType = docHTML;
3366: if (docProfile == L_Other)
3367: docProfile = L_Transitional;
3368: unknown = FALSE;
3369: }
3370: else if ((contentText || contentApplication) &&
3371: !strncasecmp (&content_type[i+1], "xml", 3) &&
3372: content_type[i+1+3] == EOS)
3373: {
3374: /* Served as an XML document */
3375: if (isXML && isknown &&
3376: (thotType == docHTML ||
3377: thotType == docSVG ||
3378: thotType == docMath))
3379: /* This type comes from the doctype or a namespace declaration */
3380: docType = thotType;
3381: else
1.707 cvs 3382: {
3383: #ifdef XML_GENERIC
1.905 vatton 3384: docType = docXml;
1.707 cvs 3385: #else /* XML_GENERIC */
1.905 vatton 3386: docType = docText;
1.707 cvs 3387: #endif /* XML_GENERIC */
1.905 vatton 3388: docProfile = L_Other;
1.707 cvs 3389: }
1.905 vatton 3390: isXML = TRUE;
3391: unknown = FALSE;
3392: }
3393: else if (contentText &&
3394: !strncasecmp (&content_type[i+1], "css", 3))
3395: {
3396: docType = docCSS;
3397: docProfile = L_Other;
3398: unknown = FALSE;
3399: }
3400: else if ((contentText || contentApplication) &&
3401: (!strncasecmp (&content_type[i+1], "mathml", 6) ||
3402: !strncasecmp (&content_type[i+1], "x-mathml", 8)))
3403: {
3404: /* it's an MathML document */
3405: isXML = TRUE;
3406: docType = docMath;
3407: docProfile = L_MathML;
3408: unknown = FALSE;
3409: }
3410: else if (contentText)
3411: {
3412: docType = docText;
3413: docProfile = L_Other;
3414: unknown = FALSE;
3415: }
3416: else if (contentApplication &&
3417: !strncasecmp (&content_type[i+1], "x-sh", 4))
3418: {
3419: docType = docText;
3420: docProfile = L_Other;
3421: unknown = FALSE;
3422: }
3423: else if (contentApplication &&
3424: !strncasecmp (&content_type[i+1], "xml-dtd", 7))
3425: {
3426: /* it's an DTD document */
3427: docType = docText;
3428: docProfile = L_Other;
3429: unknown = FALSE;
3430: }
1.929 kahan 3431: else if (MultipleBookmarks () && !strncasecmp (&content_type[i+1], "rdf+xml", 7))
1.917 kahan 3432: {
3433: /* it's an RDF document. By default we assume we will
3434: parse it as generic XML */
3435: isXML = TRUE;
3436: isRDF = TRUE;
3437: #ifdef XML_GENERIC
3438: docType = docXml;
3439: #else /* XML_GENERIC */
3440: docType = docText;
3441: #endif /* XML_GENERIC */
3442: docProfile = L_Other;
3443: unknown = FALSE;
3444: }
1.905 vatton 3445: else if (contentApplication &&
3446: !strncasecmp (&content_type[i+1], "smil", 4))
3447: {
3448: /* it's a SMIL document. We handle it as an XML one */
3449: isXML = TRUE;
1.779 kahan 3450: #ifdef XML_GENERIC
1.905 vatton 3451: docType = docXml;
1.779 kahan 3452: #else /* XML_GENERIC */
1.905 vatton 3453: docType = docText;
1.779 kahan 3454: #endif /* XML_GENERIC */
1.905 vatton 3455: docProfile = L_Other;
3456: unknown = FALSE;
3457: }
3458: else if (contentApplication &&
3459: !strncasecmp (&content_type[i+1], "octet-stream", 12) &&
3460: thotType == docSVG)
3461: {
3462: /* it's a SVG document. We handle it as an XML one */
3463: isXML = TRUE;
3464: docType = thotType;
3465: unknown = FALSE;
3466: }
3467: else if (contentImage &&
3468: !strncasecmp (&content_type[i+1], "svg", 3))
3469: {
3470: /* it's an XML document */
3471: isXML = TRUE;
3472: docType = docSVG;
3473: docProfile = L_Other;
3474: unknown = FALSE;
1.478 cvs 3475: }
1.905 vatton 3476: else if (contentImage)
1.290 cvs 3477: {
1.905 vatton 3478: /* we'll generate a HTML document */
1.906 vatton 3479: if (IsImageType (&content_type[i+1]))
1.478 cvs 3480: {
1.905 vatton 3481: docType = docImage;
1.478 cvs 3482: unknown = FALSE;
1.905 vatton 3483: docProfile = L_Transitional;
1.478 cvs 3484: }
3485: }
1.163 cvs 3486: }
3487: }
1.917 kahan 3488:
3489: #ifdef BOOKMARKS
3490: if (isRDF)
3491: {
3492: /* verify if it contains bookmarks */
3493: /* we detected some bookmarks, in this rdf document */
1.924 vatton 3494: if (BM_Open (pathname, s))
1.917 kahan 3495: docType = docBookmark;
3496: }
3497: #endif /* BOOKMARKS */
1.714 cvs 3498:
1.547 cvs 3499: if (unknown && tempfile[0] != EOS)
1.163 cvs 3500: {
1.726 cvs 3501: /* The document is not a supported format and cannot be parsed */
1.163 cvs 3502: /* rename the temporary file */
1.547 cvs 3503: strcpy (SavingFile, tempfile);
1.163 cvs 3504: SavingDocument = 0;
3505: SavingObject = 0;
1.924 vatton 3506: localdoc = (char *)TtaGetMemory (MAX_LENGTH);
3507: TtaExtractName (pathname, tempfile, localdoc);
1.163 cvs 3508: /* reinitialize directories and document lists */
1.547 cvs 3509: strcpy (SavePath, DirectoryName);
1.924 vatton 3510: strcpy (SaveName, localdoc);
3511: strcpy (localdoc, SavePath);
3512: strcat (localdoc, DIR_STR);
3513: strcat (localdoc, SaveName);
1.163 cvs 3514: ResetStop (doc);
1.924 vatton 3515: InitSaveObjectForm (doc, 1, SavingFile, localdoc);
1.163 cvs 3516: }
1.547 cvs 3517: else if (pathname[0] != EOS)
1.163 cvs 3518: {
1.287 cvs 3519: if (method != CE_MAKEBOOK)
1.163 cvs 3520: {
1.287 cvs 3521: /* do not register and open the document view */
3522: if (DocumentURLs[doc])
3523: {
3524: /* save the URL of the old document in the history, if the same
3525: window is reused, i.e. if the old document has not been
3526: modified */
3527: if (history && !TtaIsDocumentModified (doc))
3528: AddDocHistory (doc, DocumentURLs[doc],
1.472 kahan 3529: DocumentMeta[doc]->initial_url,
1.287 cvs 3530: DocumentMeta[doc]->form_data,
3531: DocumentMeta[doc]->method);
3532: }
3533:
1.585 cvs 3534: if (method == CE_RELATIVE)
1.289 cvs 3535: {
1.804 vatton 3536: if (TtaIsDocumentModified (doc) || docType == docCSS)
1.585 cvs 3537: {
3538: /* open a new window to display the new document */
1.926 gully 3539: newdoc = InitDocAndView (doc,
3540: FALSE /* replaceOldDoc */,
3541: TRUE /* inNewWindow */,
3542: documentname, docType, 0, FALSE,
1.907 gully 3543: docProfile, (ClickEvent)method);
1.585 cvs 3544: ResetStop (doc);
3545: /* clear the status line of previous document */
3546: TtaSetStatus (doc, 1, " ", NULL);
3547: ActiveTransfer (newdoc);
3548: }
3549: else
3550: /* replace the current document by a new one */
1.926 gully 3551: newdoc = InitDocAndView (doc,
3552: TRUE /* replaceOldDoc */,
3553: FALSE /* inNewWindow */,
3554: documentname, docType, 0, FALSE,
1.907 gully 3555: docProfile, (ClickEvent)method);
1.289 cvs 3556: }
1.686 cvs 3557: else if (method == CE_ABSOLUTE || method == CE_HELP ||
3558: method == CE_FORM_POST || method == CE_FORM_GET)
1.585 cvs 3559: /* replace the current document by a new one */
1.926 gully 3560: newdoc = InitDocAndView (doc,
3561: TRUE /* replaceOldDoc */,
3562: FALSE /* inNewWindow */,
3563: documentname, docType, 0, FALSE,
1.907 gully 3564: docProfile, (ClickEvent)method);
1.388 cvs 3565: #ifdef ANNOTATIONS
1.721 kahan 3566: else if (method == CE_ANNOT) /* && docType == docHTML) */
1.388 cvs 3567: {
1.721 kahan 3568: /* create the body */
3569: ANNOT_CreateBodyTree (doc, docType);
3570: /* and remember its type of the body */
3571: annotBodyType = docType;
1.479 cvs 3572: docType = docAnnot;
1.469 kahan 3573: newdoc = doc;
1.388 cvs 3574: }
3575: #endif /* ANNOTATIONS */
1.452 cvs 3576: else if (method == CE_LOG)
3577: {
3578: docType = docLog;
3579: newdoc = doc;
3580: }
1.765 cvs 3581: else if (docType != DocumentTypes[doc] && DocumentTypes[doc] != docLibrary)
1.588 cvs 3582: /* replace the current document by a new one */
1.926 gully 3583: newdoc = InitDocAndView (doc,
3584: TRUE /* replaceOldDoc */,
3585: FALSE /* inNewWindow */,
3586: documentname, docType, 0, FALSE,
1.907 gully 3587: docProfile, (ClickEvent)method);
1.289 cvs 3588: else
1.690 cvs 3589: {
3590: /* document already initialized */
3591: newdoc = doc;
3592: /* store the profile of the new document */
3593: /* and update the menus according to it */
1.905 vatton 3594: TtaSetDocumentProfile (newdoc, docProfile);
1.690 cvs 3595: TtaUpdateMenus (newdoc, 1, ReadOnlyDocument[newdoc]);
3596: }
1.249 cvs 3597: }
1.287 cvs 3598: else
3599: newdoc = doc;
1.682 cvs 3600:
1.305 cvs 3601: if (docType == docImage)
3602: /* create an HTML container */
3603: {
3604: if (content_type)
3605: /* it's an image downloaded from the web */
1.924 vatton 3606: CreateHTMLContainer (pathname, documentname, tempfile, FALSE);
1.305 cvs 3607: else
3608: {
3609: /* It's a local image file */
1.547 cvs 3610: sprintf (tempfile, "%s%c%d%c%s", TempFileDirectory,
1.805 vatton 3611: DIR_SEP, newdoc, DIR_SEP, "contain.html");
1.924 vatton 3612: CreateHTMLContainer (pathname, documentname, tempfile, TRUE);
1.305 cvs 3613: }
1.638 kahan 3614: ChangeToBrowserMode (doc);
1.305 cvs 3615: }
3616:
1.163 cvs 3617: /* what we have to do if doc and targetDocument are different */
1.547 cvs 3618: if (tempfile[0] != EOS)
1.163 cvs 3619: {
3620: /* It is a document loaded from the Web */
3621: if (!TtaFileExist (tempfile))
3622: {
3623: /* Nothing is loaded */
3624: ResetStop (doc);
1.551 kahan 3625: TtaFreeMemory (content_type);
1.163 cvs 3626: return (0);
3627: }
3628: /* we have to rename the temporary file */
1.924 vatton 3629: /* allocate and initialize a teporary document */
3630: localdoc = GetLocalPath (newdoc, pathname);
3631: TtaFileUnlink (localdoc);
1.163 cvs 3632: if (doc != newdoc)
1.154 cvs 3633: {
1.163 cvs 3634: /* now we can rename the local name of a remote document */
1.924 vatton 3635: TtaFileCopy (tempfile, localdoc);
3636: TtaFileUnlink (tempfile);
1.254 cvs 3637: /* if it's an IMAGEfile, we copy it too to the new directory */
1.479 cvs 3638: if (DocumentTypes[newdoc] == docImage)
1.293 cvs 3639: MoveImageFile (doc, newdoc, documentname);
1.154 cvs 3640: }
1.479 cvs 3641: else if (DocumentTypes[newdoc] == docCSS)
1.924 vatton 3642: TtaFileCopy (tempfile, localdoc);
1.293 cvs 3643: /* now we can rename the local name of a remote document */
1.163 cvs 3644: else
3645: /* now we can rename the local name of a remote document */
1.924 vatton 3646: rename (tempfile, localdoc);
1.163 cvs 3647: }
3648: else
3649: {
1.355 cvs 3650: /* store a copy of the local document */
1.924 vatton 3651: /* allocate and initialize a teporary document */
3652: localdoc = GetLocalPath (newdoc, pathname);
3653: TtaFileCopy (pathname, localdoc);
1.352 cvs 3654: }
3655:
1.917 kahan 3656: #ifdef BOOKMARKS
3657: if (docType == docBookmark)
3658: /* update the corresponding bookmark context to point to the new tmpfile */
1.924 vatton 3659: BM_TempFileSet (pathname, localdoc);
1.917 kahan 3660: #endif /* BOOKMARKS */
3661:
3662:
1.352 cvs 3663: /* store a copy of CSS files in the directory 0 */
1.479 cvs 3664: if (DocumentTypes[newdoc] == docCSS)
1.352 cvs 3665: {
1.861 vatton 3666: css = SearchCSS (0, pathname, NULL, &pInfo);
1.352 cvs 3667: if (css == NULL)
3668: {
3669: /* store a copy of this new CSS context in .amaya/0 */
3670: s = GetLocalPath (0, pathname);
1.924 vatton 3671: TtaFileCopy (localdoc, s);
1.352 cvs 3672: /* initialize a new CSS context */
1.547 cvs 3673: if (UserCSS && !strcmp (pathname, UserCSS))
1.861 vatton 3674: AddCSS (newdoc, 0, CSS_USER_STYLE, CSS_ALL, NULL, s, NULL);
1.293 cvs 3675: else
1.861 vatton 3676: AddCSS (newdoc, 0, CSS_EXTERNAL_STYLE, CSS_ALL, pathname, s, NULL);
1.352 cvs 3677: TtaFreeMemory (s);
1.293 cvs 3678: }
1.352 cvs 3679: else
3680: css->doc = newdoc;
1.163 cvs 3681: }
3682:
3683: /* save the document name into the document table */
1.924 vatton 3684: s = TtaStrdup (pathname);
1.163 cvs 3685: if (DocumentURLs[newdoc] != NULL)
1.510 kahan 3686: {
3687: TtaFreeMemory (DocumentURLs[newdoc]);
3688: DocumentURLs[newdoc] = NULL;
3689: }
1.473 kahan 3690: /* if the document was already loaded, warn the user */
3691: if (IsDocumentLoaded (s, form_data))
1.666 vatton 3692: InitConfirm3L (newdoc, 1, TtaGetMessage (AMAYA, AM_DOUBLE_LOAD),
1.642 vatton 3693: TtaGetMessage (AMAYA, AM_UNSAVE), NULL, FALSE);
1.163 cvs 3694: DocumentURLs[newdoc] = s;
1.473 kahan 3695:
1.222 cvs 3696: /* save the document's formdata into the document table */
3697: if (DocumentMeta[newdoc] != NULL)
1.479 cvs 3698: DocumentMetaClear (DocumentMeta[newdoc]);
1.380 cvs 3699: else
1.552 kahan 3700: DocumentMeta[newdoc] = DocumentMetaDataAlloc ();
1.575 cvs 3701: DocumentMeta[newdoc]->form_data = TtaStrdup (form_data);
1.547 cvs 3702: if (initial_url && strcmp (pathname, initial_url))
1.575 cvs 3703: DocumentMeta[newdoc]->initial_url = TtaStrdup (initial_url);
1.471 kahan 3704: else
1.472 kahan 3705: DocumentMeta[newdoc]->initial_url = NULL;
1.225 cvs 3706: DocumentMeta[newdoc]->method = (ClickEvent) method;
1.728 cvs 3707: DocumentSource[newdoc] = 0;
1.461 cvs 3708: DocumentMeta[newdoc]->xmlformat = isXML;
1.222 cvs 3709:
1.516 cvs 3710: /* Set character encoding */
1.557 cvs 3711: DocumentMeta[newdoc]->charset = NULL;
1.457 cvs 3712: charEncoding = HTTP_headers (http_headers, AM_HTTP_CHARSET);
3713: httpcharset = TtaGetCharset (charEncoding);
1.557 cvs 3714:
1.743 vatton 3715: if (httpcharset != UNDEFINED_CHARSET && charEncoding)
3716: {
1.828 cvs 3717: TtaSetDocumentCharset (newdoc, httpcharset, FALSE);
1.743 vatton 3718: DocumentMeta[newdoc]->charset = TtaStrdup (charEncoding);
3719: }
3720: else if (charset != UNDEFINED_CHARSET)
1.557 cvs 3721: {
1.828 cvs 3722: TtaSetDocumentCharset (newdoc, charset, FALSE);
1.575 cvs 3723: DocumentMeta[newdoc]->charset = TtaStrdup (charsetname);
1.557 cvs 3724: }
1.516 cvs 3725: else if (metacharset != UNDEFINED_CHARSET)
1.557 cvs 3726: {
1.828 cvs 3727: TtaSetDocumentCharset (newdoc, metacharset, FALSE);
1.575 cvs 3728: DocumentMeta[newdoc]->charset = TtaStrdup (charsetname);
1.557 cvs 3729: }
3730: else if (charsetname[0] != EOS)
1.575 cvs 3731: DocumentMeta[newdoc]->charset = TtaStrdup (charsetname);
1.557 cvs 3732:
1.562 kahan 3733: /*
3734: ** copy some HTTP headers to the metadata
3735: */
3736: /* content-type */
1.551 kahan 3737: if (http_content_type)
1.575 cvs 3738: DocumentMeta[newdoc]->content_type = TtaStrdup (http_content_type);
1.551 kahan 3739: else
1.621 cvs 3740: if (local_content_type[0] != EOS)
3741: /* assign a content type to the local files */
3742: DocumentMeta[newdoc]->content_type = TtaStrdup (local_content_type);
3743: else
3744: DocumentMeta[newdoc]->content_type = NULL;
1.562 kahan 3745: /* content-length */
3746: s = HTTP_headers (http_headers, AM_HTTP_CONTENT_LENGTH);
3747: if (s)
1.575 cvs 3748: DocumentMeta[newdoc]->content_length = TtaStrdup (s);
1.562 kahan 3749: else
3750: DocumentMeta[newdoc]->content_length = NULL;
1.781 kahan 3751: /* simplified content-location */
1.647 kahan 3752: s = HTTP_headers (http_headers, AM_HTTP_CONTENT_LOCATION);
3753: if (s)
3754: DocumentMeta[newdoc]->content_location = TtaStrdup (s);
3755: else
3756: DocumentMeta[newdoc]->content_location = NULL;
1.781 kahan 3757: /* full content-location */
3758: s = HTTP_headers (http_headers, AM_HTTP_FULL_CONTENT_LOCATION);
3759: if (s)
3760: DocumentMeta[newdoc]->full_content_location = TtaStrdup (s);
3761: else
3762: DocumentMeta[newdoc]->full_content_location = NULL;
1.562 kahan 3763:
1.163 cvs 3764: if (TtaGetViewFrame (newdoc, 1) != 0)
3765: /* this document is displayed */
1.222 cvs 3766: {
1.923 vatton 3767: #ifdef _SVG
1.765 cvs 3768: if (DocumentTypes[newdoc] == docLibrary)
1.930 vatton 3769: {
3770: SelectLibraryFromPath (DocumentURLs[newdoc]);
3771: TtaSetTextZone (newdoc, 1, SVGlib_list);
3772: }
3773: else
1.884 vatton 3774: #endif /* _SVG */
1.930 vatton 3775: TtaSetTextZone (newdoc, 1, URL_list);
1.222 cvs 3776: }
3777:
1.907 gully 3778: tempdir = (char *)TtaGetMemory (MAX_LENGTH);
1.924 vatton 3779: TtaExtractName (localdoc, tempdir, documentname);
1.332 cvs 3780: /* Now we forget the method CE_INIT. It's a standard method */
3781: if (DocumentMeta[newdoc]->method == CE_INIT)
3782: DocumentMeta[newdoc]->method = CE_ABSOLUTE;
1.447 cvs 3783:
1.711 cvs 3784: if (docType == docHTML ||
3785: docType == docSVG ||
1.713 kahan 3786: #ifdef ANNOTATIONS
1.721 kahan 3787: (docType == docAnnot && annotBodyType != docText) ||
1.713 kahan 3788: #endif /* ANNOTATIONS */
1.917 kahan 3789: #ifdef BOOKMARKS
3790: docType == docBookmark ||
3791: #endif /* BOOKMARKS */
1.682 cvs 3792: docType == docXml ||
1.765 cvs 3793: docType == docLibrary ||
1.682 cvs 3794: docType == docMath)
1.474 cvs 3795: plainText = FALSE;
3796: else
1.905 vatton 3797: plainText = (docProfile == L_Other);
1.917 kahan 3798:
3799: #ifdef BOOKMARKS
3800: if (docType == docBookmark)
3801: BM_ViewBookmarks (newdoc, 1, FALSE);
3802: else
3803: #endif /* BOOKMARKS */
1.485 cvs 3804: /* Calls the corresponding parser */
1.461 cvs 3805: if (DocumentMeta[newdoc]->xmlformat && !plainText)
1.924 vatton 3806: StartXmlParser (newdoc, localdoc, documentname,
3807: tempdir, pathname, xmlDec, withDoctype);
1.447 cvs 3808: else
1.924 vatton 3809: StartParser (newdoc, localdoc, documentname, tempdir,
3810: pathname, plainText);
1.485 cvs 3811:
1.163 cvs 3812: TtaFreeMemory (tempdir);
1.717 cvs 3813:
3814: /* Update the Doctype menu */
3815: UpdateDoctypeMenu (newdoc);
1.479 cvs 3816: if (ReadOnlyDocument[newdoc])
1.932 vatton 3817: {
3818: UpdateBrowserMenus (newdoc);
3819: SetDocumentReadOnly (newdoc);
3820: }
3821: else
3822: UpdateEditorMenus (newdoc);
1.349 cvs 3823:
1.824 vatton 3824: if (*inNewWindow || newdoc != doc)
1.163 cvs 3825: /* the document is displayed in a different window */
3826: /* reset the history of the new window */
3827: InitDocHistory (newdoc);
1.546 cvs 3828: /* the document is loaded now */
1.824 vatton 3829: *inNewWindow = FALSE;
1.546 cvs 3830: /* hide template entry if no template server is configured */
1.339 cvs 3831: if (TtaGetEnvString ("TEMPLATE_URL") == NULL)
1.313 cvs 3832: TtaSetItemOff (newdoc, 1, File, BTemplate);
1.336 cvs 3833: #ifdef ANNOTATIONS
1.721 kahan 3834: /* store the annotation body type (we have to wait until now as
3835: the metadata didn't exist before) */
3836: if (docType == docAnnot)
3837: ANNOT_bodyType_set (newdoc, annotBodyType);
1.336 cvs 3838: #endif /* ANNOTATIONS */
1.163 cvs 3839: }
1.551 kahan 3840: TtaFreeMemory (content_type);
1.924 vatton 3841: TtaFreeMemory (localdoc);
1.163 cvs 3842: return (newdoc);
1.6 cvs 3843: }
1.247 cvs 3844:
3845: /*----------------------------------------------------------------------
1.245 cvs 3846: Reload_callback
1.924 vatton 3847: The urlName is encoded with the default charset.
1.9 cvs 3848: ----------------------------------------------------------------------*/
1.585 cvs 3849: void Reload_callback (int doc, int status, char *urlName,
3850: char *outputfile, AHTHeaders *http_headers,
3851: void * context)
1.177 cvs 3852: {
1.617 cvs 3853: Document newdoc;
1.585 cvs 3854: char *tempfile;
3855: char *documentname;
3856: char *form_data;
1.792 vatton 3857: char *initial_url, *ptr;
1.585 cvs 3858: ClickEvent method;
1.782 vatton 3859: Document res = 0;
1.585 cvs 3860: Element el;
3861: RELOAD_context *ctx;
1.808 vatton 3862: ThotBool stopped_flag = FALSE, keep;
1.177 cvs 3863:
1.222 cvs 3864: /* restore the context associated with the request */
3865: ctx = (RELOAD_context *) context;
3866: documentname = ctx->documentname;
3867: newdoc = ctx->newdoc;
3868: form_data = ctx->form_data;
3869: method = ctx->method;
1.177 cvs 3870:
1.903 quint 3871: if (!DocumentURLs[doc])
3872: /* the user has closed the corresponding document. Just free resources */
3873: {
3874: TtaFreeMemory (documentname);
3875: if (form_data)
3876: TtaFreeMemory (form_data);
3877: TtaFreeMemory (ctx);
3878: return;
3879: }
3880:
1.177 cvs 3881: tempfile = outputfile;
3882: if (status == 0)
3883: {
3884: TtaSetCursorWatch (0, 0);
1.471 kahan 3885:
1.472 kahan 3886: /* a bit of acrobatics so that we can retain the initial_url
1.471 kahan 3887: without reallocating memory */
1.472 kahan 3888: initial_url = DocumentMeta[doc]->initial_url;
3889: DocumentMeta[doc]->initial_url = NULL;
1.471 kahan 3890:
1.621 cvs 3891: RemoveParsingErrors (newdoc);
1.808 vatton 3892: /* add the URI in the combobox string */
1.839 kahan 3893: if (method != CE_MAKEBOOK && method != CE_ANNOT &&
3894: method != CE_LOG && method != CE_HELP &&
3895: DocumentTypes[newdoc] != docLibrary &&
3896: status == 0)
3897: {
3898: /* add the URI in the combobox string */
3899: keep = (method == CE_ABSOLUTE || method == CE_INIT);
3900: if (form_data && method == CE_FORM_GET)
1.924 vatton 3901: AddURLInCombobox (urlName, form_data, keep);
1.839 kahan 3902: else
1.924 vatton 3903: AddURLInCombobox (urlName, NULL, keep);
1.839 kahan 3904: }
1.506 kahan 3905: /* parse and display the document, res contains the new document
1.808 vatton 3906: identifier, as given by the thotlib */
1.924 vatton 3907: res = LoadDocument (newdoc, urlName, form_data, NULL, method,
1.736 kahan 3908: tempfile, documentname, http_headers, FALSE, &InNewWindow);
1.808 vatton 3909: if (!ReadOnlyDocument[doc])
3910: UpdateEditorMenus (doc);
1.471 kahan 3911:
1.506 kahan 3912: if (res == 0)
3913: {
3914: /* cannot load the document */
3915: ResetStop(newdoc);
3916: newdoc = 0;
3917: TtaFreeMemory (initial_url);
3918: }
3919: else if (newdoc != res)
3920: {
3921: newdoc = res;
3922: /* restore the initial_url */
3923: DocumentMeta[newdoc]->initial_url = initial_url;
1.535 kahan 3924: }
3925:
3926: if (newdoc)
3927: {
3928: W3Loading = 0; /* loading is complete now */
1.510 kahan 3929: #ifdef ANNOTATIONS
3930: /* if it's an annotation, add the existing metadata */
3931: if (DocumentTypes[newdoc] == docAnnot)
3932: ANNOT_ReloadAnnotMeta (newdoc);
1.596 kahan 3933: /* auto-load the annotations associated with the document */
3934: if (ANNOT_CanAnnotate (newdoc))
3935: ANNOT_AutoLoad (newdoc, 1);
1.510 kahan 3936: #endif /* ANNOTATIONS */
1.506 kahan 3937: TtaHandlePendingEvents ();
3938: /* fetch and display all images referred by the document */
1.627 cvs 3939: stopped_flag = FetchAndDisplayImages (newdoc, AMAYA_NOCACHE | AMAYA_LOAD_IMAGE, NULL);
1.506 kahan 3940: if (stopped_flag == FALSE)
3941: {
3942: TtaResetCursor (0, 0);
3943: /* show the document at the same position as before Reload */
3944: el = ElementAtPosition (newdoc, ctx->position);
3945: TtaShowElement (newdoc, 1, el, ctx->distance);
3946: }
3947: }
3948: }
1.471 kahan 3949:
1.506 kahan 3950: if (stopped_flag == FALSE && newdoc)
1.257 cvs 3951: ResetStop(newdoc);
1.621 cvs 3952:
3953: /* check parsing errors */
3954: CheckParsingErrors (newdoc);
3955:
1.792 vatton 3956: if (DocumentTypes[newdoc] == docCSS)
3957: {
3958: /* reapply the CSS to relative documents */
3959: ptr = GetLocalPath (newdoc, DocumentURLs[newdoc]);
3960: UpdateStyleSheet (DocumentURLs[newdoc], ptr);
3961: TtaFreeMemory (ptr);
3962: }
1.749 kirschpi 3963: #ifdef DAV
1.754 kirschpi 3964: /* MKP: if document has been loaded, we are *
3965: * able to discovery if the document is locked. *
3966: * do a lock discovery, set LockIndicator button */
1.792 vatton 3967: if (W3Loading == 0 && res> 0)
1.754 kirschpi 3968: {
1.749 kirschpi 3969: DAVLockDiscovery (newdoc);
3970: DAVSetLockIndicator(newdoc);
1.754 kirschpi 3971: }
1.924 vatton 3972: #endif /* DAV */
1.749 kirschpi 3973:
1.903 quint 3974: DocStatusUpdate (newdoc, FALSE);
1.177 cvs 3975: TtaFreeMemory (documentname);
1.222 cvs 3976: if (form_data)
3977: TtaFreeMemory (form_data);
3978: TtaFreeMemory (ctx);
1.177 cvs 3979: }
3980:
3981:
3982: /*----------------------------------------------------------------------
1.245 cvs 3983: Reload
1.177 cvs 3984: ----------------------------------------------------------------------*/
1.585 cvs 3985: void Reload (Document doc, View view)
1.6 cvs 3986: {
1.585 cvs 3987: char *tempfile;
3988: char *pathname;
3989: char *documentname;
3990: char *form_data;
3991: ClickEvent method;
3992: RELOAD_context *ctx;
1.6 cvs 3993: int toparse;
1.222 cvs 3994: int mode;
1.245 cvs 3995: int position;
3996: int distance;
1.6 cvs 3997:
1.278 cvs 3998: if (DocumentURLs[doc] == NULL)
1.6 cvs 3999: /* the document has not been loaded yet */
4000: return;
1.479 cvs 4001: if (DocumentTypes[doc] == docSource)
1.407 cvs 4002: /* don't reload a source document */
4003: return;
1.146 cvs 4004: /* abort all current exchanges concerning this document */
1.278 cvs 4005: StopTransfer (doc, 1);
4006: if (!CanReplaceCurrentDocument (doc, view))
1.146 cvs 4007: /* abort the command */
4008: return;
1.10 cvs 4009: /* reload the document */
1.907 gully 4010: pathname = (char *)TtaGetMemory (MAX_LENGTH);
4011: documentname = (char *)TtaGetMemory (MAX_LENGTH);
1.313 cvs 4012: /* if the document is a template, restore the template script URL */
4013: if (DocumentMeta[doc]->method == CE_TEMPLATE)
1.411 cvs 4014: ReloadTemplateParams (&(DocumentURLs[doc]), &(DocumentMeta[doc]->method));
1.291 cvs 4015: NormalizeURL (DocumentURLs[doc], 0, pathname, documentname, NULL);
1.183 cvs 4016:
1.210 cvs 4017: if (!IsW3Path (pathname) && !TtaFileExist (pathname))
4018: {
1.334 cvs 4019: /* Free Memory */
1.210 cvs 4020: TtaFreeMemory (pathname);
4021: TtaFreeMemory (documentname);
4022: /* cannot reload this document */
4023: return;
4024: }
1.475 kahan 4025:
4026: if (DocumentMeta[doc]->form_data)
1.575 cvs 4027: form_data = TtaStrdup (DocumentMeta[doc]->form_data);
1.475 kahan 4028: else
4029: form_data = NULL;
1.579 kahan 4030:
1.510 kahan 4031: if (DocumentTypes[doc] == docAnnot)
1.579 kahan 4032: method = CE_ANNOT;
4033: else
4034: method = DocumentMeta[doc]->method;
1.183 cvs 4035:
1.245 cvs 4036: /* get the current position in the document */
1.278 cvs 4037: position = RelativePosition (doc, &distance);
1.245 cvs 4038:
1.278 cvs 4039: W3Loading = doc; /* this document is currently in load */
1.238 cvs 4040: mode = AMAYA_ASYNC | AMAYA_NOCACHE | AMAYA_FLUSH_REQUEST;
1.222 cvs 4041:
4042: if (method == CE_FORM_POST)
4043: mode |= AMAYA_FORM_POST;
4044:
1.907 gully 4045: tempfile = (char *)TtaGetMemory (MAX_LENGTH);
1.10 cvs 4046: tempfile[0] = EOS;
4047: toparse = 0;
1.278 cvs 4048: ActiveTransfer (doc);
1.222 cvs 4049: /* Create the context for the callback */
4050:
1.907 gully 4051: ctx = (RELOAD_context*)TtaGetMemory (sizeof (RELOAD_context));
1.278 cvs 4052: ctx->newdoc = doc;
1.222 cvs 4053: ctx->documentname = documentname;
4054: ctx->form_data = form_data;
4055: ctx->method = method;
1.245 cvs 4056: ctx->position = position;
4057: ctx->distance = distance;
1.222 cvs 4058:
1.10 cvs 4059: if (IsW3Path (pathname))
4060: {
1.150 cvs 4061: /* load the document from the Web */
1.874 vatton 4062: toparse = GetObjectWWW (doc, 0, pathname, form_data, tempfile,
1.222 cvs 4063: mode,
1.907 gully 4064: NULL, NULL, (void (*)(int, int, char*, char*, const AHTHeaders*, void*)) Reload_callback,
1.222 cvs 4065: (void *) ctx, YES, NULL);
1.10 cvs 4066: }
1.180 cvs 4067: else if (TtaFileExist (pathname))
1.278 cvs 4068: Reload_callback (doc, 0, pathname, tempfile, NULL, (void *) ctx);
1.222 cvs 4069:
1.137 cvs 4070: TtaFreeMemory (tempfile);
4071: TtaFreeMemory (pathname);
1.177 cvs 4072: TtaHandlePendingEvents ();
1.6 cvs 4073: }
4074:
1.9 cvs 4075: /*----------------------------------------------------------------------
4076: ----------------------------------------------------------------------*/
1.585 cvs 4077: void ShowTargets (Document document, View view)
1.219 cvs 4078: {
1.220 cvs 4079: int visibility;
1.229 cvs 4080: View tocView;
1.219 cvs 4081:
4082: visibility = TtaGetSensibility (document, view);
4083: if (visibility == 4)
4084: {
4085: visibility = 5;
4086: TtaSetToggleItem (document, 1, Views, TShowTargets, FALSE);
4087: }
4088: else
4089: {
4090: visibility = 4;
4091: TtaSetToggleItem (document, 1, Views, TShowTargets, TRUE);
4092: }
1.229 cvs 4093: /* Change visibility threshold in the main view */
1.219 cvs 4094: TtaSetSensibility (document, view, visibility);
1.229 cvs 4095: /* Change visibility threshold in the table of content view if it's open */
1.408 cvs 4096: tocView = TtaGetViewFromName (document, "Table_of_contents");
1.529 cvs 4097: if (tocView && TtaIsViewOpen (document, tocView))
1.229 cvs 4098: TtaSetSensibility (document, tocView, visibility);
1.219 cvs 4099: }
4100:
4101:
4102: /*----------------------------------------------------------------------
4103: ----------------------------------------------------------------------*/
1.585 cvs 4104: void ZoomIn (Document document, View view)
1.206 cvs 4105: {
4106: int zoom, zoomVal;
1.585 cvs 4107: char *zoomStr;
1.206 cvs 4108:
4109: zoom = TtaGetZoom (document, view);
4110: if (zoom < 10)
4111: {
4112: zoom++;
4113: TtaSetZoom (document, view, zoom);
4114: }
4115:
4116: /* compare to the standard value? */
1.339 cvs 4117: zoomStr = TtaGetEnvString ("ZOOM");
1.206 cvs 4118: if (zoomStr == NULL)
4119: zoomVal = 0;
4120: else
4121: {
1.607 cvs 4122: sscanf (zoomStr, "%d", &zoomVal);
1.206 cvs 4123: if (zoomVal > 10 || zoomVal < -10)
4124: zoomVal = 0;
4125: }
4126: if (zoom > zoomVal)
4127: TtaSetToggleItem (document, 1, Views, TZoomIn, TRUE);
4128: else
4129: TtaSetToggleItem (document, 1, Views, TZoomIn, FALSE);
4130: if (zoom < zoomVal)
4131: TtaSetToggleItem (document, 1, Views, TZoomOut, TRUE);
4132: else
4133: TtaSetToggleItem (document, 1, Views, TZoomOut, FALSE);
4134: }
4135:
4136: /*----------------------------------------------------------------------
4137: ----------------------------------------------------------------------*/
1.585 cvs 4138: void ZoomOut (Document document, View view)
1.206 cvs 4139: {
4140: int zoom, zoomVal;
1.585 cvs 4141: char *zoomStr;
1.206 cvs 4142:
4143: zoom = TtaGetZoom (document, view);
4144: if (zoom > -10)
4145: {
4146: zoom--;
4147: TtaSetZoom (document, view, zoom);
4148: }
4149:
4150: /* compare to the standard value? */
1.339 cvs 4151: zoomStr = TtaGetEnvString ("ZOOM");
1.206 cvs 4152: if (zoomStr == NULL)
4153: zoomVal = 0;
4154: else
4155: {
1.607 cvs 4156: sscanf (zoomStr, "%d", &zoomVal);
1.206 cvs 4157: if (zoomVal > 10 || zoomVal < -10)
4158: zoomVal = 0;
4159: }
4160: if (zoom > zoomVal)
4161: TtaSetToggleItem (document, 1, Views, TZoomIn, TRUE);
4162: else
4163: TtaSetToggleItem (document, 1, Views, TZoomIn, FALSE);
4164: if (zoom < zoomVal)
4165: TtaSetToggleItem (document, 1, Views, TZoomOut, TRUE);
4166: else
4167: TtaSetToggleItem (document, 1, Views, TZoomOut, FALSE);
1.275 cvs 4168: }
4169:
4170: /*----------------------------------------------------------------------
1.338 cvs 4171: ShowSource
1.691 cvs 4172: Display the source code of a document
1.206 cvs 4173: ----------------------------------------------------------------------*/
1.585 cvs 4174: void ShowSource (Document document, View view)
1.334 cvs 4175: {
1.658 vatton 4176: CHARSET charset;
1.600 cvs 4177: char *tempdocument;
4178: char *s;
4179: char documentname[MAX_LENGTH];
4180: char tempdir[MAX_LENGTH];
4181: Document sourceDoc;
4182: NotifyElement event;
1.334 cvs 4183:
1.348 cvs 4184: if (!DocumentURLs[document])
4185: /* the document is not loaded yet */
1.884 vatton 4186: #ifdef _SVG
4187: ShowSourceOfTimeline (document, view);
4188: #else /* _SVG */
1.348 cvs 4189: return;
1.884 vatton 4190: #endif /* _SVG */
1.352 cvs 4191: if (DocumentTypes[document] != docHTML &&
1.474 cvs 4192: DocumentTypes[document] != docSVG &&
1.545 cvs 4193: DocumentTypes[document] != docXml &&
1.765 cvs 4194: DocumentTypes[document] != docLibrary &&
1.479 cvs 4195: DocumentTypes[document] != docMath)
1.474 cvs 4196: /* it's not an HTML or an XML document */
1.352 cvs 4197: return;
1.334 cvs 4198: if (DocumentSource[document])
1.338 cvs 4199: /* the source code of this document is already shown */
4200: /* raise its window */
1.334 cvs 4201: TtaRaiseView (DocumentSource[document], 1);
4202: else
4203: {
1.352 cvs 4204: /* save the current state of the document into the temporary file */
4205: tempdocument = GetLocalPath (document, DocumentURLs[document]);
1.834 vatton 4206: if (TtaIsDocumentModified (document) || !TtaFileExist (tempdocument))
1.352 cvs 4207: {
1.525 cvs 4208: SetNamespacesAndDTD (document);
1.824 vatton 4209: if (DocumentTypes[document] == docLibrary ||
4210: DocumentTypes[document] == docHTML)
1.640 cvs 4211: {
1.808 vatton 4212: if (TtaGetDocumentProfile (document) == L_Xhtml11)
1.640 cvs 4213: TtaExportDocumentWithNewLineNumbers (document, tempdocument,
4214: "HTMLT11");
4215: else if (DocumentMeta[document]->xmlformat)
4216: TtaExportDocumentWithNewLineNumbers (document, tempdocument,
4217: "HTMLTX");
4218: else
4219: TtaExportDocumentWithNewLineNumbers (document, tempdocument,
4220: "HTMLT");
4221: }
1.479 cvs 4222: else if (DocumentTypes[document] == docSVG)
4223: TtaExportDocumentWithNewLineNumbers (document, tempdocument,
1.652 vatton 4224: "SVGT");
1.479 cvs 4225: else if (DocumentTypes[document] == docMath)
4226: TtaExportDocumentWithNewLineNumbers (document, tempdocument,
1.547 cvs 4227: "MathMLT");
1.616 cvs 4228: #ifdef XML_GENERIC
1.545 cvs 4229: else if (DocumentTypes[document] == docXml)
1.726 cvs 4230: TtaExportDocumentWithNewLineNumbers (document, tempdocument, NULL);
1.616 cvs 4231: #endif /* XML_GENERIC */
1.352 cvs 4232: }
1.334 cvs 4233: TtaExtractName (tempdocument, tempdir, documentname);
1.338 cvs 4234: /* open a window for the source code */
1.926 gully 4235: sourceDoc = InitDocAndView (document,
4236: FALSE /* replaceOldDoc */,
4237: TRUE /* inNewWindow */,
4238: documentname, (DocumentType)docSource, document, FALSE,
1.907 gully 4239: L_Other, (ClickEvent)CE_ABSOLUTE);
1.334 cvs 4240: if (sourceDoc > 0)
1.349 cvs 4241: {
4242: DocumentSource[document] = sourceDoc;
1.575 cvs 4243: s = TtaStrdup (DocumentURLs[document]);
1.349 cvs 4244: DocumentURLs[sourceDoc] = s;
1.552 kahan 4245: DocumentMeta[sourceDoc] = DocumentMetaDataAlloc ();
1.349 cvs 4246: DocumentMeta[sourceDoc]->form_data = NULL;
1.472 kahan 4247: DocumentMeta[sourceDoc]->initial_url = NULL;
1.349 cvs 4248: DocumentMeta[sourceDoc]->method = CE_ABSOLUTE;
1.381 cvs 4249: DocumentMeta[sourceDoc]->xmlformat = FALSE;
1.651 kahan 4250: /* copy the MIME type, charset, and content location */
1.633 kahan 4251: if (DocumentMeta[document]->content_type)
4252: DocumentMeta[sourceDoc]->content_type = TtaStrdup (DocumentMeta[document]->content_type);
4253: if (DocumentMeta[document]->charset)
4254: DocumentMeta[sourceDoc]->charset = TtaStrdup (DocumentMeta[document]->charset);
1.651 kahan 4255: if (DocumentMeta[document]->content_location)
4256: DocumentMeta[sourceDoc]->content_location = TtaStrdup (DocumentMeta[document]->content_location);
1.781 kahan 4257: if (DocumentMeta[document]->full_content_location)
4258: DocumentMeta[sourceDoc]->full_content_location = TtaStrdup (DocumentMeta[document]->full_content_location);
1.349 cvs 4259: DocumentTypes[sourceDoc] = docSource;
1.658 vatton 4260: charset = TtaGetDocumentCharset (document);
4261: if (charset == UNDEFINED_CHARSET)
4262: {
4263: if (DocumentMeta[document]->xmlformat)
1.828 cvs 4264: TtaSetDocumentCharset (SavingDocument, UTF_8, FALSE);
1.658 vatton 4265: else
1.828 cvs 4266: TtaSetDocumentCharset (SavingDocument, ISO_8859_1, FALSE);
1.658 vatton 4267: }
4268: else
1.828 cvs 4269: TtaSetDocumentCharset (sourceDoc, charset, FALSE);
1.349 cvs 4270: DocNetworkStatus[sourceDoc] = AMAYA_NET_INACTIVE;
4271: StartParser (sourceDoc, tempdocument, documentname, tempdir,
4272: tempdocument, TRUE);
1.376 cvs 4273: SetWindowTitle (document, sourceDoc, 0);
1.349 cvs 4274: /* Set the document read-only when needed */
1.479 cvs 4275: if (ReadOnlyDocument[document])
1.349 cvs 4276: {
1.479 cvs 4277: ReadOnlyDocument[sourceDoc] = TRUE;
1.349 cvs 4278: SetDocumentReadOnly (sourceDoc);
4279: }
1.410 cvs 4280: /* Switch the synchronization entry */
4281: if (TtaIsDocumentModified (document))
4282: DocStatusUpdate (document, TRUE);
1.352 cvs 4283: /* Synchronize selections */
4284: event.document = document;
1.349 cvs 4285: SynchronizeSourceView (&event);
4286: }
1.334 cvs 4287: TtaFreeMemory (tempdocument);
4288: }
4289: }
4290:
4291: /*----------------------------------------------------------------------
1.407 cvs 4292: ShowStructure
1.735 cvs 4293: Open the structure view(s) of a document.
1.334 cvs 4294: ----------------------------------------------------------------------*/
1.585 cvs 4295: void ShowStructure (Document document, View view)
1.6 cvs 4296: {
1.10 cvs 4297: View structView;
4298: int x, y, w, h;
1.547 cvs 4299: char structureName[30];
1.6 cvs 4300:
1.547 cvs 4301: strcpy (structureName, "Structure_view");
1.474 cvs 4302: structView = TtaGetViewFromName (document, structureName);
1.529 cvs 4303: if (structView != 0 && TtaIsViewOpen (document, structView))
1.132 cvs 4304: TtaRaiseView (document, structView);
1.10 cvs 4305: else
1.132 cvs 4306: {
1.474 cvs 4307: TtaGetViewGeometry (document, structureName, &x, &y, &w, &h);
4308: structView = TtaOpenView (document, structureName, x, y, w, h);
4309:
1.302 cvs 4310: if (structView != 0)
1.203 cvs 4311: {
1.452 cvs 4312: TtcSwitchButtonBar (document, structView); /* no button bar */
4313: TtcSwitchCommands (document, structView); /* no command open */
1.479 cvs 4314: if (ReadOnlyDocument[document])
1.302 cvs 4315: {
4316: TtaSetItemOff (document, structView, Edit_, BCut);
4317: TtaSetItemOff (document, structView, Edit_, BPaste);
4318: TtaSetItemOff (document, structView, Edit_, BClear);
4319: TtaSetItemOff (document, structView, Edit_, BSpellCheck);
4320: TtaSetItemOff (document, structView, Edit_, BTransform);
4321: TtaSetMenuOff (document, structView, StructTypes);
4322: TtaSetMenuOff (document, structView, Types);
4323: TtaSetMenuOff (document, structView, Attributes_);
4324: }
1.735 cvs 4325: #ifdef XML_GENERIC
4326: if (DocumentTypes[document] == docXml)
4327: {
4328: TtaSetMenuOff (document, structView, StructTypes);
4329: TtaSetMenuOff (document, structView, Types);
4330: TtaSetItemOff (document, structView, Edit_, BTransform);
4331: }
4332: #endif /* XML_GENERIC */
1.203 cvs 4333: }
1.132 cvs 4334: }
1.376 cvs 4335: SetWindowTitle (document, document, 0);
1.6 cvs 4336: }
4337:
1.9 cvs 4338: /*----------------------------------------------------------------------
1.407 cvs 4339: ShowAlternate
1.735 cvs 4340: Open the Alternate view of a document.
1.9 cvs 4341: ----------------------------------------------------------------------*/
1.681 vatton 4342: void ShowAlternate (Document document, View view)
1.6 cvs 4343: {
1.10 cvs 4344: View altView;
4345: int x, y, w, h;
1.6 cvs 4346:
1.408 cvs 4347: altView = TtaGetViewFromName (document, "Alternate_view");
1.10 cvs 4348: if (view == altView)
1.131 cvs 4349: TtaRaiseView (document, view);
1.529 cvs 4350: else if (altView != 0 && TtaIsViewOpen (document, altView))
1.130 cvs 4351: TtaRaiseView (document, altView);
1.10 cvs 4352: else
4353: {
1.452 cvs 4354: TtaGetViewGeometry (document, "Alternate_view", &x, &y, &w, &h);
1.547 cvs 4355: altView = TtaOpenView (document, "Alternate_view", x, y, w, h);
1.302 cvs 4356: if (altView != 0)
1.249 cvs 4357: {
1.376 cvs 4358: SetWindowTitle (document, document, altView);
1.452 cvs 4359: TtcSwitchButtonBar (document, altView); /* no button bar */
4360: TtcSwitchCommands (document, altView); /* no command open */
1.479 cvs 4361: if (ReadOnlyDocument[document])
1.302 cvs 4362: {
4363: TtaSetItemOff (document, altView, Edit_, BCut);
4364: TtaSetItemOff (document, altView, Edit_, BPaste);
4365: TtaSetItemOff (document, altView, Edit_, BClear);
4366: TtaSetItemOff (document, altView, Edit_, BSpellCheck);
4367: TtaSetItemOff (document, altView, Edit_, BTransform);
4368: TtaSetMenuOff (document, altView, Types);
4369: TtaSetMenuOff (document, altView, Attributes_);
4370: }
1.249 cvs 4371: }
1.10 cvs 4372: }
1.6 cvs 4373: }
4374:
4375:
1.9 cvs 4376: /*----------------------------------------------------------------------
1.407 cvs 4377: ShowLinks
1.735 cvs 4378: Open the Links view of a document
1.48 cvs 4379: ----------------------------------------------------------------------*/
1.585 cvs 4380: void ShowLinks (Document document, View view)
1.48 cvs 4381: {
4382: View linksView;
4383: int x, y, w, h;
4384:
1.408 cvs 4385: linksView = TtaGetViewFromName (document, "Links_view");
1.48 cvs 4386: if (view == linksView)
1.131 cvs 4387: TtaRaiseView (document, view);
1.529 cvs 4388: else if (linksView != 0 && TtaIsViewOpen (document, linksView))
1.130 cvs 4389: TtaRaiseView (document, linksView);
1.48 cvs 4390: else
4391: {
1.452 cvs 4392: TtaGetViewGeometry (document, "Links_view", &x, &y, &w, &h);
1.547 cvs 4393: linksView = TtaOpenView (document, "Links_view", x, y, w, h);
1.302 cvs 4394: if (linksView != 0)
1.249 cvs 4395: {
1.376 cvs 4396: SetWindowTitle (document, document, linksView);
1.452 cvs 4397: TtcSwitchButtonBar (document, linksView); /* no button bar */
4398: TtcSwitchCommands (document, linksView); /* no command open */
1.479 cvs 4399: if (ReadOnlyDocument[document])
1.302 cvs 4400: {
4401: TtaSetItemOff (document, linksView, Edit_, BCut);
4402: TtaSetItemOff (document, linksView, Edit_, BPaste);
4403: TtaSetItemOff (document, linksView, Edit_, BClear);
4404: TtaSetItemOff (document, linksView, Edit_, BSpellCheck);
4405: TtaSetItemOff (document, linksView, Edit_, BTransform);
4406: TtaSetMenuOff (document, linksView, Types);
4407: TtaSetMenuOff (document, linksView, Attributes_);
4408: }
1.735 cvs 4409: if (DocumentTypes[document] == docXml)
4410: {
4411: TtaSetMenuOff (document, linksView, Types);
4412: TtaSetItemOff (document, linksView, Edit_, BTransform);
4413: }
1.249 cvs 4414: }
1.48 cvs 4415: }
4416: }
4417:
4418:
4419: /*----------------------------------------------------------------------
1.407 cvs 4420: ShowToC
1.735 cvs 4421: Open the Table of content view of a document
1.48 cvs 4422: ----------------------------------------------------------------------*/
1.585 cvs 4423: void ShowToC (Document document, View view)
1.48 cvs 4424: {
4425: View tocView;
4426: int x, y, w, h;
4427:
1.408 cvs 4428: tocView = TtaGetViewFromName (document, "Table_of_contents");
1.48 cvs 4429: if (view == tocView)
1.131 cvs 4430: TtaRaiseView (document, view);
1.529 cvs 4431: else if (tocView != 0 && TtaIsViewOpen (document, tocView))
1.130 cvs 4432: TtaRaiseView (document, tocView);
1.48 cvs 4433: else
4434: {
1.452 cvs 4435: TtaGetViewGeometry (document, "Table_of_contents", &x, &y, &w, &h);
1.547 cvs 4436: tocView = TtaOpenView (document, "Table_of_contents", x, y, w, h);
1.302 cvs 4437: if (tocView != 0)
1.249 cvs 4438: {
1.376 cvs 4439: SetWindowTitle (document, document, tocView);
1.452 cvs 4440: TtcSwitchButtonBar (document, tocView); /* no button bar */
4441: TtcSwitchCommands (document, tocView); /* no command open */
1.479 cvs 4442: if (ReadOnlyDocument[document])
1.302 cvs 4443: {
4444: TtaSetItemOff (document, tocView, Edit_, BCut);
4445: TtaSetItemOff (document, tocView, Edit_, BPaste);
4446: TtaSetItemOff (document, tocView, Edit_, BClear);
4447: TtaSetItemOff (document, tocView, Edit_, BSpellCheck);
4448: TtaSetItemOff (document, tocView, Edit_, BTransform);
4449: TtaSetMenuOff (document, tocView, Types);
4450: TtaSetMenuOff (document, tocView, Attributes_);
4451: }
1.249 cvs 4452: }
1.10 cvs 4453: }
1.6 cvs 4454: }
4455:
4456:
1.9 cvs 4457: /*----------------------------------------------------------------------
1.22 cvs 4458: ViewToClose
4459: ----------------------------------------------------------------------*/
1.878 vatton 4460: ThotBool ViewToClose (NotifyDialog *event)
1.22 cvs 4461: {
1.103 cvs 4462: Document document;
1.456 cvs 4463: View view, structView, altView, linksView, tocView;
1.22 cvs 4464:
4465: view = event->view;
4466: document = event->document;
1.408 cvs 4467: structView = TtaGetViewFromName (document, "Structure_view");
4468: altView = TtaGetViewFromName (document, "Alternate_view");
4469: linksView = TtaGetViewFromName (document, "Links_view");
4470: tocView = TtaGetViewFromName (document, "Table_of_contents");
1.22 cvs 4471: if (view != 1)
1.148 cvs 4472: /* let Thot perform normal operation */
4473: return FALSE;
1.878 vatton 4474: else if (DocumentTypes[document] == docLibrary)
4475: {
4476: if (TtaIsDocumentModified (document))
4477: {
4478: InitConfirm (document, view, TtaGetMessage (AMAYA, AM_SAVE_DISK));
4479: if (UserAnswer)
4480: SaveDocument (document, view);
4481: TtaSetDocumentUnmodified (document);
4482: }
4483: }
4484: else if (!CanReplaceCurrentDocument (document, view))
4485: /* abort the command and don't let Thot perform normal operation */
4486: return TRUE;
1.22 cvs 4487:
1.529 cvs 4488: if (structView != 0 && TtaIsViewOpen (document, structView))
1.22 cvs 4489: TtaCloseView (document, structView);
1.529 cvs 4490: if (altView != 0 && TtaIsViewOpen (document, altView))
1.22 cvs 4491: TtaCloseView (document, altView);
1.529 cvs 4492: if (linksView != 0 && TtaIsViewOpen (document, linksView))
1.48 cvs 4493: TtaCloseView (document, linksView);
1.529 cvs 4494: if (tocView != 0 && TtaIsViewOpen (document, tocView))
1.48 cvs 4495: TtaCloseView (document, tocView);
1.148 cvs 4496: /* let Thot perform normal operation */
4497: return FALSE;
1.22 cvs 4498: }
4499:
1.193 cvs 4500: /*----------------------------------------------------------------------
1.924 vatton 4501: The urlName is encoded with the default charset.
1.193 cvs 4502: ----------------------------------------------------------------------*/
1.751 vatton 4503: void GetAmayaDoc_callback (int newdoc, int status, char *urlName,
1.558 cvs 4504: char *outputfile, AHTHeaders *http_headers,
4505: void * context)
1.177 cvs 4506: {
1.799 vatton 4507: Element elFound;
4508: Document doc;
4509: Document res;
1.924 vatton 4510: AmayaDoc_context *ctx;
1.799 vatton 4511: TTcbf *cbf;
4512: ClickEvent method;
4513: void *ctx_cbf;
4514: char tempdocument[MAX_LENGTH];
4515: char *tempfile;
4516: char *target;
4517: char *pathname;
4518: char *initial_url;
4519: char *documentname;
4520: char *form_data;
4521: char *s;
4522: int i;
1.824 vatton 4523: ThotBool inNewWindow;
1.799 vatton 4524: ThotBool ok, keep;
4525: ThotBool stopped_flag = FALSE;
4526: ThotBool local_link;
4527:
4528: /* restore GETHTMLDocument's context */
1.924 vatton 4529: ctx = (AmayaDoc_context *) context;
1.799 vatton 4530: if (!ctx)
4531: return;
4532: doc = ctx->doc;
4533: target = ctx->target;
4534: documentname = ctx->documentname;
4535: initial_url = ctx->initial_url;
4536: form_data = ctx->form_data;
4537: cbf = ctx->cbf;
4538: ctx_cbf = ctx->ctx_cbf;
4539: method = ctx->method;
4540: local_link = ctx->local_link;
1.824 vatton 4541: inNewWindow = ctx->inNewWindow;
1.799 vatton 4542: ok = TRUE;
1.907 gully 4543: pathname = (char *)TtaGetMemory (MAX_LENGTH + 1);
1.799 vatton 4544: strncpy (pathname, urlName, MAX_LENGTH);
4545: pathname[MAX_LENGTH] = EOS;
1.907 gully 4546: tempfile = (char *)TtaGetMemory (MAX_LENGTH + 1);
1.799 vatton 4547: if (method != CE_MAKEBOOK && method != CE_ANNOT &&
4548: method != CE_LOG && method != CE_HELP &&
1.805 vatton 4549: DocumentTypes[newdoc] != docLibrary &&
4550: status == 0)
1.799 vatton 4551: {
4552: /* add the URI in the combobox string */
4553: keep = (method == CE_ABSOLUTE || method == CE_INIT);
1.839 kahan 4554: if (form_data && method == CE_FORM_GET)
4555: AddURLInCombobox (pathname, form_data, keep);
4556: else
4557: AddURLInCombobox (pathname, NULL, keep);
1.799 vatton 4558: }
4559: if (outputfile != NULL)
1.220 cvs 4560: {
1.547 cvs 4561: strncpy (tempfile, outputfile, MAX_LENGTH);
1.220 cvs 4562: tempfile[MAX_LENGTH] = EOS;
4563: }
4564: else
1.293 cvs 4565: tempfile[0] = EOS;
1.177 cvs 4566:
1.809 vatton 4567: /* now the new window is open */
1.824 vatton 4568: if (inNewWindow && (method == CE_RELATIVE || method == CE_ABSOLUTE))
1.809 vatton 4569: /* don't free the current loaded document */
4570: method = CE_INIT;
1.763 vatton 4571: if (!local_link)
1.177 cvs 4572: {
1.542 cvs 4573: /* memorize the initial newdoc value in doc because LoadDocument */
1.180 cvs 4574: /* will open a new document if newdoc is a modified document */
1.177 cvs 4575: if (status == 0)
4576: {
1.805 vatton 4577: /* the document was successfully loaded */
1.305 cvs 4578: if (IsW3Path (pathname))
1.191 cvs 4579: NormalizeURL (pathname, 0, tempdocument, documentname, NULL);
1.471 kahan 4580: /* parse and display the document */
1.542 cvs 4581: res = LoadDocument (newdoc, pathname, form_data,
4582: initial_url, method,
4583: tempfile, documentname,
1.824 vatton 4584: http_headers, ctx->history, &inNewWindow);
1.177 cvs 4585: W3Loading = 0; /* loading is complete now */
4586: if (res == 0)
4587: {
4588: /* cannot load the document */
4589: ResetStop(newdoc);
4590: newdoc = 0;
4591: ok = FALSE;
4592: }
4593: else if (newdoc != res)
4594: newdoc = res;
4595: if (ok)
1.526 kahan 4596: {
4597: /* fetch and display all images referred by the document */
1.530 kahan 4598: if (method == CE_MAKEBOOK)
1.805 vatton 4599: stopped_flag = FetchAndDisplayImages (newdoc,
4600: AMAYA_LOAD_IMAGE | AMAYA_MBOOK_IMAGE,
4601: NULL);
1.526 kahan 4602: else
1.560 kahan 4603: {
1.627 cvs 4604: stopped_flag = FetchAndDisplayImages (newdoc, AMAYA_LOAD_IMAGE, NULL);
1.560 kahan 4605: #ifdef ANNOTATIONS
4606: /* if it's an annotation, add the existing metadata */
4607: if (DocumentTypes[newdoc] == docAnnot)
1.799 vatton 4608: ANNOT_LoadAnnotation (ctx->baseDoc, newdoc);
1.596 kahan 4609: /* auto-load the annotations associated with the document */
4610: if (ANNOT_CanAnnotate (newdoc))
4611: ANNOT_AutoLoad (newdoc, 1);
1.563 kahan 4612: #endif /* ANNOTATIONS */
1.560 kahan 4613: }
1.526 kahan 4614: }
1.617 cvs 4615: /* check parsing errors */
1.879 vatton 4616: if (DocumentTypes[newdoc] == docLog || method == CE_MAKEBOOK)
4617: CleanUpParsingErrors ();
4618: else
1.659 vatton 4619: CheckParsingErrors (newdoc);
1.177 cvs 4620: }
4621: else
4622: {
1.805 vatton 4623: /* a stop or an error occured */
1.177 cvs 4624: if (DocumentURLs[newdoc] == NULL)
4625: {
1.334 cvs 4626: /* save the document name into the document table */
1.575 cvs 4627: s = TtaStrdup (pathname);
1.177 cvs 4628: DocumentURLs[newdoc] = s;
1.765 cvs 4629: if (DocumentTypes[newdoc] == docLibrary)
4630: {
1.884 vatton 4631: #ifdef _SVG
1.799 vatton 4632: SelectLibraryFromPath (DocumentURLs[newdoc]);
4633: TtaSetTextZone (newdoc, 1, SVGlib_list);
1.884 vatton 4634: #endif /* _SVG */
1.765 cvs 4635: }
1.798 vatton 4636: else
1.799 vatton 4637: TtaSetTextZone (newdoc, 1, URL_list);
1.222 cvs 4638: /* save the document's formdata into the document table */
1.228 cvs 4639: if (DocumentMeta[newdoc])
1.471 kahan 4640: DocumentMetaClear (DocumentMeta[(int) newdoc]);
1.380 cvs 4641: else
1.552 kahan 4642: DocumentMeta[newdoc] = DocumentMetaDataAlloc ();
1.575 cvs 4643: DocumentMeta[newdoc]->form_data = TtaStrdup (form_data);
1.547 cvs 4644: if (strcmp (pathname, initial_url))
1.575 cvs 4645: DocumentMeta[newdoc]->initial_url = TtaStrdup (initial_url);
1.471 kahan 4646: else
1.472 kahan 4647: DocumentMeta[newdoc]->initial_url = NULL;
1.222 cvs 4648: DocumentMeta[newdoc]->method = method;
1.380 cvs 4649: DocumentMeta[newdoc]->xmlformat = FALSE;
1.334 cvs 4650: DocumentSource[newdoc] = 0;
1.257 cvs 4651: ResetStop(newdoc);
1.177 cvs 4652: }
4653: W3Loading = 0; /* loading is complete now */
1.805 vatton 4654: ResetStop(newdoc);
4655: ok = FALSE;
4656: if (status == -2)
4657: {
1.812 kahan 4658: s = HTTP_headers (http_headers, AM_HTTP_REASON);
4659: if (!s)
4660: s = "";
1.813 vatton 4661: sprintf (tempdocument, TtaGetMessage (AMAYA, AM_CANNOT_LOAD), pathname);
4662: InitConfirm3L (newdoc, 1, tempdocument, s, NULL, FALSE);
1.805 vatton 4663: }
1.177 cvs 4664: }
1.560 kahan 4665:
1.292 cvs 4666: if (ok && !stopped_flag)
1.177 cvs 4667: ResetStop(newdoc);
4668: }
4669:
4670: /* select the target if present */
1.445 cvs 4671: if (ok && !stopped_flag && target != NULL && target[0] != EOS &&
4672: newdoc != 0)
1.177 cvs 4673: {
4674: /* attribute HREF contains the NAME of a target anchor */
1.833 vatton 4675: elFound = SearchNAMEattribute (newdoc, target, NULL, NULL);
1.177 cvs 4676: if (elFound != NULL)
4677: {
4678: /* show the target element in all views */
4679: for (i = 1; i < 4; i++)
1.529 cvs 4680: if (TtaIsViewOpen (newdoc, i))
1.177 cvs 4681: TtaShowElement (newdoc, i, elFound, 0);
4682: }
4683: }
4684:
1.257 cvs 4685: /*** if stopped_flag == true, how to deal with cbf? */
1.182 cvs 4686: if (cbf)
4687: (*cbf) (newdoc, status, pathname, tempfile, NULL, ctx_cbf);
4688:
1.749 kirschpi 4689:
4690: #ifdef DAV
1.754 kirschpi 4691: /* MKP: if document has been loaded, we are *
4692: * able to discovery if the document is locked. *
4693: * do a lock discovery, set LockIndicator button */
4694: if (W3Loading == 0)
4695: {
1.749 kirschpi 4696: DAVLockDiscovery (newdoc);
4697: DAVSetLockIndicator(newdoc);
1.754 kirschpi 4698: }
1.749 kirschpi 4699: #endif
4700:
1.177 cvs 4701: TtaFreeMemory (target);
4702: TtaFreeMemory (documentname);
1.472 kahan 4703: TtaFreeMemory (initial_url);
1.177 cvs 4704: TtaFreeMemory (pathname);
4705: TtaFreeMemory (tempfile);
1.222 cvs 4706: if (form_data)
4707: TtaFreeMemory (form_data);
1.182 cvs 4708: TtaFreeMemory (ctx);
1.177 cvs 4709: }
1.22 cvs 4710:
4711: /*----------------------------------------------------------------------
1.799 vatton 4712: GetAmayaDoc loads the document if it is not loaded yet and calls the
4713: parser if the document can be parsed.
1.924 vatton 4714: - urlname: can be relative or absolute address.
4715: It's encoded with the default charset.
1.81 cvs 4716: - form_data: the text to be posted.
4717: - doc: the document which can be removed if not updated.
1.924 vatton 4718: - baseDoc: the document which urlname is relative to.
1.799 vatton 4719: - method: CE_FORM_POST for a post request, CE_RELATIVE for a double
1.325 cvs 4720: click.
1.143 cvs 4721: - history: record the URL in the browsing history
1.9 cvs 4722: ----------------------------------------------------------------------*/
1.924 vatton 4723: Document GetAmayaDoc (char *urlname, char *form_data,
1.799 vatton 4724: Document doc, Document baseDoc, ClickEvent method,
1.924 vatton 4725: ThotBool history, TTcbf *cbf, void *ctx_cbf)
1.6 cvs 4726: {
1.874 vatton 4727: Document newdoc, refdoc;
1.861 vatton 4728: CSSInfoPtr css;
4729: PInfoPtr pInfo;
1.924 vatton 4730: AmayaDoc_context *ctx = NULL;
1.861 vatton 4731: char *tempfile;
4732: char *parameters;
4733: char *target;
1.924 vatton 4734: char *initial_url;
1.861 vatton 4735: char *documentname;
4736: char *content_type = NULL;
4737: int toparse;
4738: int mode;
4739: int docType;
4740: ThotBool ok;
1.10 cvs 4741:
1.861 vatton 4742: /* Extract parameters if necessary */
1.924 vatton 4743: if (strlen (urlname) > MAX_LENGTH - 1)
1.861 vatton 4744: {
4745: TtaSetStatus (baseDoc, 1, TtaGetMessage (AMAYA, AM_TOO_LONG_URL), "512");
4746: return (0);
4747: }
4748: else
4749: /* clean up the status line */
4750: TtaSetStatus (baseDoc, 1, " ", NULL);
4751: ok = TRUE;
1.907 gully 4752: target = (char *)TtaGetMemory (MAX_LENGTH);
4753: documentname = (char *)TtaGetMemory (MAX_LENGTH);
4754: parameters = (char *)TtaGetMemory (MAX_LENGTH);
4755: tempfile = (char *)TtaGetMemory (MAX_LENGTH);
1.861 vatton 4756: tempfile[0] = EOS;
1.924 vatton 4757: initial_url = (char *)TtaGetMemory (MAX_LENGTH);
4758: ExtractParameters (urlname, parameters);
1.861 vatton 4759: /* Extract the target if necessary */
1.924 vatton 4760: ExtractTarget (urlname, target);
1.861 vatton 4761: /* Add the base content if necessary */
4762: if (method == CE_RELATIVE || method == CE_FORM_GET ||
4763: method == CE_FORM_POST || method == CE_MAKEBOOK)
1.924 vatton 4764: NormalizeURL (urlname, baseDoc, initial_url, documentname, NULL);
1.861 vatton 4765: else
1.924 vatton 4766: NormalizeURL (urlname, 0, initial_url, documentname, NULL);
1.861 vatton 4767: /* check the document suffix */
4768: if (IsMathMLName (documentname))
4769: docType = docMath;
4770: else if (IsSVGName (documentname))
4771: docType = docSVG;
4772: else if (IsCSSName (documentname))
4773: docType = docCSS;
4774: else if (IsTextName (documentname))
1.588 cvs 4775: docType = docText;
1.616 cvs 4776: #ifdef XML_GENERIC
1.861 vatton 4777: else if (IsXMLName (documentname))
4778: docType = docXml;
1.616 cvs 4779: #endif /* XML_GENERIC */
1.884 vatton 4780: #ifdef _SVG
1.861 vatton 4781: else if (IsLibraryName (documentname))
4782: docType = docLibrary;
1.884 vatton 4783: #endif /* _SVG */
1.861 vatton 4784: else if (method == CE_CSS)
4785: docType = docCSS;
4786: else
4787: docType = docHTML;
4788:
1.422 cvs 4789: /* we skip the file: prefix if it is present and do other local
1.861 vatton 4790: file urls conversions */
1.924 vatton 4791: if (!IsW3Path (initial_url))
1.861 vatton 4792: {
4793: /* we take the long way around to get the result
4794: of normalizeFile, as the function doesn't allocate
4795: memory dynamically (note: this can generate some MAX_LENGTH
4796: problems) */
4797: if (method == CE_RELATIVE || method == CE_FORM_GET ||
4798: method == CE_ANNOT || method == CE_FORM_POST ||
4799: method == CE_MAKEBOOK)
4800: /* we're following a link, so do all the convertions on
4801: the URL */
1.924 vatton 4802: NormalizeFile (initial_url, tempfile, AM_CONV_ALL);
1.861 vatton 4803: else
1.924 vatton 4804: NormalizeFile (initial_url, tempfile, AM_CONV_NONE);
4805: strcpy (initial_url, tempfile);
1.861 vatton 4806: tempfile[0] = EOS;
4807: }
1.336 cvs 4808:
1.861 vatton 4809: /* check if the user is already browsing the document in another window */
4810: if (method == CE_FORM_GET)
4811: {
1.924 vatton 4812: newdoc = IsDocumentLoaded (initial_url, form_data);
1.861 vatton 4813: /* we don't concatenate the new parameters as we give preference
4814: to the form data */
4815: }
4816: else
4817: {
4818: /* concatenate the parameters before making the test */
4819: if (parameters[0] != EOS)
4820: {
1.924 vatton 4821: strcat (initial_url, "?");
4822: strcat (initial_url, parameters);
1.861 vatton 4823: }
4824: /* if it's a POST form, we search the document using the
4825: form_data */
4826: if (method == CE_FORM_POST)
1.924 vatton 4827: newdoc = IsDocumentLoaded (initial_url, form_data);
1.861 vatton 4828: else
1.924 vatton 4829: newdoc = IsDocumentLoaded (initial_url, NULL);
1.861 vatton 4830: }
1.471 kahan 4831:
1.861 vatton 4832: if (newdoc != 0)
4833: /* the document is already loaded */
4834: {
4835: if (newdoc == doc)
4836: /* it's a move in the same document */
4837: {
4838: if (history)
1.471 kahan 4839: /* record the current position in the history */
1.861 vatton 4840: AddDocHistory (newdoc, DocumentURLs[newdoc],
4841: DocumentMeta[doc]->initial_url,
4842: DocumentMeta[doc]->form_data,
4843: DocumentMeta[doc]->method);
4844: }
4845: else
4846: /* following the link to another open window */
4847: {
4848: /* raise its window */
4849: TtaRaiseView (newdoc, 1);
4850: /* don't add it to the doc's historic */
4851: history = FALSE;
4852: }
4853: }
1.185 cvs 4854:
1.861 vatton 4855: /* Create the context for the callback */
1.924 vatton 4856: ctx = (AmayaDoc_context*)TtaGetMemory (sizeof (AmayaDoc_context));
1.861 vatton 4857: ctx->doc = doc;
4858: ctx->baseDoc = baseDoc;
4859: ctx->history = history;
4860: ctx->target = target;
4861: ctx->documentname = documentname;
1.924 vatton 4862: ctx->initial_url = TtaStrdup (initial_url);
1.861 vatton 4863: if (form_data)
4864: ctx->form_data = TtaStrdup (form_data);
4865: else
4866: ctx->form_data = NULL;
4867: ctx->method = method;
4868: ctx->cbf = cbf;
4869: ctx->ctx_cbf = ctx_cbf;
4870: ctx->local_link = 0;
4871: ctx->inNewWindow = InNewWindow;
1.185 cvs 4872:
1.861 vatton 4873: toparse = 0;
4874: if (newdoc == 0)
4875: {
1.924 vatton 4876: /*
4877: DocumentURLs and DocHistory are coded in the default charset */
1.861 vatton 4878: /* document not loaded yet */
4879: if ((method == CE_RELATIVE || method == CE_FORM_GET ||
4880: method == CE_FORM_POST || method == CE_MAKEBOOK ||
4881: method == CE_ANNOT) &&
1.924 vatton 4882: !IsW3Path (initial_url) && !TtaFileExist (initial_url))
1.861 vatton 4883: {
4884: /* the target document doesn't exist */
1.924 vatton 4885: TtaSetStatus (baseDoc, 1, TtaGetMessage (AMAYA, AM_CANNOT_LOAD), initial_url);
1.861 vatton 4886: ok = FALSE; /* do not continue */
4887: }
4888: else if (method == CE_LOG)
4889: /* need to create a new window for the document */
1.926 gully 4890: newdoc = InitDocAndView (doc,
4891: FALSE /* replaceOldDoc */,
4892: TRUE /* inNewWindow */,
4893: documentname, (DocumentType)docLog, 0, FALSE,
1.907 gully 4894: L_Other, (ClickEvent)method);
1.861 vatton 4895: else if (method == CE_HELP)
4896: {
4897: /* add the URI in the combobox string */
1.924 vatton 4898: AddURLInCombobox (initial_url, NULL, FALSE);
1.861 vatton 4899: /* need to create a new window for the document */
1.926 gully 4900: newdoc = InitDocAndView (doc,
4901: FALSE /* replaceOldDoc */,
4902: TRUE /* inNewWindow */,
4903: documentname, (DocumentType)docType, 0, TRUE,
1.907 gully 4904: L_Other, (ClickEvent)method);
1.861 vatton 4905: if (newdoc)
4906: {
4907: /* help document has to be in read-only mode */
4908: TtcSwitchCommands (newdoc, 1); /* no command open */
4909: TtaSetToggleItem (newdoc, 1, Views, TShowTextZone, FALSE);
4910: TtaSetMenuOff (newdoc, 1, Help_);
4911: }
4912: }
1.452 cvs 4913: #ifdef ANNOTATIONS
1.861 vatton 4914: else if (method == CE_ANNOT)
4915: {
4916: /* need to create a new window for the document */
1.926 gully 4917: newdoc = InitDocAndView (doc,
4918: FALSE /* replaceOldDoc */,
4919: TRUE /* inNewWindow */,
4920: documentname, (DocumentType)docAnnot, 0, FALSE,
1.907 gully 4921: L_Other, (ClickEvent)method);
1.861 vatton 4922: /* we're downloading an annotation, fix the accept_header
4923: (thru the content_type variable) to application/rdf */
4924: content_type = "application/rdf";
4925: }
1.452 cvs 4926: #endif /* ANNOTATIONS */
1.861 vatton 4927: else if (doc == 0 || InNewWindow)
4928: {
4929: /* In case of initial document, open the view before loading */
4930: /* add the URI in the combobox string */
1.924 vatton 4931: AddURLInCombobox (initial_url, NULL, FALSE);
1.926 gully 4932: newdoc = InitDocAndView (doc,
4933: FALSE /* replaceOldDoc */,
4934: #ifndef _WX
4935: TRUE /* inNewWindow */,
4936: #else /* _WX */
4937: /* by default the new document is open
4938: in the same window (new page)
4939: TODO : rendre ceci configurable
4940: par l'utilisateur */
4941: FALSE /* inNewWindow */,
4942: #endif /* _WX */
4943: documentname, (DocumentType)docType, 0, FALSE,
1.907 gully 4944: L_Other, (ClickEvent)method);
1.861 vatton 4945: }
4946: else
4947: {
4948: newdoc = doc;
4949: /* stop current transfer for previous document */
4950: if (method != CE_MAKEBOOK)
4951: StopTransfer (baseDoc, 1);
4952: else
4953: /* temporary docs to make a book are not in ReadOnly mode */
4954: DocumentTypes[newdoc] = docHTML;
4955: }
4956:
4957: if (newdoc == 0)
4958: /* cannot display the new document */
4959: ok = FALSE;
4960: if (ok)
4961: {
4962: /* this document is currently in load */
4963: W3Loading = newdoc;
4964: ActiveTransfer (newdoc);
4965: /* set up the transfer mode */
4966: mode = AMAYA_ASYNC | AMAYA_FLUSH_REQUEST;
4967:
4968: if (method == CE_FORM_POST)
4969: mode = mode | AMAYA_FORM_POST | AMAYA_NOCACHE;
4970: else if (method == CE_MAKEBOOK)
4971: mode = AMAYA_ASYNC;
1.452 cvs 4972:
1.924 vatton 4973: if (IsW3Path (initial_url))
1.861 vatton 4974: {
1.924 vatton 4975: css = SearchCSS (0, initial_url, NULL, &pInfo);
1.874 vatton 4976: if (method == CE_MAKEBOOK || method == CE_RELATIVE)
4977: /* add the referer field in the GET */
4978: refdoc = doc;
4979: else
4980: refdoc = 0;
1.886 cvs 4981: if ((css == NULL) || (css != NULL && newdoc == doc))
1.924 vatton 4982: toparse = GetObjectWWW (newdoc, refdoc, initial_url, form_data,
1.861 vatton 4983: tempfile, mode, NULL, NULL,
1.907 gully 4984: (void (*)(int, int, char*, char*, const AHTHeaders*, void*)) GetAmayaDoc_callback,
1.861 vatton 4985: (void *) ctx, YES, content_type);
4986: else
4987: {
4988: /* it was already loaded, we need to open it */
4989: TtaSetStatus (newdoc, 1,
4990: TtaGetMessage (AMAYA, AM_DOCUMENT_LOADED), NULL);
4991: /* just take a copy of the local temporary file */
4992: strcpy (tempfile, css->localName);
1.924 vatton 4993: GetAmayaDoc_callback (newdoc, 0, initial_url,
1.861 vatton 4994: tempfile, NULL, (void *) ctx);
4995: TtaHandlePendingEvents ();
4996: }
4997: }
4998: else
4999: {
5000: /* wasn't a document off the web, we need to open it */
5001: TtaSetStatus (newdoc, 1,
5002: TtaGetMessage (AMAYA, AM_DOCUMENT_LOADED),
5003: NULL);
1.924 vatton 5004: GetAmayaDoc_callback (newdoc, 0, initial_url, tempfile,
1.861 vatton 5005: NULL, (void *) ctx);
5006: TtaHandlePendingEvents ();
5007: }
5008: }
5009: }
5010: else if (ok && newdoc != 0)
5011: {
5012: /* following a local link */
5013: TtaSetStatus (newdoc, 1, TtaGetMessage (AMAYA, AM_DOCUMENT_LOADED), NULL);
5014: ctx->local_link = 1;
1.924 vatton 5015: GetAmayaDoc_callback (newdoc, 0, initial_url, tempfile, NULL, (void *) ctx);
1.861 vatton 5016: TtaHandlePendingEvents ();
5017: }
5018:
5019: if (ok == FALSE)
5020: /* if the document isn't loaded off the web (because of an error, or
5021: because it was already loaded), we invoke the callback function */
5022: {
5023: if (ctx->form_data)
5024: TtaFreeMemory (ctx->form_data);
5025: TtaFreeMemory (ctx->initial_url);
5026: if (ctx)
5027: TtaFreeMemory (ctx);
5028: if (cbf)
1.924 vatton 5029: (*cbf) (newdoc, -1, initial_url, tempfile, NULL, ctx_cbf);
1.861 vatton 5030: /* Free the memory associated with the context */
5031: TtaFreeMemory (target);
5032: TtaFreeMemory (documentname);
5033: }
5034: TtaFreeMemory (parameters);
5035: TtaFreeMemory (tempfile);
1.924 vatton 5036: TtaFreeMemory (initial_url);
1.861 vatton 5037: InNewWindow = FALSE;
5038: return (newdoc);
1.6 cvs 5039: }
5040:
1.9 cvs 5041: /*----------------------------------------------------------------------
1.706 cvs 5042: ChangeDoctype
1.711 cvs 5043: Mofity the doctype declaration for a HTML document saved as XML
5044: and vice-versa.
1.706 cvs 5045: isXml indicates is the new doctype corresponds to an XML document
5046: ----------------------------------------------------------------------*/
1.905 vatton 5047: static void ChangeDoctype (ThotBool isXml)
1.706 cvs 5048: {
5049: int profile;
5050: Document doc;
5051: ElementType elType;
1.840 cvs 5052: Element root, htmlRoot, doctype, doctypeLine, prevLine, text;
1.706 cvs 5053:
5054: doc = SavingDocument;
5055: root = TtaGetMainRoot (doc);
5056: elType.ElSSchema = TtaGetDocumentSSchema (doc);
5057: if (strcmp (TtaGetSSchemaName (elType.ElSSchema), "HTML"))
5058: return;
1.840 cvs 5059:
5060: /* Update the namespace declaration for the HTML element */
5061: elType.ElTypeNum = HTML_EL_HTML;
5062: htmlRoot = TtaSearchTypedElement (elType, SearchForward, root);
5063: if (!htmlRoot)
5064: return;
5065: if (isXml)
5066: TtaSetANamespaceDeclaration (doc, htmlRoot, NULL, XHTML_URI);
5067: else
5068: TtaFreeElemNamespaceDeclarations (doc, htmlRoot);
5069:
5070: /* Search the DOCTYPE element */
1.706 cvs 5071: elType.ElTypeNum = HTML_EL_DOCTYPE;
5072: doctype = TtaSearchTypedElement (elType, SearchForward, root);
5073: if (!doctype)
5074: return;
5075:
5076: /* Remove the previous doctype element */
5077: TtaDeleteTree (doctype, doc);
5078:
5079: profile = TtaGetDocumentProfile (doc);
1.723 quint 5080: /* Don't check the Thot abstract tree against the structure schema. */
1.706 cvs 5081: TtaSetStructureChecking (0, doc);
5082:
5083: doctype = TtaNewElement (doc, elType);
5084: TtaInsertFirstChild (&doctype, root, doc);
1.712 cvs 5085: /* Make the DOCTYPE element read-only */
5086: TtaSetAccessRight (doctype, ReadOnly, doc);
1.706 cvs 5087: /* create the first DOCTYPE_line element */
5088: elType.ElTypeNum = HTML_EL_DOCTYPE_line;
5089: doctypeLine = TtaNewElement (doc, elType);
5090: TtaInsertFirstChild (&doctypeLine, doctype, doc);
5091: elType.ElTypeNum = 1;
5092: text = TtaNewElement (doc, elType);
5093: if (text != NULL)
5094: {
5095: TtaInsertFirstChild (&text, doctypeLine, SavingDocument);
5096: if (isXml)
5097: {
5098: /* XML document */
5099: if (profile == L_Strict)
1.907 gully 5100: TtaSetTextContent (text, (unsigned char *)DOCTYPE1_XHTML10_STRICT, Latin_Script, doc);
1.706 cvs 5101: else
1.907 gully 5102: TtaSetTextContent (text, (unsigned char *)DOCTYPE1_XHTML10_TRANSITIONAL, Latin_Script, doc);
1.706 cvs 5103: }
5104: else
5105: {
5106: /* HTML document */
5107: if (profile == L_Strict)
1.907 gully 5108: TtaSetTextContent (text, (unsigned char *)DOCTYPE1_HTML_STRICT, Latin_Script, doc);
1.706 cvs 5109: else
1.907 gully 5110: TtaSetTextContent (text, (unsigned char *)DOCTYPE1_HTML_TRANSITIONAL, Latin_Script, doc);
1.706 cvs 5111: }
5112: }
5113: /* create the second DOCTYPE_line element */
5114: elType.ElTypeNum = HTML_EL_DOCTYPE_line;
5115: prevLine = doctypeLine;
5116: doctypeLine = TtaNewElement (doc, elType);
5117: TtaInsertSibling (doctypeLine, prevLine, FALSE, doc);
5118: elType.ElTypeNum = 1;
5119: text = TtaNewElement (doc, elType);
5120: if (text != NULL)
5121: {
5122: TtaInsertFirstChild (&text, doctypeLine, doc);
5123: if (isXml)
5124: {
5125: /* XML document */
5126: if (profile == L_Strict)
1.907 gully 5127: TtaSetTextContent (text, (unsigned char *)DOCTYPE2_XHTML10_STRICT, Latin_Script, doc);
1.706 cvs 5128: else
1.907 gully 5129: TtaSetTextContent (text, (unsigned char *)DOCTYPE2_XHTML10_TRANSITIONAL, Latin_Script, doc);
1.706 cvs 5130: }
5131: else
5132: {
5133: /* HTML document */
5134: if (profile == L_Strict)
1.907 gully 5135: TtaSetTextContent (text, (unsigned char *)DOCTYPE2_HTML_STRICT, Latin_Script, doc);
1.706 cvs 5136: else
1.907 gully 5137: TtaSetTextContent (text, (unsigned char *)DOCTYPE2_HTML_TRANSITIONAL, Latin_Script, doc);
1.706 cvs 5138: }
5139: }
5140: TtaSetStructureChecking (1, doc);
5141: }
5142:
5143: /*----------------------------------------------------------------------
1.139 cvs 5144: UpdateSaveAsButtons
5145: Maintain consistency between buttons in the Save As dialog box
5146: ----------------------------------------------------------------------*/
1.678 vatton 5147: static void UpdateSaveAsButtons ()
1.139 cvs 5148: {
1.911 gully 5149: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.140 cvs 5150: int active;
5151:
1.626 vatton 5152: if (SaveAsHTML || SaveAsXML)
5153: active = 1;
1.140 cvs 5154: else
1.515 cvs 5155: active = 0;
1.915 gully 5156: TtaRedrawMenuEntry (BaseDialog + ToggleSave, 0, NULL, (ThotColor)-1, active);
5157: TtaRedrawMenuEntry (BaseDialog + ToggleSave, 1, NULL, (ThotColor)-1, active);
1.911 gully 5158: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.139 cvs 5159: }
5160:
5161: /*----------------------------------------------------------------------
5162: SetFileSuffix
5163: Set the suffix of the file name used for saving a document
5164: ----------------------------------------------------------------------*/
1.548 cvs 5165: static void SetFileSuffix ()
1.139 cvs 5166: {
1.548 cvs 5167: char suffix[6];
5168: char *filename;
5169: int i, len;
1.139 cvs 5170:
1.756 vatton 5171: if (SavingDocument && SaveName[0] != EOS)
1.445 cvs 5172: {
1.498 cvs 5173: if (SaveAsHTML)
1.547 cvs 5174: strcpy (suffix, "html");
1.498 cvs 5175: else if (SaveAsXML)
1.548 cvs 5176: strcpy (suffix, "html");
1.412 cvs 5177: else if (SaveAsText)
1.547 cvs 5178: strcpy (suffix, "txt");
1.412 cvs 5179: else
1.445 cvs 5180: return;
1.139 cvs 5181:
1.412 cvs 5182: /* looks for a suffix at the end of the document name */
1.547 cvs 5183: len = strlen (SaveName);
5184: for (i = len-1; i > 0 && SaveName[i] != '.'; i--);
5185: if (SaveName[i] != '.')
1.445 cvs 5186: {
5187: /* there is no suffix */
5188: i = len;
1.547 cvs 5189: SaveName[i++] = '.';
1.445 cvs 5190: }
5191: else
5192: {
5193: /* there is a suffix */
5194: i++;
1.547 cvs 5195: if (strncmp (suffix, &SaveName[i], 3) == 0)
1.445 cvs 5196: /* the requested suffix is already here. Do nothing */
5197: i = 0;
1.916 cvs 5198: #ifdef _WINGUI
1.756 vatton 5199: strcpy (DocToOpen, SavePath);
1.547 cvs 5200: if (strchr (SavePath, '/'))
5201: strcat (DocToOpen, URL_STR);
1.445 cvs 5202: else
1.547 cvs 5203: strcat (DocToOpen, DIR_STR);
5204: strcat (DocToOpen, SaveName);
1.916 cvs 5205: #endif /* _WINGUI */
1.445 cvs 5206: }
5207:
5208: if (i > 0)
5209: {
5210: /* change or append the suffix */
1.547 cvs 5211: strcpy (&SaveName[i], suffix);
1.445 cvs 5212: /* display the new filename in the dialog box */
1.907 gully 5213: filename = (char *)TtaGetMemory (MAX_LENGTH);
1.756 vatton 5214: strcpy (filename, SavePath);
1.547 cvs 5215: if (strchr (SavePath, '/'))
5216: strcat (filename, URL_STR);
1.445 cvs 5217: else
1.547 cvs 5218: strcat (filename, DIR_STR);
5219: strcat (filename, SaveName);
1.891 gully 5220:
1.916 cvs 5221: #ifdef _WINGUI
1.547 cvs 5222: sprintf (DocToOpen, filename);
1.916 cvs 5223: #endif /* _WINGUI */
1.891 gully 5224:
1.911 gully 5225: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.445 cvs 5226: TtaSetTextForm (BaseDialog + NameSave, filename);
1.911 gully 5227: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5228:
1.445 cvs 5229: TtaFreeMemory (filename);
5230: }
5231: }
1.139 cvs 5232: }
5233:
5234: /*----------------------------------------------------------------------
1.9 cvs 5235: Callback procedure for dialogue events.
5236: ----------------------------------------------------------------------*/
1.599 cvs 5237: void CallbackDialogue (int ref, int typedata, char *data)
1.6 cvs 5238: {
1.626 vatton 5239: char tempfile[MAX_LENGTH];
5240: char tempname[MAX_LENGTH];
1.924 vatton 5241: char sep, *utf8value, *ptr;
1.659 vatton 5242: int val;
1.916 cvs 5243: #if defined(_MOTIF) || defined(_WINGUI) || defined(_WX)
1.896 cvs 5244: int i;
1.916 cvs 5245: #endif /* #if defined(_MOTIF) || defined(_WINGUI) || defined(_WX) */
1.810 vatton 5246: ThotBool change, updated;
1.126 cvs 5247:
1.924 vatton 5248: utf8value = NULL;
1.547 cvs 5249: if (typedata == STRING_DATA && data && strchr (data, '/'))
5250: sep = URL_SEP;
1.389 cvs 5251: else
1.547 cvs 5252: sep = DIR_SEP;
1.756 vatton 5253: val = (int) data;
5254: if (ref - BaseDialog >= OptionMenu &&
5255: ref - BaseDialog <= OptionMenu + MAX_SUBMENUS)
5256: /* a popup menu corresponding to a SELECT element or a submenu
5257: corresponding to an OPTGROUP element*/
5258: {
5259: ReturnOption = val;
5260: ReturnOptionMenu = ref - BaseDialog - OptionMenu;
5261: TtaDestroyDialogue (BaseDialog + OptionMenu);
5262: }
5263: else switch (ref - BaseDialog)
5264: {
5265: case OpenForm:
5266: /* *********Load URL or local document********* */
5267: if (val == 1)
5268: /* Confirm */
5269: {
5270: TtaDestroyDialogue (BaseDialog + OpenForm);
5271: TtaDestroyDialogue (BaseDialog + FileBrowserForm);
5272:
5273: if (LastURLName[0] != EOS)
5274: {
5275: TtaSetStatus (CurrentDocument, 1,
5276: TtaGetMessage (AMAYA, AM_CANNOT_LOAD),
5277: DocumentName);
1.794 vatton 5278: /* update the list of URLs */
1.756 vatton 5279: if (NewFile)
5280: InitializeNewDoc (LastURLName, NewDocType, 0, NewDocProfile);
5281: /* load an URL */
5282: else if (InNewWindow)
1.907 gully 5283: GetAmayaDoc (LastURLName, NULL, 0, 0, (ClickEvent)Loading_method,
1.924 vatton 5284: FALSE, NULL, NULL);
1.756 vatton 5285: else
5286: GetAmayaDoc (LastURLName, NULL, CurrentDocument,
1.907 gully 5287: CurrentDocument, (ClickEvent)Loading_method, TRUE,
1.924 vatton 5288: NULL, NULL);
1.756 vatton 5289: }
5290: else if (DirectoryName[0] != EOS && DocumentName[0] != EOS)
5291: {
5292: /* load a local file */
5293: strcpy (tempfile, DirectoryName);
5294: strcat (tempfile, DIR_STR);
5295: strcat (tempfile, DocumentName);
1.794 vatton 5296: /* update the list of URLs */
1.842 kahan 5297: NormalizeFile (tempfile, tempname, AM_CONV_ALL);
5298: if (FileExistTarget (tempname))
1.756 vatton 5299: {
5300: if (InNewWindow)
1.907 gully 5301: GetAmayaDoc (tempfile, NULL, 0, 0, (ClickEvent)Loading_method,
1.924 vatton 5302: FALSE, NULL, NULL);
1.756 vatton 5303: else
5304: GetAmayaDoc (tempfile, NULL, CurrentDocument,
1.907 gully 5305: CurrentDocument, (ClickEvent)Loading_method,
1.924 vatton 5306: TRUE, NULL, NULL);
1.756 vatton 5307: }
5308: else if (NewFile)
5309: InitializeNewDoc (tempfile, NewDocType, 0, NewDocProfile);
5310: else
5311: {
5312: if (IsMathMLName (tempfile))
5313: NewDocType = docMath;
5314: else if (IsSVGName (tempfile))
5315: NewDocType = docSVG;
5316: else if (IsCSSName (tempfile))
5317: NewDocType = docCSS;
1.616 cvs 5318: #ifdef XML_GENERIC
1.756 vatton 5319: else if (IsXMLName (tempfile))
5320: NewDocType = docXml;
1.616 cvs 5321: #endif /* XML_GENERIC */
1.884 vatton 5322: #ifdef _SVG
1.765 cvs 5323: else if (IsLibraryName (tempfile))
5324: NewDocType = docLibrary;
1.884 vatton 5325: #endif /* _SVG */
1.756 vatton 5326: else
5327: NewDocType = docHTML;
5328: InitializeNewDoc (tempfile, NewDocType, CurrentDocument, NewDocProfile);
5329: }
5330: }
5331: else if (DocumentName[0] != EOS)
5332: {
1.810 vatton 5333: ptr = DocumentName;
5334: updated = CompleteUrl (&ptr);
5335: if (updated)
5336: {
5337: strcpy (DocumentName, ptr);
5338: TtaFreeMemory (ptr);
5339: }
1.795 vatton 5340: /* update the list of URLs */
1.756 vatton 5341: if (InNewWindow)
1.907 gully 5342: GetAmayaDoc (DocumentName, NULL, 0, 0, (ClickEvent)Loading_method,
1.924 vatton 5343: FALSE, NULL, NULL);
1.756 vatton 5344: else
5345: GetAmayaDoc (DocumentName, NULL, CurrentDocument,
1.907 gully 5346: CurrentDocument, (ClickEvent)Loading_method, TRUE,
1.924 vatton 5347: NULL, NULL);
1.756 vatton 5348: }
5349: else if (DirectoryName[0] != EOS)
5350: TtaSetStatus (CurrentDocument, 1,
5351: TtaGetMessage (AMAYA, AM_CANNOT_LOAD),
5352: DirectoryName);
5353: else
5354: TtaSetStatus (CurrentDocument, 1,
5355: TtaGetMessage (AMAYA, AM_CANNOT_LOAD), "");
5356: NewFile = FALSE;
5357: CurrentDocument = 0;
5358: }
5359: else if (val == 2)
5360: {
5361: /* Browse button */
1.911 gully 5362: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5363: WidgetParent = OpenDocBrowser;
5364: BrowserForm (CurrentDocument, 1, &LastURLName[0]);
1.911 gully 5365: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.756 vatton 5366: }
5367: else if (val == 3)
5368: {
5369: /* Clear button */
5370: LastURLName[0] = EOS;
5371: DirectoryName[0] = EOS;
5372: DocumentName[0] = EOS;
1.911 gully 5373: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5374: TtaSetTextForm (BaseDialog + URLName, LastURLName);
1.911 gully 5375: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.756 vatton 5376: }
5377: else if (NewFile)
5378: {
5379: /* the command is aborted */
5380: CheckAmayaClosed ();
5381: NewFile = FALSE;
5382: }
5383: break;
1.485 cvs 5384:
1.756 vatton 5385: case URLName:
5386: RemoveNewLines (data);
1.810 vatton 5387: ptr = data;
5388: updated = CompleteUrl (&ptr);
5389: if (IsW3Path (ptr))
1.756 vatton 5390: {
5391: /* save the URL name */
1.810 vatton 5392: strcpy (LastURLName, ptr);
1.756 vatton 5393: DocumentName[0] = EOS;
5394: }
5395: else
5396: {
5397: LastURLName[0] = EOS;
1.810 vatton 5398: change = NormalizeFile (ptr, tempfile, AM_CONV_NONE);
1.756 vatton 5399: if (!IsW3Path (tempfile))
5400: {
5401: if (TtaCheckDirectory (tempfile))
5402: {
5403: strcpy (DirectoryName, tempfile);
5404: DocumentName[0] = EOS;
5405: }
5406: else
5407: TtaExtractName (tempfile, DirectoryName, DocumentName);
5408: }
5409: else
1.671 cheyroul 5410: {
1.756 vatton 5411: /* save the URL name */
5412: strcpy (LastURLName, tempfile);
5413: DocumentName[0] = EOS;
1.671 cheyroul 5414: }
1.810 vatton 5415: }
5416: if (updated)
5417: TtaFreeMemory (ptr);
1.756 vatton 5418: break;
1.485 cvs 5419:
1.756 vatton 5420: case DirSelect:
1.916 cvs 5421: #ifdef _WINGUI
1.756 vatton 5422: sprintf (DirectoryName, "%s", data);
1.916 cvs 5423: #endif /* _WINGUI */
1.891 gully 5424:
1.911 gully 5425: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5426: if (DirectoryName[0] != EOS)
5427: {
5428: if (!strcmp (data, ".."))
5429: {
5430: /* suppress last directory */
5431: strcpy (tempname, DirectoryName);
5432: TtaExtractName (tempname, DirectoryName, tempfile);
5433: }
5434: else
5435: {
5436: strcat (DirectoryName, DIR_STR);
5437: strcat (DirectoryName, data);
5438: }
5439: TtaSetTextForm (BaseDialog + URLName, DirectoryName);
5440: TtaListDirectory (DirectoryName, BaseDialog + OpenForm,
5441: TtaGetMessage (LIB, TMSG_DOC_DIR),
5442: BaseDialog + DirSelect, ScanFilter,
5443: TtaGetMessage (AMAYA, AM_FILES),
5444: BaseDialog + DocSelect);
5445: DocumentName[0] = EOS;
5446: }
1.911 gully 5447: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5448:
1.756 vatton 5449: break;
5450: case DocSelect:
5451: if (DirectoryName[0] == EOS)
5452: /* set path on current directory */
5453: getcwd (DirectoryName, MAX_LENGTH);
5454:
5455: /* Extract suffix from document name */
5456: strcpy (DocumentName, data);
5457: LastURLName[0] = EOS;
5458: /* construct the document full name */
5459: strcpy (tempfile, DirectoryName);
5460: strcat (tempfile, DIR_STR);
5461: strcat (tempfile, DocumentName);
1.891 gully 5462:
1.911 gully 5463: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5464: TtaSetTextForm (BaseDialog + URLName, tempfile);
1.911 gully 5465: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5466:
1.756 vatton 5467: break;
5468: case ConfirmForm:
5469: /* *********Confirm********* */
5470: UserAnswer = (val == 1);
5471: ShowErrors = (val == 2);
5472: TtaDestroyDialogue (BaseDialog + ConfirmForm);
5473: break;
5474: case FilterText:
5475: /* Filter value */
5476: if (strlen (data) <= NAME_LENGTH)
5477: strcpy (ScanFilter, data);
1.891 gully 5478:
1.911 gully 5479: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5480: else
5481: TtaSetTextForm (BaseDialog + FilterText, ScanFilter);
1.911 gully 5482: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5483:
1.756 vatton 5484: break;
5485: case FormAnswer:
5486: /* *********Get an answer********* */
5487: if (val == 0)
5488: {
5489: /* no answer */
5490: Answer_text[0] = EOS;
5491: Answer_name[0] = EOS;
5492: Answer_password[0] = EOS;
5493: UserAnswer = 0;
5494: }
5495: else
5496: UserAnswer = 1;
5497: TtaDestroyDialogue (BaseDialog + FormAnswer);
5498: break;
5499: case AnswerText:
5500: strncpy (Answer_text, data, MAX_LENGTH);
5501: Answer_text[MAX_LENGTH - 1] = EOS;
5502: break;
5503: case NameText:
5504: strncpy (Answer_name, data, NAME_LENGTH);
5505: Answer_text[NAME_LENGTH - 1] = EOS;
5506: break;
5507: case PasswordText:
1.891 gully 5508:
1.916 cvs 5509: #if defined(_MOTIF) || defined(_WINGUI) || defined(_WX)
1.756 vatton 5510: i = strlen (data);
5511: if (i < NAME_LENGTH - 1)
5512: {
5513: if (Lg_password < i)
5514: {
5515: /* a new char */
5516: Answer_password[Lg_password] = data[Lg_password];
5517: Display_password[Lg_password] = '*';
5518: Answer_password[++Lg_password] = EOS;
5519: Display_password[Lg_password] = EOS;
5520: }
5521: else if (Lg_password > i)
5522: {
5523: /* a valid backspace */
5524: Lg_password--;
5525: Answer_password[Lg_password] = EOS;
5526: Display_password[Lg_password] = EOS;
5527: }
5528: }
5529: else
5530: Answer_password[NAME_LENGTH - 1] = EOS;
1.916 cvs 5531: #endif /* #if defined(_MOTIF) || defined(_WINGUI) || defined(_WX) */
1.891 gully 5532:
5533: #ifdef _MOTIF
1.756 vatton 5534: if (i > 0)
5535: TtaSetTextForm (BaseDialog + PasswordText, Display_password);
1.891 gully 5536: #endif /* _MOTIF */
5537:
5538: #ifdef _GTK
1.756 vatton 5539: strncpy (Answer_password, data, NAME_LENGTH);
5540: Answer_password[NAME_LENGTH - 1] = EOS;
1.659 vatton 5541: #endif /* _GTK */
1.891 gully 5542:
1.756 vatton 5543: break;
5544:
5545: /* *********Save document as********* */
5546: case RadioSave:
5547: /* Output format */
5548: switch (val)
5549: {
5550: case 0: /* "Save as HTML" button */
5551: SaveAsHTML = TRUE;
5552: SaveAsXML = FALSE;
5553: SaveAsText = FALSE;
5554: UpdateSaveAsButtons ();
5555: SetFileSuffix ();
5556: break;
5557: case 1: /* "Save as XML" button */
5558: SaveAsXML = TRUE;
5559: SaveAsHTML = FALSE;
5560: SaveAsText = FALSE;
5561: UpdateSaveAsButtons ();
5562: SetFileSuffix ();
5563: /* Set the document charset */
5564: if (TtaGetDocumentCharset (SavingDocument) == UNDEFINED_CHARSET)
1.828 cvs 5565: TtaSetDocumentCharset (SavingDocument, ISO_8859_1, FALSE);
1.756 vatton 5566: break;
5567: case 2: /* "Save as Text" button */
5568: SaveAsText = TRUE;
5569: SaveAsHTML = FALSE;
5570: SaveAsXML = FALSE;
1.891 gully 5571:
1.911 gully 5572: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5573: TtaSetToggleMenu (BaseDialog + ToggleSave, 1, SaveAsXML);
5574: TtaSetToggleMenu (BaseDialog + ToggleSave, 0, SaveAsHTML);
5575: UpdateSaveAsButtons ();
1.911 gully 5576: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5577:
1.756 vatton 5578: SetFileSuffix ();
5579: break;
5580: }
5581: break;
5582: case ToggleSave:
5583: switch (val)
5584: {
5585: case 0: /* "Copy Images" button */
5586: CopyImages = !CopyImages;
5587: break;
5588: case 1: /* "Transform URLs" button */
5589: UpdateURLs = !UpdateURLs;
5590: break;
5591: }
5592: break;
5593: case SaveForm:
5594: if (val == 1)
5595: /* "Confirm" Button */
5596: {
5597: /* protect against saving without a MIME type */
5598: if (SavingDocument != 0)
5599: {
1.840 cvs 5600: if (DocumentTypes[SavingDocument] == docHTML &&
5601: DocumentMeta[SavingDocument])
5602: {
5603: if (DocumentMeta[SavingDocument]->xmlformat && SaveAsHTML)
5604: /* XHTML -> HTML */
5605: ChangeDoctype (FALSE);
5606: if (!DocumentMeta[SavingDocument]->xmlformat && SaveAsXML)
5607: /* HTML -> XHTML */
5608: ChangeDoctype (TRUE);
5609: }
5610:
1.756 vatton 5611: if ((!DocumentMeta[SavingDocument]
5612: || !DocumentMeta[SavingDocument]->content_type
5613: || DocumentMeta[SavingDocument]->content_type[0] == EOS)
5614: && (UserMimeType[0] == EOS))
5615: {
1.891 gully 5616:
1.911 gully 5617: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5618: TtaNewLabel (BaseDialog + SaveFormStatus,
5619: BaseDialog + SaveForm,
5620: TtaGetMessage (AMAYA, AM_INVALID_MIMETYPE));
1.911 gully 5621: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5622:
1.916 cvs 5623: #ifdef _WINGUI
1.756 vatton 5624: SaveAsDlgStatus (TtaGetMessage (AMAYA, AM_INVALID_MIMETYPE));
1.916 cvs 5625: #endif /* _WINGUI */
1.891 gully 5626:
5627: break;
1.756 vatton 5628: }
5629: }
5630: TtaDestroyDialogue (BaseDialog + SaveForm);
5631: if (SavingDocument != 0)
5632: DoSaveAs (UserCharset, UserMimeType);
5633: else if (SavingObject != 0)
5634: DoSaveObjectAs ();
1.165 cvs 5635:
1.756 vatton 5636: /* Move the information into LastURLName or DirectoryName */
5637: if (IsW3Path (SavePath))
5638: {
5639: strcpy (LastURLName, SavePath);
5640: strcat (LastURLName, "/");
5641: strcat (LastURLName, SaveName);
5642: DirectoryName[0] = EOS;
5643: }
5644: else
5645: {
5646: LastURLName[0] = EOS;
5647: strcpy (DirectoryName, SavePath);
5648: strcat (DocumentName, SaveName);
5649: }
5650: }
5651: else if (val == 2)
5652: /* "Browse" button */
5653: {
1.891 gully 5654:
1.911 gully 5655: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5656: WidgetParent = DocSaveBrowser;
5657: strcpy (LastURLName, SavePath);
5658: strcat (LastURLName, DIR_STR);
5659: strcat (LastURLName, SaveName);
5660: BrowserForm (SavingDocument, 1, LastURLName);
1.911 gully 5661: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5662:
1.756 vatton 5663: }
5664: else if (val == 3)
5665: /* "Clear" button */
5666: {
5667: if (SavingDocument != 0)
5668: {
5669: SavePath[0] = EOS;
5670: SaveImgsURL[0] = EOS;
5671: SaveName[0] = EOS;
1.891 gully 5672:
1.911 gully 5673: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5674: TtaSetTextForm (BaseDialog + NameSave, SaveImgsURL);
5675: TtaSetTextForm (BaseDialog + ImgDirSave, SaveImgsURL);
1.911 gully 5676: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5677:
1.756 vatton 5678: }
5679: }
5680: else if (val == 4)
5681: /* "Charset" button */
5682: {
5683: if (SavingDocument != 0)
5684: {
5685: if (DocumentTypes[SavingDocument] != docImage)
5686: {
5687: /* clear the status message */
1.911 gully 5688: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5689: TtaNewLabel (BaseDialog + SaveFormStatus,
5690: BaseDialog + SaveForm, " ");
1.911 gully 5691: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5692:
1.916 cvs 5693: #ifdef _WINGUI
1.756 vatton 5694: SaveAsDlgStatus ("");
1.916 cvs 5695: #endif /* _WINGUI */
1.891 gully 5696:
5697: InitCharset (SavingDocument, 1, SavePath);
1.756 vatton 5698: if (SaveFormTmp[0] != EOS)
5699: {
5700: strcpy (UserCharset, SaveFormTmp);
1.891 gully 5701:
1.911 gully 5702: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5703: TtaNewLabel (BaseDialog + CharsetSave,
5704: BaseDialog + SaveForm, UserCharset);
1.911 gully 5705: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5706:
5707: }
1.756 vatton 5708: }
5709: else
5710: {
1.891 gully 5711:
1.911 gully 5712: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5713: TtaNewLabel (BaseDialog + SaveFormStatus,
5714: BaseDialog + SaveForm,
5715: TtaGetMessage (AMAYA, AM_NOCHARSET_SUPPORT));
1.911 gully 5716: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5717:
1.916 cvs 5718: #ifdef _WINGUI
1.756 vatton 5719: SaveAsDlgStatus (TtaGetMessage (AMAYA, AM_NOCHARSET_SUPPORT));
1.916 cvs 5720: #endif /* _WINGUI */
1.891 gully 5721:
5722: }
1.756 vatton 5723: }
5724: }
5725: else if (val == 5)
5726: /* "MIME type" button */
5727: {
5728: if (SavingDocument != 0)
5729: {
5730: if (SavePath[0] && IsW3Path (SavePath))
5731: {
5732: /* clear the status message */
1.891 gully 5733:
1.911 gully 5734: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5735: TtaNewLabel (BaseDialog + SaveFormStatus,
5736: BaseDialog + SaveForm,
5737: " ");
1.911 gully 5738: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5739:
1.916 cvs 5740: #ifdef _WINGUI
1.756 vatton 5741: SaveAsDlgStatus ("");
1.916 cvs 5742: #endif /* _WINGUI */
1.891 gully 5743:
5744: InitMimeType (SavingDocument, 1, SavePath, NULL);
1.756 vatton 5745: if (SaveFormTmp[0] != EOS)
5746: {
5747: strcpy (UserMimeType, SaveFormTmp);
5748:
1.911 gully 5749: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5750: TtaNewLabel (BaseDialog + MimeTypeSave,
5751: BaseDialog + SaveForm, UserMimeType);
1.911 gully 5752: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5753:
1.756 vatton 5754: }
5755: }
5756: else
5757: {
1.911 gully 5758: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5759: TtaNewLabel (BaseDialog + SaveFormStatus,
5760: BaseDialog + SaveForm,
5761: TtaGetMessage (AMAYA, AM_NOMIMETYPE_SUPPORT));
1.911 gully 5762: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5763:
1.916 cvs 5764: #ifdef _WINGUI
1.756 vatton 5765: SaveAsDlgStatus (TtaGetMessage (AMAYA, AM_NOMIMETYPE_SUPPORT));
1.916 cvs 5766: #endif /* _WINGUI */
1.891 gully 5767:
1.756 vatton 5768: }
5769: }
5770: }
5771: else
5772: /* "Cancel" button */
5773: {
5774: TtaDestroyDialogue (BaseDialog + SaveForm);
5775: if (SavingObject != 0)
5776: /* delete temporary file */
5777: DeleteTempObjectFile ();
5778: SavingDocument = 0;
5779: SavingObject = 0;
5780: }
5781: break;
5782: case NameSave:
5783: /* Document location */
5784: if (!IsW3Path (data))
5785: change = NormalizeFile (data, tempfile, AM_CONV_NONE);
5786: else
5787: strcpy (tempfile, data);
5788:
5789: if (*tempfile && tempfile[strlen (tempfile) - 1] == sep)
5790: {
5791: strcpy (SavePath, tempfile);
5792: SaveName[0] = EOS;
5793: }
5794: else
5795: {
5796: /* Extract document name */
5797: if (SavingDocument != 0)
5798: TtaExtractName (tempfile, SavePath, SaveName);
5799: else
5800: TtaExtractName (tempfile, SavePath, ObjectName);
5801: }
5802: break;
5803: case ImgDirSave:
5804: /* Image directory */
5805: if (!IsW3Path (data))
5806: change = NormalizeFile (data, SaveImgsURL, AM_CONV_NONE);
5807: else
5808: strcpy (SaveImgsURL, data);
5809: break;
5810: case ConfirmSave:
5811: /* *********SaveConfirm********* */
5812: UserAnswer = (val == 1);
5813: TtaDestroyDialogue (BaseDialog + ConfirmSave);
5814: if (!UserAnswer)
5815: {
5816: SavingDocument = 0;
5817: SavingObject = 0;
5818: }
5819: break;
1.84 cvs 5820:
1.756 vatton 5821: case AttrHREFForm:
5822: /* *********HREF Attribute*********** */
5823: if (val == 1)
5824: {
5825: /* Confirm button */
5826: if (AttrHREFvalue[0] != EOS)
5827: {
1.924 vatton 5828: utf8value = (char *)TtaConvertByteToMbs ((unsigned char *)AttrHREFvalue,
5829: TtaGetDefaultCharset ());
1.756 vatton 5830: /* create an attribute HREF for the Link_Anchor */
5831: SetREFattribute (AttrHREFelement, AttrHREFdocument,
1.924 vatton 5832: utf8value, NULL);
5833: TtaFreeMemory (utf8value);
1.756 vatton 5834: }
5835: TtaDestroyDialogue (BaseDialog + AttrHREFForm);
5836: TtaDestroyDialogue (BaseDialog + FileBrowserForm);
5837: }
5838: else if (val == 2)
5839: /* Browse button */
5840: {
1.911 gully 5841: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.854 vatton 5842: if (LinkAsXmlCSS || LinkAsCSS)
5843: strcpy (ScanFilter, "*.css");
5844: else if (!strcmp (ScanFilter, "*.css"))
5845: strcpy (ScanFilter, "*");
1.756 vatton 5846: WidgetParent = HrefAttrBrowser;
5847: BrowserForm (AttrHREFdocument, 1, &AttrHREFvalue[0]);
1.911 gully 5848: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.756 vatton 5849: }
5850: else if (val == 3)
1.852 vatton 5851: /* allow one to click the target */
5852: SelectDestination (AttrHREFdocument, AttrHREFelement, AttrHREFundoable, TRUE);
5853: else if (val == 4)
1.756 vatton 5854: {
5855: /* Clear button */
5856: AttrHREFvalue[0] = EOS;
1.891 gully 5857:
1.911 gully 5858: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5859: TtaSetTextForm (BaseDialog + AttrHREFText, AttrHREFvalue);
1.911 gully 5860: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5861:
1.756 vatton 5862: }
5863: else
5864: /* Cancel button */
5865: if (IsNewAnchor)
5866: {
5867: LinkAsCSS = FALSE;
1.789 cvs 5868: LinkAsXmlCSS = FALSE;
1.756 vatton 5869: /* remove the link if it was just created */
5870: TtaCancelLastRegisteredSequence (AttrHREFdocument);
5871: DeleteAnchor (AttrHREFdocument, 1);
5872: TtaCancelLastRegisteredSequence (AttrHREFdocument);
5873: }
5874: break;
1.212 cvs 5875:
1.756 vatton 5876: case AttrHREFText:
5877: /* save the HREF name */
1.758 vatton 5878: RemoveNewLines (data);
5879: if (IsW3Path (data))
1.756 vatton 5880: {
5881: /* save the URL name */
1.758 vatton 5882: strcpy (AttrHREFvalue, data);
1.756 vatton 5883: DocumentName[0] = EOS;
5884: }
5885: else
5886: {
1.758 vatton 5887: change = NormalizeFile (data, tempfile, AM_CONV_NONE);
1.756 vatton 5888: if (TtaCheckDirectory (tempfile))
5889: {
5890: strcpy (DirectoryName, tempfile);
5891: DocumentName[0] = EOS;
5892: }
5893: else
5894: TtaExtractName (tempfile, DirectoryName, DocumentName);
5895: strcpy (AttrHREFvalue, tempfile);
5896: }
5897: break;
5898:
5899: /* *********File Browser*********** */
5900: case FileBrowserForm:
5901: if (val == 1)
5902: {
5903: /* Confirm button */
5904: /* it's no longer the default Welcome page */
5905: WelcomePage = FALSE;
1.891 gully 5906:
1.911 gully 5907: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5908: /* this code is only valid under Unix. */
5909: /* In Windows, we're using a system widget */
5910: strcpy (tempfile, DirectoryName);
5911: strcat (tempfile, DIR_STR);
5912: strcat (tempfile, DocumentName);
5913: if (WidgetParent == HrefAttrBrowser)
5914: {
5915: TtaSetTextForm (BaseDialog + AttrHREFText, tempfile);
5916: strcpy (AttrHREFvalue, tempfile);
5917: CallbackDialogue (BaseDialog + AttrHREFForm, INTEGER_DATA, (char *) 1);
5918: }
5919: else if (WidgetParent == OpenDocBrowser)
5920: {
5921: TtaSetTextForm (BaseDialog + URLName, tempfile);
5922: CallbackDialogue (BaseDialog + OpenForm, INTEGER_DATA, (char *) 1);
5923: }
5924: else if (WidgetParent == DocSaveBrowser)
5925: {
5926: TtaSetTextForm (BaseDialog + NameSave, tempfile);
5927: CallbackDialogue (BaseDialog + NameSave, STRING_DATA, tempfile);
5928: }
5929: /* remove the browsing dialogue */
5930: TtaDestroyDialogue (ref);
1.911 gully 5931: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5932:
1.756 vatton 5933: }
5934: else if (val == 2)
5935: /* Clear button */
5936: {
5937: if (WidgetParent == OpenDocBrowser)
5938: {
5939: LastURLName[0] = EOS;
1.911 gully 5940: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5941: TtaSetTextForm (BaseDialog + FileBrowserText, LastURLName);
1.911 gully 5942: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5943:
1.756 vatton 5944: }
5945: else if (WidgetParent == HrefAttrBrowser)
5946: {
5947: tempname[0] = EOS;
1.891 gully 5948:
1.911 gully 5949: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5950: TtaSetTextForm (BaseDialog + FileBrowserText, tempname);
1.911 gully 5951: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 5952:
1.756 vatton 5953: }
5954: }
5955: else if (val == 3)
5956: /* Filter button */
5957: {
5958: /* reinitialize directories and document lists */
5959: TtaListDirectory (DirectoryName, BaseDialog + FileBrowserForm,
5960: TtaGetMessage (LIB, TMSG_DOC_DIR),
5961: BaseDialog + BrowserDirSelect,
5962: ScanFilter, TtaGetMessage (AMAYA, AM_FILES),
5963: BaseDialog + BrowserDocSelect);
5964: }
5965: else
5966: /* Cancel button */
5967: {
5968: }
5969: break;
5970:
5971: case FileBrowserText:
5972: RemoveNewLines (data);
5973: if (IsW3Path (data))
5974: {
5975: DocumentName[0] = EOS;
5976: }
5977: else
5978: {
5979: change = NormalizeFile (data, tempfile, AM_CONV_NONE);
5980: if (TtaCheckDirectory (tempfile))
5981: {
5982: strcpy (DirectoryName, tempfile);
5983: DocumentName[0] = EOS;
5984: }
5985: else
5986: TtaExtractName (tempfile, DirectoryName, DocumentName);
5987: strcpy (AttrHREFvalue, tempfile);
5988: }
5989: break;
5990:
5991: /* *********Browser DirSelect*********** */
5992: case BrowserDirSelect:
1.891 gully 5993:
1.916 cvs 5994: #ifdef _WINGUI
1.756 vatton 5995: sprintf (DirectoryName, "%s", data);
1.916 cvs 5996: #endif /* _WINGUI */
1.891 gully 5997:
1.911 gully 5998: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 5999: if (DirectoryName[0] != EOS)
6000: {
6001: if (!strcmp (data, ".."))
6002: {
6003: /* suppress last directory */
6004: strcpy (tempname, DirectoryName);
6005: TtaExtractName (tempname, DirectoryName, tempfile);
6006: if (DirectoryName[0] == EOS)
6007: strcpy (DirectoryName, DIR_STR);
6008: }
6009: else
6010: {
6011: strcat (DirectoryName, DIR_STR);
6012: strcat (DirectoryName, data);
6013: }
6014:
6015: if (WidgetParent == OpenDocBrowser)
6016: LastURLName[0] = EOS;
6017:
6018: TtaSetTextForm (BaseDialog + FileBrowserText, DirectoryName);
6019: TtaListDirectory (DirectoryName, BaseDialog + FileBrowserForm,
6020: TtaGetMessage (LIB, TMSG_DOC_DIR),
6021: BaseDialog + BrowserDirSelect, ScanFilter,
6022: TtaGetMessage (AMAYA, AM_FILES),
6023: BaseDialog + BrowserDocSelect);
6024: DocumentName[0] = EOS;
6025: }
1.911 gully 6026: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.756 vatton 6027: break;
6028:
6029: /* *********Browser DocSelect*********** */
6030: case BrowserDocSelect:
6031: /* set path on current directory */
6032: if (DirectoryName[0] == EOS)
6033: getcwd (DirectoryName, MAX_LENGTH);
6034:
6035: /* Extract suffix from document name */
6036: strcpy (DocumentName, data);
6037:
6038: if (WidgetParent == OpenDocBrowser)
6039: LastURLName[0] = EOS;
6040:
6041: /* construct the document full name */
6042: strcpy (tempfile, DirectoryName);
6043: strcat (tempfile, DIR_STR);
6044: strcat (tempfile, DocumentName);
1.891 gully 6045:
1.911 gully 6046: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 6047: TtaSetTextForm (BaseDialog + FileBrowserText, tempfile);
1.911 gully 6048: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 6049:
1.756 vatton 6050: break;
6051:
6052: /* *********Browser Filter*********** */
6053: case FileBrowserFilter:
6054: /* Filter value */
6055: if (strlen(data) <= NAME_LENGTH)
6056: strcpy (ScanFilter, data);
1.891 gully 6057:
1.911 gully 6058: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 6059: else
6060: TtaSetTextForm (BaseDialog + BrowserFilterText, ScanFilter);
1.911 gully 6061: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 6062:
1.756 vatton 6063: break;
6064:
6065: case TitleForm:
6066: /* ********Change the document title*********** */
6067: TtaDestroyDialogue (BaseDialog + TitleForm);
6068: if (val == 1)
6069: SetNewTitle (CurrentDocument);
6070: break;
6071:
6072: case TitleText:
6073: /* new document name */
6074: strncpy (Answer_text, data, MAX_LENGTH);
6075: Answer_text[MAX_LENGTH - 1] = EOS;
6076: break;
6077:
6078: case ClassForm:
6079: case ClassSelect:
6080: case AClassForm:
6081: case AClassSelect:
6082: StyleCallbackDialogue (ref, typedata, data);
6083: break;
6084:
6085: case TableForm:
6086: /* *********Table Form*********** */
6087: UserAnswer = (val == 1);
6088: TtaDestroyDialogue (BaseDialog + TableForm);
6089: break;
6090: case TableRows:
6091: NumberRows = val;
6092: break;
6093: case TableCols:
6094: NumberCols = val;
6095: break;
6096: case TableBorder:
6097: TBorder = val;
6098: break;
6099: case MathEntityForm:
6100: /* ********* MathML entity form ********* */
6101: if (val == 0)
6102: /* no answer */
6103: MathMLEntityName[0] = EOS;
6104: break;
6105: case MathEntityText:
6106: strncpy (MathMLEntityName, data, MAX_LENGTH);
6107: MathMLEntityName[MAX_LENGTH - 1] = EOS;
6108: break;
6109: case MakeIdMenu:
6110: switch (val)
6111: {
6112: case 1:
6113: CreateRemoveIDAttribute (IdElemName, IdDoc, TRUE,
6114: (IdApplyToSelection) ? TRUE: FALSE);
1.911 gully 6115: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 6116: /* and show the status */
6117: TtaNewLabel (BaseDialog + mIdStatus,
6118: BaseDialog + MakeIdMenu,
6119: IdStatus);
1.911 gully 6120: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.756 vatton 6121: break;
6122: case 2:
6123: CreateRemoveIDAttribute (IdElemName, IdDoc, FALSE,
6124: (IdApplyToSelection) ? TRUE: FALSE);
1.911 gully 6125: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 6126: /* and show the status */
6127: TtaNewLabel (BaseDialog + mIdStatus,
6128: BaseDialog + MakeIdMenu,
6129: IdStatus);
1.911 gully 6130: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.756 vatton 6131: break;
6132: }
6133: break;
6134: case mElemName:
6135: strncpy (IdElemName, data, MAX_LENGTH);
6136: IdElemName[MAX_LENGTH - 1] = EOS;
6137: break;
6138: case mIdUseSelection:
6139: IdApplyToSelection = val;
6140: break;
6141: /* Charset Save As menu */
6142: case CharsetForm:
6143: {
6144: switch (val)
6145: {
6146: case 0:
6147: SaveFormTmp[0] = EOS;
6148: TtaDestroyDialogue (ref);
6149: break;
6150: case 1:
6151: TtaDestroyDialogue (ref);
6152: break;
6153: }
6154: }
6155: break;
6156: case CharsetSel:
6157: switch (val)
6158: {
6159: case 0:
6160: strcpy (SaveFormTmp, "us-ascii");
6161: break;
6162: case 1:
6163: strcpy (SaveFormTmp, "UTF-8");
6164: break;
6165: case 2:
6166: strcpy (SaveFormTmp, "iso-8859-1");
6167: break;
6168: case 3:
6169: strcpy (SaveFormTmp, "iso-8859-2");
6170: break;
6171: }
6172: break;
1.618 kahan 6173:
1.756 vatton 6174: /* MIME type Save As menu */
6175: case MimeTypeForm:
6176: {
6177: switch (val)
6178: {
6179: case 0:
6180: SaveFormTmp[0] = EOS;
6181: TtaDestroyDialogue (ref);
6182: break;
6183: case 1:
6184: {
6185: char *src, *dst;
6186: /* filter the UserMimeType */
6187: src = dst = SaveFormTmp;
6188: while (*src)
6189: {
6190: if (!isascii (*src)
6191: || (!isalnum (*src) && *src != '/' && *src != '-'
6192: && *src != '+'))
6193: {
6194: /* skip the character */
6195: src++;
6196: continue;;
6197: }
6198:
6199: if (isupper (*src))
6200: /* convert to lower case */
6201: *dst = tolower (*src);
6202: else
6203: *dst = *src;
6204: src++;
6205: dst++;
6206: }
6207: *dst = EOS;
6208: /* validate the mime type */
6209: if (SaveFormTmp[0] == EOS ||!strchr (SaveFormTmp, '/'))
6210: {
6211: SaveFormTmp[0] = EOS;
1.891 gully 6212:
1.911 gully 6213: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.756 vatton 6214: InitMimeType (SavingDocument, 1, SavePath,
6215: TtaGetMessage (AMAYA, AM_INVALID_MIMETYPE));
1.911 gully 6216: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 6217:
1.916 cvs 6218: #ifdef _WINGUI
1.891 gully 6219: /* the Window dialog won't be closed */
1.756 vatton 6220: MimeTypeDlgStatus (TtaGetMessage (AMAYA, AM_INVALID_MIMETYPE));
1.916 cvs 6221: #endif /* _WINGUI */
1.891 gully 6222:
6223: }
1.756 vatton 6224: else
6225: TtaDestroyDialogue (ref);
6226: }
6227: break;
6228: }
6229: }
6230: break;
6231: case MimeTypeSel:
6232: if (data)
6233: strcpy (SaveFormTmp, data);
6234: else
6235: SaveFormTmp[0] = EOS;
6236: break;
6237: }
1.6 cvs 6238: }
1.18 cvs 6239:
1.9 cvs 6240: /*----------------------------------------------------------------------
1.924 vatton 6241: RestoreOneAmayaDoc restores a saved file doc is the suggested doc to
6242: be loaded or 0.
1.230 cvs 6243: docname is the original name of the document.
6244: tempdoc is the name of the saved file.
1.233 cvs 6245: Return the new recovered document
1.924 vatton 6246: URIs are encoded with the default charset.
1.230 cvs 6247: ----------------------------------------------------------------------*/
1.588 cvs 6248: static int RestoreOneAmayaDoc (Document doc, char *tempdoc, char *docname,
1.890 cvs 6249: DocumentType docType, ThotBool iscrash)
1.333 cvs 6250: {
1.873 cvs 6251: AHTHeaders http_headers;
6252: char content_type[MAX_LENGTH];
6253: char tempfile[MAX_LENGTH];
6254: int newdoc, len;
6255: ThotBool stopped_flag;
1.333 cvs 6256:
6257: W3Loading = doc;
6258: BackupDocument = doc;
6259: TtaExtractName (tempdoc, DirectoryName, DocumentName);
1.873 cvs 6260: AddURLInCombobox (docname, NULL, TRUE);
1.926 gully 6261: newdoc = InitDocAndView (doc,
1.927 vatton 6262: FALSE /* replaceOldDoc */,
6263: TRUE /* inNewWindow */,
6264: DocumentName, (DocumentType)docType, 0, FALSE,
6265: L_Other, (ClickEvent)CE_ABSOLUTE);
1.720 cvs 6266: if (newdoc != 0)
1.333 cvs 6267: {
6268: /* load the saved file */
6269: W3Loading = newdoc;
6270: if (IsW3Path (docname))
6271: {
6272: /* it's a remote file */
1.603 kahan 6273:
6274: /* clear the headers */
6275: memset ((void *) &http_headers, 0, sizeof (AHTHeaders));
1.333 cvs 6276: if (docType == docHTML)
1.419 cvs 6277: {
1.547 cvs 6278: strcpy (content_type, "text/html");
1.419 cvs 6279: http_headers.content_type = content_type;
6280: }
1.333 cvs 6281: else
1.419 cvs 6282: http_headers.content_type = NULL;
1.542 cvs 6283: LoadDocument (newdoc, docname, NULL, NULL, CE_ABSOLUTE,
1.736 kahan 6284: tempdoc, DocumentName, &http_headers, FALSE, &InNewWindow);
1.333 cvs 6285: }
6286: else
6287: {
6288: /* it's a local file */
6289: tempfile[0] = EOS;
6290: /* load the temporary file */
1.542 cvs 6291: LoadDocument (newdoc, tempdoc, NULL, NULL, CE_ABSOLUTE,
1.736 kahan 6292: tempfile, DocumentName, NULL, FALSE, &InNewWindow);
1.333 cvs 6293: /* change its URL */
6294: TtaFreeMemory (DocumentURLs[newdoc]);
1.547 cvs 6295: len = strlen (docname) + 1;
1.816 vatton 6296: DocumentURLs[newdoc] = TtaStrdup (docname);
1.334 cvs 6297: DocumentSource[newdoc] = 0;
1.799 vatton 6298: /* add the URI in the combobox string */
1.839 kahan 6299: AddURLInCombobox (docname, NULL, FALSE);
1.799 vatton 6300: TtaSetTextZone (newdoc, 1, URL_list);
1.333 cvs 6301: /* change its directory name */
6302: TtaSetDocumentDirectory (newdoc, DirectoryName);
6303: }
1.359 cvs 6304: TtaSetDocumentModified (newdoc);
1.333 cvs 6305: W3Loading = 0; /* loading is complete now */
6306: DocNetworkStatus[newdoc] = AMAYA_NET_ACTIVE;
1.627 cvs 6307: stopped_flag = FetchAndDisplayImages (newdoc, AMAYA_LOAD_IMAGE, NULL);
1.333 cvs 6308: if (!stopped_flag)
6309: {
6310: DocNetworkStatus[newdoc] = AMAYA_NET_INACTIVE;
6311: /* almost one file is restored */
1.445 cvs 6312: TtaSetStatus (newdoc, 1, TtaGetMessage (AMAYA, AM_DOCUMENT_LOADED),
6313: NULL);
1.333 cvs 6314: }
1.617 cvs 6315: /* check parsing errors */
6316: CheckParsingErrors (newdoc);
1.333 cvs 6317: /* unlink this saved file */
1.890 cvs 6318: if (iscrash)
6319: TtaFileUnlink (tempdoc);
1.720 cvs 6320: /* Update the doctype menu */
6321: UpdateDoctypeMenu (newdoc);
1.333 cvs 6322: }
6323: BackupDocument = 0;
6324: return (newdoc);
6325: }
6326:
6327:
1.230 cvs 6328: /*----------------------------------------------------------------------
1.890 cvs 6329: RestoreAmayaDocs
6330: Checks if Amaya has previously crashed.
6331: The file Crash.amaya gives the list of saved files.
6332: The file AutoSave.dat gives the list of auto-saved files
1.220 cvs 6333: ----------------------------------------------------------------------*/
1.678 vatton 6334: static ThotBool RestoreAmayaDocs ()
1.220 cvs 6335: {
1.890 cvs 6336: FILE *f;
6337: char tempname[MAX_LENGTH], tempdoc[MAX_LENGTH];
6338: char docname[MAX_LENGTH];
6339: char line[MAX_LENGTH * 2];
6340: int docType, i, j;
1.904 vatton 6341: ThotBool aDoc, iscrash, restore;
1.890 cvs 6342:
6343: /* no document is opened */
6344: aDoc = FALSE;
6345: iscrash = FALSE;
1.220 cvs 6346:
6347: /* check if Amaya has crashed */
1.547 cvs 6348: sprintf (tempname, "%s%cCrash.amaya", TempFileDirectory, DIR_SEP);
1.890 cvs 6349: if (TtaFileExist (tempname))
6350: iscrash = TRUE;
1.899 vatton 6351: else if (!AmayaUniqueInstance)
6352: return FALSE;
1.890 cvs 6353: else
6354: sprintf (tempname, "%s%cAutoSave.dat", TempFileDirectory, DIR_SEP);
6355:
1.276 cvs 6356: if (TtaFileExist (tempname))
6357: {
6358: InitConfirm (0, 0, TtaGetMessage (AMAYA, AM_RELOAD_FILES));
1.904 vatton 6359: restore = UserAnswer;
1.547 cvs 6360: f = fopen (tempname, "r");
1.454 cvs 6361: if (f != NULL)
6362: {
6363: InNewWindow = TRUE;
1.533 cvs 6364: i = 0;
6365: line[i] = EOS;
6366: fread (&line[i], 1, 1, f);
6367: while (line[0] == '"')
1.454 cvs 6368: {
1.533 cvs 6369: /* get the temp name */
6370: do
6371: {
6372: i++;
6373: fread (&line[i], 1, 1, f);
6374: }
6375: while (line[i] != '"');
6376: line[i] = EOS;
1.608 cvs 6377: strcpy (tempdoc, &line[1]);
1.533 cvs 6378: /* skip spaces and the next first " */
6379: do
1.454 cvs 6380: {
1.533 cvs 6381: i++;
6382: fread (&line[i], 1, 1, f);
1.454 cvs 6383: }
1.533 cvs 6384: while (line[i] != '"');
6385: /* get the origin name */
6386: j = i + 1;
6387: do
6388: {
6389: i++;
6390: fread (&line[i], 1, 1, f);
6391: }
6392: while (line[i] != '"');
6393: line[i] = EOS;
1.608 cvs 6394: strcpy (docname, &line[j]);
1.533 cvs 6395: /* skip spaces */
6396: do
6397: {
6398: i++;
6399: fread (&line[i], 1, 1, f);
6400: }
6401: while (line[i] == ' ');
6402: /* get the docType */
6403: j = i;
6404: do
6405: {
6406: i++;
6407: fread (&line[i], 1, 1, f);
6408: }
6409: while (line[i] != '\n');
6410: line[i] = EOS;
6411: sscanf (&line[j], "%d", &docType);
1.547 cvs 6412: if (tempdoc[0] != EOS && TtaFileExist (tempdoc))
1.533 cvs 6413: {
1.904 vatton 6414: if (restore)
1.533 cvs 6415: {
1.924 vatton 6416: if (RestoreOneAmayaDoc (0, tempdoc, docname,
6417: (DocumentType) docType, iscrash))
1.533 cvs 6418: aDoc = TRUE;
6419: }
6420: else
6421: /* unlink this saved file */
6422: TtaFileUnlink (tempdoc);
6423: }
1.890 cvs 6424: /* next saved file */
1.533 cvs 6425: i = 0;
6426: line[i] = EOS;
6427: fread (&line[i], 1, 1, f);
1.454 cvs 6428: }
6429: InNewWindow = FALSE;
6430: fclose (f);
6431: }
1.901 vatton 6432:
1.890 cvs 6433: if (iscrash)
6434: {
6435: TtaFileUnlink (tempname);
6436: sprintf (tempname, "%s%cAutoSave.dat", TempFileDirectory, DIR_SEP);
6437: if (TtaFileExist (tempname))
6438: {
6439: f = fopen (tempname, "r");
6440: if (f != NULL)
6441: {
6442: i = 0;
6443: line[i] = EOS;
6444: fread (&line[i], 1, 1, f);
6445: while (line[0] == '"')
6446: {
6447: /* get the temp name */
6448: do
6449: {
6450: i++;
6451: fread (&line[i], 1, 1, f);
6452: }
6453: while (line[i] != '"');
6454: line[i] = EOS;
6455: strcpy (tempdoc, &line[1]);
6456: /* skip spaces and the next first " */
6457: do
6458: {
6459: i++;
6460: fread (&line[i], 1, 1, f);
6461: }
6462: while (line[i] != '"');
6463: /* get the origin name */
6464: j = i + 1;
6465: do
6466: {
6467: i++;
6468: fread (&line[i], 1, 1, f);
6469: }
6470: while (line[i] != '"');
6471: line[i] = EOS;
6472: strcpy (docname, &line[j]);
6473: /* skip spaces */
6474: do
6475: {
6476: i++;
6477: fread (&line[i], 1, 1, f);
6478: }
6479: while (line[i] == ' ');
6480: /* get the docType */
6481: j = i;
6482: do
6483: {
6484: i++;
6485: fread (&line[i], 1, 1, f);
6486: }
6487: while (line[i] != '\n');
6488: line[i] = EOS;
6489: sscanf (&line[j], "%d", &docType);
6490: if (tempdoc[0] != EOS && TtaFileExist (tempdoc))
6491: /* unlink the auto-saved file */
6492: TtaFileUnlink (tempdoc);
6493: /*next auto-saved file */
6494: i = 0;
6495: line[i] = EOS;
6496: fread (&line[i], 1, 1, f);
6497: }
6498: fclose (f);
6499: }
6500: TtaFileUnlink (tempname);
6501: }
6502: }
6503: else
6504: {
6505: if (!UserAnswer)
6506: TtaFileUnlink (tempname);
6507: }
1.454 cvs 6508: }
1.220 cvs 6509: return (aDoc);
6510: }
6511:
1.333 cvs 6512:
1.220 cvs 6513: /*----------------------------------------------------------------------
1.314 cvs 6514: CheckMakeDirectory verifies if a directory name exists. If it doesn't
6515: exist, it tries to create it. If recusive == TRUE, it tries to create
6516: all the intermediary directories.
6517: Returns TRUE if the operation succeeds, FALSE otherwise.
6518: ----------------------------------------------------------------------*/
1.547 cvs 6519: ThotBool CheckMakeDirectory (char *name, ThotBool recursive)
1.314 cvs 6520: {
1.394 cvs 6521: ThotBool i;
1.547 cvs 6522: char *tmp_name;
6523: char *ptr;
6524: char tmp_char;
1.314 cvs 6525:
6526: /* protection against bad calls */
1.547 cvs 6527: if (!name || *name == EOS)
1.314 cvs 6528: return FALSE;
6529:
6530: /* does the directory exist? */
6531: if (TtaMakeDirectory (name))
6532: return TRUE;
6533:
6534: /* no, try to create it then */
6535: i = TtaMakeDirectory (name);
6536:
6537: /* were be able to create the directory (or found it already?) */
6538: if (!i)
6539: {
6540: /* don't do anything else */
6541: if (!recursive)
6542: return FALSE;
6543:
6544: /* try to create all the missing directories up to name */
1.575 cvs 6545: tmp_name = TtaStrdup (name);
1.314 cvs 6546: ptr = tmp_name;
6547: /* create all the intermediary directories */
1.547 cvs 6548: while (*ptr != EOS)
1.314 cvs 6549: {
1.547 cvs 6550: if (*ptr != DIR_SEP)
1.314 cvs 6551: ptr++;
6552: else
6553: {
6554: tmp_char = *ptr;
1.547 cvs 6555: *ptr = EOS;
1.314 cvs 6556: i = TtaMakeDirectory (tmp_name);
6557: if (!i)
6558: {
6559: TtaFreeMemory (tmp_name);
6560: return FALSE;
6561: }
6562: *ptr = tmp_char;
6563: ptr++;
6564: }
6565: }
6566: /* create the last dir */
6567: i = TtaMakeDirectory (tmp_name);
6568: TtaFreeMemory (tmp_name);
6569: if (!i)
6570: return FALSE;
6571: }
6572: return TRUE;
6573: }
6574:
1.379 cvs 6575: /*----------------------------------------------------------------------
6576: FreeAmayaStructures cleans up memory ressources.
6577: ----------------------------------------------------------------------*/
1.678 vatton 6578: void FreeAmayaStructures ()
1.379 cvs 6579: {
6580: if (LastURLName)
6581: {
6582: /* now exit the application */
6583: TtaFreeMemory (LastURLName);
6584: LastURLName = NULL;
6585: TtaFreeMemory (DocumentName);
6586: TtaFreeMemory (DirectoryName);
6587: TtaFreeMemory (SavePath);
6588: TtaFreeMemory (SaveName);
6589: TtaFreeMemory (ObjectName);
6590: TtaFreeMemory (SaveImgsURL);
6591: TtaFreeMemory (SavingFile);
1.601 cvs 6592: TtaFreeMemory (SavedDocumentURL);
1.379 cvs 6593: TtaFreeMemory (AttrHREFvalue);
6594: TtaFreeMemory (UserCSS);
1.795 vatton 6595: TtaFreeMemory (URL_list);
1.890 cvs 6596: TtaFreeMemory (AutoSave_list);
1.379 cvs 6597: FreeHTMLParser ();
1.447 cvs 6598: FreeXmlParserContexts ();
1.379 cvs 6599: FreeDocHistory ();
6600: FreeTransform ();
6601: QueryClose ();
6602: #ifdef ANNOTATIONS
1.567 kahan 6603: XPointer_bufferFree ();
1.379 cvs 6604: ANNOT_Quit ();
6605: #endif /* ANNOTATIONS */
1.856 kahan 6606: #ifdef BOOKMARKS
6607: BM_Quit ();
6608: #endif /* BOOKMARKS */
1.807 kahan 6609: FreeAmayaCache ();
1.379 cvs 6610: }
6611: }
6612:
1.314 cvs 6613:
6614: /*----------------------------------------------------------------------
1.882 vatton 6615: InitAmaya intializes Amaya variables and open the first document window.
1.9 cvs 6616: ----------------------------------------------------------------------*/
1.678 vatton 6617: void InitAmaya (NotifyEvent * event)
1.6 cvs 6618: {
1.547 cvs 6619: char *s;
1.795 vatton 6620: char *ptr;
1.10 cvs 6621: int i;
1.795 vatton 6622: ThotBool restoredDoc;
6623: ThotBool numbering, map, add, bt;
1.10 cvs 6624:
6625: if (AmayaInitialized)
6626: return;
6627: AmayaInitialized = 1;
1.233 cvs 6628: W3Loading = 0;
6629: BackupDocument = 0;
1.10 cvs 6630: /* initialize status */
6631: SelectionDoc = 0;
1.893 vatton 6632: ParsedDoc = 0;
1.10 cvs 6633: SelectionInPRE = FALSE;
6634: SelectionInComment = FALSE;
6635: SelectionInEM = FALSE;
6636: SelectionInSTRONG = FALSE;
6637: SelectionInCITE = FALSE;
1.211 cvs 6638: SelectionInABBR = FALSE;
6639: SelectionInACRONYM = FALSE;
1.212 cvs 6640: SelectionInINS = FALSE;
6641: SelectionInDEL = FALSE;
1.10 cvs 6642: SelectionInDFN = FALSE;
6643: SelectionInCODE = FALSE;
6644: SelectionInVAR = FALSE;
6645: SelectionInSAMP = FALSE;
6646: SelectionInKBD = FALSE;
6647: SelectionInI = FALSE;
6648: SelectionInB = FALSE;
6649: SelectionInTT = FALSE;
6650: SelectionInBIG = FALSE;
6651: SelectionInSMALL = FALSE;
1.882 vatton 6652: Synchronizing = FALSE;
1.857 vatton 6653: IdElemName[0] = EOS;
1.617 cvs 6654: /* Initialize the LogFile variables */
6655: CleanUpParsingErrors ();
1.789 cvs 6656: /* we're not linking an external CSS */
6657: LinkAsCSS = FALSE;
6658: LinkAsXmlCSS = FALSE;
1.326 cvs 6659:
1.10 cvs 6660: /* initialize icons */
1.911 gully 6661: #if defined(_NOGUI) && !defined(_WX) // TODO "&& !defined(_WX)" a virer a la fin de la migration wxWindows
1.891 gully 6662: stopR = (ThotIcon) 0;
6663: stopN = (ThotIcon) 0;
6664: iconSave = (ThotIcon) 0;
6665: iconSaveNo = (ThotIcon) 0;
6666: iconFind = (ThotIcon) 0;
6667: iconReload = (ThotIcon) 0;
6668: iconHome = (ThotIcon) 0;
6669: iconI = (ThotIcon) 0;
6670: iconINo = (ThotIcon) 0;
6671: iconB = (ThotIcon) 0;
6672: iconBNo = (ThotIcon) 0;
6673: iconT = (ThotIcon) 0;
6674: iconTNo = (ThotIcon) 0;
6675: iconBack = (ThotIcon) 0;
6676: iconBackNo = (ThotIcon) 0;
6677: iconForward = (ThotIcon) 0;
6678: iconForwardNo = (ThotIcon) 0;
6679: iconBrowser = (ThotIcon) 0;
6680: iconEditor = (ThotIcon) 0;
6681: iconH1 = (ThotIcon) 0;
6682: iconH1No = (ThotIcon) 0;
6683: iconH2 = (ThotIcon) 0;
6684: iconH2No = (ThotIcon) 0;
6685: iconH3 = (ThotIcon) 0;
6686: iconH3No = (ThotIcon) 0;
6687: iconPrint = (ThotIcon) 0;
6688: iconBullet = (ThotIcon) 0;
6689: iconBulletNo = (ThotIcon) 0;
6690: iconNum = (ThotIcon) 0;
6691: iconNumNo = (ThotIcon) 0;
6692: iconImage = (ThotIcon) 0;
6693: iconImageNo = (ThotIcon) 0;
6694: iconDL = (ThotIcon) 0;
6695: iconDLNo = (ThotIcon) 0;
6696: iconLink = (ThotIcon) 0;
6697: iconLinkNo = (ThotIcon) 0;
6698: iconTable = (ThotIcon) 0;
6699: iconTableNo = (ThotIcon) 0;
6700: #endif /* #ifdef _NOGUI */
6701:
1.911 gully 6702: #if defined(_GTK) || defined(_WX)
1.670 cheyroul 6703: stopR = (ThotIcon) TtaCreatePixmapLogo (stopR_xpm);
6704: stopN = (ThotIcon) TtaCreatePixmapLogo (stopN_xpm);
6705: iconSave = (ThotIcon) TtaCreatePixmapLogo (save_xpm);
6706: iconSaveNo = (ThotIcon) TtaCreatePixmapLogo (saveNo_xpm);
6707: iconFind = (ThotIcon) TtaCreatePixmapLogo (find_xpm);
6708: iconReload = (ThotIcon) TtaCreatePixmapLogo (Reload_xpm);
6709: iconHome = (ThotIcon) TtaCreatePixmapLogo (home_xpm);
6710: iconI = (ThotIcon) TtaCreatePixmapLogo (I_xpm);
6711: iconINo = (ThotIcon) TtaCreatePixmapLogo (INo_xpm);
6712: iconB = (ThotIcon) TtaCreatePixmapLogo (B_xpm);
6713: iconBNo = (ThotIcon) TtaCreatePixmapLogo (BNo_xpm);
6714: iconT = (ThotIcon) TtaCreatePixmapLogo (T_xpm);
6715: iconTNo = (ThotIcon) TtaCreatePixmapLogo (TNo_xpm);
6716: iconBack = (ThotIcon) TtaCreatePixmapLogo (Back_xpm);
6717: iconBackNo = (ThotIcon) TtaCreatePixmapLogo (BackNo_xpm);
6718: iconForward = (ThotIcon) TtaCreatePixmapLogo (Forward_xpm);
6719: iconForwardNo = (ThotIcon) TtaCreatePixmapLogo (ForwardNo_xpm);
6720: iconBrowser = (ThotIcon) TtaCreatePixmapLogo (Browser_xpm);
6721: iconEditor = (ThotIcon) TtaCreatePixmapLogo (Editor_xpm);
6722: iconH1 = (ThotIcon) TtaCreatePixmapLogo (H1_xpm);
6723: iconH1No = (ThotIcon) TtaCreatePixmapLogo (H1No_xpm);
6724: iconH2 = (ThotIcon) TtaCreatePixmapLogo (H2_xpm);
6725: iconH2No = (ThotIcon) TtaCreatePixmapLogo (H2No_xpm);
6726: iconH3 = (ThotIcon) TtaCreatePixmapLogo (H3_xpm);
6727: iconH3No = (ThotIcon) TtaCreatePixmapLogo (H3No_xpm);
6728: iconPrint = (ThotIcon) TtaCreatePixmapLogo (Print_xpm);
6729: iconBullet = (ThotIcon) TtaCreatePixmapLogo (Bullet_xpm);
6730: iconBulletNo = (ThotIcon) TtaCreatePixmapLogo (BulletNo_xpm);
6731: iconNum = (ThotIcon) TtaCreatePixmapLogo (Num_xpm);
6732: iconNumNo = (ThotIcon) TtaCreatePixmapLogo (NumNo_xpm);
6733: iconImage = (ThotIcon) TtaCreatePixmapLogo (Image_xpm);
6734: iconImageNo = (ThotIcon) TtaCreatePixmapLogo (ImageNo_xpm);
6735: iconDL = (ThotIcon) TtaCreatePixmapLogo (DL_xpm);
6736: iconDLNo = (ThotIcon) TtaCreatePixmapLogo (DLNo_xpm);
6737: iconLink = (ThotIcon) TtaCreatePixmapLogo (Link_xpm);
6738: iconLinkNo = (ThotIcon) TtaCreatePixmapLogo (LinkNo_xpm);
6739: iconTable = (ThotIcon) TtaCreatePixmapLogo (Table_xpm);
6740: iconTableNo = (ThotIcon) TtaCreatePixmapLogo (TableNo_xpm);
1.911 gully 6741: #endif /* _GTK || defined(_WX) */
1.891 gully 6742:
6743: #ifdef _MOTIF
1.765 cvs 6744: stopR = TtaCreatePixmapLogo (stopR_xpm);
1.670 cheyroul 6745: stopN = TtaCreatePixmapLogo (stopN_xpm);
6746: iconSave = TtaCreatePixmapLogo (save_xpm);
6747: iconSaveNo = TtaCreatePixmapLogo (saveNo_xpm);
6748: iconFind = TtaCreatePixmapLogo (find_xpm);
6749: iconReload = TtaCreatePixmapLogo (Reload_xpm);
6750: iconHome = TtaCreatePixmapLogo (home_xpm);
6751: iconI = TtaCreatePixmapLogo (I_xpm);
6752: iconINo = TtaCreatePixmapLogo (INo_xpm);
6753: iconB = TtaCreatePixmapLogo (B_xpm);
6754: iconBNo = TtaCreatePixmapLogo (BNo_xpm);
6755: iconT = TtaCreatePixmapLogo (T_xpm);
6756: iconTNo = TtaCreatePixmapLogo (TNo_xpm);
6757: iconBack = TtaCreatePixmapLogo (Back_xpm);
6758: iconBackNo = TtaCreatePixmapLogo (BackNo_xpm);
6759: iconForward = TtaCreatePixmapLogo (Forward_xpm);
6760: iconForwardNo = TtaCreatePixmapLogo (ForwardNo_xpm);
6761: iconBrowser = TtaCreatePixmapLogo (Browser_xpm);
6762: iconEditor = TtaCreatePixmapLogo (Editor_xpm);
6763: iconH1 = TtaCreatePixmapLogo (H1_xpm);
6764: iconH1No = TtaCreatePixmapLogo (H1No_xpm);
6765: iconH2 = TtaCreatePixmapLogo (H2_xpm);
6766: iconH2No = TtaCreatePixmapLogo (H2No_xpm);
6767: iconH3 = TtaCreatePixmapLogo (H3_xpm);
6768: iconH3No = TtaCreatePixmapLogo (H3No_xpm);
6769: iconPrint = TtaCreatePixmapLogo (Print_xpm);
6770: iconBullet = TtaCreatePixmapLogo (Bullet_xpm);
6771: iconBulletNo = TtaCreatePixmapLogo (BulletNo_xpm);
6772: iconNum = TtaCreatePixmapLogo (Num_xpm);
6773: iconNumNo = TtaCreatePixmapLogo (NumNo_xpm);
6774: iconImage = TtaCreatePixmapLogo (Image_xpm);
6775: iconImageNo = TtaCreatePixmapLogo (ImageNo_xpm);
6776: iconDL = TtaCreatePixmapLogo (DL_xpm);
6777: iconDLNo = TtaCreatePixmapLogo (DLNo_xpm);
6778: iconLink = TtaCreatePixmapLogo (Link_xpm);
6779: iconLinkNo = TtaCreatePixmapLogo (LinkNo_xpm);
6780: iconTable = TtaCreatePixmapLogo (Table_xpm);
6781: iconTableNo = TtaCreatePixmapLogo (TableNo_xpm);
1.891 gully 6782: #endif /* !_MOTIF */
1.851 cheyroul 6783:
1.294 cvs 6784: /* init transformation callback */
1.270 cvs 6785: TtaSetTransformCallback ((Func) TransformIntoType);
1.18 cvs 6786: TargetName = NULL;
1.541 cvs 6787: TtaSetAccessKeyFunction ((Proc) AccessKeyHandler);
1.565 cvs 6788: TtaSetEntityFunction ((Proc) MapEntityByCode);
1.601 cvs 6789: TtaSetCopyAndCutFunction ((Proc) RegisterURLSavedElements);
1.920 vatton 6790: TtaSetCopyCellFunction ((Proc3) CopyCell);
1.921 quint 6791: TtaSetCopyRowFunction ((Proc3) CopyRow);
1.540 cvs 6792: /* Initialize the Amaya user and tmp directories */
1.339 cvs 6793: s = TtaGetEnvString ("APP_TMPDIR");
1.314 cvs 6794: if (!CheckMakeDirectory (s, TRUE))
1.318 cvs 6795: /* try to use the default value */
6796: {
1.386 cvs 6797: s = TtaGetDefEnvString ("APP_TMPDIR");
1.318 cvs 6798: if (CheckMakeDirectory (s, TRUE))
6799: /* make it the current user one */
1.386 cvs 6800: TtaSetEnvString ("APP_TMPDIR", s, TRUE);
1.318 cvs 6801: else
6802: /* didn't work, so we exit */
6803: {
1.547 cvs 6804: sprintf (TempFileDirectory,
1.701 vatton 6805: TtaGetMessage (AMAYA, AM_CANNOT_CREATE_DIRECTORY), s);
1.916 cvs 6806: #ifdef _WINGUI
1.547 cvs 6807: MessageBox (NULL, TempFileDirectory, "Error", MB_OK);
1.916 cvs 6808: #endif /* _WINGUI */
1.911 gully 6809: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.318 cvs 6810: fprintf (stderr, TempFileDirectory);
1.911 gully 6811: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.318 cvs 6812: exit (1);
6813: }
6814: }
6815:
1.10 cvs 6816: /* add the temporary directory in document path */
1.547 cvs 6817: strcpy (TempFileDirectory, s);
1.10 cvs 6818: TtaAppendDocumentPath (TempFileDirectory);
1.916 cvs 6819: #ifdef _WINGUI
1.339 cvs 6820: s = TtaGetEnvString ("APP_HOME");
1.314 cvs 6821: if (!CheckMakeDirectory (s, TRUE))
1.318 cvs 6822: /* didn't work, so we exit */
6823: {
1.547 cvs 6824: sprintf (TempFileDirectory,
1.701 vatton 6825: TtaGetMessage (AMAYA, AM_CANNOT_CREATE_DIRECTORY), s);
1.547 cvs 6826: MessageBox (NULL, TempFileDirectory, "Error", MB_OK);
1.318 cvs 6827: exit (1);
6828: }
1.916 cvs 6829: #endif /* _WINGUI */
1.294 cvs 6830: /*
6831: * Build the User preferences file name:
6832: * $HOME/.amaya/amaya.css on Unix platforms
6833: * $HOME\amaya\amaya.css on Windows platforms
6834: */
1.907 gully 6835: ptr = (char *)TtaGetMemory (MAX_LENGTH);
1.795 vatton 6836: sprintf (ptr, "%s%c%s.css", s, DIR_SEP, HTAppName);
6837: UserCSS = TtaStrdup (ptr);
1.220 cvs 6838:
1.645 vatton 6839: /* Initialize environment variables if they are not defined */
6840: TtaSetEnvBoolean ("SECTION_NUMBERING", FALSE, FALSE);
1.772 vatton 6841: TtaSetEnvBoolean ("SHOW_BUTTONS", TRUE, FALSE);
6842: TtaSetEnvBoolean ("SHOW_ADDRESS", TRUE, FALSE);
1.645 vatton 6843: TtaSetEnvBoolean ("SHOW_MAP_AREAS", FALSE, FALSE);
6844: TtaSetEnvBoolean ("SHOW_TARGET", FALSE, FALSE);
1.774 vatton 6845: TtaSetEnvBoolean ("LOAD_IMAGES", TRUE, FALSE);
1.887 gully 6846: TtaSetEnvBoolean ("LOAD_OBJECTS", TRUE, FALSE);
1.862 vatton 6847: TtaSetEnvBoolean ("LOAD_CSS", TRUE, FALSE);
1.876 vatton 6848: TtaSetEnvBoolean ("SEND_REFERER", FALSE, FALSE);
1.645 vatton 6849: /* get current value */
6850: TtaGetEnvBoolean ("SECTION_NUMBERING", &numbering);
1.772 vatton 6851: TtaGetEnvBoolean ("SHOW_BUTTONS", &bt);
6852: TtaGetEnvBoolean ("SHOW_ADDRESS", &add);
1.645 vatton 6853: TtaGetEnvBoolean ("SHOW_MAP_AREAS", &map);
1.143 cvs 6854: /* Create and intialize resources needed for each document */
1.210 cvs 6855: /* Style sheets are strored in directory .amaya/0 */
6856: for (i = 0; i < DocumentTableLength; i++)
1.100 cvs 6857: {
6858: /* initialize document table */
6859: DocumentURLs[i] = NULL;
1.203 cvs 6860: DocumentTypes[i] = docHTML;
1.334 cvs 6861: DocumentSource[i] = 0;
1.222 cvs 6862: DocumentMeta[i] = NULL;
1.479 cvs 6863: ReadOnlyDocument[i] = FALSE;
1.644 vatton 6864: SNumbering[i] = numbering;
1.645 vatton 6865: MapAreas[i] = map;
1.772 vatton 6866: SButtons[i] = bt;
6867: SAddress[i] = add;
1.143 cvs 6868: /* initialize history */
1.152 cvs 6869: InitDocHistory (i);
1.100 cvs 6870: }
1.294 cvs 6871:
6872: /* allocate working buffers */
1.907 gully 6873: LastURLName = (char *)TtaGetMemory (MAX_LENGTH);
1.547 cvs 6874: LastURLName[0] = EOS;
1.907 gully 6875: DirectoryName = (char *)TtaGetMemory (MAX_LENGTH);
1.601 cvs 6876: SavedDocumentURL = NULL;
1.100 cvs 6877:
1.10 cvs 6878: /* set path on current directory */
1.607 cvs 6879: getcwd (DirectoryName, MAX_LENGTH);
1.907 gully 6880: DocumentName = (char *)TtaGetMemory (MAX_LENGTH);
1.323 cvs 6881: memset (DocumentName, EOS, MAX_LENGTH);
1.907 gully 6882: SavePath = (char *)TtaGetMemory (MAX_LENGTH);
1.547 cvs 6883: SavePath[0] = EOS;
1.907 gully 6884: SaveName = (char *)TtaGetMemory (MAX_LENGTH);
1.165 cvs 6885: SaveName[0] = EOS;
1.907 gully 6886: ObjectName = (char *)TtaGetMemory (MAX_LENGTH);
1.10 cvs 6887: ObjectName[0] = EOS;
1.907 gully 6888: SaveImgsURL = (char *)TtaGetMemory (MAX_LENGTH);
1.10 cvs 6889: SaveImgsURL[0] = EOS;
1.669 vatton 6890: strcpy (ScanFilter, "*.*htm*");
1.59 cvs 6891: SaveAsHTML = TRUE;
1.498 cvs 6892: SaveAsXML = FALSE;
1.59 cvs 6893: SaveAsText = FALSE;
1.204 cvs 6894: CopyImages = FALSE;
1.95 cvs 6895: UpdateURLs = FALSE;
1.907 gully 6896: SavingFile = (char *)TtaGetMemory (MAX_LENGTH);
6897: AttrHREFvalue = (char *)TtaGetMemory (MAX_LENGTH);
1.10 cvs 6898: AttrHREFvalue[0] = EOS;
1.6 cvs 6899:
6900: #ifdef WITH_SOCKS
1.10 cvs 6901: SOCKSinit ("amaya");
1.6 cvs 6902: #endif
6903:
1.10 cvs 6904: /* initialize parser mapping table and HTLib */
6905: InitMapping ();
6906:
1.186 cvs 6907: /* Define the backup function */
6908: TtaSetBackup (BackUpDocs);
1.890 cvs 6909:
6910: /* Define the auto-save function */
1.907 gully 6911: TtaSetAutoSave ((Proc)GenerateAutoSavedDoc);
1.890 cvs 6912: /* Define the auto-save interval */
6913: TtaGetEnvInt ("AUTO_SAVE", &AutoSave_Interval);
1.897 vatton 6914: TtaSetDocumentBackUpInterval (AutoSave_Interval);
1.890 cvs 6915:
1.379 cvs 6916: TtaSetApplicationQuit (FreeAmayaStructures);
1.310 cvs 6917: TtaSetDocStatusUpdate ((Proc) DocStatusUpdate);
1.547 cvs 6918: AMAYA = TtaGetMessageTable ("amayamsg", AMAYA_MSG_MAX);
1.10 cvs 6919: /* allocate callbacks for amaya */
1.907 gully 6920: BaseDialog = TtaSetCallback ((Proc)CallbackDialogue, MAX_REF);
1.10 cvs 6921: /* init the Picture context */
6922: InitImage ();
1.66 cvs 6923: /* init the Picture context */
6924: InitPrint ();
1.10 cvs 6925: /* init the CSS context */
6926: InitCSS ();
1.30 cvs 6927: /* initialize the structure transformation context */
1.10 cvs 6928: InitTransform ();
1.30 cvs 6929: /* initialize automaton for the HTML parser */
6930: InitAutomaton ();
1.271 cvs 6931: /* initialize the configuration menu context */
6932: InitConfMenu ();
1.336 cvs 6933: #ifdef ANNOTATIONS
6934: ANNOT_Init ();
6935: #endif /* ANNOTATIONS */
1.868 kahan 6936: /* initialize the libwww */
6937: QueryInit ();
6938: /* initialize the Amaya cache */
6939: InitAmayaCache ();
1.899 vatton 6940: /* now we know if it's a unique instance */
1.856 kahan 6941: #ifdef BOOKMARKS
6942: BM_Init ();
6943: #endif /* BOOKMARKS */
6944:
1.916 cvs 6945: #ifdef _WINGUI
1.795 vatton 6946: sprintf (LostPicturePath, "%s\\amaya\\lost.gif",
6947: TtaGetEnvString ("THOTDIR"));
1.916 cvs 6948: #endif /* _WINGUI */
1.891 gully 6949:
1.831 cheyroul 6950: #ifdef _GTK
6951: sprintf (LostPicturePath, "%s/amaya/lost.gif",
6952: TtaGetEnvString ("THOTDIR"));
6953: #endif /* _GTK */
1.799 vatton 6954:
6955: InitMathML ();
6956: #ifdef _SVG
6957: InitSVG ();
6958: InitSVGAnim ();
1.824 vatton 6959: InitSVGLibraryManagerStructure ();
6960: InitLibrary();
6961: #endif /* _SVG */
1.749 kirschpi 6962: /* MKP: disable "Cooperation" menu if DAV is not defined or
6963: * initialize davlib module otherwise */
6964: #ifdef DAV
1.799 vatton 6965: InitDAV ();
1.857 vatton 6966: #else /* DAV */
6967: DAVLibEnable = FALSE;
1.749 kirschpi 6968: #endif /* DAV */
1.798 vatton 6969: URL_list = NULL;
1.824 vatton 6970: URL_list_len = 0;
1.890 cvs 6971: InitStringForCombobox ();
6972:
6973: AutoSave_list = NULL;
6974: AutoSave_list_len = 0;
6975: InitAutoSave ();
6976:
1.10 cvs 6977: CurrentDocument = 0;
1.171 cvs 6978: DocBook = 0;
1.10 cvs 6979: InNewWindow = FALSE;
1.220 cvs 6980: restoredDoc = RestoreAmayaDocs ();
1.497 cvs 6981: s = NULL;
1.630 vatton 6982: if (restoredDoc)
1.818 vatton 6983: {
6984: /* old documents are restored */
6985: TtaFreeMemory (ptr);
6986: return;
6987: }
1.10 cvs 6988: if (appArgc % 2 == 0)
1.667 vatton 6989: /* The last argument in the command line is the document to be opened */
6990: s = appArgv[appArgc - 1];
1.798 vatton 6991: if (s == NULL || s[0] == EOS)
6992: /* no argument: display the Home Page */
6993: s = TtaGetEnvString ("HOME_PAGE");
1.815 vatton 6994: if (URL_list && s && !strcasecmp (s, "$PREV"))
1.795 vatton 6995: {
1.798 vatton 6996: /* no argument and no Home: display the previous open URI */
1.795 vatton 6997: for (i = 0; URL_list[i] != EOS && URL_list[i] != EOL; i++)
6998: ptr[i] = URL_list[i];
6999: ptr[i] = EOS;
7000: s = ptr;
7001: }
1.798 vatton 7002:
7003: if (s == NULL || s[0] == EOS)
7004: /* no argument, no Home, and no previous page: display default Amaya URL */
7005: GoToHome (0, 1);
7006: else if (IsW3Path (s))
1.496 cvs 7007: {
7008: /* it's a remote document */
1.547 cvs 7009: strcpy (LastURLName, s);
7010: CallbackDialogue (BaseDialog + OpenForm, INTEGER_DATA, (char *) 1);
1.496 cvs 7011: }
1.51 cvs 7012: else
1.10 cvs 7013: {
1.429 cvs 7014: NormalizeFile (s, LastURLName, AM_CONV_NONE);
1.672 cheyroul 7015: if (IsW3Path (LastURLName))
1.795 vatton 7016: {
1.672 cheyroul 7017: /* if the command line paremeter
7018: is a url without http://
7019: it's a remote document or
7020: a new file (doesn't exist yet )
7021: in the current path */
7022: strcpy (s, LastURLName);
7023: CallbackDialogue (BaseDialog + OpenForm, INTEGER_DATA, (char *) 1);
1.795 vatton 7024: }
1.672 cheyroul 7025: else
1.795 vatton 7026: {
1.672 cheyroul 7027: /* check if it is an absolute or a relative name */
1.891 gully 7028:
1.916 cvs 7029: #ifdef _WINGUI
1.795 vatton 7030: if (LastURLName[0] == DIR_SEP || LastURLName[1] == ':')
1.891 gully 7031: /* it is an absolute name */
7032: TtaExtractName (LastURLName, DirectoryName, DocumentName);
7033: else
7034: /* it is a relative name */
7035: strcpy (DocumentName, LastURLName);
1.916 cvs 7036: #endif /* !_WINGUI */
1.891 gully 7037:
1.911 gully 7038: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.672 cheyroul 7039: if (LastURLName[0] == DIR_SEP)
1.795 vatton 7040: /* it is an absolute name */
7041: TtaExtractName (LastURLName, DirectoryName, DocumentName);
1.220 cvs 7042: else
7043: /* it is a relative name */
1.795 vatton 7044: strcpy (DocumentName, LastURLName);
1.911 gully 7045: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 7046:
7047: /* start with the local document */
1.547 cvs 7048: LastURLName[0] = EOS;
7049: CallbackDialogue (BaseDialog + OpenForm, INTEGER_DATA, (char *) 1);
1.795 vatton 7050: }
1.558 cvs 7051: }
1.795 vatton 7052: TtaFreeMemory (ptr);
7053: ptr = NULL;
1.325 cvs 7054: Loading_method = CE_ABSOLUTE;
1.6 cvs 7055: }
7056:
1.40 cvs 7057: /*----------------------------------------------------------------------
1.60 cvs 7058: ChangeAttrOnRoot
7059: If the root element of the document does not have an attribute of
7060: type attrNum, create one.
7061: If the root has such an attribute, delete it.
1.48 cvs 7062: ----------------------------------------------------------------------*/
1.727 vatton 7063: void ChangeAttrOnRoot (Document doc, int attrNum)
1.48 cvs 7064: {
1.732 vatton 7065: Element root, el;
7066: AttributeType attrType;
7067: Attribute attr;
7068: int position;
7069: int distance;
7070: ThotBool docModified;
1.48 cvs 7071:
1.727 vatton 7072: docModified = TtaIsDocumentModified (doc);
7073: root = TtaGetRootElement (doc);
1.732 vatton 7074: /* get the current position in the document */
7075: position = RelativePosition (doc, &distance);
1.727 vatton 7076: TtaSetDisplayMode (doc, NoComputedDisplay);
7077: attrType.AttrSSchema = TtaGetDocumentSSchema (doc);
7078: attrType.AttrTypeNum = attrNum;
7079: attr = TtaGetAttribute (root, attrType);
7080: if (attr != NULL)
7081: /* the root element has that attribute. Remove it */
7082: TtaRemoveAttribute (root, attr, doc);
7083: else
7084: /* the root element does not have that attribute. Create it */
7085: {
7086: attr = TtaNewAttribute (attrType);
7087: TtaAttachAttribute (root, attr, doc);
7088: TtaSetAttributeValue (attr, 1, root, doc);
7089: }
7090: if (!docModified)
7091: {
7092: TtaSetDocumentUnmodified (doc);
7093: /* switch Amaya buttons and menus */
7094: DocStatusUpdate (doc, docModified);
7095: }
7096: TtaSetDisplayMode (doc, DisplayImmediately);
1.732 vatton 7097: /* show the document at the same position */
7098: el = ElementAtPosition (doc, position);
7099: TtaShowElement (doc, 1, el, distance);
1.60 cvs 7100: }
7101:
7102: /*----------------------------------------------------------------------
7103: ShowMapAreas
7104: Execute the "Show Map Areas" command
7105: ----------------------------------------------------------------------*/
1.646 cvs 7106: void ShowMapAreas (Document doc, View view)
1.60 cvs 7107: {
1.916 cvs 7108: #ifdef _WINGUI
1.646 cvs 7109: int frame = GetWindowNumber (doc, view);
1.176 cvs 7110:
1.645 vatton 7111: if (frame == 0 || frame > 10)
7112: TtaError (ERR_invalid_parameter);
7113: else
7114: {
7115: HMENU hmenu = WIN_GetMenu (frame);
1.646 cvs 7116: if (!MapAreas[doc])
1.645 vatton 7117: {
1.176 cvs 7118: CheckMenuItem (hmenu, menu_item, MF_BYCOMMAND | MF_CHECKED);
1.646 cvs 7119: MapAreas[doc] = TRUE;
1.645 vatton 7120: }
7121: else
7122: {
7123: hmenu = WIN_GetMenu (frame);
7124: CheckMenuItem (hmenu, menu_item, MF_BYCOMMAND | MF_UNCHECKED);
1.646 cvs 7125: MapAreas[doc] = FALSE;
1.645 vatton 7126: }
1.176 cvs 7127: }
1.916 cvs 7128: #endif /* _WINGUI */
1.891 gully 7129:
1.911 gully 7130: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.646 cvs 7131: MapAreas[doc] = !MapAreas[doc];
1.911 gully 7132: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 7133:
1.646 cvs 7134: ChangeAttrOnRoot (doc, HTML_ATTR_ShowAreas);
7135: }
7136:
7137: /*----------------------------------------------------------------------
1.772 vatton 7138: ShowButtons
7139: Execute the "Show Buttons" command
7140: ----------------------------------------------------------------------*/
7141: void ShowButtons (Document doc, View view)
7142: {
1.891 gully 7143:
1.916 cvs 7144: #ifdef _WINGUI
1.772 vatton 7145: int frame = GetWindowNumber (doc, view);
7146:
7147: if (frame == 0 || frame > 10)
7148: TtaError (ERR_invalid_parameter);
7149: else
7150: {
7151: HMENU hmenu = WIN_GetMenu (frame);
7152: if (!SButtons[doc])
7153: {
7154: CheckMenuItem (hmenu, menu_item, MF_BYCOMMAND | MF_CHECKED);
7155: SButtons[doc] = TRUE;
7156: }
7157: else
7158: {
7159: hmenu = WIN_GetMenu (frame);
7160: CheckMenuItem (hmenu, menu_item, MF_BYCOMMAND | MF_UNCHECKED);
7161: SButtons[doc] = FALSE;
7162: }
7163: }
1.916 cvs 7164: #endif /* _WINGUI */
1.891 gully 7165:
1.911 gully 7166: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.772 vatton 7167: SButtons[doc] = !SButtons[doc];
1.911 gully 7168: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 7169:
1.772 vatton 7170: TtaSetToggleItem (doc, 1, Views, TShowButtonbar, SButtons[doc]);
7171: TtcSwitchButtonBar (doc, view);
7172: }
7173:
7174: /*----------------------------------------------------------------------
7175: ShowAddress
7176: Execute the "Show Address" command
7177: ----------------------------------------------------------------------*/
7178: void ShowAddress (Document doc, View view)
7179: {
1.891 gully 7180:
1.916 cvs 7181: #ifdef _WINGUI
1.772 vatton 7182: int frame = GetWindowNumber (doc, view);
7183:
7184: if (frame == 0 || frame > 10)
7185: TtaError (ERR_invalid_parameter);
7186: else
7187: {
7188: HMENU hmenu = WIN_GetMenu (frame);
7189: if (!SAddress[doc])
7190: {
7191: CheckMenuItem (hmenu, menu_item, MF_BYCOMMAND | MF_CHECKED);
7192: SAddress[doc] = TRUE;
7193: }
7194: else
7195: {
7196: hmenu = WIN_GetMenu (frame);
7197: CheckMenuItem (hmenu, menu_item, MF_BYCOMMAND | MF_UNCHECKED);
7198: SAddress[doc] = FALSE;
7199: }
7200: }
1.916 cvs 7201: #endif /* _WINGUI */
1.891 gully 7202:
1.911 gully 7203: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.772 vatton 7204: SAddress[doc] = !SAddress[doc];
1.911 gully 7205: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 7206:
1.772 vatton 7207: TtaSetToggleItem (doc, 1, Views, TShowTextZone, SAddress[doc]);
7208: TtcSwitchCommands (doc, view);
7209: }
7210:
7211: /*----------------------------------------------------------------------
1.646 cvs 7212: SectionNumbering
7213: Execute the "Section Numbering" command
7214: ----------------------------------------------------------------------*/
7215: void SectionNumbering (Document doc, View view)
7216: {
1.891 gully 7217:
1.916 cvs 7218: #ifdef _WINGUI
1.646 cvs 7219: int frame = GetWindowNumber (doc, view);
7220:
7221: if (frame == 0 || frame > 10)
7222: TtaError (ERR_invalid_parameter);
7223: else
7224: {
7225: HMENU hmenu = WIN_GetMenu (frame);
7226: if (!SNumbering[doc])
7227: {
7228: CheckMenuItem (hmenu, menu_item, MF_BYCOMMAND | MF_CHECKED);
7229: SNumbering[doc] = TRUE;
7230: }
7231: else
7232: {
7233: hmenu = WIN_GetMenu (frame);
7234: CheckMenuItem (hmenu, menu_item, MF_BYCOMMAND | MF_UNCHECKED);
7235: SNumbering[doc] = FALSE;
7236: }
7237: }
1.916 cvs 7238: #endif /* _WINGUI */
1.891 gully 7239:
1.911 gully 7240: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.646 cvs 7241: SNumbering[doc] = !SNumbering[doc];
1.772 vatton 7242: TtaSetToggleItem (doc, 1, Special, TSectionNumber, SNumbering[doc]);
1.911 gully 7243: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 7244:
1.646 cvs 7245: ChangeAttrOnRoot (doc, HTML_ATTR_SectionNumbering);
1.40 cvs 7246: }
1.41 cvs 7247:
1.486 kahan 7248: /*----------------------------------------------------------------------
7249: MakeIDMenu
7250: A menu for adding or removing ID attributes in a document
7251: ----------------------------------------------------------------------*/
1.595 cvs 7252: void MakeIDMenu (Document doc, View view)
1.486 kahan 7253: {
1.911 gully 7254: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.486 kahan 7255: int i;
1.547 cvs 7256: char s[MAX_LENGTH];
1.911 gully 7257: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.486 kahan 7258:
7259: /* initialize the global variables */
1.495 kahan 7260: IdStatus[0] = EOS;
1.494 kahan 7261: IdDoc = doc;
1.486 kahan 7262:
7263: /* Create the dialogue form */
1.911 gully 7264: #if defined(_MOTIF) || defined(_GTK) || defined(_WX)
1.486 kahan 7265: i = 0;
1.857 vatton 7266: strcpy (&s[i], TtaGetMessage (AMAYA, ADD_ID));
1.547 cvs 7267: i += strlen (&s[i]) + 1;
1.857 vatton 7268: strcpy (&s[i], TtaGetMessage (AMAYA, REMOVE_ID));
1.486 kahan 7269: TtaNewSheet (BaseDialog + MakeIdMenu,
1.494 kahan 7270: TtaGetViewFrame (doc, view),
1.857 vatton 7271: TtaGetMessage (AMAYA, ADD_REMOVE_ID),
1.486 kahan 7272: 2, s, FALSE, 6, 'L', D_DONE);
7273: TtaNewTextForm (BaseDialog + mElemName,
7274: BaseDialog + MakeIdMenu,
1.857 vatton 7275: TtaGetMessage (AMAYA, ENTER_ELEMENT_NAME),
7276: 10, 1, FALSE);
7277: TtaSetTextForm (BaseDialog + mElemName, IdElemName);
1.495 kahan 7278: /* apply operation in */
1.857 vatton 7279: i = 0;
7280: sprintf (&s[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_IN_WHOLE_DOC));
1.547 cvs 7281: i += strlen (&s[i]) + 1;
1.857 vatton 7282: sprintf (&s[i], "%s%s", "B", TtaGetMessage (LIB, TMSG_WITHIN_SEL));
1.495 kahan 7283: TtaNewSubmenu (BaseDialog + mIdUseSelection,
1.857 vatton 7284: BaseDialog + MakeIdMenu, 0,
7285: TtaGetMessage (AMAYA, APPLY_OPERATION),
7286: 2, s,
7287: NULL, FALSE);
1.495 kahan 7288: /* status label */
7289: TtaNewLabel (BaseDialog + mIdStatus,
7290: BaseDialog + MakeIdMenu,
7291: " ");
7292: /* select the current radio button */
7293: TtaSetMenuForm (BaseDialog + mIdUseSelection, IdApplyToSelection);
1.486 kahan 7294: TtaSetDialoguePosition ();
7295: TtaShowDialogue (BaseDialog + MakeIdMenu, TRUE);
1.911 gully 7296: #endif /* #if defined(_MOTIF) || defined(_GTK) || defined(_WX) */
1.891 gully 7297:
1.916 cvs 7298: #ifdef _WINGUI
1.494 kahan 7299: CreateMakeIDDlgWindow (TtaGetViewFrame (doc, view));
1.916 cvs 7300: #endif /* _WINGUI */
1.486 kahan 7301: }
1.6 cvs 7302:
1.9 cvs 7303: /*----------------------------------------------------------------------
1.379 cvs 7304: CheckAmayaClosed closes the application when there is any more
7305: opened document
7306: ----------------------------------------------------------------------*/
1.678 vatton 7307: void CheckAmayaClosed ()
1.379 cvs 7308: {
7309: int i;
7310:
7311: /* is it the last loaded document ? */
7312: i = 1;
7313: while (i < DocumentTableLength && DocumentURLs[i] == NULL)
7314: i++;
7315:
7316: if (i == DocumentTableLength)
1.771 cvs 7317: {
1.836 vatton 7318: /* remove images loaded by shared CSS style sheets */
7319: RemoveDocumentImages (0);
1.884 vatton 7320: #ifdef _SVG
7321: SVGLIB_FreeDocumentResource ();
7322: #endif /* _SVG */
1.900 vatton 7323: /* remove the AutoSave file */
1.771 cvs 7324: TtaQuit ();
7325: }
1.379 cvs 7326: }
7327:
7328:
7329: /*----------------------------------------------------------------------
1.9 cvs 7330: ----------------------------------------------------------------------*/
1.678 vatton 7331: void CloseDocument (Document doc, View view)
1.365 cvs 7332: {
1.900 vatton 7333: if (DocumentURLs[doc])
7334: TtcCloseDocument (doc, view);
1.365 cvs 7335: if (!W3Loading)
1.460 cvs 7336: CheckAmayaClosed ();
1.890 cvs 7337:
1.365 cvs 7338: }
7339:
7340: /*----------------------------------------------------------------------
7341: ----------------------------------------------------------------------*/
1.678 vatton 7342: void AmayaClose (Document document, View view)
1.6 cvs 7343: {
1.890 cvs 7344: int i;
7345: ThotBool documentClosed;
1.925 cvs 7346: ThotBool saveGeometry = FALSE;
1.6 cvs 7347:
1.15 cvs 7348: /* invalid current loading */
7349: W3Loading = 0;
1.56 cvs 7350:
1.93 cvs 7351: documentClosed = TRUE;
1.925 cvs 7352:
7353: /* Save the current windows geometry */
7354: TtaGetEnvBoolean ("SAVE_GEOMETRY", &saveGeometry);
7355: if (saveGeometry)
7356: SetGeometryConf ();
1.10 cvs 7357: /* free each loaded document */
7358: for (i = 1; i < DocumentTableLength; i++)
7359: if (DocumentURLs[i] != NULL)
7360: {
1.85 cvs 7361: TtcCloseDocument (i, 1);
7362: documentClosed = (DocumentURLs[i] == NULL);
1.900 vatton 7363: if (!documentClosed)
7364: return;
1.10 cvs 7365: }
1.836 vatton 7366: /* remove images loaded by shared CSS style sheets */
7367: RemoveDocumentImages (0);
1.884 vatton 7368: #ifdef _SVG
1.826 vatton 7369: SVGLIB_FreeDocumentResource ();
1.884 vatton 7370: #endif /* _SVG */
1.379 cvs 7371: TtaQuit ();
1.783 cvs 7372: }
7373:
7374:
7375: /*----------------------------------------------------------------------
1.924 vatton 7376: AddURLInCombobox adds the new pathname in the combobox list.
1.890 cvs 7377: Store that URL into the file only if keep is TRUE.
1.924 vatton 7378: URIs are encoded with the default charset.
1.794 vatton 7379: ----------------------------------------------------------------------*/
1.924 vatton 7380: void AddURLInCombobox (char *pathname, char *form_data, ThotBool keep)
1.794 vatton 7381: {
1.825 vatton 7382: char *urlstring, *app_home, *ptr, *url;
1.794 vatton 7383: int i, j, len, nb, end;
1.814 cvs 7384: FILE *file = NULL;
1.794 vatton 7385:
1.924 vatton 7386: if (pathname == NULL || pathname[0] == EOS)
1.794 vatton 7387: return;
1.839 kahan 7388: if (form_data && form_data[0] != EOS)
7389: {
1.924 vatton 7390: url = (char *)TtaGetMemory (strlen (pathname) + strlen (form_data) + 2);
7391: sprintf (url, "%s?%s", pathname, form_data);
1.839 kahan 7392: }
7393: else
1.924 vatton 7394: url = TtaStrdup (pathname);
1.794 vatton 7395: urlstring = (char *) TtaGetMemory (MAX_LENGTH);
7396: /* open the file list_url.dat into APP_HOME directory */
7397: app_home = TtaGetEnvString ("APP_HOME");
7398: sprintf (urlstring, "%s%clist_url.dat", app_home, DIR_SEP);
7399: /* keep the previous list */
7400: ptr = URL_list;
7401: /* create a new list */
1.798 vatton 7402: len = strlen (url) + 1;
1.794 vatton 7403: i = 0;
7404: j = len;
7405: nb = 1;
1.798 vatton 7406: URL_list_len = URL_list_len + len + 1;
1.907 gully 7407: URL_list = (char *)TtaGetMemory (URL_list_len);
1.799 vatton 7408: if (keep)
7409: file = TtaWriteOpen (urlstring);
7410: *urlstring = EOS;
7411: if (!keep || file)
1.794 vatton 7412: {
7413: /* put the new url */
7414: strcpy (URL_list, url);
1.799 vatton 7415: if (keep)
7416: fprintf (file, "\"%s\"\n", url);
7417: if (ptr && *ptr != EOS)
1.794 vatton 7418: {
7419: /* now write other urls */
7420: while (ptr[i] != EOS && nb < MAX_URL_list)
7421: {
1.798 vatton 7422: end = strlen (&ptr[i]) + 1;
1.799 vatton 7423: if ((URL_list_keep || i != 0) &&
7424: (end != len || strncmp (url, &ptr[i], len)))
1.794 vatton 7425: {
7426: /* add the newline between two urls */
7427: strcpy (&URL_list[j], &ptr[i]);
1.799 vatton 7428: if (keep)
7429: fprintf (file, "\"%s\"\n", &ptr[i]);
1.794 vatton 7430: j += end;
7431: nb++;
7432: }
1.814 cvs 7433: i += end;
1.794 vatton 7434: }
7435: }
1.814 cvs 7436:
1.798 vatton 7437: URL_list[j] = EOS;
1.799 vatton 7438: URL_list_keep = keep;
7439: if (keep)
7440: TtaWriteClose (file);
1.794 vatton 7441: }
7442: TtaFreeMemory (ptr);
7443: TtaFreeMemory (urlstring);
1.825 vatton 7444: TtaFreeMemory (url);
1.794 vatton 7445: }
7446:
7447: /*----------------------------------------------------------------------
1.783 cvs 7448: InitStringForCombobox
1.794 vatton 7449: Initializes the URLs string for combobox
1.783 cvs 7450: ----------------------------------------------------------------------*/
1.794 vatton 7451: void InitStringForCombobox ()
1.783 cvs 7452: {
1.814 cvs 7453: unsigned char *urlstring, c;
7454: char *app_home;
7455: FILE *file;
7456: int i, nb, len;
1.794 vatton 7457:
7458: /* remove the previous list */
7459: TtaFreeMemory (URL_list);
1.803 vatton 7460: URL_list_keep = TRUE;
1.907 gully 7461: urlstring = (unsigned char *) TtaGetMemory (MAX_LENGTH);
1.794 vatton 7462: /* open the file list_url.dat into APP_HOME directory */
1.785 cheyroul 7463: app_home = TtaGetEnvString ("APP_HOME");
1.907 gully 7464: sprintf ((char *)urlstring, "%s%clist_url.dat", app_home, DIR_SEP);
7465: file = TtaReadOpen ((char *)urlstring);
1.784 cheyroul 7466: *urlstring = EOS;
1.794 vatton 7467: if (file)
1.783 cvs 7468: {
1.794 vatton 7469: /* get the size of the file */
7470: fseek (file, 0L, 2); /* end of the file */
7471: URL_list_len = ftell (file) + MAX_URL_list + 4;
1.907 gully 7472: URL_list = (char *)TtaGetMemory (URL_list_len);
1.890 cvs 7473: URL_list[0] = EOS;
1.794 vatton 7474: fseek (file, 0L, 0); /* beginning of the file */
7475: /* initialize the list by reading the file */
7476: i = 0;
7477: nb = 0;
1.820 vatton 7478: while (TtaReadByte (file, &c))
1.794 vatton 7479: {
1.814 cvs 7480: if (c == '"')
1.820 vatton 7481: {
7482: len = 0;
7483: urlstring[len] = EOS;
7484: while (len < MAX_LENGTH && TtaReadByte (file, &c) && c != EOL)
1.814 cvs 7485: {
1.820 vatton 7486: if (c == '"')
7487: urlstring[len] = EOS;
1.822 vatton 7488: else if (c == 13)
1.821 vatton 7489: urlstring[len] = EOS;
1.820 vatton 7490: else
7491: urlstring[len++] = (char)c;
1.814 cvs 7492: }
1.820 vatton 7493: if (i > 0 && len)
7494: /* add an EOS between two urls */
7495: URL_list[i++] = EOS;
7496: if (len)
7497: {
7498: nb++;
1.907 gully 7499: strcpy ((char *)&URL_list[i], (char *)urlstring);
1.820 vatton 7500: i += len;
7501: }
7502: }
1.783 cvs 7503: }
1.820 vatton 7504: URL_list[i + 1] = EOS;
1.890 cvs 7505: TtaReadClose (file);
7506: }
7507: TtaFreeMemory (urlstring);
7508: }
7509:
7510:
7511: /*----------------------------------------------------------------------
7512: RemoveDocFromSaveList remove the file from the AutoSave list
7513: ----------------------------------------------------------------------*/
1.924 vatton 7514: void RemoveDocFromSaveList (char *name, char *initial_url, int doctype)
1.890 cvs 7515: {
1.924 vatton 7516: char *urlstring, *app_home, *ptr, *list_item;
1.890 cvs 7517: char *ptr_end, *ptr_beg;
1.897 vatton 7518: int i, j, len, nb, end;
1.890 cvs 7519: FILE *file = NULL;
7520:
1.924 vatton 7521: if (name == NULL || name[0] == EOS)
1.890 cvs 7522: return;
7523: if (initial_url == NULL || initial_url[0] == EOS)
7524: return;
7525: /* keep the previous list */
7526: ptr = AutoSave_list;
7527: /* create a new list */
1.907 gully 7528: AutoSave_list = (char *)TtaGetMemory (AutoSave_list_len + 1);
1.924 vatton 7529: len = strlen (initial_url) + strlen (name) + 1;
1.898 quint 7530: len += 17; /*doctype + quotation marks + spaces */
1.907 gully 7531: list_item = (char *)TtaGetMemory (len);
1.924 vatton 7532: sprintf (list_item, "\"%s\" \"%s\" %d", name, initial_url, doctype);
1.890 cvs 7533: /* open the file AutoSave.dat into APP_HOME directory */
7534: app_home = TtaGetEnvString ("APP_HOME");
1.902 vatton 7535: urlstring = (char *) TtaGetMemory (MAX_LENGTH);
1.890 cvs 7536: sprintf (urlstring, "%s%cAutoSave.dat", app_home, DIR_SEP);
7537:
7538: if (TtaFileExist (urlstring))
7539: {
7540: file = TtaWriteOpen (urlstring);
1.913 vatton 7541: if (file && AutoSave_list)
1.890 cvs 7542: {
7543: i = 0;
7544: j = 0;
1.913 vatton 7545: nb = 0;
1.890 cvs 7546: /* remove the line (write other urls) */
7547: if (ptr && *ptr != EOS)
7548: {
1.913 vatton 7549: while (ptr[i] != EOS && nb <= MAX_AutoSave_list)
1.890 cvs 7550: {
7551: end = strlen (&ptr[i]) + 1;
7552: ptr_end = strrchr (&ptr[i], '\"');
7553: if (ptr_end)
7554: {
7555: *ptr_end = EOS;
7556: ptr_beg = strrchr (&ptr[i], '\"');
7557: if (ptr_beg)
7558: {
7559: ptr_beg++;
1.924 vatton 7560: if (strcmp (initial_url, ptr_beg))
1.890 cvs 7561: {
1.902 vatton 7562: /* keep this entry */
1.890 cvs 7563: *ptr_end = '\"';
7564: strcpy (&AutoSave_list[j], &ptr[i]);
7565: AutoSave_list_len += end;
7566: fprintf (file, "%s\n", &ptr[i]);
7567: j += end;
7568: nb++;
7569: }
7570: }
7571: *ptr_end = '\"';
7572: }
7573: i += end;
7574: }
7575: }
7576: AutoSave_list[j] = EOS;
7577: TtaWriteClose (file);
1.913 vatton 7578: /* remove the backup file */
1.890 cvs 7579: if (j == 0 && TtaFileExist (urlstring))
7580: {
7581: TtaFileUnlink (urlstring);
7582: AutoSave_list = NULL;
7583: TtaFreeMemory (AutoSave_list);
7584: AutoSave_list_len = 0;
7585: }
7586: }
7587: }
7588: else
7589: {
7590: TtaFreeMemory (AutoSave_list);
7591: AutoSave_list = NULL;
7592: AutoSave_list_len = 0;
7593: }
7594:
1.924 vatton 7595: TtaFreeMemory (ptr);
7596: TtaFreeMemory (urlstring);
7597: TtaFreeMemory (list_item);
1.890 cvs 7598: }
7599:
7600: /*----------------------------------------------------------------------
7601: AddDocInSaveList adds the new URL into the AutoSave list
7602: ----------------------------------------------------------------------*/
1.924 vatton 7603: void AddDocInSaveList (char *name, char *initial_url, int doctype)
1.890 cvs 7604: {
1.924 vatton 7605: char *urlstring, *app_home, *ptr;
1.890 cvs 7606: char *ptr_end, *ptr_beg;
1.897 vatton 7607: int i, j, len, nb, end;
1.890 cvs 7608: FILE *file = NULL;
7609:
1.897 vatton 7610: if (AutoSave_Interval == 0)
1.890 cvs 7611: return;
1.924 vatton 7612: if (name == NULL || name[0] == EOS)
1.890 cvs 7613: return;
7614: if (initial_url == NULL || initial_url[0] == EOS)
7615: return;
7616: /* keep the previous list */
7617: ptr = AutoSave_list;
7618: /* create a new list */
1.924 vatton 7619: len = strlen (initial_url) + strlen (name) + 1;
1.890 cvs 7620: len += 7; /*doctype + quotation marks + spaces */
1.907 gully 7621: AutoSave_list = (char *)TtaGetMemory (AutoSave_list_len + len + 1);
1.890 cvs 7622:
7623: /* open the file AutoSave.dat into APP_HOME directory */
7624: urlstring = (char *) TtaGetMemory (MAX_LENGTH);
7625: app_home = TtaGetEnvString ("APP_HOME");
7626: sprintf (urlstring, "%s%cAutoSave.dat", app_home, DIR_SEP);
7627: file = TtaWriteOpen (urlstring);
7628: *urlstring = EOS;
7629:
7630: if (file)
7631: {
7632: i = 0;
7633: j = len;
7634: nb = 1;
7635: /* put the new line */
1.924 vatton 7636: sprintf (AutoSave_list, "\"%s\" \"%s\" %d", name, initial_url, doctype);
1.890 cvs 7637: AutoSave_list_len = len + 1;
7638: fprintf (file, "%s\n", AutoSave_list);
7639: if (ptr && *ptr != EOS)
7640: {
7641: /* now write other urls */
7642: while (ptr[i] != EOS && nb < MAX_AutoSave_list)
7643: {
7644: end = strlen (&ptr[i]) + 1;
7645:
7646: ptr_end = strrchr (&ptr[i], '\"');
7647: if (ptr_end)
7648: {
7649: *ptr_end = EOS;
7650: ptr_beg = strrchr (&ptr[i], '\"');
7651: if (ptr_beg)
7652: {
7653: ptr_beg++;
1.924 vatton 7654: if ((end != len) || (strcmp (initial_url, ptr_beg)))
1.890 cvs 7655: {
7656: /* copy the url */
7657: *ptr_end = '\"';
7658: strcpy (&AutoSave_list[j], &ptr[i]);
7659: AutoSave_list_len += end;
7660: fprintf (file, "%s\n", &ptr[i]);
7661: j += end;
7662: nb++;
7663: }
7664: }
7665: *ptr_end = '\"';
7666: }
7667: i += end;
7668: }
7669: }
7670: AutoSave_list[j] = EOS;
7671: TtaWriteClose (file);
7672: }
1.924 vatton 7673:
7674: TtaFreeMemory (ptr);
7675: TtaFreeMemory (urlstring);
1.890 cvs 7676: }
7677:
7678: /*----------------------------------------------------------------------
7679: InitAutoSave list
7680: ----------------------------------------------------------------------*/
7681: void InitAutoSave ()
7682: {
7683: unsigned char *urlstring, c;
7684: char *app_home;
7685: FILE *file;
1.897 vatton 7686: int i, nb, len;
1.890 cvs 7687:
7688: /* remove the previous list */
7689: TtaFreeMemory (AutoSave_list);
7690: AutoSave_list = NULL;
7691: AutoSave_list_len = 0;
1.907 gully 7692: urlstring = (unsigned char *) TtaGetMemory (MAX_LENGTH);
1.890 cvs 7693: /* open the file AutoSave.dat into APP_HOME directory */
7694: app_home = TtaGetEnvString ("APP_HOME");
1.907 gully 7695: sprintf ((char *)urlstring, "%s%cAutoSave.dat", app_home, DIR_SEP);
7696: file = TtaReadOpen ((char *)urlstring);
1.890 cvs 7697: *urlstring = EOS;
7698: if (file)
7699: {
7700: /* get the size of the file */
7701: fseek (file, 0L, 2); /* end of the file */
7702: AutoSave_list_len = ftell (file) + MAX_URL_list + 4;
1.907 gully 7703: AutoSave_list = (char *)TtaGetMemory (AutoSave_list_len);
1.890 cvs 7704: URL_list[0] = EOS;
7705: fseek (file, 0L, 0); /* beginning of the file */
7706: /* initialize the list by reading the file */
7707: i = 0;
7708: nb = 0;
7709: while (TtaReadByte (file, &c))
7710: {
7711: if (c == '"')
7712: {
7713: len = 0;
7714: urlstring[len] = EOS;
7715: while (len < MAX_LENGTH && TtaReadByte (file, &c) && c != EOL)
7716: {
7717: if (c == '"')
7718: urlstring[len] = EOS;
7719: else if (c == 13)
7720: urlstring[len] = EOS;
7721: else
7722: urlstring[len++] = (char)c;
7723: }
7724: if (i > 0 && len)
7725: /* add an EOS between two urls */
7726: AutoSave_list[i++] = EOS;
7727: if (len)
7728: {
7729: nb++;
1.907 gully 7730: strcpy ((char *)&AutoSave_list[i], (char *)urlstring);
1.890 cvs 7731: i += len;
7732: }
7733: }
7734: }
7735: AutoSave_list[i + 1] = EOS;
1.794 vatton 7736: TtaReadClose (file);
1.783 cvs 7737: }
7738: TtaFreeMemory (urlstring);
1.6 cvs 7739: }
Webmaster