From 839598cdda20adbc1a3b5d0982c13558440d1fcb Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 1 Mar 2010 22:10:16 -0800 Subject: [PATCH] Cleanup on id access. --- src/conn-avoid-ref.cpp | 4 +- src/connector-context.cpp | 2 +- src/desktop.cpp | 2 +- src/dialogs/export.cpp | 78 ++++++------ src/dialogs/item-properties.cpp | 4 +- src/extension/execution-env.cpp | 4 +- src/extension/implementation/script.cpp | 10 +- src/extension/init.cpp | 16 +-- src/extension/internal/javafx-out.cpp | 8 +- src/extension/internal/pov-out.cpp | 34 +++--- src/gradient-chemistry.cpp | 4 +- src/graphlayout/graphlayout.cpp | 150 ++++++++++++------------ src/id-clash.cpp | 12 +- src/interface.cpp | 6 +- src/main.cpp | 4 +- src/selection-chemistry.cpp | 4 +- src/selection-describer.cpp | 2 +- src/sp-conn-end-pair.cpp | 16 +-- src/sp-namedview.cpp | 4 +- src/sp-object.cpp | 95 ++++++++++----- src/sp-object.h | 10 ++ src/style.cpp | 36 +++--- src/ui/dialog/filter-effects-dialog.cpp | 4 +- src/ui/dialog/icon-preview.cpp | 6 +- src/ui/dialog/layers.cpp | 4 +- src/ui/dialog/svg-fonts-dialog.cpp | 4 +- src/ui/dialog/swatches.cpp | 8 +- src/unclump.cpp | 34 +++--- src/widgets/gradient-vector.cpp | 2 +- 29 files changed, 306 insertions(+), 261 deletions(-) diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index b2aa0ce6b..88c84a84c 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -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(); diff --git a/src/connector-context.cpp b/src/connector-context.cpp index eed03385c..ba6c067c0 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -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; } diff --git a/src/desktop.cpp b/src/desktop.cpp index 32d25164f..52f172577 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -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()); /* diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 2c04135bc..fa0fa5b6f 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -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) diff --git a/src/dialogs/item-properties.cpp b/src/dialogs/item-properties.cpp index 211b800dc..abc45b44b 100644 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@ -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! ")); diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index e8d7c4baf..7ed389195 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -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); diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 4e8d0b360..60623191f 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -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; } diff --git a/src/extension/init.cpp b/src/extension/init.cpp index 84cc45de9..777e3d718 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -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(list->data); + Inkscape::Extension *extension; + extension = reinterpret_cast(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)); } diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index a2f387406..ca061a63a 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -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)) { diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index 1cb14fb58..16877c370 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -312,12 +312,12 @@ bool PovOutput::doCurve(SPItem *item, const String &id) int segmentCount = 0; /** * For all Subpaths in the - */ + */ 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 - */ + */ 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(&*cit)) - { + { std::vector 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(); diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 4abd7483f..d669fa378 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -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 = '#'; diff --git a/src/graphlayout/graphlayout.cpp b/src/graphlayout/graphlayout.cpp index 81ea59059..23b0ee13b 100644 --- a/src/graphlayout/graphlayout.cpp +++ b/src/graphlayout/graphlayout.cpp @@ -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& - selected,vector& rs,map& nodelookup) : + selected,vector& rs,map& 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="<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::iterator i(selected.begin()); - i != selected.end(); - ++i) - { - SPItem *iu=*i; - map::iterator i=nodelookup.find(iu->id); + for (list::iterator i(selected.begin()); + i != selected.end(); + ++i) + { + SPItem *iu=*i; + map::iterator i=nodelookup.find(iu->getId()); if(i==nodelookup.end()) { continue; } unsigned u=i->second; GSList *nlist=iu->avoidRef->getAttachedConnectors(Avoid::runningFrom); list connectors; - + connectors.insert >(connectors.end(),nlist,NULL); for (list::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::iterator v_pair=nodelookup.find(iv->id); + map::iterator v_pair=nodelookup.find(iv->getId()); if(v_pair!=nodelookup.end()) { unsigned v=v_pair->second; //cout << "Edge: (" << u <<","<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 cs; connectedComponents(rs,es,scx,scy,cs); for(unsigned i=0;i::iterator it(selected.begin()); - it != selected.end(); - ++it) - { - SPItem *u=*it; - if(!isConnector(u)) { - map::iterator i=nodelookup.find(u->id); - if(i!=nodelookup.end()) { + + for (list::iterator it(selected.begin()); + it != selected.end(); + ++it) + { + SPItem *u=*it; + if(!isConnector(u)) { + map::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;iisPaintserver() && 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::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); diff --git a/src/interface.cpp b/src/interface.cpp index b29b91d18..9c1870019 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -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. , 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); diff --git a/src/main.cpp b/src/main.cpp index 4bb5dfdc1..f55731be8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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]; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 4dfb4597d..3bfde6de9 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -333,7 +333,7 @@ void add_ids_recursive(std::vector &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]); diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 78cf9be33..9321ea0ef 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -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(_("%s"), quoted_parent_label); g_free(quoted_parent_label); diff --git a/src/sp-conn-end-pair.cpp b/src/sp-conn-end-pair.cpp index 33225f467..7f019979a 100644 --- a/src/sp-conn-end-pair.cpp +++ b/src/sp-conn-end-pair.cpp @@ -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+2curveto( 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; } diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 9b72a4157..44c3bf620 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -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"); } diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 85e8a4e9a..f77f228cb 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -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); diff --git a/src/sp-object.h b/src/sp-object.h index bbb8ecbd0..22a15a0a4 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -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. diff --git a/src/style.cpp b/src/style.cpp index 111018c2a..6d73e62ea 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -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 attrs = prefs->getAllEntries(path); for (std::vector::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 { diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 1345ffe55..132e5fd4e 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -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); diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 336afc3c5..088f63031 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -90,7 +90,7 @@ IconPreviewPanel::IconPreviewPanel() : std::vector pref_sizes = prefs->getAllDirs("/iconpreview/sizes/default"); std::vector rawSizes; - + for (std::vector::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 ); diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index a06b6c9b6..98bf236fc 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -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; diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index cb22e029b..998f4e1e1 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -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); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 450d4202d..cd6bef05a 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -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); diff --git a/src/unclump.cpp b/src/unclump.cpp index aebcfd908..85306698c 100644 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@ -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 c_cache; std::map wh_cache; @@ -26,18 +26,18 @@ Center of bbox of item Geom::Point unclump_center (SPItem *item) { - std::map::iterator i = c_cache.find(SP_OBJECT_ID(item)); + std::map::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::iterator i = wh_cache.find(SP_OBJECT_ID(item)); + std::map::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::iterator i = c_cache.find(SP_OBJECT_ID(what)); + std::map::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::iterator i = c_cache.find(SP_OBJECT_ID(what)); + std::map::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)); } } diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index c884604a2..0a53cfb3e 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -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); -- 2.30.2