Diff for /Amaya/amaya/HTMLbook.c between versions 1.11 and 1.12

version 1.11, 1997/06/17 08:50:51 version 1.12, 1997/06/27 16:27:39
Line 496  Element             nextEl; Line 496  Element             nextEl;
   document.    document.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 #ifdef __STDC__  #ifdef __STDC__
 static void         MoveDocumentBody (Element *el, Document destDoc,  static void    MoveDocumentBody (Element *el, Document destDoc,
                                       Document sourceDoc, boolean deleteTree)                                   Document sourceDoc, char *target, boolean deleteTree)
 #else  #else
 static void         MoveDocumentBody (el, destDoc, sourceDoc, deleteTree)  static void    MoveDocumentBody (el, destDoc, sourceDoc, target, deleteTree)
 Element            *el;  Element       *el;
 Document           destDoc;  Document       destDoc;
 Document           sourceDoc;  Document       sourceDoc;
 boolean            deleteTree;  char          *target;
   boolean        deleteTree;
 #endif  #endif
 {  {
    Element         root, body, ancestor, elem, firstInserted,    Element          root, body, ancestor, elem, firstInserted;
                    lastInserted, srce, copy, old, parent, sibling;    Element          lastInserted, srce, copy, old, parent, sibling;
    ElementType     elType;    ElementType      elType;
    NotifyElement   event;    NotifyElement    event;
    int             checkingMode;    int              checkingMode;
   
    firstInserted = NULL;    firstInserted = NULL;
    /* get the BODY element of source document */    /* get the BODY element of source document */
    root = TtaGetMainRoot (sourceDoc);    root = TtaGetMainRoot (sourceDoc);
    elType = TtaGetElementType (root);    elType = TtaGetElementType (root);
    elType.ElTypeNum = HTML_EL_BODY;    elType.ElTypeNum = HTML_EL_BODY;
    body = TtaSearchTypedElement (elType, SearchForward, root);    body = TtaSearchTypedElement (elType, SearchForward, root);
    if (body != NULL)    if (body != NULL)
      {      {
      /* don't check the abstract tree against the structure schema */        /* don't check the abstract tree against the structure schema */
      checkingMode = TtaGetStructureChecking (destDoc);        checkingMode = TtaGetStructureChecking (destDoc);
      TtaSetStructureChecking (0, destDoc);        TtaSetStructureChecking (0, destDoc);
      /* get elem, the ancestor of *el which is a child of a DIV or BODY        /* get elem, the ancestor of *el which is a child of a DIV or BODY
         element in the destination document. The copied elements will be           element in the destination document. The copied elements will be
         inserted just before this element. */           inserted just before this element. */
      elem = *el;        elem = *el;
      do        do
         {          {
         ancestor = TtaGetParent (elem);            ancestor = TtaGetParent (elem);
         if (ancestor != NULL);            if (ancestor != NULL)
            {              {
            elType = TtaGetElementType (ancestor);                elType = TtaGetElementType (ancestor);
            if (elType.ElTypeNum == HTML_EL_BODY ||                if (elType.ElTypeNum == HTML_EL_BODY ||
                elType.ElTypeNum == HTML_EL_Division)                    elType.ElTypeNum == HTML_EL_Division)
               ancestor = NULL;                  ancestor = NULL;
            else                else
               elem = ancestor;                  elem = ancestor;
            }              }
         }          }
      while (ancestor != NULL);        while (ancestor != NULL);
      parent = TtaGetParent (elem);        parent = TtaGetParent (elem);
             
      /* do copy */        /* do copy */
      lastInserted = NULL;        lastInserted = NULL;
      srce = TtaGetFirstChild (body);        srce = TtaGetFirstChild (body);
      while (srce != NULL)        while (srce != NULL)
         {          {
         copy = TtaCopyTree (srce, sourceDoc, destDoc, parent);            copy = TtaCopyTree (srce, sourceDoc, destDoc, parent);
         if (copy != NULL)            if (copy != NULL)
            {              {
            if (lastInserted == NULL)                if (lastInserted == NULL)
               /* this is the first copied element. Insert it before elem */                  /* this is the first copied element. Insert it before elem */
               {                  {
               TtaInsertSibling (copy, elem, TRUE, destDoc);                    TtaInsertSibling (copy, elem, TRUE, destDoc);
               firstInserted = copy;                    firstInserted = copy;
               }                  }
            else                else
               /* insert the new copied element after the element previously                  /* insert the new copied element after the element previously
                  copied */                     copied */
               TtaInsertSibling (copy, lastInserted, FALSE, destDoc);                  TtaInsertSibling (copy, lastInserted, FALSE, destDoc);
            lastInserted = copy;                lastInserted = copy;
            /* update the NAMEs and URLs in the copied element */                /* update the NAMEs and URLs in the copied element */
            event.document = destDoc;                event.document = destDoc;
            event.position = sourceDoc;                event.position = sourceDoc;
            UpdateURLsInSubtree(&event, copy);                UpdateURLsInSubtree(&event, copy);
            }              }
         /* get the next element in the source document */            /* get the next element in the source document */
         old = srce;            old = srce;
         TtaNextSibling (&srce);            TtaNextSibling (&srce);
         if (deleteTree)            if (deleteTree)
           TtaDeleteTree (old, sourceDoc);              TtaDeleteTree (old, sourceDoc);
         }          }
         
      /* delete the element(s) containing the link to the copied document */        /* delete the element(s) containing the link to the copied document */
      /* delete the parent element of *el and all empty ancestors */        /* delete the parent element of *el and all empty ancestors */
      elem = TtaGetParent (*el);        elem = TtaGetParent (*el);
      do        do
         {          {
         sibling = elem;            sibling = elem;
         TtaNextSibling (&sibling);            TtaNextSibling (&sibling);
         if (sibling == NULL)            if (sibling == NULL)
            {              {
            sibling = elem;                sibling = elem;
            TtaPreviousSibling (&sibling);                TtaPreviousSibling (&sibling);
            if (sibling == NULL)                if (sibling == NULL)
               elem = TtaGetParent (elem);                  elem = TtaGetParent (elem);
            }              }
         }          }
      while (sibling == NULL);        while (sibling == NULL);
      TtaDeleteTree (elem, destDoc);        TtaDeleteTree (elem, destDoc);
      /* restore previous chacking mode */        /* restore previous chacking mode */
      TtaSetStructureChecking (checkingMode, destDoc);        TtaSetStructureChecking (checkingMode, destDoc);
      /* return the address of the first copied element */        /* return the address of the first copied element */
      *el = firstInserted;        *el = firstInserted;
      }      }
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
Line 616  Document            document; Line 617  Document            document;
    Attribute            RelAttr, HrefAttr;     Attribute            RelAttr, HrefAttr;
    AttributeType        attrType;     AttributeType        attrType;
    int                  length;     int                  length;
    char                 *text, *ptr;     char                 *text, *ptr, *url;
    Document             includedDocument, newdoc;     Document             includedDocument, newdoc;
   
    attrType.AttrSSchema = TtaGetDocumentSSchema (document);     attrType.AttrSSchema = TtaGetDocumentSSchema (document);
Line 651  Document            document; Line 652  Document            document;
            length = TtaGetTextAttributeLength (HrefAttr);             length = TtaGetTextAttributeLength (HrefAttr);
            text = TtaGetMemory (length + 1);             text = TtaGetMemory (length + 1);
            TtaGiveTextAttributeValue (HrefAttr, text, &length);             TtaGiveTextAttributeValue (HrefAttr, text, &length);
            /* ignore links to a particular position within a document */  
            ptr = strrchr (text, '#');             ptr = strrchr (text, '#');
            if (ptr == NULL)             url = text;
              /* this link designate the whole document */             if (ptr != NULL)
                {
                  if (ptr == text)
                    url = NULL;
                  /* link to a particular position within a document */
                  ptr[0] = EOS;
                  ptr = &ptr[1];
                }
   
              if (url != NULL)
                /* this link designate an external document */
              {               {
                /* create a new document and loads the target document */                 /* create a new document and loads the target document */
                includedDocument = TtaNewDocument ("HTML", "tmp");                 includedDocument = TtaNewDocument ("HTML", "tmp");
                TtaSetStatus (document, 1, TtaGetMessage (AMAYA, AM_FETCHING), text);                 TtaSetStatus (document, 1, TtaGetMessage (AMAYA, AM_FETCHING), url);
                newdoc = GetHTMLDocument (text, NULL, includedDocument,                 newdoc = GetHTMLDocument (url, NULL, includedDocument,
                                          document, DC_TRUE);                                           document, DC_TRUE);
                if (newdoc != 0 && newdoc != document)                 if (newdoc != 0 && newdoc != document)
                    {
                    /* it's not the document itself */                     /* it's not the document itself */
                    /* copy the target document at the position of the link */                     /* copy the target document at the position of the link */
                    MoveDocumentBody (&next, document, newdoc,                     MoveDocumentBody (&next, document, newdoc, ptr,
                                      newdoc == includedDocument);                                       newdoc == includedDocument);
                    }
                FreeDocumentResource (includedDocument);                 FreeDocumentResource (includedDocument);
                TtaCloseDocument (includedDocument);                 TtaCloseDocument (includedDocument);
              }               }
                
            TtaFreeMemory (text);             TtaFreeMemory (text);
          }           }
        return (next);         return (next);

Removed from v.1.11  
changed lines
  Added in v.1.12


Webmaster