Code

Cleanup on id access.
authorJon A. Cruz <jon@joncruz.org>
Tue, 2 Mar 2010 06:10:16 +0000 (22:10 -0800)
committerJon A. Cruz <jon@joncruz.org>
Tue, 2 Mar 2010 06:10:16 +0000 (22:10 -0800)
29 files changed:
src/conn-avoid-ref.cpp
src/connector-context.cpp
src/desktop.cpp
src/dialogs/export.cpp
src/dialogs/item-properties.cpp
src/extension/execution-env.cpp
src/extension/implementation/script.cpp
src/extension/init.cpp
src/extension/internal/javafx-out.cpp
src/extension/internal/pov-out.cpp
src/gradient-chemistry.cpp
src/graphlayout/graphlayout.cpp
src/id-clash.cpp
src/interface.cpp
src/main.cpp
src/selection-chemistry.cpp
src/selection-describer.cpp
src/sp-conn-end-pair.cpp
src/sp-namedview.cpp
src/sp-object.cpp
src/sp-object.h
src/style.cpp
src/ui/dialog/filter-effects-dialog.cpp
src/ui/dialog/icon-preview.cpp
src/ui/dialog/layers.cpp
src/ui/dialog/svg-fonts-dialog.cpp
src/ui/dialog/swatches.cpp
src/unclump.cpp
src/widgets/gradient-vector.cpp

index b2aa0ce6bc1e9877242de5f3697a7a90048c410f..88c84a84c449333d5d18cc94d3fcf10ff53e1547 100644 (file)
@@ -341,7 +341,7 @@ GSList *SPAvoidRef::getAttachedShapes(const unsigned int type)
     GSList *list = NULL;
 
     Avoid::IntList shapes;
-    GQuark shapeId = g_quark_from_string(item->id);
+    GQuark shapeId = g_quark_from_string(item->getId());
     item->document->router->attachedShapes(shapes, shapeId, type);
 
     Avoid::IntList::iterator finish = shapes.end();
@@ -365,7 +365,7 @@ GSList *SPAvoidRef::getAttachedConnectors(const unsigned int type)
     GSList *list = NULL;
 
     Avoid::IntList conns;
-    GQuark shapeId = g_quark_from_string(item->id);
+    GQuark shapeId = g_quark_from_string(item->getId());
     item->document->router->attachedConns(conns, shapeId, type);
 
     Avoid::IntList::iterator finish = conns.end();
index eed03385c21c25ae971627f8cc92620a65f2f5fc..ba6c067c0eb7513c8f708813a106c6d688af5667 100644 (file)
@@ -590,7 +590,7 @@ conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p, gchar **href, gchar
     {
         p = cc->active_handle->pos;
         const ConnectionPoint& cp = cc->connpthandles[cc->active_handle];
-        *href = g_strdup_printf("#%s", SP_OBJECT_ID(cc->active_shape));
+        *href = g_strdup_printf("#%s", cc->active_shape->getId());
         *cpid = g_strdup_printf("%c%d", cp.type == ConnPointDefault ? 'd' : 'u' , cp.id);
         return true;
     }
index 32d25164f5b628c1cc446a3e392c3deb8c7df822..52f1725779a2b0a00fd89c704b04bf6a8995920c 100644 (file)
@@ -1635,7 +1635,7 @@ static void
 _reconstruction_start (SPDesktop * desktop)
 {
     // printf("Desktop, starting reconstruction\n");
-    desktop->_reconstruction_old_layer_id = g_strdup(SP_OBJECT_ID(desktop->currentLayer()));
+    desktop->_reconstruction_old_layer_id = g_strdup(desktop->currentLayer()->getId());
     desktop->_layer_hierarchy->setBottom(desktop->currentRoot());
 
     /*
index 2c04135bcdefaff6da354b369bac961b6f6ce0c1..fa0fa5b6f45741fb5a24ee86b7af7b820f005791 100644 (file)
@@ -1111,7 +1111,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base)
             const gchar *filename = SP_OBJECT_REPR(item)->attribute("inkscape:export-filename");
             gchar *path = 0;
             if (!filename) {
-                path = create_filepath_from_id (SP_OBJECT_ID(item), NULL);
+                path = create_filepath_from_id(item->getId(), NULL);
             } else {
                 path = absolutize_path_from_document_location(doc, filename);
             }
@@ -1356,51 +1356,51 @@ sp_export_browse_clicked (GtkButton */*button*/, gpointer /*userdata*/)
     gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fs), filename);
 
 #ifdef WIN32
-       // code in this section is borrowed from ui/dialogs/filedialogimpl-win32.cpp
-       OPENFILENAMEW opf;
-       WCHAR filter_string[20];
-       wcsncpy(filter_string, L"PNG#*.png##", 11);
-       filter_string[3] = L'\0';
-       filter_string[9] = L'\0';
-       filter_string[10] = L'\0';
-       WCHAR* title_string = (WCHAR*)g_utf8_to_utf16(_("Select a filename for exporting"), -1, NULL, NULL, NULL);
-       WCHAR* extension_string = (WCHAR*)g_utf8_to_utf16("*.png", -1, NULL, NULL, NULL);
-       // Copy the selected file name, converting from UTF-8 to UTF-16
-       WCHAR _filename[_MAX_PATH + 1];
+    // code in this section is borrowed from ui/dialogs/filedialogimpl-win32.cpp
+    OPENFILENAMEW opf;
+    WCHAR filter_string[20];
+    wcsncpy(filter_string, L"PNG#*.png##", 11);
+    filter_string[3] = L'\0';
+    filter_string[9] = L'\0';
+    filter_string[10] = L'\0';
+    WCHAR* title_string = (WCHAR*)g_utf8_to_utf16(_("Select a filename for exporting"), -1, NULL, NULL, NULL);
+    WCHAR* extension_string = (WCHAR*)g_utf8_to_utf16("*.png", -1, NULL, NULL, NULL);
+    // Copy the selected file name, converting from UTF-8 to UTF-16
+    WCHAR _filename[_MAX_PATH + 1];
     memset(_filename, 0, sizeof(_filename));
     gunichar2* utf16_path_string = g_utf8_to_utf16(filename, -1, NULL, NULL, NULL);
     wcsncpy(_filename, (wchar_t*)utf16_path_string, _MAX_PATH);
     g_free(utf16_path_string);
 
-       opf.hwndOwner = (HWND)(GDK_WINDOW_HWND(GTK_WIDGET(dlg)->window));
-       opf.lpstrFilter = filter_string;
-       opf.lpstrCustomFilter = 0;
-       opf.nMaxCustFilter = 0L;
-       opf.nFilterIndex = 1L;
-       opf.lpstrFile = _filename;
-       opf.nMaxFile = _MAX_PATH;
-       opf.lpstrFileTitle = NULL;
-       opf.nMaxFileTitle=0;
-       opf.lpstrInitialDir = 0;
-       opf.lpstrTitle = title_string;
-       opf.nFileOffset = 0;
-       opf.nFileExtension = 2;
-       opf.lpstrDefExt = extension_string;
-       opf.lpfnHook = NULL;
-       opf.lCustData = 0;
-       opf.Flags = OFN_PATHMUSTEXIST;
-       opf.lStructSize = sizeof(OPENFILENAMEW);
-       if (GetSaveFileNameW(&opf) != 0)
-       {
-               // Copy the selected file name, converting from UTF-16 to UTF-8
-               gchar *utf8string = g_utf16_to_utf8((const gunichar2*)opf.lpstrFile, _MAX_PATH, NULL, NULL, NULL);
-               gtk_entry_set_text (GTK_ENTRY (fe), utf8string);
+    opf.hwndOwner = (HWND)(GDK_WINDOW_HWND(GTK_WIDGET(dlg)->window));
+    opf.lpstrFilter = filter_string;
+    opf.lpstrCustomFilter = 0;
+    opf.nMaxCustFilter = 0L;
+    opf.nFilterIndex = 1L;
+    opf.lpstrFile = _filename;
+    opf.nMaxFile = _MAX_PATH;
+    opf.lpstrFileTitle = NULL;
+    opf.nMaxFileTitle=0;
+    opf.lpstrInitialDir = 0;
+    opf.lpstrTitle = title_string;
+    opf.nFileOffset = 0;
+    opf.nFileExtension = 2;
+    opf.lpstrDefExt = extension_string;
+    opf.lpfnHook = NULL;
+    opf.lCustData = 0;
+    opf.Flags = OFN_PATHMUSTEXIST;
+    opf.lStructSize = sizeof(OPENFILENAMEW);
+    if (GetSaveFileNameW(&opf) != 0)
+    {
+        // Copy the selected file name, converting from UTF-16 to UTF-8
+        gchar *utf8string = g_utf16_to_utf8((const gunichar2*)opf.lpstrFile, _MAX_PATH, NULL, NULL, NULL);
+        gtk_entry_set_text (GTK_ENTRY (fe), utf8string);
         g_object_set_data (G_OBJECT (dlg), "filename", fe);
-               g_free(utf8string);
+        g_free(utf8string);
 
-       }
-       g_free(extension_string);
-       g_free(title_string);
+    }
+    g_free(extension_string);
+    g_free(title_string);
 
 #else
     if (gtk_dialog_run (GTK_DIALOG (fs)) == GTK_RESPONSE_ACCEPT)
index 211b800dc0f66c116e721cda3ec2ef93e64dbf8c..abc45b44be8f22b97856c66a63b834e1edda1f02 100644 (file)
@@ -328,7 +328,7 @@ sp_item_widget_setup ( SPWidget *spw, Inkscape::Selection *selection )
 
         /* ID */
         w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id"));
-        gtk_entry_set_text (GTK_ENTRY (w), obj->id);
+        gtk_entry_set_text (GTK_ENTRY (w), obj->getId());
         gtk_widget_set_sensitive (w, TRUE);
         w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id_label"));
         gtk_label_set_markup_with_mnemonic (GTK_LABEL (w), _("_Id"));
@@ -439,7 +439,7 @@ sp_item_widget_label_changed( GtkWidget */*widget*/, SPWidget *spw )
     gchar *id = (gchar *) gtk_entry_get_text (GTK_ENTRY (id_entry));
     g_strcanon (id, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.:", '_');
     GtkWidget *id_label = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id_label"));
-    if (!strcmp (id, SP_OBJECT_ID(item))) {
+    if (!strcmp (id, item->getId())) {
         gtk_label_set_markup_with_mnemonic (GTK_LABEL (id_label), _("_Id"));
     } else if (!*id || !isalnum (*id)) {
         gtk_label_set_text (GTK_LABEL (id_label), _("Id invalid! "));
index e8d7c4baf3f53b198120e4da24011ef49c5649b0..7ed3891951c33a38ebd6328d7a57dfc0f3c2a4bb 100644 (file)
@@ -58,7 +58,7 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Imp
              sp_desktop_selection(desktop)->itemList();
         while ( selected != NULL ) {
             Glib::ustring selected_id;
-            selected_id = SP_OBJECT_ID(*selected);
+            selected_id = (*selected)->getId();
             _selected.insert(_selected.end(), selected_id);
             //std::cout << "Selected: " << selected_id << std::endl;
             ++selected;
@@ -127,7 +127,7 @@ ExecutionEnv::createWorkingDialog (void) {
 
     SPDesktop *desktop = (SPDesktop *)_doc;
     GtkWidget *toplevel = gtk_widget_get_toplevel(&(desktop->canvas->widget));
-    if (!toplevel || !GTK_WIDGET_TOPLEVEL (toplevel)) 
+    if (!toplevel || !GTK_WIDGET_TOPLEVEL (toplevel))
         return;
     Gtk::Window *window = Glib::wrap(GTK_WINDOW(toplevel), false);
 
index 4e8d0b3607aba700a417cd8ad14fac3df67ec525..60623191f290c3fc2e6ce53bf32f434797723504 100644 (file)
@@ -65,8 +65,8 @@ namespace Implementation {
 
 /** \brief  Make GTK+ events continue to come through a little bit
 
-       This just keeps coming the events through so that we'll make the GUI
-       update and look pretty.
+    This just keeps coming the events through so that we'll make the GUI
+    update and look pretty.
 */
 void Script::pump_events (void) {
     while ( Gtk::Main::events_pending() ) {
@@ -97,9 +97,9 @@ Script::interpreter_t const Script::interpreterTab[] = {
 
 
 /** \brief Look up an interpreter name, and translate to something that
-           is executable
+    is executable
     \param interpNameArg  The name of the interpreter that we're looking
-                             for, should be an entry in interpreterTab
+    for, should be an entry in interpreterTab
 */
 Glib::ustring Script::resolveInterpreterExecutable(const Glib::ustring &interpNameArg)
 {
@@ -739,7 +739,7 @@ void Script::effect(Inkscape::Extension::Effect *module,
         while ( selected != NULL ) {
             Glib::ustring selected_id;
             selected_id += "--id=";
-            selected_id += (*selected)->id;
+            selected_id += (*selected)->getId();
             params.insert(params.begin(), selected_id);
             ++selected;
         }
index 84cc45de965fedb98592b528521cd940646d0d6d..777e3d718379c9a473ddbd8c53c9519ea421077e 100644 (file)
@@ -124,10 +124,10 @@ update_pref(Glib::ustring const &pref_path,
     /*
     gboolean missing=TRUE;
     for (GSList *list = extension_family; list; list = g_slist_next(list)) {
-       g_assert( list->data );
+        g_assert( list->data );
 
-       Inkscape::Extension *extension;
-               extension = reinterpret_cast<Inkscape::Extension *>(list->data);
+        Inkscape::Extension *extension;
+        extension = reinterpret_cast<Inkscape::Extension *>(list->data);
 
         if (!strcmp(extension->get_id(),pref)) missing=FALSE;
     }
@@ -185,7 +185,7 @@ init()
     Internal::BlurEdge::init();
     Internal::GimpGrad::init();
     Internal::Grid::init();
-       
+
     /* Raster Effects */
 #ifdef WITH_IMAGE_MAGICK
     Internal::Bitmap::AdaptiveThreshold::init();
@@ -224,14 +224,14 @@ init()
     Internal::Bitmap::Wave::init();
 #endif /* WITH_IMAGE_MAGICK */
 
-       Internal::Filter::Filter::filters_all();
+    Internal::Filter::Filter::filters_all();
 
     /* Load search path for extensions */
     if (Inkscape::Extension::Extension::search_path.size() == 0)
     {
-       Inkscape::Extension::Extension::search_path.push_back(profile_path("extensions"));
-       
-       Inkscape::Extension::Extension::search_path.push_back(g_strdup(INKSCAPE_EXTENSIONDIR));
+        Inkscape::Extension::Extension::search_path.push_back(profile_path("extensions"));
+
+        Inkscape::Extension::Extension::search_path.push_back(g_strdup(INKSCAPE_EXTENSIONDIR));
 
     }
 
index a2f3874062bf7dcb87c04110ae44db85f722f63f..ca061a63a79f562206a2eca6e147d7fc6efd4aa4 100644 (file)
@@ -707,7 +707,7 @@ bool JavaFXOutput::doTreeRecursive(SPDocument *doc, SPObject *obj)
      * Check the type of node and process
      */
     String id;
-    if (!obj->id)
+    if (!obj->getId())
         {
         char buf[16];
         sprintf(buf, "id%d", idindex++);
@@ -715,7 +715,7 @@ bool JavaFXOutput::doTreeRecursive(SPDocument *doc, SPObject *obj)
         }
     else
         {
-        id = obj->id;
+            id = obj->getId();
         }
     if (SP_IS_ITEM(obj))
         {
@@ -773,7 +773,7 @@ bool JavaFXOutput::doBody(SPDocument *doc, SPObject *obj)
      * Check the type of node and process
      */
     String id;
-    if (!obj->id)
+    if (!obj->getId())
         {
         char buf[16];
         sprintf(buf, "id%d", idindex++);
@@ -781,7 +781,7 @@ bool JavaFXOutput::doBody(SPDocument *doc, SPObject *obj)
         }
     else
         {
-        id = obj->id;
+            id = obj->getId();
         }
 
     if (SP_IS_ITEM(obj)) {
index 1cb14fb58bd6522f0b7ed8b34af0ffb3610a4cc7..16877c370568aa6da791194362a9ddce7b91c472 100644 (file)
@@ -312,12 +312,12 @@ bool PovOutput::doCurve(SPItem *item, const String &id)
     int segmentCount = 0;
     /**
      * For all Subpaths in the <path>
-     */             
+     */
     for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit)
     {
         /**
          * For all segments in the subpath, including extra closing segment defined by 2geom
-         */                     
+         */
         for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_closed(); ++cit)
         {
 
@@ -340,14 +340,14 @@ bool PovOutput::doCurve(SPItem *item, const String &id)
     nrSegments += segmentCount;
 
     /**
-     *  at moment of writing, 2geom lacks proper initialization of empty intervals in rect...
-     */     
-    Geom::Rect cminmax( pathv.front().initialPoint(), pathv.front().initialPoint() ); 
-   
-   
+     *   at moment of writing, 2geom lacks proper initialization of empty intervals in rect...
+     */
+    Geom::Rect cminmax( pathv.front().initialPoint(), pathv.front().initialPoint() );
+
+
     /**
      * For all Subpaths in the <path>
-     */             
+     */
     for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit)
         {
 
@@ -355,7 +355,7 @@ bool PovOutput::doCurve(SPItem *item, const String &id)
 
         /**
          * For all segments in the subpath, including extra closing segment defined by 2geom
-         */                     
+         */
         for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_closed(); ++cit)
             {
 
@@ -372,7 +372,7 @@ bool PovOutput::doCurve(SPItem *item, const String &id)
                 nrNodes += 8;
                 }
             else if(Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const*>(&*cit))
-                           {
+            {
                 std::vector<Geom::Point> points = cubic->points();
                 Geom::Point p0 = points[0];
                 Geom::Point p1 = points[1];
@@ -383,7 +383,7 @@ bool PovOutput::doCurve(SPItem *item, const String &id)
                 nrNodes += 8;
                 }
             else
-               {
+            {
                 err("logical error, because pathv_to_linear_and_cubic_beziers was used");
                 return false;
                 }
@@ -444,7 +444,7 @@ bool PovOutput::doTreeRecursive(SPDocument *doc, SPObject *obj)
 {
 
     String id;
-    if (!obj->id)
+    if (!obj->getId())
         {
         char buf[16];
         sprintf(buf, "id%d", idIndex++);
@@ -452,7 +452,7 @@ bool PovOutput::doTreeRecursive(SPDocument *doc, SPObject *obj)
         }
     else
         {
-        id = obj->id;
+            id = obj->getId();
         }
 
     if (SP_IS_ITEM(obj))
@@ -467,9 +467,9 @@ bool PovOutput::doTreeRecursive(SPDocument *doc, SPObject *obj)
      */
     for (SPObject *child = obj->firstChild() ; child ; child = child->next)
         {
-               if (!doTreeRecursive(doc, child))
-                   return false;
-               }
+            if (!doTreeRecursive(doc, child))
+                return false;
+        }
 
     return true;
 }
@@ -610,7 +610,7 @@ void PovOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8)
         err("Could not output curves for %s", filename_utf8);
         return;
         }
-        
+
     String curveBuf = outbuf;
     outbuf.clear();
 
index 4abd7483f42207c2c968d39e51e4ea5c8da17992..d669fa378423adf446a7b0c93c7ba3479698cc48 100644 (file)
@@ -62,7 +62,7 @@ sp_gradient_ensure_vector_normalized(SPGradient *gr)
     if (gr->state == SP_GRADIENT_STATE_VECTOR) return gr;
     /* Fail, if we have wrong state set */
     if (gr->state != SP_GRADIENT_STATE_UNKNOWN) {
-        g_warning("file %s: line %d: Cannot normalize private gradient to vector (%s)", __FILE__, __LINE__, SP_OBJECT_ID(gr));
+        g_warning("file %s: line %d: Cannot normalize private gradient to vector (%s)", __FILE__, __LINE__, gr->getId());
         return NULL;
     }
 
@@ -1193,7 +1193,7 @@ sp_gradient_repr_set_link(Inkscape::XML::Node *repr, SPGradient *link)
 
     gchar *ref;
     if (link) {
-        gchar const *id = SP_OBJECT_ID(link);
+        gchar const *id = link->getId();
         size_t const len = strlen(id);
         ref = (gchar*) alloca(len + 2);
         *ref = '#';
index 81ea590598397ba993e4163abb4b6e456dcad680..23b0ee13b73929003e951842be1bc5d941520f86 100644 (file)
@@ -44,21 +44,21 @@ using namespace vpsc;
  * Returns true if item is a connector
  */
 bool isConnector(SPItem const *const i) {
-       SPPath *path = NULL;
-       if(SP_IS_PATH(i)) {
-               path = SP_PATH(i);
-       }
-       return path && path->connEndPair.isAutoRoutingConn();
+    SPPath *path = NULL;
+    if(SP_IS_PATH(i)) {
+        path = SP_PATH(i);
+    }
+    return path && path->connEndPair.isAutoRoutingConn();
 }
 
 struct CheckProgress : TestConvergence {
     CheckProgress(double d,unsigned i,list<SPItem *>&
-            selected,vector<Rectangle*>& rs,map<string,unsigned>& nodelookup) :
+                  selected,vector<Rectangle*>& rs,map<string,unsigned>& nodelookup) :
         TestConvergence(d,i), selected(selected), rs(rs), nodelookup(nodelookup) {}
-       bool operator()(double new_stress, double* X, double* Y) {
+    bool operator()(double new_stress, double* X, double* Y) {
         /* This is where, if we wanted to animate the layout, we would need to update
          * the positions of all objects and redraw the canvas and maybe sleep a bit
-               cout << "stress="<<new_stress<<endl;
+         cout << "stress="<<new_stress<<endl;
         cout << "x[0]="<<rs[0]->getMinX()<<endl;
         for (list<SPItem *>::iterator it(selected.begin());
             it != selected.end();
@@ -74,43 +74,43 @@ struct CheckProgress : TestConvergence {
             }
         }
         */
-               return TestConvergence::operator()(new_stress,X,Y);
-       }
+        return TestConvergence::operator()(new_stress,X,Y);
+    }
     list<SPItem *>& selected;
     vector<Rectangle*>& rs;
     map<string,unsigned>& nodelookup;
 };
 
 /**
- * Scans the items list and places those items that are 
+ * Scans the items list and places those items that are
  * not connectors in filtered
  */
 void filterConnectors(GSList const *const items, list<SPItem *> &filtered) {
-       for(GSList *i=(GSList *)items; i!=NULL; i=i->next) {
-               SPItem *item=SP_ITEM(i->data);
-               if(!isConnector(item)) {
-                       filtered.push_back(item);
-               }
-       }
+    for(GSList *i=(GSList *)items; i!=NULL; i=i->next) {
+        SPItem *item=SP_ITEM(i->data);
+        if(!isConnector(item)) {
+            filtered.push_back(item);
+        }
+    }
 }
 /**
-* Takes a list of inkscape items, extracts the graph defined by 
+* Takes a list of inkscape items, extracts the graph defined by
 * connectors between them, and uses graph layout techniques to find
 * a nice layout
 */
 void graphlayout(GSList const *const items) {
-       if(!items) {
-               return;
-       }
+    if(!items) {
+        return;
+    }
 
-       using Inkscape::Util::GSListConstIterator;
-       list<SPItem *> selected;
-       filterConnectors(items,selected);
-       if (selected.empty()) return;
+    using Inkscape::Util::GSListConstIterator;
+    list<SPItem *> selected;
+    filterConnectors(items,selected);
+    if (selected.empty()) return;
 
-       const unsigned n=selected.size();
-       //Check 2 or more selected objects
-       if (n < 2) return;
+    const unsigned n=selected.size();
+    //Check 2 or more selected objects
+    if (n < 2) return;
 
     // add the connector spacing to the size of node bounding boxes
     // so that connectors can always be routed between shapes
@@ -118,19 +118,19 @@ void graphlayout(GSList const *const items) {
     double spacing = 0;
     if(desktop) spacing = desktop->namedview->connector_spacing+0.1;
 
-       map<string,unsigned> nodelookup;
-       vector<Rectangle*> rs;
-       vector<Edge> es;
-       for (list<SPItem *>::iterator i(selected.begin());
-               i != selected.end();
-               ++i)
-       {
-               SPItem *u=*i;
-               Geom::OptRect const item_box(sp_item_bbox_desktop(u));
+    map<string,unsigned> nodelookup;
+    vector<Rectangle*> rs;
+    vector<Edge> es;
+    for (list<SPItem *>::iterator i(selected.begin());
+         i != selected.end();
+         ++i)
+    {
+        SPItem *u=*i;
+        Geom::OptRect const item_box(sp_item_bbox_desktop(u));
         if(item_box) {
             Geom::Point ll(item_box->min());
             Geom::Point ur(item_box->max());
-            nodelookup[u->id]=rs.size();
+            nodelookup[u->getId()]=rs.size();
             rs.push_back(new Rectangle(ll[0]-spacing,ur[0]+spacing,
                         ll[1]-spacing,ur[1]+spacing));
         } else {
@@ -140,29 +140,29 @@ void graphlayout(GSList const *const items) {
             // probably pretty safe to simply ignore
             //fprintf(stderr,"NULL item_box found in graphlayout, ignoring!\n");
         }
-       }
+    }
 
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-       SimpleConstraints scx,scy;
-       double ideal_connector_length = prefs->getDouble("/tools/connector/length", 100.0);
-       double directed_edge_height_modifier = 1.0;
-       
-       bool directed =       prefs->getBool("/tools/connector/directedlayout");
-       bool avoid_overlaps = prefs->getBool("/tools/connector/avoidoverlaplayout");
+    SimpleConstraints scx,scy;
+    double ideal_connector_length = prefs->getDouble("/tools/connector/length", 100.0);
+    double directed_edge_height_modifier = 1.0;
+
+    bool directed =       prefs->getBool("/tools/connector/directedlayout");
+    bool avoid_overlaps = prefs->getBool("/tools/connector/avoidoverlaplayout");
 
-       for (list<SPItem *>::iterator i(selected.begin());
-               i != selected.end();
-               ++i)
-       {
-               SPItem *iu=*i;
-        map<string,unsigned>::iterator i=nodelookup.find(iu->id);
+    for (list<SPItem *>::iterator i(selected.begin());
+         i != selected.end();
+         ++i)
+    {
+        SPItem *iu=*i;
+        map<string,unsigned>::iterator i=nodelookup.find(iu->getId());
         if(i==nodelookup.end()) {
             continue;
         }
         unsigned u=i->second;
         GSList *nlist=iu->avoidRef->getAttachedConnectors(Avoid::runningFrom);
         list<SPItem *> connectors;
-        
+
         connectors.insert<GSListConstIterator<SPItem *> >(connectors.end(),nlist,NULL);
         for (list<SPItem *>::iterator j(connectors.begin());
                 j != connectors.end();
@@ -177,35 +177,35 @@ void graphlayout(GSList const *const items) {
             } else {
                 iv=items[0];
             }
-    
+
             if (iv == NULL) {
-                // The connector is not attached to anything at the 
+                // The connector is not attached to anything at the
                 // other end so we should just ignore it.
                 continue;
             }
 
             // If iv not in nodelookup we again treat the connector
             // as disconnected and continue
-            map<string,unsigned>::iterator v_pair=nodelookup.find(iv->id);
+            map<string,unsigned>::iterator v_pair=nodelookup.find(iv->getId());
             if(v_pair!=nodelookup.end()) {
                 unsigned v=v_pair->second;
                 //cout << "Edge: (" << u <<","<<v<<")"<<endl;
                 es.push_back(make_pair(u,v));
                 if(conn->style->marker[SP_MARKER_LOC_END].set) {
                     if(directed && strcmp(conn->style->marker[SP_MARKER_LOC_END].value,"none")) {
-                        scy.push_back(new SimpleConstraint(v, u, 
+                        scy.push_back(new SimpleConstraint(v, u,
                                     (ideal_connector_length * directed_edge_height_modifier)));
                     }
                 }
             }
         }
-               if(nlist) {
-                       g_slist_free(nlist);
-               }
-       }
-       const unsigned E = es.size();
-       double eweights[E];
-       fill(eweights,eweights+E,1);
+        if(nlist) {
+            g_slist_free(nlist);
+        }
+    }
+    const unsigned E = es.size();
+    double eweights[E];
+    fill(eweights,eweights+E,1);
     vector<Component*> cs;
     connectedComponents(rs,es,scx,scy,cs);
     for(unsigned i=0;i<cs.size();i++) {
@@ -218,15 +218,15 @@ void graphlayout(GSList const *const items) {
         alg.run();
     }
     separateComponents(cs);
-       
-       for (list<SPItem *>::iterator it(selected.begin());
-               it != selected.end();
-               ++it)
-       {
-               SPItem *u=*it;
-               if(!isConnector(u)) {
-                       map<string,unsigned>::iterator i=nodelookup.find(u->id);
-                       if(i!=nodelookup.end()) {
+
+    for (list<SPItem *>::iterator it(selected.begin());
+         it != selected.end();
+         ++it)
+    {
+        SPItem *u=*it;
+        if(!isConnector(u)) {
+            map<string,unsigned>::iterator i=nodelookup.find(u->getId());
+            if(i!=nodelookup.end()) {
                 Rectangle* r=rs[i->second];
                 Geom::OptRect item_box(sp_item_bbox_desktop(u));
                 if(item_box) {
@@ -235,8 +235,8 @@ void graphlayout(GSList const *const items) {
                     sp_item_move_rel(u, Geom::Translate(dest - curr));
                 }
             }
-               }
-       }
+        }
+    }
     for(unsigned i=0;i<scx.size();i++) {
         delete scx[i];
     }
@@ -247,7 +247,7 @@ void graphlayout(GSList const *const items) {
         delete rs[i];
     }
 }
-// vim: set cindent 
+// vim: set cindent
 // vim: ts=4 sw=4 et tw=0 wm=0
 
 /*
index b215576a4d506f8ca39fc9a875313dfe31edf0e4..43ce393ddf6c82fa2999797b10664b8e2625a9d7 100644 (file)
@@ -132,7 +132,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 +144,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);
         }
@@ -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.
@@ -226,7 +226,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 +234,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);
index b29b91d18ec549badd524a56672d056865e466f5..9c187001986ecb616ebaa5f614cd0797777706a5 100644 (file)
@@ -1098,7 +1098,7 @@ sp_ui_context_menu(Inkscape::UI::View::View *view, SPItem *item)
 
     if ( group && group != dt->currentLayer() ) {
         /* TRANSLATORS: #%s is the id of the group e.g. <g id="#g7">, not a number. */
-        gchar *label=g_strdup_printf(_("Enter group #%s"), SP_OBJECT_ID(group));
+        gchar *label=g_strdup_printf(_("Enter group #%s"), group->getId());
         GtkWidget *w = gtk_menu_item_new_with_label(label);
         g_free(label);
         g_object_set_data(G_OBJECT(w), "group", group);
@@ -1316,7 +1316,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
                         const GSList *gradients = sp_document_get_resource_list(doc, "gradient");
                         for (const GSList *item = gradients; item; item = item->next) {
                             SPGradient* grad = SP_GRADIENT(item->data);
-                            if ( color.descr == grad->id ) {
+                            if ( color.descr == grad->getId() ) {
                                 if ( grad->has_stops ) {
                                     matches = grad;
                                     break;
@@ -1325,7 +1325,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
                         }
                         if (matches) {
                             colorspec = "url(#";
-                            colorspec += matches->id;
+                            colorspec += matches->getId();
                             colorspec += ")";
                         } else {
                             gchar* tmp = g_strdup_printf("#%02x%02x%02x", r, g, b);
index 4bb5dfdc12e4aa2449bb872c18c6260d8c36e894..f55731be825a80060de1b39b90d06ed0e91e35eb 100644 (file)
@@ -1212,11 +1212,11 @@ static void
 do_query_all_recurse (SPObject *o)
 {
     SPItem *item = ((SPItem *) o);
-    if (o->id && SP_IS_ITEM(item)) {
+    if (o->getId() && SP_IS_ITEM(item)) {
         Geom::OptRect area = item->getBounds(sp_item_i2doc_affine(item));
         if (area) {
             Inkscape::SVGOStringStream os;
-            os << o->id;
+            os << o->getId();
             os << "," << area->min()[Geom::X];
             os << "," << area->min()[Geom::Y];
             os << "," << area->dimensions()[Geom::X];
index 4dfb4597d0f840f604f95794d22b9a09d812a4cd..3bfde6de969c08467cf6c8475f1ec1dd3807d731 100644 (file)
@@ -333,7 +333,7 @@ void add_ids_recursive(std::vector<const gchar *> &ids, SPObject *obj)
     if (!obj)
         return;
 
-    ids.push_back(SP_OBJECT_ID(obj));
+    ids.push_back(obj->getId());
 
     if (SP_IS_GROUP(obj)) {
         for (SPObject *child = sp_object_first_child(obj) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
@@ -403,7 +403,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone)
                 if (!orig) // orphaned
                     continue;
                 for (unsigned int j = 0; j < old_ids.size(); j++) {
-                    if (!strcmp(SP_OBJECT_ID(orig), old_ids[j])) {
+                    if (!strcmp(orig->getId(), old_ids[j])) {
                         // we have both orig and clone in selection, relink
                         // std::cout << id  << " old, its ori: " << SP_OBJECT_ID(orig) << "; will relink:" << new_ids[i] << " to " << new_ids[j] << "\n";
                         gchar *newref = g_strdup_printf("#%s", new_ids[j]);
index 78cf9be33b537e48f0b3462d7ce5b935ccad77ea..9321ea0efba3a742ddb67ffe6e8805afad8de04f 100644 (file)
@@ -158,7 +158,7 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select
 
         // Parent name
         SPObject *parent = SP_OBJECT_PARENT (item);
-        gchar *parent_label = SP_OBJECT_ID(parent);
+        gchar const *parent_label = parent->getId();
         char *quoted_parent_label = xml_quote_strdup(parent_label);
         gchar *parent_name = g_strdup_printf(_("<i>%s</i>"), quoted_parent_label);
         g_free(quoted_parent_label);
index 33225f467c3055dad6a5f33cff66bc0de745443a..7f019979a7bd65b95fd3589de02aba5310a80d06 100644 (file)
@@ -63,7 +63,7 @@ SPConnEndPair::release()
         this->_connEnd[handle_ix]->ref.detach();
     }
 
-    // If the document is being destroyed then the router instance 
+    // If the document is being destroyed then the router instance
     // and the ConnRefs will have been destroyed with it.
     const bool routerInstanceExists = (_path->document->router != NULL);
 
@@ -106,12 +106,12 @@ SPConnEndPair::setAttr(unsigned const key, gchar const *const value)
         case SP_ATTR_CONNECTOR_TYPE:
             if (value && (strcmp(value, "polyline") == 0 || strcmp(value, "orthogonal") == 0)) {
                 int newconnType = strcmp(value, "polyline") ? SP_CONNECTOR_ORTHOGONAL : SP_CONNECTOR_POLYLINE;
-                
+
                 if (!_connRef)
                 {
                     _connType = newconnType;
                     Avoid::Router *router = _path->document->router;
-                    GQuark itemID = g_quark_from_string(SP_OBJECT(_path)->id);
+                    GQuark itemID = g_quark_from_string(_path->getId());
                     _connRef = new Avoid::ConnRef(router, itemID);
                     switch (newconnType)
                     {
@@ -339,7 +339,7 @@ void recreateCurve(SPCurve *curve, Avoid::ConnRef *connRef, const gdouble curvat
     if (!straight)
         route = route.curvedPolyline(curvature);
     connRef->calcRouteDist();
-    
+
     curve->reset();
 
     curve->moveto( Geom::Point(route.ps[0].x, route.ps[0].y) );
@@ -359,7 +359,7 @@ void recreateCurve(SPCurve *curve, Avoid::ConnRef *connRef, const gdouble curvat
                     break;
                 case 'C':
                     g_assert( i+2<pn );
-                    curve->curveto( p, Geom::Point(route.ps[i+1].x, route.ps[i+1].y), 
+                    curve->curveto( p, Geom::Point(route.ps[i+1].x, route.ps[i+1].y),
                             Geom::Point(route.ps[i+2].x, route.ps[i+2].y) );
                     i+=2;
                     break;
@@ -404,10 +404,10 @@ SPConnEndPair::reroutePathFromLibavoid(void)
     SPCurve *curve = _path->original_curve ?_path->original_curve : _path->curve;
 
     recreateCurve( curve, _connRef, _connCurvature );
-    
+
     Geom::Matrix doc2item = sp_item_i2doc_affine(SP_ITEM(_path)).inverse();
-    curve->transform(doc2item); 
-    
+    curve->transform(doc2item);
+
     return true;
 }
 
index 9b72a41578492440ac2257540e8a4caf893b2f5a..44c3bf62013c42d84cffbf5f6facce5f66a42c01 100644 (file)
@@ -829,7 +829,7 @@ void sp_namedview_document_from_window(SPDesktop *desktop)
         sp_repr_set_int(view, "inkscape:window-maximized", desktop->is_maximized());
     }
 
-    view->setAttribute("inkscape:current-layer", SP_OBJECT_ID(desktop->currentLayer()));
+    view->setAttribute("inkscape:current-layer", desktop->currentLayer()->getId());
 
     // restore undoability
     sp_document_set_undo_sensitive(sp_desktop_document(desktop), saved);
@@ -978,7 +978,7 @@ SPNamedView *sp_document_namedview(SPDocument *document, const gchar *id)
         return (SPNamedView *) nv;
     }
 
-    while (nv && strcmp(nv->id, id)) {
+    while (nv && strcmp(nv->getId(), id)) {
         nv = sp_item_group_get_child_by_name((SPGroup *) document->root, nv, "sodipodi:namedview");
     }
 
index 85e8a4e9ab4ad8898967f1de925bd74da2dbcb97..f77f228cbfcaff724872ebc7435a1366d7243389 100644 (file)
@@ -112,6 +112,37 @@ Inkscape::XML::NodeEventVector object_event_vector = {
     sp_object_repr_order_changed
 };
 
+// A friend class used to set internal members on SPObject so as to not expose settors in SPObject's public API
+class SPObjectImpl
+{
+public:
+
+/**
+ * Null's the id member of an SPObject without attempting to free prior contents.
+ */
+    static void setIdNull( SPObject* obj ) {
+        if (obj) {
+            obj->id = 0;
+        }
+    }
+
+/**
+ * Sets the id member of an object, freeing any prior content.
+ */
+    static void setId( SPObject* obj, gchar const* id ) {
+        if (obj && (id != obj->id) ) {
+            if (obj->id) {
+                g_free(obj->id);
+                obj->id = 0;
+            }
+            if (id) {
+                obj->id = g_strdup(id);
+            }
+        }
+    }
+};
+
+
 static GObjectClass *parent_class;
 
 /**
@@ -177,7 +208,7 @@ sp_object_init(SPObject *object)
     object->children = object->_last_child = NULL;
     object->parent = object->next = NULL;
     object->repr = NULL;
-    object->id = NULL;
+    SPObjectImpl::setIdNull(object);
 
     object->_collection_policy = SPObject::COLLECT_WITH_PARENT;
 
@@ -188,8 +219,8 @@ sp_object_init(SPObject *object)
     object->_successor = NULL;
 
     // FIXME: now we create style for all objects, but per SVG, only the following can have style attribute:
-    // vg, g, defs, desc, title, symbol, use, image, switch, path, rect, circle, ellipse, line, polyline, 
-    // polygon, text, tspan, tref, textPath, altGlyph, glyphRef, marker, linearGradient, radialGradient, 
+    // vg, g, defs, desc, title, symbol, use, image, switch, path, rect, circle, ellipse, line, polyline,
+    // polygon, text, tspan, tref, textPath, altGlyph, glyphRef, marker, linearGradient, radialGradient,
     // stop, pattern, clipPath, mask, filter, feImage, a, font, glyph, missing-glyph, foreignObject
     object->style = sp_style_new_from_object(object);
 
@@ -259,6 +290,10 @@ public:
 
 }
 
+gchar const* SPObject::getId() const {
+    return id;
+}
+
 /**
  * Increase reference count of object, with possible debugging.
  *
@@ -808,8 +843,7 @@ sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
     }
 }
 
-void
-sp_object_invoke_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned)
+void sp_object_invoke_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned)
 {
     debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object));
 
@@ -820,7 +854,7 @@ sp_object_invoke_build(SPObject *object, SPDocument *document, Inkscape::XML::No
 
     g_assert(object->document == NULL);
     g_assert(object->repr == NULL);
-    g_assert(object->id == NULL);
+    g_assert(object->getId() == NULL);
 
     /* Bookkeeping */
 
@@ -837,27 +871,30 @@ sp_object_invoke_build(SPObject *object, SPDocument *document, Inkscape::XML::No
             /* If we are not cloned, and not seeking, force unique id */
             gchar const *id = object->repr->attribute("id");
             if (!document->isSeeking()) {
-                gchar *realid = sp_object_get_unique_id(object, id);
-                g_assert(realid != NULL);
+                {
+                    gchar *realid = sp_object_get_unique_id(object, id);
+                    g_assert(realid != NULL);
 
-                object->document->bindObjectToId(realid, object);
-                object->id = realid;
+                    object->document->bindObjectToId(realid, object);
+                    SPObjectImpl::setId(object, realid);
+                    g_free(realid);
+                }
 
                 /* Redefine ID, if required */
-                if ((id == NULL) || (strcmp(id, realid) != 0)) {
-                    object->repr->setAttribute("id", realid);
+                if ((id == NULL) || (strcmp(id, object->getId()) != 0)) {
+                    object->repr->setAttribute("id", object->getId());
                 }
             } else if (id) {
                 // bind if id, but no conflict -- otherwise, we can expect
                 // a subsequent setting of the id attribute
                 if (!object->document->getObjectById(id)) {
                     object->document->bindObjectToId(id, object);
-                    object->id = g_strdup(id);
+                    SPObjectImpl::setId(object, id);
                 }
             }
         }
     } else {
-        g_assert(object->id == NULL);
+        g_assert(object->getId() == NULL);
     }
 
     /* Invoke derived methods, if any */
@@ -982,16 +1019,14 @@ sp_object_private_set(SPObject *object, unsigned int key, gchar const *value)
                     }
                 }
 
-                if (object->id) {
-                    document->bindObjectToId(object->id, NULL);
-                    g_free(object->id);
+                if (object->getId()) {
+                    document->bindObjectToId(object->getId(), NULL);
+                    SPObjectImpl::setId(object, 0);
                 }
 
                 if (new_id) {
-                    object->id = g_strdup((char const*)new_id);
-                    document->bindObjectToId(object->id, object);
-                } else {
-                    object->id = NULL;
+                    SPObjectImpl::setId(object, new_id);
+                    document->bindObjectToId(object->getId(), object);
                 }
 
                 g_free(object->_default_label);
@@ -1130,7 +1165,7 @@ sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape
             repr->setAttribute("inkscape:collect", NULL);
         }
     } else {
-        repr->setAttribute("id", object->id);
+        repr->setAttribute("id", object->getId());
 
         if (object->xml_space.set) {
             char const *xml_space;
@@ -1145,7 +1180,7 @@ sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape
         } else {
             repr->setAttribute("inkscape:collect", NULL);
         }
+
         SPStyle const *const obj_style = SP_OBJECT_STYLE(object);
         if (obj_style) {
             gchar *s = sp_style_write_string(obj_style, SP_STYLE_FLAG_IFSET);
@@ -1201,7 +1236,7 @@ SPObject::updateRepr(unsigned int flags) {
     }
 }
 
-/** Used both to create reprs in the original document, and to create 
+/** Used both to create reprs in the original document, and to create
  *  reprs in another document (e.g. a temporary document used when
  *  saving as "Plain SVG"
  */
@@ -1311,7 +1346,7 @@ SPObject::updateDisplay(SPCtx *ctx, unsigned int flags)
     }
     catch(...)
     {
-        /** \todo 
+        /** \todo
         * in case of catching an exception we need to inform the user somehow that the document is corrupted
         * maybe by implementing an document flag documentOk
         * or by a modal error dialog
@@ -1323,8 +1358,8 @@ SPObject::updateDisplay(SPCtx *ctx, unsigned int flags)
 }
 
 /**
- * Request modified always bubbles *up* the tree, as opposed to 
- * request display update, which trickles down and relies on the 
+ * Request modified always bubbles *up* the tree, as opposed to
+ * request display update, which trickles down and relies on the
  * flags set during this pass...
  */
 void
@@ -1355,9 +1390,9 @@ SPObject::requestModified(unsigned int flags)
     }
 }
 
-/** 
+/**
  *  Emits the MODIFIED signal with the object's flags.
- *  The object's mflags are the original set aside during the update pass for 
+ *  The object's mflags are the original set aside during the update pass for
  *  later delivery here.  Once emitModified() is called, those flags don't
  *  need to be stored any longer.
  */
@@ -1748,7 +1783,7 @@ SPObject::textualContent() const
     for (const SPObject *child = firstChild(); child; child = child->next)
     {
         Inkscape::XML::NodeType child_type = child->repr->type();
-        
+
         if (child_type == Inkscape::XML::ELEMENT_NODE) {
             GString * new_text = child->textualContent();
             g_string_append(text, new_text->str);
index bbb8ecbd0a2d096e14baa0ccffaad3c75dec5f6c..22a15a0a4b272a60ac4ce1b6ad2bd31ebd832156 100644 (file)
@@ -155,7 +155,15 @@ struct SPObject : public GObject {
     SPObject *_last_child; /* Remembered last child */
     SPObject *next; /* Next object in linked list */
     Inkscape::XML::Node *repr; /* Our xml representation */
+
+private:
     gchar *id; /* Our very own unique id */
+public:
+
+    /**
+     * Returns the objects current ID string.
+     */
+    gchar const* getId() const;
 
     /** @brief cleans up an SPObject, releasing its references and
      *         requesting that references to it be released
@@ -495,6 +503,8 @@ private:
     gchar * getTitleOrDesc(gchar const *svg_tagname) const;
     SPObject * findFirstChild(gchar const *tagname) const;
     GString * textualContent() const;
+
+    friend class SPObjectImpl;
 };
 
 /// The SPObject vtable.
index 111018c2a5df104a246b449010c05cd3f8d3010b..6d73e62ea37f076093b6c6fa1d607d99101dd330 100644 (file)
@@ -363,7 +363,7 @@ sp_style_filter_ref_changed(SPObject *old_ref, SPObject *ref, SPStyle *style)
     }
     if ( SP_IS_FILTER(ref))
     {
-        style->filter_modified_connection = 
+        style->filter_modified_connection =
            ref->connectModified(sigc::bind(sigc::ptr_fun(&sp_style_filter_ref_modified), style));
     }
 
@@ -416,7 +416,7 @@ sp_style_fill_paint_server_ref_changed(SPObject *old_ref, SPObject *ref, SPStyle
         style->fill_ps_modified_connection.disconnect();
     }
     if (SP_IS_PAINT_SERVER(ref)) {
-        style->fill_ps_modified_connection = 
+        style->fill_ps_modified_connection =
            ref->connectModified(sigc::bind(sigc::ptr_fun(&sp_style_paint_server_ref_modified), style));
     }
 
@@ -433,7 +433,7 @@ sp_style_stroke_paint_server_ref_changed(SPObject *old_ref, SPObject *ref, SPSty
         style->stroke_ps_modified_connection.disconnect();
     }
     if (SP_IS_PAINT_SERVER(ref)) {
-        style->stroke_ps_modified_connection = 
+        style->stroke_ps_modified_connection =
           ref->connectModified(sigc::bind(sigc::ptr_fun(&sp_style_paint_server_ref_modified), style));
     }
 
@@ -724,7 +724,7 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr)
             style->stroke_dashoffset_set = FALSE;
         }
     }
-    
+
     /* -inkscape-font-specification */
     if (!style->text_private || !style->text->font_specification.set) {
         val = repr->attribute("-inkscape-font-specification");
@@ -751,7 +751,7 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr)
     if (!style->filter.set) {
         val = repr->attribute("filter");
         if (val) {
-                     sp_style_read_ifilter(val, style, (object) ? SP_OBJECT_DOCUMENT(object) : NULL);
+            sp_style_read_ifilter(val, style, (object) ? SP_OBJECT_DOCUMENT(object) : NULL);
         }
     }
     SPS_READ_PENUM_IF_UNSET(&style->enable_background, repr,
@@ -805,21 +805,21 @@ sp_style_read_from_prefs(SPStyle *style, Glib::ustring const &path)
 {
     g_return_if_fail(style != NULL);
     g_return_if_fail(path != "");
-    
+
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
     // not optimal: we reconstruct the node based on the prefs, then pass it to
     // sp_style_read for actual processing.
     Inkscape::XML::SimpleDocument *tempdoc = new Inkscape::XML::SimpleDocument;
     Inkscape::XML::Node *tempnode = tempdoc->createElement("temp");
-    
+
     std::vector<Inkscape::Preferences::Entry> attrs = prefs->getAllEntries(path);
     for (std::vector<Inkscape::Preferences::Entry>::iterator i = attrs.begin(); i != attrs.end(); ++i) {
         tempnode->setAttribute(i->getEntryName().data(), i->getString().data());
     }
 
     sp_style_read(style, NULL, tempnode);
-    
+
     Inkscape::GC::release(tempnode);
     Inkscape::GC::release(tempdoc);
     delete tempdoc;
@@ -1949,7 +1949,7 @@ sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const pare
     if (style->text && parent->text) {
         sp_style_merge_string_prop_from_dying_parent(style->text->font_specification,
                                                      parent->text->font_specification);
-        
+
         sp_style_merge_string_prop_from_dying_parent(style->text->font_family,
                                                      parent->text->font_family);
     }
@@ -2287,10 +2287,10 @@ sp_style_write_string(SPStyle const *const style, guint const flags)
     p += sp_style_write_ipaint(p, c + BMAX - p, "stroke", &style->stroke, NULL, flags);
 
     // stroke width affects markers, so write it if there's stroke OR any markers
-    if (!style->stroke.noneSet || 
+    if (!style->stroke.noneSet ||
         style->marker[SP_MARKER_LOC].set ||
         style->marker[SP_MARKER_LOC_START].set ||
-        style->marker[SP_MARKER_LOC_MID].set || 
+        style->marker[SP_MARKER_LOC_MID].set ||
         style->marker[SP_MARKER_LOC_END].set) {
         p += sp_style_write_ilength(p, c + BMAX - p, "stroke-width", &style->stroke_width, NULL, flags);
     }
@@ -2349,7 +2349,7 @@ sp_style_write_string(SPStyle const *const style, guint const flags)
         p += g_snprintf(p, c + BMAX - p, "marker:none;");
         marker_none = true;
     }
-    if (style->marker[SP_MARKER_LOC_START].set 
+    if (style->marker[SP_MARKER_LOC_START].set
        && (!master || strcmp(master, style->marker[SP_MARKER_LOC_START].value))) {
         p += g_snprintf(p, c + BMAX - p, "marker-start:%s;", style->marker[SP_MARKER_LOC_START].value);
     } else if (flags == SP_STYLE_FLAG_ALWAYS && !marker_none) {
@@ -2450,10 +2450,10 @@ sp_style_write_difference(SPStyle const *const from, SPStyle const *const to)
     p += sp_style_write_ipaint(p, c + BMAX - p, "stroke", &from->stroke, &to->stroke, SP_STYLE_FLAG_IFDIFF);
 
     // stroke width affects markers, so write it if there's stroke OR any markers
-    if (!from->stroke.noneSet || 
+    if (!from->stroke.noneSet ||
         from->marker[SP_MARKER_LOC].set ||
         from->marker[SP_MARKER_LOC_START].set ||
-        from->marker[SP_MARKER_LOC_MID].set || 
+        from->marker[SP_MARKER_LOC_MID].set ||
         from->marker[SP_MARKER_LOC_END].set) {
         p += sp_style_write_ilength(p, c + BMAX - p, "stroke-width", &from->stroke_width, &to->stroke_width, SP_STYLE_FLAG_IFDIFF);
     }
@@ -3281,12 +3281,12 @@ sp_style_read_ifilter(gchar const *str, SPStyle * style, SPDocument *document)
         f->set = TRUE;
         f->inherit = TRUE;
         if (f->href && f->href->getObject())
-            f->href->detach(); 
+            f->href->detach();
     } else if(streq(str, "none")) {
         f->set = TRUE;
         f->inherit = FALSE;
         if (f->href && f->href->getObject())
-           f->href->detach(); 
+           f->href->detach();
     } else if (strneq(str, "url", 3)) {
         char *uri = extract_uri(str);
         if(uri == NULL || uri[0] == '\0') {
@@ -3320,7 +3320,7 @@ sp_style_read_ifilter(gchar const *str, SPStyle * style, SPDocument *document)
         f->set = FALSE;
         f->inherit = FALSE;
         if (f->href && f->href->getObject())
-            f->href->detach(); 
+            f->href->detach();
     }
 }
 
@@ -3887,7 +3887,7 @@ sp_style_set_property_url (SPObject *item, gchar const *property, SPObject *link
 
     SPCSSAttr *css = sp_repr_css_attr_new();
     if (linked) {
-        gchar *val = g_strdup_printf("url(#%s)", SP_OBJECT_ID(linked));
+        gchar *val = g_strdup_printf("url(#%s)", linked->getId());
         sp_repr_css_set_property(css, property, val);
         g_free(val);
     } else {
index 1345ffe550ac898d6b6934c5b00dcdc24f479f01..132e5fd4e4ddc8494171f2bff3ef457fda579f89 100644 (file)
@@ -1265,7 +1265,7 @@ void FilterEffectsDialog::FilterModifier::update_filters()
         SPFilter* f = (SPFilter*)l->data;
         row[_columns.filter] = f;
         const gchar* lbl = f->label();
-        const gchar* id = SP_OBJECT_ID(f);
+        const gchar* id = f->getId();
         row[_columns.label] = lbl ? lbl : (id ? id : "filter");
     }
 
@@ -1485,7 +1485,7 @@ void FilterEffectsDialog::PrimitiveList::update()
                 row[_columns.primitive] = prim;
                 row[_columns.type_id] = FPConverter.get_id_from_key(prim->repr->name());
                 row[_columns.type] = _(FPConverter.get_label(row[_columns.type_id]).c_str());
-                row[_columns.id] = SP_OBJECT_ID(prim);
+                row[_columns.id] = prim->getId();
 
                 if(prim == active_prim) {
                     get_selection()->select(row);
index 336afc3c563f872c291358b76640062f05741678..088f630314fb1f5dcca0b2b8cb6d92c76168bd84 100644 (file)
@@ -90,7 +90,7 @@ IconPreviewPanel::IconPreviewPanel() :
 
     std::vector<Glib::ustring> pref_sizes = prefs->getAllDirs("/iconpreview/sizes/default");
     std::vector<int> rawSizes;
-    
+
     for (std::vector<Glib::ustring>::iterator i = pref_sizes.begin(); i != pref_sizes.end(); ++i) {
         if (prefs->getBool(*i + "/show", true)) {
             int sizeVal = prefs->getInt(*i + "/value", -1);
@@ -215,7 +215,7 @@ void IconPreviewPanel::refreshPreview()
                 while ( items && !target ) {
                     SPItem* item = SP_ITEM( items->data );
                     SPObject * obj = SP_OBJECT(item);
-                    gchar const *id = SP_OBJECT_ID( obj );
+                    gchar const *id = obj->getId();
                     if ( id ) {
                         target = obj;
                     }
@@ -248,7 +248,7 @@ void IconPreviewPanel::modeToggled()
 void IconPreviewPanel::renderPreview( SPObject* obj )
 {
     SPDocument * doc = SP_OBJECT_DOCUMENT(obj);
-    gchar * id = SP_OBJECT_ID(obj);
+    gchar const * id = obj->getId();
 
 //    g_message(" setting up to render '%s' as the icon", id );
 
index a06b6c9b68c0c9d562f35b9dbbae22b4eebe969f..98bf236fc0c3bf1c106b447e6e32a431f9de218f 100644 (file)
@@ -304,7 +304,7 @@ bool LayersPanel::_checkForUpdated(const Gtk::TreePath &/*path*/, const Gtk::Tre
     Glib::ustring tmp = row[_model->_colLabel];
     if ( layer == row[_model->_colObject] )
     {
-        row[_model->_colLabel] = layer->label() ? layer->label() : SP_OBJECT_ID(layer);
+        row[_model->_colLabel] = layer->label() ? layer->label() : layer->getId();
         row[_model->_colVisible] = SP_IS_ITEM(layer) ? !SP_ITEM(layer)->isHidden() : false;
         row[_model->_colLocked] = SP_IS_ITEM(layer) ? SP_ITEM(layer)->isLocked() : false;
 
@@ -381,7 +381,7 @@ void LayersPanel::_addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::R
                 Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend();
                 Gtk::TreeModel::Row row = *iter;
                 row[_model->_colObject] = child;
-                row[_model->_colLabel] = child->label() ? child->label() : SP_OBJECT_ID(child);
+                row[_model->_colLabel] = child->label() ? child->label() : child->getId();
                 row[_model->_colVisible] = SP_IS_ITEM(child) ? !SP_ITEM(child)->isHidden() : false;
                 row[_model->_colLocked] = SP_IS_ITEM(child) ? SP_ITEM(child)->isLocked() : false;
 
index cb22e029b099f91016a8992b48343c11ff80ff2c..998f4e1e1b343a908197cb07a83989fa65da3201 100644 (file)
@@ -252,7 +252,7 @@ void SvgFontsDialog::update_fonts()
         row[_columns.spfont] = f;
         row[_columns.svgfont] = new SvgFont(f);
         const gchar* lbl = f->label();
-        const gchar* id = SP_OBJECT_ID(f);
+        const gchar* id = f->getId();
         row[_columns.label] = lbl ? lbl : (id ? id : "font");
     }
 
@@ -653,7 +653,7 @@ Gtk::VBox* SvgFontsDialog::glyphs_tab(){
     missing_glyph_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::missing_glyph_description_from_selected_path));
     missing_glyph_reset_button.set_label(_("Reset"));
     missing_glyph_reset_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::reset_missing_glyph_description));
-    
+
     glyphs_vbox.pack_start(*missing_glyph_hbox, false,false);
 
     glyphs_vbox.add(_GlyphsListScroller);
index 450d4202daba194d596ae011fc5dad035a80a7d8..cd6bef05a93d81e0045f626de3e4363fe7fabd88 100644 (file)
@@ -386,7 +386,7 @@ static void editGradient( GtkMenuItem */*menuitem*/, gpointer /*user_data*/ )
             const GSList *gradients = sp_document_get_resource_list(doc, "gradient");
             for (const GSList *item = gradients; item; item = item->next) {
                 SPGradient* grad = SP_GRADIENT(item->data);
-                if ( targetName == grad->id ) {
+                if ( targetName == grad->getId() ) {
                     editGradientImpl( grad );
                     break;
                 }
@@ -867,7 +867,7 @@ void ColorItem::buttonClicked(bool secondary)
                 } else {
                     SPGradient* grad = gradMap[this];
                     colorspec = "url(#";
-                    colorspec += grad->id;
+                    colorspec += grad->getId();
                     colorspec += ")";
                 }
                 sp_repr_css_set_property( css, attrName, colorspec.c_str() );
@@ -1433,7 +1433,7 @@ void SwatchesPanel::handleGradientsChange()
 
                     if ( (grad->vector.stops.size() <= 2) && (together == together2) ) {
                         // Treat as solid-color
-                        Glib::ustring name( grad->id );
+                        Glib::ustring name( grad->getId() );
                         unsigned int r = SP_RGBA32_R_U(together);
                         unsigned int g = SP_RGBA32_G_U(together);
                         unsigned int b = SP_RGBA32_B_U(together);
@@ -1443,7 +1443,7 @@ void SwatchesPanel::handleGradientsChange()
                         gradMap[item] = grad;
                     } else {
                         // Treat as gradient
-                        Glib::ustring name( grad->id );
+                        Glib::ustring name( grad->getId() );
                         unsigned int r = SP_RGBA32_R_U(together);
                         unsigned int g = SP_RGBA32_G_U(together);
                         unsigned int b = SP_RGBA32_B_U(together);
index aebcfd9088f05f368f1f6e089259d18c503a774a..85306698c1b80a8dc546e7322b7ffa2eeff9d455 100644 (file)
@@ -16,7 +16,7 @@
 // Taking bbox of an item is an expensive operation, and we need to do it many times, so here we
 // cache the centers, widths, and heights of items
 
-//FIXME: make a class with these cashes as members instead of globals 
+//FIXME: make a class with these cashes as members instead of globals
 std::map<const gchar *, Geom::Point> c_cache;
 std::map<const gchar *, Geom::Point> wh_cache;
 
@@ -26,18 +26,18 @@ Center of bbox of item
 Geom::Point
 unclump_center (SPItem *item)
 {
-    std::map<const gchar *, Geom::Point>::iterator i = c_cache.find(SP_OBJECT_ID(item));
+    std::map<const gchar *, Geom::Point>::iterator i = c_cache.find(item->getId());
     if ( i != c_cache.end() ) {
         return i->second;
     }
 
     Geom::OptRect r = item->getBounds(sp_item_i2d_affine(item));
     if (r) {
-       Geom::Point const c = r->midpoint();
-       c_cache[SP_OBJECT_ID(item)] = c;
-        return c; 
+        Geom::Point const c = r->midpoint();
+        c_cache[item->getId()] = c;
+        return c;
     } else {
-       // FIXME
+        // FIXME
         return Geom::Point(0, 0);
     }
 }
@@ -46,16 +46,16 @@ Geom::Point
 unclump_wh (SPItem *item)
 {
     Geom::Point wh;
-    std::map<const gchar *, Geom::Point>::iterator i = wh_cache.find(SP_OBJECT_ID(item));
+    std::map<const gchar *, Geom::Point>::iterator i = wh_cache.find(item->getId());
     if ( i != wh_cache.end() ) {
         wh = i->second;
     } else {
         Geom::OptRect r = item->getBounds(sp_item_i2d_affine(item));
-       if (r) {
+        if (r) {
             wh = r->dimensions();
-            wh_cache[SP_OBJECT_ID(item)] = wh;
+            wh_cache[item->getId()] = wh;
         } else {
-           wh = Geom::Point(0, 0);
+            wh = Geom::Point(0, 0);
         }
     }
 
@@ -63,7 +63,7 @@ unclump_wh (SPItem *item)
 }
 
 /**
-Distance between "edges" of item1 and item2. An item is considered to be an ellipse inscribed into its w/h, 
+Distance between "edges" of item1 and item2. An item is considered to be an ellipse inscribed into its w/h,
 so its radius (distance from center to edge) depends on the w/h and the angle towards the other item.
 May be negative if the edge of item1 is between the center and the edge of item2.
 */
@@ -287,7 +287,7 @@ unclump_push (SPItem *from, SPItem *what, double dist)
 
     Geom::Matrix move = Geom::Translate (by);
 
-    std::map<const gchar *, Geom::Point>::iterator i = c_cache.find(SP_OBJECT_ID(what));
+    std::map<const gchar *, Geom::Point>::iterator i = c_cache.find(what->getId());
     if ( i != c_cache.end() ) {
         i->second *= move;
     }
@@ -310,7 +310,7 @@ unclump_pull (SPItem *to, SPItem *what, double dist)
 
     Geom::Matrix move = Geom::Translate (by);
 
-    std::map<const gchar *, Geom::Point>::iterator i = c_cache.find(SP_OBJECT_ID(what));
+    std::map<const gchar *, Geom::Point>::iterator i = c_cache.find(what->getId());
     if ( i != c_cache.end() ) {
         i->second *= move;
     }
@@ -325,7 +325,7 @@ unclump_pull (SPItem *to, SPItem *what, double dist)
 /**
 Unclumps the items in \a items, reducing local unevenness in their distribution. Produces an effect
 similar to "engraver dots". The only distribution which is unchanged by unclumping is a hexagonal
-grid. May be called repeatedly for stronger effect. 
+grid. May be called repeatedly for stronger effect.
  */
 void
 unclump (GSList *items)
@@ -333,7 +333,7 @@ unclump (GSList *items)
     c_cache.clear();
     wh_cache.clear();
 
-    for (GSList *i = items; i != NULL; i = i->next) { //  for each original/clone x: 
+    for (GSList *i = items; i != NULL; i = i->next) { //  for each original/clone x:
         SPItem *item = SP_ITEM (i->data);
 
         GSList *nei = NULL;
@@ -353,7 +353,7 @@ unclump (GSList *items)
                 g_slist_free (rest);
                 break;
             }
-        } 
+        }
 
         if (g_slist_length (nei) >= 2) {
             double ave = unclump_average (item, nei);
@@ -369,7 +369,7 @@ unclump (GSList *items)
             if (fabs (ave) < 1e6 && fabs (dist_closest) < 1e6 && fabs (dist_farest) < 1e6) { // otherwise the items are bogus
                 // increase these coefficients to make unclumping more aggressive and less stable
                 // the pull coefficient is a bit bigger to counteract the long-term expansion trend
-                unclump_push (closest, item, 0.3 * (ave - dist_closest)); 
+                unclump_push (closest, item, 0.3 * (ave - dist_closest));
                 unclump_pull (farest, item, 0.35 * (dist_farest - ave));
             }
         }
index c884604a2e6f10432ae5f4080b82182c270bfeb8..0a53cfb3e92f7b869a17c1142feb13a9904fc571 100644 (file)
@@ -305,7 +305,7 @@ sp_gvs_rebuild_gui_full (SPGradientVectorSelector *gvs)
                 GtkWidget *hb, *l;
                 hb = gtk_hbox_new (FALSE, 4);
                 gtk_widget_show (hb);
-                l = gtk_label_new (SP_OBJECT_ID (gr));
+                l = gtk_label_new(gr->getId());
                 gtk_widget_show (l);
                 gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5);
                 gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0);