Code

Mnemonics in "Fill and stroke", "Align and distribute", and "Transform" dialogs ...
[inkscape.git] / src / sp-anchor.cpp
index 5d61d543b08bf97b368fd68ce069ca29c0cd7748..e57ac8a585ea0c9487fd2f5358c56a603fe4ec06 100644 (file)
@@ -1,10 +1,9 @@
-#define __SP_ANCHOR_C__
-
 /*
  * SVG <a> element implementation
  *
  * Author:
  *   Lauris Kaplinski <lauris@kaplinski.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2001-2002 Lauris Kaplinski
  * Copyright (C) 2001 Ximian, Inc.
@@ -24,6 +23,7 @@
 #include "attributes.h"
 #include "sp-anchor.h"
 #include "ui/view/view.h"
+#include "document.h"
 
 static void sp_anchor_class_init(SPAnchorClass *ac);
 static void sp_anchor_init(SPAnchor *anchor);
@@ -31,7 +31,7 @@ static void sp_anchor_init(SPAnchor *anchor);
 static void sp_anchor_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
 static void sp_anchor_release(SPObject *object);
 static void sp_anchor_set(SPObject *object, unsigned int key, const gchar *value);
-static Inkscape::XML::Node *sp_anchor_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static Inkscape::XML::Node *sp_anchor_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
 
 static gchar *sp_anchor_description(SPItem *item);
 static gint sp_anchor_event(SPItem *item, SPEvent *event);
@@ -41,7 +41,7 @@ static SPGroupClass *parent_class;
 GType sp_anchor_get_type(void)
 {
     static GType type = 0;
-    
+
     if (!type) {
         GTypeInfo info = {
             sizeof(SPAnchorClass),
@@ -57,17 +57,17 @@ GType sp_anchor_get_type(void)
         };
         type = g_type_register_static(SP_TYPE_GROUP, "SPAnchor", &info, (GTypeFlags) 0);
     }
-    
+
     return type;
 }
 
 static void sp_anchor_class_init(SPAnchorClass *ac)
 {
-    SPObjectClass *sp_object_class = (SPObjectClass *) ac; 
+    SPObjectClass *sp_object_class = (SPObjectClass *) ac;
     SPItemClass *item_class = (SPItemClass *) ac;
-    
+
     parent_class = (SPGroupClass *) g_type_class_ref(SP_TYPE_GROUP);
-    
+
     sp_object_class->build = sp_anchor_build;
     sp_object_class->release = sp_anchor_release;
     sp_object_class->set = sp_anchor_set;
@@ -88,14 +88,14 @@ static void sp_anchor_build(SPObject *object, SPDocument *document, Inkscape::XM
         ((SPObjectClass *) (parent_class))->build(object, document, repr);
     }
 
-    sp_object_read_attr(object, "xlink:type");
-    sp_object_read_attr(object, "xlink:role");
-    sp_object_read_attr(object, "xlink:arcrole");
-    sp_object_read_attr(object, "xlink:title");
-    sp_object_read_attr(object, "xlink:show");
-    sp_object_read_attr(object, "xlink:actuate");
-    sp_object_read_attr(object, "xlink:href");
-    sp_object_read_attr(object, "target");
+    object->readAttr( "xlink:type" );
+    object->readAttr( "xlink:role" );
+    object->readAttr( "xlink:arcrole" );
+    object->readAttr( "xlink:title" );
+    object->readAttr( "xlink:show" );
+    object->readAttr( "xlink:actuate" );
+    object->readAttr( "xlink:href" );
+    object->readAttr( "target" );
 }
 
 static void sp_anchor_release(SPObject *object)
@@ -142,28 +142,30 @@ static void sp_anchor_set(SPObject *object, unsigned int key, const gchar *value
 
 #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key));
 
-static Inkscape::XML::Node *sp_anchor_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
+static Inkscape::XML::Node *sp_anchor_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
 {
     SPAnchor *anchor = SP_ANCHOR(object);
 
     if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
-        repr = sp_repr_new("svg:a");
+        repr = xml_doc->createElement("svg:a");
     }
 
     repr->setAttribute("xlink:href", anchor->href);
 
     if (repr != SP_OBJECT_REPR(object)) {
-        COPY_ATTR(repr, object->repr, "xlink:type");
-        COPY_ATTR(repr, object->repr, "xlink:role");
-        COPY_ATTR(repr, object->repr, "xlink:arcrole");
-        COPY_ATTR(repr, object->repr, "xlink:title");
-        COPY_ATTR(repr, object->repr, "xlink:show");
-        COPY_ATTR(repr, object->repr, "xlink:actuate");
-        COPY_ATTR(repr, object->repr, "target");
+        // XML Tree being directly used while it shouldn't be in the
+        //  below COPY_ATTR lines
+        COPY_ATTR(repr, object->getRepr(), "xlink:type");
+        COPY_ATTR(repr, object->getRepr(), "xlink:role");
+        COPY_ATTR(repr, object->getRepr(), "xlink:arcrole");
+        COPY_ATTR(repr, object->getRepr(), "xlink:title");
+        COPY_ATTR(repr, object->getRepr(), "xlink:show");
+        COPY_ATTR(repr, object->getRepr(), "xlink:actuate");
+        COPY_ATTR(repr, object->getRepr(), "target");
     }
 
     if (((SPObjectClass *) (parent_class))->write) {
-        ((SPObjectClass *) (parent_class))->write(object, repr, flags);
+        ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags);
     }
 
     return repr;
@@ -187,7 +189,7 @@ static gchar *sp_anchor_description(SPItem *item)
 static gint sp_anchor_event(SPItem *item, SPEvent *event)
 {
     SPAnchor *anchor = SP_ANCHOR(item);
-    
+
     switch (event->type) {
        case SP_EVENT_ACTIVATE:
             if (anchor->href) {
@@ -204,7 +206,7 @@ static gint sp_anchor_event(SPItem *item, SPEvent *event)
        default:
             break;
     }
-    
+
     return FALSE;
 }