Annotation of Amaya/amaya/XLinkedit.c, revision 1.3

1.1       cvs         1: /*
                      2:  *
                      3:  *  (c) COPYRIGHT MIT and INRIA, 2000
                      4:  *  Please first read the full copyright statement in file COPYRIGHT.
                      5:  *
                      6:  */
                      7: 
                      8: /*
                      9:  * This module contains editing functions for handling XLink hypertext links
                     10:  *
                     11:  * Author: V. Quint
                     12:  *
                     13:  */
                     14: 
                     15: /* Included headerfiles */
                     16: #define THOT_EXPORT
                     17: #include "amaya.h"
                     18: #include "XLink.h"
                     19: 
1.2       cvs        20: #include "HTMLedit_f.h"
                     21: 
1.1       cvs        22: /*----------------------------------------------------------------------
                     23:    SetXLinkTypeSimple attach an attribute xlink:type="simple" to element el
                     24:   ----------------------------------------------------------------------*/
                     25: #ifdef __STDC__
                     26: void         SetXLinkTypeSimple (Element el, Document doc, ThotBool withUndo)
                     27: #else  /* __STDC__ */
                     28: void         SetXLinkTypeSimple (el, doc, withUndo)
                     29: Element             el;
                     30: Document     doc;
                     31: ThotBool     withUndo;
                     32: 
                     33: #endif /* __STDC__ */
                     34: {
                     35:   AttributeType        attrType;
                     36:   Attribute    attr;
                     37:   SSchema       XLinkSchema;
                     38:   ThotBool     new;
                     39: 
1.3     ! cvs        40:   XLinkSchema = TtaGetSSchema ("XLink", doc);
1.1       cvs        41:   attrType.AttrSSchema = XLinkSchema;
                     42:   attrType.AttrTypeNum = XLink_ATTR_type;
                     43:   attr = TtaGetAttribute (el, attrType);
                     44:   if (attr == NULL)
                     45:     {
                     46:       attr = TtaNewAttribute (attrType);
                     47:       TtaAttachAttribute (el, attr, doc);
                     48:       new = TRUE;
                     49:     }
                     50:   else
                     51:     {
                     52:       new = FALSE;
                     53:       if (withUndo)
                     54:        TtaRegisterAttributeReplace (attr, el, doc);
                     55:     }
                     56:   TtaSetAttributeValue (attr, XLink_ATTR_type_VAL_simple, el, doc);
                     57:   if (new && withUndo)
                     58:     TtaRegisterAttributeCreate (attr, el, doc);
                     59: }
                     60: 
                     61: /*----------------------------------------------------------------------
                     62:  XLinkPasted
1.2       cvs        63:  An element from any namespace has been pasted.
1.1       cvs        64:  If it has some XLink attributes, update the link.
                     65:  -----------------------------------------------------------------------*/
                     66: #ifdef __STDC__
                     67: void XLinkPasted (NotifyElement *event)
                     68: #else /* __STDC__*/
                     69: void XLinkPasted(event)
                     70:      NotifyElement *event;
                     71: #endif /* __STDC__*/
                     72: {
1.2       cvs        73:   Document       originDocument;
                     74:   AttributeType  attrType;
                     75:   Attribute      attr;
                     76:   SSchema        XLinkSchema;
                     77: 
                     78:   /* does the pasted element come from another document? */
                     79:   originDocument = (Document) event->position;
                     80:   if (originDocument > 0 && originDocument != event->document)
                     81:     /* this element has changed document. Check its links */
                     82:     {
1.3     ! cvs        83:     XLinkSchema = TtaGetSSchema ("XLink", event->document);
1.2       cvs        84:     if (XLinkSchema)
                     85:       {
                     86:       /* is there an href attribute from the XLink namespace? */
                     87:       attrType.AttrSSchema = XLinkSchema;
                     88:       attrType.AttrTypeNum = XLink_ATTR_href_;
                     89:       attr = TtaGetAttribute (event->element, attrType);
                     90:       if (attr)
                     91:        /* the pasted element has an href attribute. Update the value
                     92:           of that attribute */
                     93:         ChangeURI (event->element, attr, originDocument, event->document);
                     94:       }
                     95:     }
1.1       cvs        96: }

Webmaster