Code

Translations. French translation minor update.
[inkscape.git] / src / id-clash.cpp
index b215576a4d506f8ca39fc9a875313dfe31edf0e4..0594fe8e66f6191d82faf2169bd553e98a12f659 100644 (file)
@@ -1,9 +1,10 @@
-#define __ID_CLASH_C__
 /** \file
  * Routines for resolving ID clashes when importing or pasting.
  *
  * Authors:
  *   Stephen Silver <sasilver@users.sourceforge.net>
+ *   Jon A. Cruz <jon@joncruz.org>
+ *   Abhishek Sharma
  *
  * Copyright (C) 2008 authors
  *
@@ -132,7 +133,7 @@ find_references(SPObject *elem, refmap_type *refmap)
         if (paint->isPaintserver() && paint->value.href) {
             const SPObject *obj = paint->value.href->getObject();
             if (obj) {
-                const gchar *id = SP_OBJECT_ID(obj);
+                const gchar *id = obj->getId();
                 IdReference idref = { REF_STYLE, elem, SPIPaint_properties[i] };
                 (*refmap)[id].push_back(idref);
             }
@@ -144,7 +145,7 @@ find_references(SPObject *elem, refmap_type *refmap)
     if (filter->href) {
         const SPObject *obj = filter->href->getObject();
         if (obj) {
-            const gchar *id = SP_OBJECT_ID(obj);
+            const gchar *id = obj->getId();
             IdReference idref = { REF_STYLE, elem, "filter" };
             (*refmap)[id].push_back(idref);
         }
@@ -164,9 +165,8 @@ find_references(SPObject *elem, refmap_type *refmap)
         }
     }
     
-    /* recurse */
-    for (SPObject *child = sp_object_first_child(elem);
-         child; child = SP_OBJECT_NEXT(child) )
+    // recurse
+    for (SPObject *child = elem->firstChild(); child; child = child->getNext() )
     {
         find_references(child, refmap);
     }
@@ -181,7 +181,7 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc,
                     SPObject *elem, const refmap_type *refmap,
                     id_changelist_type *id_changes)
 {
-    const gchar *id = SP_OBJECT_ID(elem);
+    const gchar *id = elem->getId();
 
     if (id && current_doc->getObjectById(id)) {
         // Choose a new ID.
@@ -203,9 +203,8 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc,
             id_changes->push_back(id_changeitem_type(elem, old_id));
     }
 
-    /* recurse */
-    for (SPObject *child = sp_object_first_child(elem);
-         child; child = SP_OBJECT_NEXT(child) )
+    // recurse
+    for (SPObject *child = elem->firstChild(); child; child = child->getNext() )
     {
         change_clashing_ids(imported_doc, current_doc, child, refmap, id_changes);
     }
@@ -226,7 +225,7 @@ fix_up_refs(const refmap_type *refmap, const id_changelist_type &id_changes)
         const std::list<IdReference>::const_iterator it_end = pos->second.end();
         for (it = pos->second.begin(); it != it_end; ++it) {
             if (it->type == REF_HREF) {
-                gchar *new_uri = g_strdup_printf("#%s", SP_OBJECT_ID(obj));
+                gchar *new_uri = g_strdup_printf("#%s", obj->getId());
                 SP_OBJECT_REPR(it->elem)->setAttribute(it->attr, new_uri);
                 g_free(new_uri);
             }
@@ -234,13 +233,13 @@ fix_up_refs(const refmap_type *refmap, const id_changelist_type &id_changes)
                 sp_style_set_property_url(it->elem, it->attr, obj, false);
             }
             else if (it->type == REF_URL) {
-                gchar *url = g_strdup_printf("url(#%s)", SP_OBJECT_ID(obj));
+                gchar *url = g_strdup_printf("url(#%s)", obj->getId());
                 SP_OBJECT_REPR(it->elem)->setAttribute(it->attr, url);
                 g_free(url);
             }
             else if (it->type == REF_CLIPBOARD) {
                 SPCSSAttr *style = sp_repr_css_attr(SP_OBJECT_REPR(it->elem), "style");
-                gchar *url = g_strdup_printf("url(#%s)", SP_OBJECT_ID(obj));
+                gchar *url = g_strdup_printf("url(#%s)", obj->getId());
                 sp_repr_css_set_property(style, it->attr, url);
                 g_free(url);
                 gchar *style_string = sp_repr_css_write_string(style);
@@ -263,7 +262,7 @@ prevent_id_clashes(SPDocument *imported_doc, SPDocument *current_doc)
 {
     refmap_type *refmap = new refmap_type;
     id_changelist_type id_changes;
-    SPObject *imported_root = SP_DOCUMENT_ROOT(imported_doc);
+    SPObject *imported_root = imported_doc->getRoot();
         
     find_references(imported_root, refmap);
     change_clashing_ids(imported_doc, current_doc, imported_root, refmap,