/amaya/init.c
C | 8244 lines | 6422 code | 507 blank | 1315 comment | 1962 complexity | 6ac534b4467ef1867d7cf58f63e02277 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- /*
- *
- * (c) COPYRIGHT INRIA and W3C, 1996-2010
- * Please first read the full copyright statement in file COPYRIGHT.
- *
- */
- /*
- * Initialization functions and button functions of Amaya application.
- *
- * Author: I. Vatton
- * R. Guetari (W3C/INRIA) - Windows version
- */
- /* Included headerfiles */
- #include "wx/wx.h"
- #undef THOT_EXPORT
- #define THOT_EXPORT extern /* defined into css.c */
- #include "amaya.h"
- #undef THOT_EXPORT
- #define THOT_EXPORT extern
- #include "css.h"
- #include "trans.h"
- #include "zlib.h"
- #include "profiles.h"
- #include "MENUconf.h"
- #include "containers.h"
- #include "Elemlist.h"
- #include "insertelem_f.h"
- #include "tips.h"
- #ifdef TEMPLATES
- #include "Template.h"
- #include "templates.h"
- #include "templates_f.h"
- #include "templateDeclarations_f.h"
- #endif /* TEMPLATES */
- #ifdef _WINDOWS
- #include <commctrl.h>
- extern char LostPicturePath [MAX_LENGTH];
- #endif /* _WINDOWS */
- #include "message_wx.h"
- #include "wxdialogapi_f.h"
- #include "windowtypes_wx.h"
- #include "paneltypes_wx.h"
- #include "registry_wx.h"
- #include "appdialogue_wx.h"
- #include "AmayaWindowIterator.h"
- #include "AmayaParams.h"
- #include "Elemlist.h"
- #include "wxdialog/StyleListToolPanel.h"
- #include "javascript_f.h"
- extern XmlEntity *pMathEntityTable;
- #include "appdialogue_wx.h"
- /* SVG Templates */
- char *LastSVGelement = NULL;
- char *LastSVGelementTitle = NULL;
- ThotBool LastSVGelementIsFilled = FALSE;
- /* SVG Style panel */
- int Current_Opacity = 100;
- ThotBool FillEnabled = FALSE;
- int Current_FillColor = -1;
- int Current_FillOpacity = 100;
- ThotBool StrokeEnabled = TRUE;
- int Current_StrokeColor = -1;
- int Current_StrokeOpacity = 100;
- int Current_StrokeWidth = 1;
- /* HTML Style panel */
- int Current_Color = -1;
- int Current_BackgroundColor = -1;
- int SavePANEL_PREFERENCES = 1;
- int Current_FontFamily = 1;
- int Current_FontSize = 12;
- static int AmayaInitialized = 0;
- static ThotBool NewFile = FALSE;
- static int NewDocType = 0;
- static int NewDocProfile = 0;
- static int NewDocExtraProfile = 0;
- static ThotBool NewXML = TRUE;
- static ThotBool BADMimeType = FALSE;
- static ThotBool CriticConfirm = FALSE;
- static ThotBool CriticCheckError = FALSE;
- static ThotBool CriticLogError = FALSE;
- /* the open document is the Amaya default page */
- static ThotBool WelcomePage = FALSE;
- /* we have to mark the initial loading status to avoid to re-open the
- document view twice */
- static int Loading_method = CE_INIT;
- #include "MENUconf.h"
- #include "AHTURLTools_f.h"
- #include "css_f.h"
- #include "document.h"
- #include "EDITORactions_f.h"
- #include "EDITimage_f.h"
- #include "EDITstyle_f.h"
- #include "fetchXMLname_f.h"
- #ifdef _SVG
- #include "SVGedit_f.h"
- #endif /* _SVG */
- #include "HTMLactions_f.h"
- #include "HTMLbook_f.h"
- #include "HTMLedit_f.h"
- #include "HTMLhistory_f.h"
- #include "HTMLimage_f.h"
- #include "HTMLpresentation_f.h"
- #include "HTMLsave_f.h"
- #include "HTMLtable_f.h"
- #include "html2thot_f.h"
- #include "Mathedit_f.h"
- #include "MENUconf_f.h"
- #include "init_f.h"
- #include "query_f.h"
- #include "styleparser_f.h"
- #include "trans_f.h"
- #include "transparse_f.h"
- #include "UIcss_f.h"
- #include "string.h"
- #include "Xml2thot_f.h"
- #include "XPointer_f.h"
- #include "anim_f.h"
- #include "animbuilder_f.h"
- #ifdef ANNOTATIONS
- #include "annotlib.h"
- #include "ANNOTevent_f.h"
- #include "ANNOTfiles_f.h"
- #include "ANNOTtools_f.h"
- #endif /* ANNOTATIONS */
- #ifdef BOOKMARKS
- #include "BMevent_f.h"
- #endif /* BOOKMARKS */
- #include "wxdialogapi_f.h"
- #include "archives.h"
- #ifdef DAV
- #define WEBDAV_EXPORT extern
- #include "davlib.h"
- #include "davlib_f.h"
- #include "davlibRequests_f.h"
- #include "davlibUI_f.h"
- #endif /* DAV */
- extern void InitMathML ();
- extern void InitTemplates ();
- typedef enum
- {
- OpenDocBrowser,
- HrefAttrBrowser,
- DocSaveBrowser
- } TypeBrowserFile;
- TypeBrowserFile WidgetParent;
- /*----------------------------------------------------------------------
- ----------------------------------------------------------------------*/
- static int AmayaPopupDocContextMenu (int doc, int view, int window,
- wxWindow* win, int x, int y)
- {
- wxMenu *p_menu = TtaGetDocContextMenu ( window );
- if (p_menu && doc)
- {
- #ifdef TEMPLATES
- ElementType elType, parentType;
- DLList list = NULL;
- ForwardIterator iter;
- Element el, last, prev, parent;
- DLListNode node;
- int i, firstChar, lastChar, id = 1000;
- wxMenuItem *itemTemplateInsert = NULL,
- *itemTemplateAppend = NULL,
- *oldInsert = NULL,
- *oldAppend = NULL;
- wxMenu *menuTemplateInsert = NULL,
- *menuTemplateAppend = NULL;
- ThotBool bTemplate = IsTemplateInstanceDocument(doc);
- ThotBool do_insert = TRUE, do_append = TRUE;
- #endif /* TEMPLATES */
- #ifdef _SVG
- ElementType elementType;
- SSchema svgSchema;
- #endif /* _SVG */
- /* First items of the context menu can be displayed/hidden. */
- #define NB_ITEM 16
- #define CUT_POS NB_ITEM-6
- wxMenuItem* items[NB_ITEM];
- ThotBool display_item[NB_ITEM];
- /* By default, the first item until the "cut" command
- are not displayed... */
- for(i = 0; i < CUT_POS; i++)
- display_item[i] = FALSE;
- /* ... and cut, paste etc are displayed. */
- for(i = CUT_POS; i < NB_ITEM; i++)
- display_item[i] = TRUE;
- /* Is the element a link? */
- if (CanFollowTheLink(doc))
- {
- for(i = 0; i < 4; i++)
- display_item[i] = TRUE;
- }
- #ifdef _SVG
- /* Is it an SVG element? */
- TtaGiveFirstSelectedElement (doc, &el, &firstChar, &lastChar);
- if (el)
- {
- svgSchema = GetSVGSSchema (doc);
- elementType = TtaGetElementType(el);
- parent = TtaGetParent (el);
- parentType = TtaGetElementType (parent);
- if (elementType.ElSSchema == svgSchema && view == 1 &&
- parentType.ElSSchema == svgSchema)
- {
- if(!TtaIsLeaf(elementType) ||
- elementType.ElTypeNum == SVG_EL_TEXT_UNIT)
- /* Display the SVG transforms if a non-terminal SVG element
- or a TEXT_UNIT is selected */
- {
- display_item[4] = TRUE;
- display_item[5] = TRUE;
- display_item[6] = TRUE;
- display_item[7] = TRUE;
- display_item[8] = (elementType.ElTypeNum == SVG_EL_g);
- display_item[9] = TRUE;
- }
- else if(elementType.ElTypeNum == SVG_EL_GRAPHICS_UNIT)
- {
- /* Remove cut, copy, paste commands */
- for(i = 0; i < 3; i++)
- display_item[CUT_POS+i] = FALSE;
- }
- }
- }
- #endif /* _SVG */
- /* Remove all the item that must not be displayed */
- for(i = NB_ITEM - 1; i >= 0; i--)
- {
- if(!display_item[i])
- items[i] = p_menu->Remove(p_menu->FindItemByPosition(i));
- }
- #ifdef TEMPLATES
- TtaGiveFirstSelectedElement (doc, &el, &firstChar, &lastChar);
- TtaGiveLastSelectedElement (doc, &last, &i, &lastChar);
- if (el && el == last && bTemplate)
- {
- // only one element selected
- elType = TtaGetElementType (el);
- parent = TtaGetParent (el);
- parentType = TtaGetElementType (parent);
- if (parent == NULL || TtaIsReadOnly (parent))
- do_insert = do_append = FALSE;
- else if (!strcmp (TtaGetSSchemaName (parentType.ElSSchema), "Template") &&
- parentType.ElTypeNum == Template_EL_useSimple)
- do_insert = do_append = FALSE;
- else if (TtaIsLeaf (elType))
- {
- if ((firstChar == 0 && lastChar == 0) || lastChar >= TtaGetElementVolume(el))
- // check the end of the enclosing element
- TtaNextSibling (&last);
- prev = el;
- if ((firstChar == 0 && lastChar == 0) || (firstChar == 1 && lastChar == 0))
- // check the beginning of the enclosing element
- TtaPreviousSibling (&prev);
- do_insert = (prev == NULL);
- do_append = (last == NULL);
- }
- if (do_insert || do_append)
- {
- // prepare insert and apppend submenus
- list = InsertableElement_ComputeList (doc, el);
- if(DLList_GetSize(list)!=0)
- {
- menuTemplateInsert = new wxMenu;
- menuTemplateAppend = new wxMenu;
- iter = DLList_GetForwardIterator (list);
- ITERATOR_FOREACH (iter, DLListNode, node)
- {
- ElemListElement elem = (ElemListElement)node->elem;
- if (elem)
- {
- wxString str = TtaConvMessageToWX(ElemListElement_GetName(elem));
- menuTemplateInsert->Append(id, str);
- menuTemplateAppend->Append(100 + id++, str);
- }
- }
- // remove standard menu entries
- oldAppend = p_menu->Remove (p_menu->FindItemByPosition(p_menu->GetMenuItemCount()-1));
- oldInsert = p_menu->Remove (p_menu->FindItemByPosition(p_menu->GetMenuItemCount()-1));
- // new insert entry
- if (do_insert)
- {
- itemTemplateInsert = new wxMenuItem (p_menu, oldInsert->GetId(), oldInsert->GetLabel(),
- wxT(""), wxITEM_NORMAL, menuTemplateInsert);
- itemTemplateInsert->SetBitmap(oldInsert->GetBitmap());
- p_menu->Append(itemTemplateInsert);
- }
- else if (oldInsert)
- p_menu->Append(oldInsert);
- // new append entry
- if (do_append)
- {
- itemTemplateAppend = new wxMenuItem(p_menu, oldAppend->GetId(), oldAppend->GetLabel(),
- wxT(""), wxITEM_NORMAL, menuTemplateAppend);
- itemTemplateAppend->SetBitmap(oldAppend->GetBitmap());
- p_menu->Append(itemTemplateAppend);
- }
- else if (oldAppend)
- p_menu->Append(oldAppend);
-
- }
- else
- do_insert = do_append = FALSE;
- }
- TtaResetEnumContextMenu();
- }
- #endif /* TEMPLATES */
- // display the popup menu
- win->PopupMenu (p_menu, win->ScreenToClient(wxPoint(x, y)));
- #ifdef TEMPLATES
- // manage the selected entry
- if (itemTemplateInsert || itemTemplateAppend)
- {
- id = TtaGetEnumContextMenu();
- if(id!=-1)
- {
- id -= 1000;
- DLListNode node = DLList_GetElement(list, id<100?id:id-100);
- if(node && node->elem)
- InsertableElement_QueryInsertElement((ElemListElement)node->elem, id<100);
- }
- if (list)
- DLList_Destroy(list);
- // destroy submenus or remove entries
- if (itemTemplateAppend)
- p_menu->Destroy(itemTemplateAppend);
- else if (oldAppend)
- p_menu->Remove (oldAppend);
- if (itemTemplateInsert)
- p_menu->Destroy(itemTemplateInsert);
- else if (oldInsert)
- p_menu->Remove (oldInsert);
- // reattach standard menu entries
- if (oldInsert)
- p_menu->Append(oldInsert);
- if (oldAppend)
- p_menu->Append(oldAppend);
- }
- #endif /* TEMPLATES */
- /* Reinsert the menu items */
- for(i = 0; i < NB_ITEM; i++)
- {
- if(!display_item[i])
- p_menu->Insert(i, items[i]);
- }
- }
- return -1;
- }
- /*----------------------------------------------------------------------
- DocumentMetaDataAlloc
- Creates a DocumentMeta element and initializes it to its default
- values.
- ----------------------------------------------------------------------*/
- DocumentMetaDataElement *DocumentMetaDataAlloc (void)
- {
- DocumentMetaDataElement *me;
- me = (DocumentMetaDataElement *) TtaGetMemory (sizeof (DocumentMetaDataElement));
- memset ((void *) me, 0, sizeof (DocumentMetaDataElement));
- me->method = CE_ABSOLUTE;
- return (me);
- }
- /*----------------------------------------------------------------------
- DocumentMetaClear
- Clears the dynamically allocated memory associated to a metadata
- element. Doesn't free the element or clears any of its other elements.
- ----------------------------------------------------------------------*/
- void DocumentMetaClear (DocumentMetaDataElement *me)
- {
- if (!me)
- return;
- TtaFreeMemory (me->form_data);
- me->form_data = NULL;
- TtaFreeMemory (me->initial_url);
- me->initial_url = NULL;
- TtaFreeMemory (me->content_type);
- me->content_type = NULL;
- TtaFreeMemory (me->charset);
- me->charset = NULL;
- TtaFreeMemory (me->content_length);
- me->content_length = NULL;
- TtaFreeMemory (me->content_location);
- me->content_location = NULL;
- TtaFreeMemory (me->full_content_location);
- me->full_content_location = NULL;
- TtaFreeMemory (me->reason);
- me->reason = NULL;
- me->link_icon = NULL;
- }
- /*----------------------------------------------------------------------
- IsXMLDocType
- Returns TRUE if the DocumentTypes of the document is XML
- ----------------------------------------------------------------------*/
- ThotBool IsXMLDocType (Document doc)
- {
- if (DocumentTypes[doc] == docHTML ||
- DocumentTypes[doc] == docLibrary ||
- DocumentTypes[doc] == docMath ||
- DocumentTypes[doc] == docSVG ||
- DocumentTypes[doc] == docTemplate ||
- DocumentTypes[doc] == docXml)
- return TRUE;
- else
- return FALSE;
- }
- /*----------------------------------------------------------------------
- DocumentTypeString
- Returns a string that represents the document type or the current
- profile.
- ----------------------------------------------------------------------*/
- const char * DocumentTypeString (Document document)
- {
- const char *result;
- ThotBool isXml;
- result = NULL;
- switch (DocumentTypes[document])
- {
- case docText:
- result = "Text file";
- break;
- case docImage:
- result = "Image";
- case docCSS:
- result = "CSS style sheet";
- break;
- case docSource:
- result = "Document source";
- break;
- case docAnnot:
- result = "Annotation";
- break;
- case docLog:
- result = "Log file";
- break;
- case docSVG:
- result = "SVG";
- break;
- case docXml:
- result = "XML";
- break;
- case docLibrary:
- result = "HTML";
- break;
- case docTemplate:
- result = "XTiger template";
- break;
- default:
- break;
- }
- if (!result && DocumentMeta[document]) /* try the profiles */
- {
- isXml = DocumentMeta[document]->xmlformat;
- switch (TtaGetDocumentProfile (document))
- {
- case L_Other:
- result = "Unknown";
- break;
- case L_Xhtml11:
- if (TtaGetDocumentExtraProfile(document) == L_RDFa)
- result = "XHTML+RDFa";
- else
- result = "XHTML 1.1";
- break;
- case L_Basic:
- result = "XHTML 1.0 Basic";
- break;
- case L_Strict:
- if (isXml)
- result = "XHTML 1.0 Strict";
- else
- result = "HTML Strict";
- break;
- case L_Transitional:
- if (isXml)
- result = "XHTML 1.0 Transitional";
- else
- result = "HTML Transitional";
- break;
- case L_MathML:
- result = "MathML";
- break;
- }
- }
- return (result);
- }
- /*----------------------------------------------------------------------
- DocumentInfo
- Displays the document informations given by the header
- ----------------------------------------------------------------------*/
- void DocumentInfo (Document document, View view)
- {
- ThotBool created = CreateDocInfoDlgWX (BaseDialog + DocInfoForm,
- TtaGetViewFrame (document, view), document);
- if (created)
- {
- TtaSetDialoguePosition ();
- TtaShowDialogue (BaseDialog + DocInfoForm, FALSE, TRUE);
- /* wait for an answer */
- TtaWaitShowDialogue ();
- }
- }
- /*----------------------------------------------------------------------
- IsDocumentLoaded returns the document identification if the
- corresponding document is already loaded or 0.
- ----------------------------------------------------------------------*/
- Document IsDocumentLoaded (const char *documentURL, const char *form_data)
- {
- int i;
- ThotBool found;
- if (!documentURL)
- return ((Document) None);
- i = 1;
- found = FALSE;
- /* look for the URL into the list of downloaded documents */
- while (!found && i < DocumentTableLength)
- {
- if (DocumentURLs[i] && DocumentTypes[i] != docTemplate && DocumentMeta[i])
- {
- /* compare the url */
- found = (!strcmp (documentURL, DocumentURLs[i]) ||
- (DocumentMeta[i]->initial_url &&
- !strcmp (documentURL, DocumentMeta[i]->initial_url)));
- /* compare the form_data */
- if (found && (!((!form_data && !DocumentMeta[i]->form_data) ||
- (form_data && DocumentMeta[i]->form_data &&
- !strcmp (form_data, DocumentMeta[i]->form_data)))))
- found = FALSE;
- }
- if (!found)
- i++;
- }
-
- if (found)
- {
- /* document is found */
- UpdateEditorMenus ((Document) i);
- return ((Document) i);
- }
- else
- /* document is not found */
- return ((Document) None);
- }
- /*----------------------------------------------------------------------
- ExtractParameters extract parameters from document nane.
- ----------------------------------------------------------------------*/
- void ExtractParameters (char *aName, char *parameters)
- {
- long int lg, i;
- char *ptr;
- char *oldptr;
- if (!parameters || !aName)
- /* bad parameters */
- return;
- parameters[0] = EOS;
- lg = strlen (aName);
- if (lg)
- {
- /* the name is not empty */
- oldptr = ptr = &aName[0];
- do
- {
- ptr = strrchr (oldptr, '?');
- if (ptr)
- oldptr = &ptr[1];
- }
- while (ptr);
- i = (long int) (oldptr) - (long int) (aName); /* name length */
- if (i > 1)
- {
- aName[i - 1] = EOS;
- if (i != lg)
- strcpy (parameters, oldptr);
- }
- }
- }
- /*----------------------------------------------------------------------
- FileExistTarget
- Removes the URL target separator ('#') before verifying if a file
- exists.
- ----------------------------------------------------------------------*/
- static ThotBool FileExistTarget (char *filename)
- {
- char *ptr;
- ThotBool result;
- ptr = strrchr (filename, '#');
- if (ptr)
- *ptr = EOS;
- result = TtaFileExist(filename);
- if (ptr)
- *ptr = '#';
- return result;
- }
- /*----------------------------------------------------------------------
- SetArrowButton
- Change the appearance of the Back (if back == TRUE) or Forward button
- for a given document.
- ----------------------------------------------------------------------*/
- void SetArrowButton (Document doc, ThotBool back, ThotBool on)
- {
- ThotBool state;
- if (back)
- {
- if (on)
- {
- state = TRUE;
- TtaSetItemOn (doc, 1, File, BBack);
- if (DocumentSource[doc])
- /* update the document source too */
- TtaSetItemOn (DocumentSource[doc], 1, File, BBack);
- }
- else
- {
- state = FALSE;
- TtaSetItemOff (doc, 1, File, BBack);
- if (DocumentSource[doc])
- /* update the document source too */
- TtaSetItemOff (DocumentSource[doc], 1, File, BBack);
- }
- }
- else
- {
- if (on)
- {
- state = TRUE;
- TtaSetItemOn (doc, 1, File, BForward);
- if (DocumentSource[doc])
- /* update the document source too */
- TtaSetItemOn (DocumentSource[doc], 1, File, BForward);
- }
- else
- {
- state = FALSE;
- TtaSetItemOff (doc, 1, File, BForward);
- if (DocumentSource[doc])
- /* update the document source too */
- TtaSetItemOff (DocumentSource[doc], 1, File, BForward);
- }
- }
- }
- /*----------------------------------------------------------------------
- ResetStop resets the stop button state
- ----------------------------------------------------------------------*/
- void ResetStop (Document document)
- {
- if (document)
- {
- if (FilesLoading[document] != 0)
- FilesLoading[document]--;
- if (FilesLoading[document] == 0)
- /* The last object associated to the document has been loaded */
- {
- if (TtaGetViewFrame (document, 1) != 0)
- /* this document is displayed */
- {
- if(!(DocNetworkStatus[document] & AMAYA_NET_ERROR) &&
- (DocNetworkStatus[document] & AMAYA_NET_ACTIVE))
- /* if there was no error message, display the LOADED message */
- TtaSetStatus (document, 1,
- TtaGetMessage (AMAYA, AM_DOCUMENT_LOADED), NULL);
- TtaEnableAction(document, "StopTransfer", FALSE);
- }
- DocNetworkStatus[document] = AMAYA_NET_INACTIVE;
- }
- }
- }
- /*----------------------------------------------------------------------
- ActiveTransfer initialize the current transfer
- ----------------------------------------------------------------------*/
- void ActiveTransfer (Document document)
- {
- if (document)
- {
- DocNetworkStatus[document] = AMAYA_NET_ACTIVE;
- FilesLoading[document] = 1;
- if (TtaGetViewFrame (document, 1) != 0)
- /* this document is displayed */
- TtaEnableAction(document, "StopTransfer", TRUE);
- }
- }
- /*----------------------------------------------------------------------
- SetStopButton Activates the stop button if it's turned off
- ----------------------------------------------------------------------*/
- void SetStopButton (Document document)
- {
- if (document)
- {
- if (document != DocBook)
- {
- if (DocNetworkStatus[document] != AMAYA_NET_ACTIVE)
- DocNetworkStatus[document] = AMAYA_NET_ACTIVE;
- if (FilesLoading[document] == 0)
- FilesLoading[document] = 1;
- }
- if (TtaGetViewFrame (document, 1) != 0)
- TtaEnableAction(document, "StopTransfer", TRUE);
- }
- }
- /*----------------------------------------------------------------------
- SetFormReadWrite
- Set ReadWrite access to input elements
- ----------------------------------------------------------------------*/
- static void SetFormReadWrite (Element el, Document doc)
- {
- ElementType elType;
- Element child, next;
- while (el)
- {
- /* look at all elements within this form */
- elType = TtaGetElementType (el);
- child = TtaGetFirstChild (el);
- next = el;
- TtaNextSibling (&next);
- switch (elType.ElTypeNum)
- {
- case HTML_EL_Input:
- case HTML_EL_Text_Input:
- case HTML_EL_Password_Input:
- case HTML_EL_File_Input:
- case HTML_EL_Option:
- case HTML_EL_Text_Area: /* it's a Text_Area */
- TtaSetAccessRight (child, ReadWrite, doc);
- child = NULL;
- break;
- default:
- break;
- }
- if (child != NULL)
- SetFormReadWrite (child, doc);
- el = next;
- }
- }
- /*----------------------------------------------------------------------
- Update the save button and the corresponding menu entry according to the
- document status.
- ----------------------------------------------------------------------*/
- void DocStatusUpdate (Document doc, ThotBool modified)
- {
- Document otherDoc, idoc;
- ThotBool noDocumentModified;
- if (modified && TtaGetDocumentAccessMode (doc))
- /* the document has been modified and is not in Read-Only mode */
- {
- TtaSetItemOn (doc, 1, File, BSave);
- // update all document status
- for (idoc = 1; idoc < DocumentTableLength; idoc++)
- TtaSetItemOn (idoc, 1, File, BSaveAll);
- #ifdef _JAVA
- StopJavascript (doc);
- #endif /* _JAVA */
- /* if we have a pair source/structured document allow synchronization */
- otherDoc = DocumentSource[doc];
- if (!otherDoc)
- otherDoc = GetDocFromSource (doc);
- if (otherDoc)
- {
- TtaSetItemOn (doc, 1, File, BSynchro);
- TtaSetItemOn (otherDoc, 1, File, BSynchro);
- }
- else if (DocumentTypes[doc] == docCSS)
- TtaSetItemOn (doc, 1, File, BSynchro);
- }
- else
- /* the document is no longer modified */
- {
- noDocumentModified = TRUE;
- for (idoc = 1; noDocumentModified && idoc < DocumentTableLength; idoc++)
- {
- if (TtaIsDocumentModified (idoc) && idoc != doc)
- noDocumentModified = FALSE;
- }
- TtaSetItemOff (doc, 1, File, BSave);
- if (noDocumentModified)
- // update all document status
- for (idoc = 1; noDocumentModified && idoc < DocumentTableLength; idoc++)
- TtaSetItemOff (idoc, 1, File, BSaveAll);
- if (TtaIsDocumentUpdated (doc))
- {
- /* if we have a pair source/structured document allow synchronization */
- otherDoc = DocumentSource[doc];
- if (!otherDoc)
- otherDoc = GetDocFromSource (doc);
- if (otherDoc)
- {
- TtaSetItemOn (doc, 1, File, BSynchro);
- TtaSetItemOn (otherDoc, 1, File, BSynchro);
- }
- else if (DocumentTypes[doc] == docCSS)
- TtaSetItemOn (doc, 1, File, BSynchro);
- }
- else
- {
- /* if we have a pair source/structured document allow synchronization */
- otherDoc = DocumentSource[doc];
- if (!otherDoc)
- otherDoc = GetDocFromSource (doc);
- if (otherDoc)
- {
- TtaSetItemOff (doc, 1, File, BSynchro);
- TtaSetItemOff (otherDoc, 1, File, BSynchro);
- }
- else if (DocumentTypes[doc] == docCSS)
- TtaSetItemOff (doc, 1, File, BSynchro);
- }
- }
- }
- /*----------------------------------------------------------------------
- SetCharsetMenuOff sets Off the charset menu in the current view.
- ----------------------------------------------------------------------*/
- static void SetCharsetMenuOff (Document doc, View view)
- {
- TtaSetItemOff (doc, view, File, BUTF_8);
- TtaSetItemOff (doc, view, File, BISO_8859_1);
- TtaSetItemOff (doc, view, File, BISO_8859_15);
- TtaSetItemOff (doc, view, File, BWINDOWS_1252);
- TtaSetItemOff (doc, view, File, BISO_8859_2);
- TtaSetItemOff (doc, view, File, BWINDOWS_1250);
- TtaSetItemOff (doc, view, File, BISO_8859_3);
- TtaSetItemOff (doc, view, File, BISO_8859_4);
- TtaSetItemOff (doc, view, File, BWINDOWS_1257);
- TtaSetItemOff (doc, view, File, BISO_8859_5);
- TtaSetItemOff (doc, view, File, BWINDOWS_1251);
- TtaSetItemOff (doc, view, File, BKOI8_R);
- TtaSetItemOff (doc, view, File, BISO_8859_6);
- TtaSetItemOff (doc, view, File, BWINDOWS_1256);
- TtaSetItemOff (doc, view, File, BISO_8859_7);
- TtaSetItemOff (doc, view, File, BWINDOWS_1253);
- TtaSetItemOff (doc, view, File, BISO_8859_8);
- TtaSetItemOff (doc, view, File, BWINDOWS_1255);
- TtaSetItemOff (doc, view, File, BISO_8859_9);
- TtaSetItemOff (doc, view, File, BWINDOWS_1254);
- TtaSetItemOff (doc, view, File, BGB_2312);
- TtaSetItemOff (doc, view, File, BISO_2022_JP);
- TtaSetItemOff (doc, view, File, BEUC_JP);
- TtaSetItemOff (doc, view, File, BSHIFT_JIS);
- }
- /*----------------------------------------------------------------------
- SetTableMenuOff sets Off the table menu in the current view.
- ----------------------------------------------------------------------*/
- void SetTableMenuOff (Document doc, View view)
- {
- TtaSetItemOff (doc, view, Types, BCaption);
- TtaSetItemOff (doc, view, Types, BTHead);
- TtaSetItemOff (doc, view, Types, BTBody);
- TtaSetItemOff (doc, view, Types, BTFoot);
- TtaSetItemOff (doc, view, Tools, BDataCell);
- TtaSetItemOff (doc, view, Tools, BHeadingCell);
- TtaSetItemOff (doc, view, Tools, BCellMerge);
- TtaSetItemOff (doc, view, Tools, BCellHExtend);
- TtaSetItemOff (doc, view, Tools, BCellVExtend);
- TtaSetItemOff (doc, view, Tools, BCellHShrink);
- TtaSetItemOff (doc, view, Tools, BCellVShrink);
- TtaSetItemOff (doc, view, Tools, BSelectRow);
- TtaSetItemOff (doc, view, Tools, BCreateRowB);
- TtaSetItemOff (doc, view, Tools, BCreateRowA);
- TtaSetItemOff (doc, view, Tools, BSelectColumn);
- TtaSetItemOff (doc, view, Tools, BCreateColumnB);
- TtaSetItemOff (doc, view, Tools, BCreateColumnA);
- TtaSetItemOff (doc, view, Tools, BPasteBefore);
- TtaSetItemOff (doc, view, Tools, BPasteAfter);
- }
- /*----------------------------------------------------------------------
- SetTableMenuOn sets On the table menu in the current view.
- ----------------------------------------------------------------------*/
- void SetTableMenuOn (Document doc, View view)
- {
- if (TableMenuActive)
- {
- /* a table element is selected */
- TtaSetItemOn (doc, view, Types, BCaption);
- TtaSetItemOn (doc, view, Types, BTHead);
- TtaSetItemOn (doc, view, Types, BTBody);
- TtaSetItemOn (doc, view, Types, BTFoot);
- TtaSetItemOn (doc, view, Tools, BDataCell);
- TtaSetItemOn (doc, view, Tools, BHeadingCell);
- }
- else
- {
- TtaSetItemOff (doc, view, Types, BCaption);
- TtaSetItemOff (doc, view, Types, BTHead);
- TtaSetItemOff (doc, view, Types, BTBody);
- TtaSetItemOff (doc, view, Types, BTFoot);
- TtaSetItemOff (doc, view, Tools, BDataCell);
- TtaSetItemOff (doc, view, Tools, BHeadingCell);
- }
- if (TableMenuActive || MTableMenuActive)
- {
- /* a table element is selected */
- TtaSetItemOn (doc, view, Tools, BCellMerge);
- TtaSetItemOn (doc, view, Tools, BCellHExtend);
- TtaSetItemOn (doc, view, Tools, BCellVExtend);
- TtaSetItemOn (doc, view, Tools, BCellHShrink);
- TtaSetItemOn (doc, view, Tools, BCellVShrink);
- TtaSetItemOn (doc, view, Tools, BSelectRow);
- TtaSetItemOn (doc, view, Tools, BCreateRowB);
- TtaSetItemOn (doc, view, Tools, BCreateRowA);
- TtaSetItemOn (doc, view, Tools, BSelectColumn);
- TtaSetItemOn (doc, view, Tools, BCreateColumnB);
- TtaSetItemOn (doc, view, Tools, BCreateColumnA);
- }
- else
- {
- TtaSetItemOff (doc, view, Tools, BCellMerge);
- TtaSetItemOff (doc, view, Tools, BCellHExtend);
- TtaSetItemOff (doc, view, Tools, BCellVExtend);
- TtaSetItemOff (doc, view, Tools, BCellHShrink);
- TtaSetItemOff (doc, view, Tools, BCellVShrink);
- TtaSetItemOff (doc, view, Tools, BSelectRow);
- TtaSetItemOff (doc, view, Tools, BCreateRowB);
- TtaSetItemOff (doc, view, Tools, BCreateRowA);
- TtaSetItemOff (doc, view, Tools, BSelectColumn);
- TtaSetItemOff (doc, view, Tools, BCreateColumnB);
- TtaSetItemOff (doc, view, Tools, BCreateColumnA);
- TtaSetItemOff (doc, view, Tools, BPasteBefore);
- TtaSetItemOff (doc, view, Tools, BPasteAfter);
- }
- }
- /*----------------------------------------------------------------------
- UpdateEditorMenus
- Update windows menus for the Editor mode
- ----------------------------------------------------------------------*/
- void UpdateEditorMenus (Document doc)
- {
- View view;
- int profile;
- ThotBool isXhtml11;
- if (DocumentTypes[doc] == docLog || DocumentTypes[doc] == docBookmark ||
- DocumentMeta[doc] == NULL || DocumentMeta[doc]->method == CE_HELP)
- return;
- // first get menu updates attached to the document profile
- TtaUpdateMenus (doc, 1, FALSE);
- profile = TtaGetDocumentProfile (doc);
- isXhtml11 = (DocumentMeta[doc] && DocumentMeta[doc]->xmlformat &&
- profile != L_Strict && profile != L_Basic);
- if (DocumentTypes[doc] == docCSS || DocumentTypes[doc] == docText ||
- DocumentTypes[doc] == docImage)
- TtaSetItemOff (doc, 1, Style, BShowAppliedStyle);
- else
- TtaSetItemOn (doc, 1, Style, BShowAppliedStyle);
- /* update specific menu entries */
- if (DocumentTypes[doc] == docHTML)
- TtaSetMenuOn (doc, 1, Types);
- /* Update the doctype menu */
- UpdateDoctypeMenu (doc);
- UpdateTemplateMenus (doc);
- if (DocumentTypes[doc] == docCSS || DocumentTypes[doc] == docSource ||
- DocumentTypes[doc] == docText || DocumentTypes[doc] == docImage)
- {
- TtaSetMenuOff (doc, 1, Types);
- TtaSetMenuOff (doc, 1, Tools);
- TtaSetMenuOff (doc, 1, Links);
- TtaSetItemOff (doc, 1, Views, TShowMapAreas);
- TtaSetItemOff (doc, 1, Views, TShowTargets);
- TtaSetItemOff (doc, 1, Views, BShowSource);
- if (DocumentTypes[doc] != docSource)
- {
- TtaSetItemOff (doc, 1, Views, BShowStructure);
- TtaSetItemOff (doc, 1, Views, BShowFormatted);
- TtaSetItemOff (doc, 1, Views, BShowLinks);
- TtaSetItemOff (doc, 1, Views, BShowAlternate);
- TtaSetItemOff (doc, 1, Views, BShowToC);
- TtaSetItemOff (doc, 1, Views, TSplitHorizontally);
- TtaSetItemOff (doc, 1, Views, TSplitVertically);
- }
- TtaSetMenuOff (doc, 1, Style);
- }
- else
- {
- TtaSetItemOn (doc, 1, Views, TShowTargets);
- TtaSetItemOn (doc, 1, Views, BShowSource);
- TtaSetItemOn (doc, 1, Views, BShowStructure);
- TtaSetItemOn (doc, 1, Views, BShowFormatted);
- TtaSetItemOn (doc, 1, Views, TSplitHorizontally);
- TtaSetItemOn (doc, 1, Views, TSplitVertically);
- if (DocumentTypes[doc] == docXml || DocumentTypes[doc] == docTemplate)
- {
- TtaSetItemOff (doc, 1, Views, BShowAlternate);
- TtaSetItemOff (doc, 1, Views, BShowToC);
- //TtaSetMenuOff (doc, 1, Style);
- }
- else if (DocumentTypes[doc] == docHTML)
- {
- TtaSetItemOn (doc, 1, Views, TShowMapAreas);
- TtaSetItemOn (doc, 1, Views, BShowLinks);
- TtaSetItemOn (doc, 1, Views, BShowAlternate);
- TtaSetItemOn (doc, 1, Views, BShowToC);
- /* structure information is active only in the structure view */
- if (profile == L_Basic)
- {
- TtaSetItemOff (doc, 1, Types, BStyle);
- TtaSetItemOff (doc, 1, Types, BScript);
- TtaSetItemOff (doc, 1, Types, BNoScript);
- }
- else
- {
- TtaSetItemOn (doc, 1, Types, BStyle);
- TtaSetItemOn (doc, 1, Types, BScript);
- TtaSetItemOn (doc, 1, Types, BNoScript);
- }
- /* invalid all table edits as long as the selection is out of a table */
- if (TtaIsDocumentSelected (doc))
- SetTableMenuOn (doc, 1);
- else
- SetTableMenuOff (doc, 1);
-
- if (IsXMLDocType (doc))
- {
- TtaSetItemOn (doc, 1, Tools, BSpellCheck);
- TtaSetMenuOn (doc, 1, Style);
- if (DocumentTypes[doc] == docMath)
- TtaSetItemOn (doc, 1, Tools, BTransform);
- else
- {
- if (DocumentTypes[doc] == docHTML)
- TtaSetItemOn (doc, 1, Tools, BTransform);
- TtaSetMenuOn (doc, 1, Types);
- TtaSetMenuOn (doc, 1, Links);
-
- }
-
- view = TtaGetViewFromName (doc, "Structure_view");
- if (view != 0 && TtaIsViewOpen (doc, view))
- {
- /* update specific menu entries */
- TtaSetItemOn (doc, view, Edit_, BCut);
- TtaSetItemOn (doc, view, Edit_, BPaste);
- TtaSetItemOn (doc, view, Edit_, BClear);
- TtaSetItemOn (doc, view, Tools, BSpellCheck);
- TtaSetItemOn (doc, view, Tools, BTransform);
- if (DocumentTypes[doc] != docMath)
- TtaSetMenuOn (doc, view, Types);
- }
- view = TtaGetViewFromName (doc, "Alternate_view");
- if (view != 0 && TtaIsViewOpen (doc, view))
- {
- /* update specific menu entries */
- TtaSetItemOn (doc, view, Edit_, BCut);
- TtaSetItemOn (doc, view, Edit_, BPaste);
- TtaSetItemOn (doc, view, Edit_, BClear);
- TtaSetItemOn (doc, view, Tools, BSpellCheck);
- }
- view = TtaGetViewFromName (doc, "Links_view");
- if (view != 0 && TtaIsViewOpen (doc, view))
- {
- /* update specific menu entries */
- TtaSetItemOn (doc, view, Edit_, BCut);
- TtaSetItemOn (doc, view, Edit_, BPaste);
- TtaSetItemOn (doc, view, Edit_, BClear);
- TtaSetItemOn (doc, view, Tools, BSpellCheck);
- TtaSetItemOn (doc, view, Tools, BTransform);
- if (DocumentTypes[doc] != docMath)
- TtaSetMenuOn (doc, view, Types);
- }
- view = TtaGetViewFromName (doc, "Table_of_contents");
- if (view != 0 && TtaIsViewOpen (doc, view))
- {
- /* update specific menu entries */
- TtaSetItemOn (doc, view, Edit_, BCut);
- TtaSetItemOn (doc, view, Edit_, BPaste);
- TtaSetItemOn (doc, view, Edit_, BClear);
- TtaSetItemOn (doc, view, Tools, BSpellCheck);
- TtaSetItemOn (doc, view, Tools, BTransform);
- }
- }
- }
- else if (TtaIsDocumentSelected (doc))
- SetTableMenuOn (doc, 1);
- }
- #ifdef _JAVA
- /* Update the javascript menus */
- UpdateJavascriptMenus ();
- #endif /* _JAVA */
-
- // Is it an annotation ?
- if (DocumentTypes[doc] == docAnnot)
- {
- TtaSetItemOn (doc, 1, Tools, BDeleteAnnot);
- TtaSetItemOn (doc, 1, Tools, BReplyToAnnotation);
- TtaSetItemOn (doc, 1, Tools, BPostAnnot);
- }
- else
- {
- TtaSetItemOff (doc, 1, Tools, BDeleteAnnot);
- TtaSetItemOff (doc, 1, Tools, BReplyToAnnotation);
- TtaSetItemOff (doc, 1, Tools, BPostAnnot);
- }
- TtaRefreshTopMenuStats (doc, -1);
- }
- /*----------------------------------------------------------------------
- StartACopyCommand says that a new copy command starts
- ----------------------------------------------------------------------*/
- void StartACopyCommand (Document doc, View view)
- {
- #ifdef _SVG
- ClearSVGDefs ();
- #endif /* _SVG */
- }
- /*----------------------------------------------------------------------
- ShowLogFile
- Show error messages generated by the parser.
- -----------------------------------------------------------------------*/
- void ShowLogFile (Document doc, View view)
- {
- char fileName[500];
- int newdoc, d;
- // prevent multiple open
- if (CriticLogError)
- return;
- CriticLogError = TRUE;
- if (DocumentTypes[doc] == docSource)
- doc = GetDocFromSource (doc);
- if (doc)
- {
- sprintf (fileName, "%s%c%d%cPARSING.ERR",
- TempFileDirectory, DIR_SEP, doc, DIR_SEP);
- // check if the log file is already open
- for (d = 1; d < MAX_DOCUMENTS; d++)
- {
- if (DocumentURLs[d] && !strcmp (DocumentURLs[d], fileName))
- {
- CriticLogError = FALSE;
- return;
- }
- }
- newdoc = GetAmayaDoc (fileName, NULL, 0, doc, CE_LOG, FALSE,
- NULL, NULL);
- /* store the relation with the original document */
- if (newdoc)
- {
- DocumentSource[newdoc] = doc;
- TtaSetStatus (newdoc, 1, " ", NULL);
- }
- }
- CriticLogError = FALSE;
- }
- /*----------------------------------------------------------------------
- MenuShowLogFile
- Show error messages generated by the parser.
- -----------------------------------------------------------------------*/
- void MenuShowLogFile (Document doc, View view)
- {
- ShowLogFile (doc, view);
- }
- /*----------------------------------------------------------------------
- OpenParsingErrors
- ----------------------------------------------------------------------*/
- ThotBool OpenParsingErrors (Document document)
- {
- char fileName[200];
- if (document == 0 || DocumentTypes[document] == docFree)
- return FALSE;
- sprintf (fileName, "%s%c%d%cPARSING.ERR",
- TempFileDirectory, DIR_SEP, document, DIR_SEP);
- /* check what error file is open */
- if (DocumentTypes[document] == docCSS)
- {
- CSSErrFile = TtaWriteOpen (fileName);
- if ((CSSErrFile == NULL))
- return FALSE;
- else
- fprintf (CSSErrFile, TtaGetMessage (AMAYA, AM_LINK_LINE));
- }
- else
- {
- ErrFile = TtaWriteOpen (fileName);
- if ((ErrFile == NULL))
- return FALSE;
- else
- fprintf (ErrFile, TtaGetMessage (AMAYA, AM_LINK_LINE));
- }
- return TRUE;
- }
- /*----------------------------------------------------------------------
- RemoveParsingErrors
- ----------------------------------------------------------------------*/
- void RemoveParsingErrors (Document document)
- {
- char htmlErrFile[200];
-
- sprintf (htmlErrFile, "%s%c%d%cPARSING.ERR",
- TempFileDirectory, DIR_SEP, document, DIR_SEP);
- if (TtaFileExist (htmlErrFile))
- TtaFileUnlink (htmlErrFile);
- }
- /*----------------------------------------------------------------------
- HasParsingErrors
- ----------------------------------------------------------------------*/
- ThotBool HasParsingErrors (Document document)
- {
- char htmlErrFile[200];
-
- sprintf (htmlErrFile, "%s%c%d%cPARSING.ERR",
- TempFileDirectory, DIR_SEP, document, DIR_SEP);
- return TtaFileExist (htmlErrFile);
- }
- /*----------------------------------------------------------------------
- CleanUpParsingErrors
- Initialize the 'PARSING.ERR' file and the related global variables
- ----------------------------------------------------------------------*/
- void CleanUpParsingErrors ()
- {
- HTMLErrorsFound = FALSE;
- XMLErrorsFound = FALSE;
- CSSErrorsFound = FALSE;
- XMLErrorsFoundInProfile = FALSE;
- XMLNotWellFormed = FALSE;
- XMLInvalidToken = FALSE;
- XMLUnknownEncoding = FALSE;
- XMLCharacterNotSupported = FALSE;
- /* close the error file */
- if (ErrFile)
- {
- TtaWriteClose (ErrFile);
- ErrFile = NULL;
- }
- }
- /*----------------------------------------------------------------------
- UpdateLogFile enables/disables the logerror button and the menu entry
- ----------------------------------------------------------------------*/
- void UpdateLogFile (Document doc, ThotBool enable)
- {
- if (doc == 0 || DocumentTypes[doc] == docLog ||
- (DocumentMeta[doc] && DocumentMeta[doc]->method == CE_HELP))
- return;
- TtaToggleLogError (doc, enable);
- if (enable)
- TtaSetItemOn (doc, 1, Views, BShowLogFile);
- else
- TtaSetItemOff (doc, 1, Views, BShowLogFile);
- if (DocumentSource[doc])
- {
- /* update the document source too */
- if (enable)
- TtaSetItemOn (DocumentSource[doc], 1, Views, BShowLogFile);
- else
- TtaSetItemOff (DocumentSource[doc], 1, Views, BShowLogFile);
- }
- }
- /*----------------------------------------------------------------------
- UpdateShowError the logerror button and the menu entry
- ----------------------------------------------------------------------*/
- void UpdateShowError (Document doc, View view)
- {
- char fileName[500];
- if (DocumentTypes[doc] == docSource)
- doc = GetDocFromSource (doc);
- if (doc)
- {
- sprintf (fileName, "%s%c%d%cPARSING.ERR",
- TempFileDirectory, DIR_SEP, doc, DIR_SEP);
- if (TtaFileExist (fileName))
- UpdateLogFile (doc, TRUE);
- else
- UpdateLogFile (doc, FALSE);
- }
- }
- /*----------------------------------------------------------------------
- CheckParsingErrors
- Checks the errors during the parsing of the document and active
- (or not) the Show Log File menu entry
- ----------------------------------------------------------------------*/
- void CheckParsingErrors (Document doc)
- {
- char *ptr;
- char fileName[200];
- char text [200];
- ThotBool closeLog = FALSE;
- ThotBool retry = FALSE;
- // Avoid recursive call
- if (CriticCheckError)
- return;
- CriticCheckError = TRUE;
- CloseLogs (doc);
- closeLog = TRUE;
- #ifdef _JAVA
- /* The document contains error : switch OFF the Javascipt/DOM */
- if(BADMimeType || ErrFile)
- StopJavascript(doc);
- #endif /* _JAVA */
- if (BADMimeType)
- {
- /* the mime type doesn't match the doctype */
- InitConfirm (doc, 1, TtaGetMessage (AMAYA, AM_INVALID_MIMETYPE));
- BADMimeType = FALSE;
- }
- if (ErrFile)
- {
- /* Activate the menu entry */
- UpdateLogFile (doc, TRUE);
- if (XMLCharacterNotSupported || XMLInvalidToken)
- {
- /* Invalid characters */
- if (XMLInvalidToken)
- ptr = TtaGetMessage (AMAYA, AM_XML_CHARACTER_RETRY);
- else
- ptr = TtaGetMessage (AMAYA, AM_XML_CHARACTER_ERROR);
- InitConfirm3L (doc, 1,
- TtaGetMessage (AMAYA, AM_XML_CHARACTER_ERROR),
- TtaGetMessage (AMAYA, AM_XML_CHARACTER_RETRY),
- NULL, FALSE);
- CleanUpParsingErrors ();
- }
- else if (XMLNotWellFormed)
- /* not a well-formed XML document */
- {
- /* If it's a XHTML document, try to read it again, but as plain HTML*/
- retry = FALSE;
- if (DocumentTypes[doc] == docHTML)
- /* it's a XHTML document */
- {
- if (!DocumentMeta[doc] || !DocumentMeta[doc]->compound)
- /* we have not yet encountered any MathML or SVG element in the
- document */
- {
- /* have we already met some namespace declarations with
- prefixes ? The HTML parser cannot handle prefixed tag
- names */
- if (!TtaDocumentUsesNsPrefixes(doc))
- retry = TRUE;
- }
- }
- if (retry)
- {
- ptr = TtaGetMessage (AMAYA, AM_XML_RETRY);
- // save the original log file
- sprintf (fileName, "%s%c%d%cPARSING.ERR",
- TempFileDirectory, DIR_SEP, doc, DIR_SEP);
- strcpy (text, fileName);
- strcat (text, ".org");
- CleanUpParsingErrors ();
- CloseLogs (doc);
- TtaFileUnlink (text);
- TtaFileRename (fileName, text);
- ParseAsHTML (doc, 1);
- // reset XML format for future saving
- DocumentMeta[doc]->xmlformat = TRUE;
- // restore the original log file
- CleanUpParsingErrors ();
- CloseLogs (doc);
- TtaFileUnlink (fileName);
- TtaFileRename (text, fileName);
- closeLog = TRUE;
- if (SavingDocument && SavingDocument == DocumentSource[doc])
- {
- ConfirmError (doc, 1, ptr,
- TtaGetMessage (AMAYA, AM_SAVE_ANYWAY),
- NULL);
- if (!ExtraChoice && !UserAnswer)
- // GTK or WX version: stop the save process
- SavingDocument = 0;
- }
- else
- {
- //InitConfirm3L (doc, 1, ptr, NULL, NULL, FALSE);
- ConfirmError (doc, 1, ptr,
- TtaGetMessage (AMAYA, AM_AFILTER_SHOW),
- NULL);
- if (ExtraChoice || UserAnswer)
- {
- ShowSource (doc, 1);
- // GTK or WX version: show errors
- ShowLogFile (doc, 1);
- }
- }
- }
- else
- // we can't rescue the document
- {
- ptr = TtaGetMessage (AMAYA, AM_XML_ERROR);
- if (SavingDocument == DocumentSource[doc])
- // stop the save process
- SavingDocument = 0;
- // Set the document in read-only mode
- TtaSetDocumentAccessMode (doc, 0);
- ConfirmError (doc, 1, ptr,
- TtaGetMessage (AMAYA, AM_AFILTER_SHOW),
- NULL);
- if (ExtraChoice || UserAnswer)
- {
- // GTK or WX version: show errors
- CleanUpParsingErrors ();
- CloseLogs (doc);
- closeLog = TRUE;
- ShowLogFile (doc, 1);
- ShowSource (doc, 1);
- }
- }
- }
- CleanUpParsingErrors ();
- if (!closeLog)
- {
- CloseLogs (doc);
- UpdateLogFile (doc, TRUE);
- }
- }
- else
- {
- // no log file
- CloseLogs (doc);
- UpdateLogFile (doc, FALSE);
- }
- CriticCheckError = FALSE;
- }
- /*----------------------------------------------------------------------
- UpdateTransfer updates the status of the current transfer
- ----------------------------------------------------------------------*/
- void UpdateTransfer (Document document)
- {
- if (document)
- FilesLoading[document]++;
- }
- /*----------------------------------------------------------------------
- StopTransfer stops the current transfer
- ----------------------------------------------------------------------*/
- void StopTransfer (Document document, View view)
- {
- if (document == 0)
- return;
- else if (document ==…
Large files files are truncated, but you can click here to view the full file