From: Jon A. Cruz Date: Sun, 12 Dec 2010 08:40:34 +0000 (-0800) Subject: Merge and cleanup of GSoC C++-ification project. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9dc68827cbd515262ecb8d5ae8547d9e82c72e00;p=inkscape.git Merge and cleanup of GSoC C++-ification project. --- 9dc68827cbd515262ecb8d5ae8547d9e82c72e00 diff --cc src/arc-context.cpp index b485dd183,2f70e16f3..1c480ecbc --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@@ -6,6 -6,6 +6,7 @@@ * Lauris Kaplinski * bulia byak * Johan Engelen ++ * Abhishek Sharma * * Copyright (C) 2000-2006 Authors * Copyright (C) 2000-2001 Ximian, Inc. @@@ -45,6 -45,6 +46,8 @@@ #include "arc-context.h" ++using Inkscape::DocumentUndo; ++ static void sp_arc_context_class_init(SPArcContextClass *klass); static void sp_arc_context_init(SPArcContext *arc_context); static void sp_arc_context_dispose(GObject *object); @@@ -410,12 -407,12 +413,12 @@@ static void sp_arc_drag(SPArcContext *a return; } -- /* Create object */ -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ // Create object ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); repr->setAttribute("sodipodi:type", "arc"); -- /* Set style */ ++ // Set style sp_desktop_apply_style_tool(desktop, repr, "/tools/shapes/arc", false); ac->item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); @@@ -503,7 -500,7 +506,7 @@@ static void sp_arc_finish(SPArcContext sp_canvas_end_forced_full_redraws(desktop->canvas); sp_desktop_selection(desktop)->set(ac->item); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC, ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC, _("Create ellipse")); ac->item = NULL; @@@ -529,7 -526,7 +532,7 @@@ static void sp_arc_cancel(SPArcContext sp_canvas_end_forced_full_redraws(desktop->canvas); - sp_document_cancel(sp_desktop_document(desktop)); - SPDocumentUndo::cancel(sp_desktop_document(desktop)); ++ DocumentUndo::cancel(sp_desktop_document(desktop)); } diff --cc src/box3d-context.cpp index 14f4470bc,99cf28963..f23e4d883 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@@ -1,11 -1,11 +1,11 @@@ --#define __SP_BOX3D_CONTEXT_C__ -- /* * 3D box drawing context * * Author: * Lauris Kaplinski * bulia byak ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2007 Maximilian Albert * Copyright (C) 2006 Johan Engelen @@@ -49,6 -49,6 +49,8 @@@ #include "line-geometry.h" #include "shape-editor.h" ++using Inkscape::DocumentUndo; ++ static void sp_box3d_context_class_init(Box3DContextClass *klass); static void sp_box3d_context_init(Box3DContext *box3d_context); static void sp_box3d_context_dispose(GObject *object); @@@ -188,10 -188,10 +190,10 @@@ static void sp_box3d_context_selection_ * circumstances, after 'vacuum defs' or when a pre-0.46 file is opened). */ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) { -- SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); ++ SPDefs *defs = reinterpret_cast(SP_DOCUMENT_DEFS(document)); bool has_persp = false; - for (SPObject *child = sp_object_first_child(defs); child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = defs->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) { if (SP_IS_PERSP3D(child)) { has_persp = true; break; @@@ -436,42 -436,42 +438,42 @@@ static gint sp_box3d_context_root_handl case GDK_bracketright: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::X, -180/snaps, MOD__ALT); - sp_document_done(document, SP_VERB_CONTEXT_3DBOX, - SPDocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, ++ DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_bracketleft: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::X, 180/snaps, MOD__ALT); - sp_document_done(document, SP_VERB_CONTEXT_3DBOX, - SPDocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, ++ DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_parenright: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Y, -180/snaps, MOD__ALT); - sp_document_done(document, SP_VERB_CONTEXT_3DBOX, - SPDocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, ++ DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_parenleft: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Y, 180/snaps, MOD__ALT); - sp_document_done(document, SP_VERB_CONTEXT_3DBOX, - SPDocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, ++ DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_braceright: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Z, -180/snaps, MOD__ALT); - sp_document_done(document, SP_VERB_CONTEXT_3DBOX, - SPDocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, ++ DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; case GDK_braceleft: persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Z, 180/snaps, MOD__ALT); - sp_document_done(document, SP_VERB_CONTEXT_3DBOX, - SPDocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, ++ DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX, _("Change perspective (angle of PLs)")); ret = true; break; @@@ -573,7 -573,8 +575,7 @@@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/) { - SPDesktop *desktop = SP_EVENT_CONTEXT(&bc)->desktop; - //SPDesktop *desktop = SP_EVENT_CONTEXT(&bc)->desktop; + SPDesktop *desktop = bc.desktop; if (!bc.item) { @@@ -581,25 -582,34 +583,19 @@@ return; } -- /* Create object */ - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc)); - Inkscape::XML::Node *repr = xml_doc->createElement("svg:g"); - repr->setAttribute("sodipodi:type", "inkscape:box3d"); - - /* Remove convoluted code. */ - //Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc)); - - /*To be removed for directly accessing the XML Document*/ - //Inkscape::XML::Document *xml_doc = desktop->doc()->rdoc; - //Inkscape::XML::Node *repr = xml_doc->createElement("svg:g"); - //repr->setAttribute("sodipodi:type", "inkscape:box3d"); - SPBox3D *box3d = 0; - box3d = SPBox3D::createBox3D((SPItem *)desktop->currentLayer()); - /* Set style */ ++ // Create object ++ SPBox3D *box3d = 0; ++ box3d = SPBox3D::createBox3D((SPItem *)desktop->currentLayer()); + - /* Set style */ - sp_desktop_apply_style_tool (desktop, repr, "/tools/shapes/3dbox", false); ++ // Set style + desktop->applyCurrentOrToolStyle(box3d, "/tools/shapes/3dbox", false); - - bc.item = box3d; - //bc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr); - //Inkscape::GC::release(repr); - //Inkscape::XML::Node *repr_side; ++ ++ bc.item = box3d; + - bc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr); - Inkscape::GC::release(repr); - Inkscape::XML::Node *repr_side; // TODO: Incorporate this in box3d-side.cpp! for (int i = 0; i < 6; ++i) { - repr_side = xml_doc->createElement("svg:path"); - repr_side->setAttribute("sodipodi:type", "inkscape:box3dside"); - repr->addChild(repr_side, NULL); - - Box3DSide *side = SP_BOX3D_SIDE(inkscape_active_document()->getObjectByRepr (repr_side)); - //repr_side = xml_doc->createElement("svg:path"); - //repr_side->setAttribute("sodipodi:type", "inkscape:box3dside"); - //repr->addChild(repr_side, NULL); -- - //Box3DSide *side = SP_BOX3D_SIDE(inkscape_active_document()->getObjectByRepr (repr_side)); - //Box3DSide *side = SP_BOX3D_SIDE(desktop->doc()->getObjectByRepr(repr_side)); - Box3DSide *side = Box3DSide::createBox3DSide(box3d); - ++ Box3DSide *side = Box3DSide::createBox3DSide(box3d); ++ guint desc = Box3D::int_to_face(i); Box3D::Axis plane = (Box3D::Axis) (desc & 0x7); @@@ -608,10 -618,32 +604,27 @@@ side->dir2 = Box3D::extract_second_axis_direction(plane); side->front_or_rear = (Box3D::FrontOrRear) (desc & 0x8); -- /* Set style */ - box3d_side_apply_style(side); - /* Removed the faulty usage */ - //box3d_side_apply_style(side); - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); ++ // Set style ++ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + - Glib::ustring descr = "/desktop/"; - descr += box3d_side_axes_string(side); - descr += "/style"; - Glib::ustring cur_style = prefs->getString(descr); ++ Glib::ustring descr = "/desktop/"; ++ descr += box3d_side_axes_string(side); ++ descr += "/style"; ++ Glib::ustring cur_style = prefs->getString(descr); + - bool use_current = prefs->getBool("/tools/shapes/3dbox/usecurrent", false); - if (use_current && !cur_style.empty()) { - // use last used style - side->setAttribute("style", cur_style.data()); ++ bool use_current = prefs->getBool("/tools/shapes/3dbox/usecurrent", false); ++ if (use_current && !cur_style.empty()) { ++ // use last used style ++ side->setAttribute("style", cur_style.data()); + - } else { - // use default style - GString *pstring = g_string_new(""); - g_string_printf (pstring, "/tools/shapes/3dbox/%s", box3d_side_axes_string(side)); - desktop->applyCurrentOrToolStyle (side, pstring->str, false); - } - ++ } else { ++ // use default style ++ GString *pstring = g_string_new(""); ++ g_string_printf (pstring, "/tools/shapes/3dbox/%s", box3d_side_axes_string(side)); ++ desktop->applyCurrentOrToolStyle (side, pstring->str, false); ++ } - SP_OBJECT(side)->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description - //SP_OBJECT(side)->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description + side->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description } box3d_set_z_orders(SP_BOX3D(bc.item)); @@@ -667,7 -699,7 +680,7 @@@ static void sp_box3d_finish(Box3DContex sp_canvas_end_forced_full_redraws(desktop->canvas); sp_desktop_selection(desktop)->set(bc->item); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX, ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX, _("Create 3D box")); bc->item = NULL; diff --cc src/box3d-side.cpp index 057d8f7df,6838008bb..72a479ca4 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@@ -1,10 -1,10 +1,9 @@@ --#define __BOX3D_SIDE_C__ -- /* * 3D box face implementation * * Authors: * Maximilian Albert ++ * Abhishek Sharma * * Copyright (C) 2007 Authors * @@@ -93,13 -93,13 +92,13 @@@ box3d_side_init (Box3DSide * side side->front_or_rear = Box3D::FRONT; } --static void --box3d_side_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) ++static void box3d_side_build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { -- if (((SPObjectClass *) parent_class)->build) -- ((SPObjectClass *) parent_class)->build (object, document, repr); ++ if (((SPObjectClass *) parent_class)->build) { ++ ((SPObjectClass *) parent_class)->build(object, document, repr); ++ } - sp_object_read_attr(object, "inkscape:box3dsidetype"); - object->readAttr( "inkscape:box3dsidetype"); ++ object->readAttr( "inkscape:box3dsidetype" ); } static Inkscape::XML::Node * @@@ -117,7 -117,7 +116,7 @@@ box3d_side_write (SPObject *object, Ink sp_repr_set_int(repr, "inkscape:box3dsidetype", side->dir1 ^ side->dir2 ^ side->front_or_rear); } - sp_shape_set_shape ((SPShape *) object); - ((SPShape *) object)->setShape (); ++ static_cast(object)->setShape(); /* Duplicate the path */ SPCurve const *curve = ((SPShape *) object)->curve; @@@ -179,13 -179,33 +178,33 @@@ box3d_side_update (SPObject *object, SP if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { - sp_shape_set_shape ((SPShape *) object); - ((SPShape *) object)->setShape (); ++ static_cast(object)->setShape (); } if (((SPObjectClass *) parent_class)->update) ((SPObjectClass *) parent_class)->update (object, ctx, flags); } + /* Create a new Box3DSide and append it to the parent box */ + Box3DSide * Box3DSide::createBox3DSide(SPBox3D *box) + { + Box3DSide *box3d_side = 0; + Inkscape::XML::Document *xml_doc = box->document->rdoc; + Inkscape::XML::Node *repr_side = xml_doc->createElement("svg:path"); + repr_side->setAttribute("sodipodi:type", "inkscape:box3dside"); - box3d_side = (Box3DSide *)box->appendChildRepr(repr_side); ++ box3d_side = static_cast(box->appendChildRepr(repr_side)); + return box3d_side; + } + + /* + * Function which return the type attribute for Box3D. + * Acts as a replacement for directly accessing the XML Tree directly. + */ + long long int Box3DSide::getFaceId() + { + return this->getIntAttribute("inkscape:box3dsidetype", -1); + } + void box3d_side_position_set (Box3DSide *side) { box3d_side_set_shape (SP_SHAPE (side)); @@@ -255,31 -275,36 +274,7 @@@ box3d_side_set_shape (SPShape *shape c->unref(); } - void -/* removed to be merged into box3d-context function sp_box3d_drag - * so as to remove the faulty mehcanism of accessing a parent's/base - * level class members from a derived subclass. - */ - -/*void --box3d_side_apply_style (Box3DSide *side) { -- Inkscape::XML::Node *repr_face = SP_OBJECT_REPR(SP_OBJECT(side)); -- Inkscape::Preferences *prefs = Inkscape::Preferences::get(); -- -- Glib::ustring descr = "/desktop/"; -- descr += box3d_side_axes_string(side); -- descr += "/style"; -- Glib::ustring cur_style = prefs->getString(descr); -- -- SPDesktop *desktop = inkscape_active_desktop(); -- bool use_current = prefs->getBool("/tools/shapes/3dbox/usecurrent", false); -- if (use_current && !cur_style.empty()) { - /* use last used style */ - // use last used style -- repr_face->setAttribute("style", cur_style.data()); -- } else { - /* use default style */ - // use default style -- GString *pstring = g_string_new(""); -- g_string_printf (pstring, "/tools/shapes/3dbox/%s", box3d_side_axes_string(side)); -- sp_desktop_apply_style_tool (desktop, repr_face, pstring->str, false); -- } - } -}*/ -- --gchar * --box3d_side_axes_string(Box3DSide *side) ++gchar *box3d_side_axes_string(Box3DSide *side) { GString *pstring = g_string_new(""); g_string_printf (pstring, "%s", Box3D::string_from_axes ((Box3D::Axis) (side->dir1 ^ side->dir2))); @@@ -314,15 -339,17 +309,14 @@@ box3d_side_perspective(Box3DSide *side return SP_BOX3D(SP_OBJECT(side)->parent)->persp_ref->getObject(); } --Inkscape::XML::Node * --box3d_side_convert_to_path(Box3DSide *side) { ++Inkscape::XML::Node *box3d_side_convert_to_path(Box3DSide *side) { // TODO: Copy over all important attributes (see sp_selected_item_to_curved_repr() for an example) SPDocument *doc = SP_OBJECT_DOCUMENT(side); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); - repr->setAttribute("d", SP_OBJECT_REPR(side)->attribute("d")); - repr->setAttribute("style", SP_OBJECT_REPR(side)->attribute("style")); - //repr->setAttribute("d", SP_OBJECT_REPR(side)->attribute("d")); + repr->setAttribute("d", side->getAttribute("d")); - //repr->setAttribute("style", SP_OBJECT_REPR(side)->attribute("style")); + repr->setAttribute("style", side->getAttribute("style")); return repr; } diff --cc src/box3d-side.h index 18c815073,29a4a6b00..a8d692b01 --- a/src/box3d-side.h +++ b/src/box3d-side.h @@@ -1,11 -1,11 +1,12 @@@ --#ifndef __BOX3D_SIDE_H__ --#define __BOX3D_SIDE_H__ ++#ifndef SEEN_BOX3D_SIDE_H ++#define SEEN_BOX3D_SIDE_H /* * 3D box face implementation * * Authors: * Maximilian Albert ++ * Abhishek Sharma * * Copyright (C) 2007 Authors * @@@ -31,6 -31,8 +32,8 @@@ struct Box3DSide : public SPPolygon Box3D::Axis dir1; Box3D::Axis dir2; Box3D::FrontOrRear front_or_rear; - long long int getFaceId(); - static Box3DSide * createBox3DSide(SPBox3D *box); ++ long long int getFaceId(); ++ static Box3DSide * createBox3DSide(SPBox3D *box); }; struct Box3DSideClass { @@@ -40,13 -42,13 +43,15 @@@ GType box3d_side_get_type (void); void box3d_side_position_set (Box3DSide *side); // FIXME: Replace this by box3d_side_set_shape?? - void box3d_side_apply_style (Box3DSide *side); -//void box3d_side_apply_style (Box3DSide *side); ++ gchar *box3d_side_axes_string(Box3DSide *side); ++ Persp3D *box3d_side_perspective(Box3DSide *side); ++ Inkscape::XML::Node *box3d_side_convert_to_path(Box3DSide *side); --#endif /* __BOX3D_SIDE_H__ */ ++#endif // SEEN_BOX3D_SIDE_H /* Local Variables: diff --cc src/box3d.cpp index aa2dc55e3,250c1f500..d51df9df3 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_BOX3D_C__ -- /* * SVG implementation * @@@ -7,6 -7,6 +5,7 @@@ * Maximilian Albert * Lauris Kaplinski * bulia byak ++ * Abhishek Sharma * * Copyright (C) 2007 Authors * Copyright (C) 1999-2002 Lauris Kaplinski @@@ -132,9 -132,9 +131,9 @@@ box3d_build(SPObject *object, SPDocumen box->persp_ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(box3d_ref_changed), box)); - sp_object_read_attr(object, "inkscape:perspectiveID"); - sp_object_read_attr(object, "inkscape:corner0"); - sp_object_read_attr(object, "inkscape:corner7"); - object->readAttr( "inkscape:perspectiveID"); - object->readAttr( "inkscape:corner0"); - object->readAttr( "inkscape:corner7"); ++ object->readAttr( "inkscape:perspectiveID" ); ++ object->readAttr( "inkscape:corner0" ); ++ object->readAttr( "inkscape:corner7" ); } /** @@@ -227,7 -227,7 +226,7 @@@ box3d_set(SPObject *object, unsigned in box3d_position_set(box); } break; -- default: ++ default: if (((SPObjectClass *) (parent_class))->set) { ((SPObjectClass *) (parent_class))->set(object, key, value); } @@@ -290,11 -290,13 +289,9 @@@ static Inkscape::XML::Node * box3d_writ repr->setAttribute("inkscape:perspectiveID", uri_string); g_free(uri_string); } else { - Inkscape::XML::Node *persp_repr = SP_OBJECT_REPR(doc->getCurrentPersp3D()); - const gchar *persp_id = persp_repr->attribute("id"); - gchar *href = g_strdup_printf("#%s", persp_id); - repr->setAttribute("inkscape:perspectiveID", href); - g_free(href); - //Inkscape::XML::Node *persp_repr = SP_OBJECT_REPR(doc->getCurrentPersp3D()); - //const gchar *persp_id = persp_repr->attribute("id"); - //gchar *href = g_strdup_printf("#%s", persp_id); - Glib::ustring href = "#"; - href += doc->getCurrentPersp3D()->getId(); ++ Glib::ustring href = "#"; ++ href += doc->getCurrentPersp3D()->getId(); + repr->setAttribute("inkscape:perspectiveID", href.c_str()); - //g_free(href); } } @@@ -327,14 -329,14 +324,14 @@@ box3d_description(SPItem *item return g_strdup(_("3D Box")); } --void --box3d_position_set (SPBox3D *box) ++void box3d_position_set(SPBox3D *box) { /* This draws the curve and calls requestDisplayUpdate() for each side (the latter is done in box3d_side_position_set() to avoid update conflicts with the parent box) */ - for (SPObject *child = sp_object_first_child(SP_OBJECT (box)); child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = SP_OBJECT (box)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { -- if (SP_IS_BOX3D_SIDE(child)) ++ for ( SPObject *child = box->firstChild(); child; child = child->getNext() ) { ++ if (SP_IS_BOX3D_SIDE(child)) { box3d_side_position_set(SP_BOX3D_SIDE(child)); ++ } } } @@@ -350,7 -352,7 +347,7 @@@ box3d_set_transform(SPItem *item, Geom: gdouble const sw = hypot(ret[0], ret[1]); gdouble const sh = hypot(ret[2], ret[3]); - for (SPObject *child = sp_object_first_child(box); child != NULL; child = SP_OBJECT_NEXT(child)) { - for (SPObject *child = box->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { ++ for ( SPObject *child = box->firstChild(); child; child = child->getNext() ) { if (SP_IS_ITEM(child)) { SPItem *childitem = SP_ITEM(child); @@@ -509,6 -511,18 +506,16 @@@ box3d_snap (SPBox3D *box, int id, Proj: return box3d_get_perspective(box)->perspective_impl->tmat.preimage (result, z_coord, Proj::Z); } -/*create a SPBox3D and append it to the parent*/ - + SPBox3D * SPBox3D::createBox3D(SPItem * parent) + { - SPBox3D *box3d = 0; - Inkscape::XML::Document *xml_doc = parent->document->rdoc; - Inkscape::XML::Node *repr = xml_doc->createElement("svg:g"); - repr->setAttribute("sodipodi:type", "inkscape:box3d"); - box3d = (SPBox3D *)parent->appendChildRepr(repr); - return box3d; ++ SPBox3D *box3d = 0; ++ Inkscape::XML::Document *xml_doc = parent->document->rdoc; ++ Inkscape::XML::Node *repr = xml_doc->createElement("svg:g"); ++ repr->setAttribute("sodipodi:type", "inkscape:box3d"); ++ box3d = reinterpret_cast(parent->appendChildRepr(repr)); ++ return box3d; + } + void box3d_set_corner (SPBox3D *box, const guint id, Geom::Point const &new_pos, const Box3D::Axis movement, bool constrained) { g_return_if_fail ((movement != Box3D::NONE) && (movement != Box3D::XYZ)); @@@ -672,15 -686,15 +679,15 @@@ box3d_half_line_crosses_joining_line (G Geom::Line lineCD(C,D); Geom::OptCrossing inters = Geom::OptCrossing(); // empty by default -- try -- { -- inters = Geom::intersection(lineAB, lineCD); -- } -- catch (Geom::InfiniteSolutions e) -- { -- // We're probably dealing with parallel lines, so they don't really cross -- return false; -- } ++ try ++ { ++ inters = Geom::intersection(lineAB, lineCD); ++ } ++ catch (Geom::InfiniteSolutions e) ++ { ++ // We're probably dealing with parallel lines, so they don't really cross ++ return false; ++ } if (!inters) { return false; @@@ -1148,13 -1162,15 +1155,14 @@@ box3d_recompute_z_orders (SPBox3D *box return false; } --static std::map --box3d_get_sides (SPBox3D *box) { ++static std::map box3d_get_sides(SPBox3D *box) ++{ std::map sides; - for (SPObject *side = sp_object_first_child(box); side != NULL; side = SP_OBJECT_NEXT(side)) { - if (SP_IS_BOX3D_SIDE(side)) - sides[Box3D::face_to_int(sp_repr_get_int_attribute(SP_OBJECT_REPR(side), - "inkscape:box3dsidetype", -1))] = SP_BOX3D_SIDE(side); - for (SPObject *side = box->first_child(); side != NULL; side = SP_OBJECT_NEXT(side)) { - ++ for ( SPObject *side = box->firstChild(); side; side = side->getNext() ) { + if (SP_IS_BOX3D_SIDE(side)){ - Box3DSide *bside = SP_BOX3D_SIDE(side); ++ Box3DSide *bside = SP_BOX3D_SIDE(side); + sides[Box3D::face_to_int(bside->getFaceId())] = bside; - } ++ } } sides.erase(-1); return sides; @@@ -1288,12 -1304,12 +1296,11 @@@ box3d_check_for_swapped_coords(SPBox3D box3d_exchange_coords(box); } --static void --box3d_extract_boxes_rec(SPObject *obj, std::list &boxes) { ++static void box3d_extract_boxes_rec(SPObject *obj, std::list &boxes) { if (SP_IS_BOX3D(obj)) { boxes.push_back(SP_BOX3D(obj)); } else if (SP_IS_GROUP(obj)) { - for (SPObject *child = sp_object_first_child(obj); child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = obj->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = obj->firstChild(); child; child = child->getNext() ) { box3d_extract_boxes_rec(child, boxes); } } @@@ -1328,35 -1344,38 +1335,33 @@@ box3d_switch_perspectives(SPBox3D *box persp3d_remove_box (old_persp, box); persp3d_add_box (new_persp, box); - gchar *href = g_strdup_printf("#%s", SP_OBJECT_REPR(new_persp)->attribute("id")); - SP_OBJECT_REPR(box)->setAttribute("inkscape:perspectiveID", href); - g_free(href); - //gchar *href = g_strdup_printf("#%s", SP_OBJECT_REPR(new_persp)->attribute("id")); - Glib::ustring href = "#"; - href += new_persp->getId(); - //SP_OBJECT_REPR(box)->setAttribute("inkscape:perspectiveID", href.c_str()); - static_cast(box)->setAttribute("inkscape:perspectiveID", href.c_str()); - //g_free(href); ++ Glib::ustring href = "#"; ++ href += new_persp->getId(); ++ box->setAttribute("inkscape:perspectiveID", href.c_str()); } /* Converts the 3D box to an ordinary SPGroup, adds it to the XML tree at the same position as the original box and deletes the latter */ --SPGroup * --box3d_convert_to_group(SPBox3D *box) { ++SPGroup *box3d_convert_to_group(SPBox3D *box) ++{ SPDocument *doc = SP_OBJECT_DOCUMENT(box); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); // remember position of the box - int pos = SP_OBJECT_REPR(box)->position(); - int pos = static_cast(box)->getPosition(); ++ int pos = box->getPosition(); // remember important attributes - Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(box); - gchar const *id = repr_source->attribute("id"); - gchar const *style = repr_source->attribute("style"); - gchar const *mask = repr_source->attribute("mask"); - gchar const *clip_path = repr_source->attribute("clip-path"); - //Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(box); - gchar const *id = static_cast(box)->getAttribute("id"); - gchar const *style = static_cast(box)->getAttribute("style"); - gchar const *mask = static_cast(box)->getAttribute("mask"); - gchar const *clip_path = static_cast(box)->getAttribute("clip-path"); ++ gchar const *id = box->getAttribute("id"); ++ gchar const *style = box->getAttribute("style"); ++ gchar const *mask = box->getAttribute("mask"); ++ gchar const *clip_path = box->getAttribute("clip-path"); // create a new group and add the sides (converted to ordinary paths) as its children Inkscape::XML::Node *grepr = xml_doc->createElement("svg:g"); -- Inkscape::XML::Node *repr; - for (SPObject *child = sp_object_first_child(SP_OBJECT(box)); child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = SP_OBJECT(box)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = box->firstChild(); child; child = child->getNext() ) { if (SP_IS_BOX3D_SIDE(child)) { -- repr = box3d_side_convert_to_path(SP_BOX3D_SIDE(child)); ++ Inkscape::XML::Node *repr = box3d_side_convert_to_path(SP_BOX3D_SIDE(child)); grepr->appendChild(repr); } else { g_warning("Non-side item encountered as child of a 3D box."); @@@ -1392,7 -1411,7 +1397,7 @@@ box3d_convert_to_guides(SPItem *item) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (!prefs->getBool("/tools/shapes/3dbox/convertguides", true)) { - sp_item_convert_to_guides(SP_ITEM(box)); - SP_ITEM(box)->convert_to_guides(); ++ box->convert_to_guides(); return; } diff --cc src/box3d.h index 8273e3542,e313f4285..5dbf0cf5e --- a/src/box3d.h +++ b/src/box3d.h @@@ -1,5 -1,5 +1,5 @@@ --#ifndef __SP_BOX3D_H__ --#define __SP_BOX3D_H__ ++#ifndef SEEN_SP_BOX3D_H ++#define SEEN_SP_BOX3D_H /* * SVG implementation @@@ -7,6 -7,6 +7,7 @@@ * Authors: * Lauris Kaplinski * Maximilian Albert ++ * Abhishek Sharma * * Copyright (C) 2007 Authors * Copyright (C) 1999-2002 Lauris Kaplinski @@@ -29,7 -29,8 +30,8 @@@ class Box3DSide class Persp3D; class Persp3DReference; - struct SPBox3D : public SPGroup { + class SPBox3D : public SPGroup { - public: ++public: gint z_orders[6]; // z_orders[i] holds the ID of the face at position #i in the group (from top to bottom) gchar *persp_href; @@@ -44,9 -45,11 +46,15 @@@ Box3D::Axis swapped; // to indicate which coordinates are swapped during dragging gint my_counter; // for debugging only - static SPBox3D * createBox3D(SPItem * parent); ++ ++ /** ++ * Create a SPBox3D and append it to the parent. ++ */ ++ static SPBox3D * createBox3D(SPItem * parent); }; - struct SPBox3DClass { + class SPBox3DClass { - public: ++public: SPGroupClass parent_class; }; @@@ -78,7 -81,7 +86,7 @@@ void box3d_switch_perspectives(SPBox3D SPGroup *box3d_convert_to_group(SPBox3D *box); --#endif /* __SP_BOX3D_H__ */ ++#endif // SEEN_SP_BOX3D_H /* Local Variables: diff --cc src/color-profile.cpp index 4c71fd72b,ee4118e4f..e08a416d3 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@@ -180,9 -178,9 +180,8 @@@ void ColorProfile::init( ColorProfile * void ColorProfile::release( SPObject *object ) { // Unregister ourselves -- SPDocument* document = SP_OBJECT_DOCUMENT(object); -- if ( document ) { - sp_document_remove_resource (SP_OBJECT_DOCUMENT (object), "iccprofile", SP_OBJECT (object)); - SP_OBJECT_DOCUMENT (object)->remove_resource ("iccprofile", SP_OBJECT (object)); ++ if ( object->document ) { ++ object->document->removeResource("iccprofile", object); } ColorProfile *cprof = COLORPROFILE(object); @@@ -256,7 -254,7 +255,7 @@@ void ColorProfile::build( SPObject *obj // Register if ( document ) { - sp_document_add_resource( document, "iccprofile", object ); - document->add_resource( "iccprofile", object ); ++ document->addResource( "iccprofile", object ); } } @@@ -290,7 -288,7 +289,7 @@@ void ColorProfile::set( SPObject *objec g_warning("object has no document. using active"); } //# 1. Get complete URI of document -- gchar const *docbase = SP_DOCUMENT_URI( doc ); ++ gchar const *docbase = doc->getURI(); if (!docbase) { // Normal for files that have not yet been saved. @@@ -477,7 -475,7 +476,7 @@@ static int getLcmsIntent( guint svgInte static SPObject* bruteFind( SPDocument* document, gchar const* name ) { SPObject* result = 0; - const GSList * current = sp_document_get_resource_list(document, "iccprofile"); - const GSList * current = document->get_resource_list("iccprofile"); ++ const GSList * current = document->getResourceList("iccprofile"); while ( current && !result ) { if ( IS_COLORPROFILE(current->data) ) { ColorProfile* prof = COLORPROFILE(current->data); diff --cc src/conditions.cpp index 8d1770d6a,7087abac2..d35f18cf1 --- a/src/conditions.cpp +++ b/src/conditions.cpp @@@ -1,10 -1,10 +1,9 @@@ --#define __SP_CONDITIONS_CPP__ -- /* * SVG conditional attribute evaluation * * Authors: * Andrius R. ++ * Abhishek Sharma * * Copyright (C) 2006 authors * @@@ -39,20 -39,21 +38,16 @@@ static Condition _condition_handlers[] { "requiredExtensions", evaluateRequiredExtensions }, }; --/* function which evaluates if item should be displayed */ ++// function which evaluates if item should be displayed bool sp_item_evaluate(SPItem const *item) { - Inkscape::XML::Node *grepr = SP_OBJECT_REPR (item); - //Inkscape::XML::Node *grepr = SP_OBJECT_REPR (item); -- -- for ( unsigned int i = 0 ; i < sizeof(_condition_handlers)/sizeof(_condition_handlers[0]) ; i++ ) { - gchar const *value = grepr->attribute(_condition_handlers[i].attribute); - if ( NULL == value ) - continue; - - if (!_condition_handlers[i].evaluator(item, value)) - return false; - //gchar const *value = grepr->attribute(_condition_handlers[i].attribute); ++ bool needDisplay = true; ++ for ( unsigned int i = 0 ; needDisplay && (i < sizeof(_condition_handlers) / sizeof(_condition_handlers[0])) ; i++ ) { + gchar const *value = item->getAttribute(_condition_handlers[i].attribute); - if ( NULL == value ) - continue; - - if (!_condition_handlers[i].evaluator(item, value)) - return false; ++ if ( value && !_condition_handlers[i].evaluator(item, value) ) { ++ needDisplay = false; ++ } } -- -- return true; ++ return needDisplay; } #define ISALNUM(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z') || ((c) >= '0' && (c) <= '9')) diff --cc src/conn-avoid-ref.cpp index fe25fa418,3e8359c57..21ef2deab --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@@ -3,6 -3,6 +3,7 @@@ * * Authors: * Michael Wybrow ++ * Abhishek Sharma * * Copyright (C) 2005 Michael Wybrow * @@@ -38,7 -37,7 +39,7 @@@ #include "inkscape.h" #include -- ++using Inkscape::DocumentUndo; using Avoid::Router; @@@ -195,10 -194,10 +196,10 @@@ void SPAvoidRef::setConnectionPointsAtt { SPDocument* doc = SP_OBJECT_DOCUMENT(item); - sp_object_setAttribute( SP_OBJECT(item), "inkscape:connection-points", value, 0 ); - SP_OBJECT(item)->setAttribute( "inkscape:connection-points", value, 0 ); ++ item->setAttribute( "inkscape:connection-points", value, 0 ); item->updateRepr(); - sp_document_ensure_up_to_date(doc); - sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, action); - doc->ensure_up_to_date(); - SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, action); ++ doc->ensureUpToDate(); ++ DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, action); } void SPAvoidRef::addConnectionPoint(ConnectionPoint &cp) @@@ -295,7 -294,7 +296,7 @@@ void SPAvoidRef::handleSettingChange(vo // isn't the same as the document that this item is part of. This // case can happen if a new document is loaded from the file chooser // or via the recent file menu. In this case, we can end up here -- // as a rersult of a sp_document_ensure_up_to_date performed on a ++ // as a rersult of a ensureUpToDate performed on a // document not yet attached to the active desktop. return; } @@@ -315,7 -314,8 +316,7 @@@ _transformed_connection = item->connectTransformed( sigc::ptr_fun(&avoid_item_move)); - const char *id = SP_OBJECT_REPR(item)->attribute("id"); - //const char *id = SP_OBJECT_REPR(item)->attribute("id"); - const char *id = item->getAttribute("id"); ++ char const *id = item->getAttribute("id"); g_assert(id != NULL); // Get a unique ID for the item. @@@ -389,7 -388,9 +390,7 @@@ Geom::Point SPAvoidRef::getConnectionPo { g_assert(item); Geom::Point pos; - const Geom::Matrix& transform = sp_item_i2doc_affine(item); + const Geom::Matrix& transform = item->i2doc_affine(); - // TODO investigate why this was asking for the active desktop: - SPDesktop *desktop = inkscape_active_desktop(); if ( type == ConnPointDefault ) { @@@ -557,8 -551,8 +558,7 @@@ static Avoid::Polygon avoid_item_poly(S GSList *get_avoided_items(GSList *list, SPObject *from, SPDesktop *desktop, bool initialised) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(from)) ; - for (SPObject *child = SP_OBJECT(from)->first_child() ; -- child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = from->firstChild() ; child != NULL; child = child->next ) { if (SP_IS_ITEM(child) && !desktop->isLayer(SP_ITEM(child)) && !SP_ITEM(child)->isLocked() && @@@ -596,8 -590,8 +596,8 @@@ void init_avoided_shape_geometry(SPDesk // Don't count this as changes to the document, // it is basically just late initialisation. SPDocument *document = sp_desktop_document(desktop); - bool saved = sp_document_get_undo_sensitive(document); - sp_document_set_undo_sensitive(document, false); - bool saved = SPDocumentUndo::get_undo_sensitive(document); - SPDocumentUndo::set_undo_sensitive(document, false); ++ bool saved = DocumentUndo::getUndoSensitive(document); ++ DocumentUndo::setUndoSensitive(document, false); bool initialised = false; GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop, @@@ -611,7 -605,7 +611,7 @@@ if (items) { g_slist_free(items); } - sp_document_set_undo_sensitive(document, saved); - SPDocumentUndo::set_undo_sensitive(document, saved); ++ DocumentUndo::setUndoSensitive(document, saved); } diff --cc src/connector-context.cpp index adc54a1ae,a419af44a..b1061c124 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@@ -3,6 -3,6 +3,7 @@@ * * Authors: * Michael Wybrow ++ * Abhishek Sharma * * Copyright (C) 2005-2008 Michael Wybrow * Copyright (C) 2009 Monash University @@@ -188,6 -188,6 +189,8 @@@ #include "sp-flowtext.h" #include "display/curve.h" ++using Inkscape::DocumentUndo; ++ static void sp_connector_context_class_init(SPConnectorContextClass *klass); static void sp_connector_context_init(SPConnectorContext *conn_context); static void sp_connector_context_dispose(GObject *object); @@@ -966,12 -962,10 +969,12 @@@ connector_handle_motion_notify(SPConnec gobble_motion_events(GDK_BUTTON1_MASK); g_assert( SP_IS_PATH(cc->clickeditem)); + m.setup(dt); m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); // Update the hidden path - Geom::Matrix i2d = sp_item_i2d_affine(cc->clickeditem); + Geom::Matrix i2d = (cc->clickeditem)->i2d_affine(); Geom::Matrix d2i = i2d.inverse(); SPPath *path = SP_PATH(cc->clickeditem); SPCurve *curve = path->original_curve ? path->original_curve : path->curve; @@@ -1070,12 -1061,10 +1073,12 @@@ connector_handle_button_release(SPConne } case SP_CONNECTOR_CONTEXT_REROUTING: { + m.setup(desktop); m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); cc_connector_rerouting_finish(cc, &p); - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); cc->state = SP_CONNECTOR_CONTEXT_IDLE; return TRUE; break; @@@ -1096,12 -1085,10 +1099,12 @@@ if (!cc->within_tolerance) { + m.setup(desktop); m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); sp_knot_set_position(cc->selected_handle, p, 0); ConnectionPoint& cp = cc->connpthandles[cc->selected_handle]; - cp.pos = p * sp_item_dt2i_affine(cc->active_shape); + cp.pos = p * (cc->active_shape)->dt2i_affine(); cc->active_shape->avoidRef->updateConnectionPoint(cp); } @@@ -1123,7 -1108,7 +1126,7 @@@ cp.dir = Avoid::ConnDirAll; g_object_unref(cc->selected_handle); cc->active_shape->avoidRef->addConnectionPoint(cp); - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); for (ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end(); ++it) if (it->second.type == ConnPointUserDefined && it->second.id == cp.id) { @@@ -1167,7 -1152,7 +1170,7 @@@ connector_handle_key_press(SPConnectorC cc_connector_rerouting_finish(cc, NULL); - sp_document_undo(doc); - SPDocumentUndo::undo(doc); ++ DocumentUndo::undo(doc); cc->state = SP_CONNECTOR_CONTEXT_IDLE; desktop->messageStack()->flash( Inkscape::NORMAL_MESSAGE, @@@ -1212,14 -1200,11 +1215,14 @@@ if (!cc->within_tolerance) { + SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop); m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); + m.unSetup(); sp_knot_set_position(cc->selected_handle, p, 0); ConnectionPoint& cp = cc->connpthandles[cc->selected_handle]; - cp.pos = p * sp_item_dt2i_affine(cc->active_shape); + cp.pos = p * (cc->active_shape)->dt2i_affine(); cc->active_shape->avoidRef->updateConnectionPoint(cp); } @@@ -1253,7 -1239,7 +1256,7 @@@ cp.dir = Avoid::ConnDirAll; g_object_unref(cc->selected_handle); cc->active_shape->avoidRef->addConnectionPoint(cp); - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); for (ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end(); ++it) if (it->second.type == ConnPointUserDefined && it->second.id == cp.id) { @@@ -1300,16 -1286,16 +1303,12 @@@ cc_connector_rerouting_finish(SPConnect if (found) { if (cc->clickedhandle == cc->endpt_handle[0]) { - sp_object_setAttribute(cc->clickeditem, - (cc->clickeditem)->setAttribute( -- "inkscape:connection-start", shape_label, false); - sp_object_setAttribute(cc->clickeditem, - (cc->clickeditem)->setAttribute( -- "inkscape:connection-start-point", cpid, false); ++ cc->clickeditem->setAttribute("inkscape:connection-start", shape_label, false); ++ cc->clickeditem->setAttribute("inkscape:connection-start-point", cpid, false); } else { - sp_object_setAttribute(cc->clickeditem, - (cc->clickeditem)->setAttribute( -- "inkscape:connection-end", shape_label, false); - sp_object_setAttribute(cc->clickeditem, - (cc->clickeditem)->setAttribute( -- "inkscape:connection-end-point", cpid, false); ++ cc->clickeditem->setAttribute("inkscape:connection-end", shape_label, false); ++ cc->clickeditem->setAttribute("inkscape:connection-end-point", cpid, false); } g_free(shape_label); } @@@ -1317,7 -1303,7 +1316,7 @@@ cc->clickeditem->setHidden(false); sp_conn_reroute_path_immediate(SP_PATH(cc->clickeditem)); cc->clickeditem->updateRepr(); - sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, - SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, ++ DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Reroute connector")); cc_set_active_conn(cc, cc->clickeditem); } @@@ -1429,7 -1415,7 +1428,7 @@@ spcc_flush_white(SPConnectorContext *cc SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); SPDocument *doc = sp_desktop_document(desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); if ( c && !c->is_empty() ) { /* We actually have something to write */ @@@ -1445,35 -1431,35 +1444,33 @@@ /* Attach repr */ cc->newconn = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); - cc->newconn->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + cc->newconn->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); bool connection = false; - sp_object_setAttribute(cc->newconn, "inkscape:connector-type", - (cc->newconn)->setAttribute( "inkscape:connector-type", -- cc->isOrthogonal ? "orthogonal" : "polyline", false); - sp_object_setAttribute(cc->newconn, "inkscape:connector-curvature", - (cc->newconn)->setAttribute( "inkscape:connector-curvature", -- Glib::Ascii::dtostr(cc->curvature).c_str(), false); ++ cc->newconn->setAttribute( "inkscape:connector-type", ++ cc->isOrthogonal ? "orthogonal" : "polyline", false ); ++ cc->newconn->setAttribute( "inkscape:connector-curvature", ++ Glib::Ascii::dtostr(cc->curvature).c_str(), false ); if (cc->shref) { - sp_object_setAttribute(cc->newconn, "inkscape:connection-start", - (cc->newconn)->setAttribute( "inkscape:connection-start", -- cc->shref, false); -- if (cc->scpid) - sp_object_setAttribute(cc->newconn, "inkscape:connection-start-point", - (cc->newconn)->setAttribute( "inkscape:connection-start-point", -- cc->scpid, false); ++ cc->newconn->setAttribute( "inkscape:connection-start", cc->shref, false); ++ if (cc->scpid) { ++ cc->newconn->setAttribute( "inkscape:connection-start-point", cc->scpid, false); ++ } connection = true; } if (cc->ehref) { - sp_object_setAttribute(cc->newconn, "inkscape:connection-end", - (cc->newconn)->setAttribute( "inkscape:connection-end", -- cc->ehref, false); -- if (cc->ecpid) - sp_object_setAttribute(cc->newconn, "inkscape:connection-end-point", - (cc->newconn)->setAttribute( "inkscape:connection-end-point", -- cc->ecpid, false); ++ cc->newconn->setAttribute( "inkscape:connection-end", cc->ehref, false); ++ if (cc->ecpid) { ++ cc->newconn->setAttribute( "inkscape:connection-end-point", cc->ecpid, false); ++ } connection = true; } // Process pending updates. cc->newconn->updateRepr(); - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); if (connection) { // Adjust endpoints to shape edge. @@@ -1491,7 -1477,7 +1488,7 @@@ c->unref(); - sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Create connector")); - SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Create connector")); ++ DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Create connector")); } @@@ -1707,7 -1693,7 +1704,7 @@@ static void cc_set_active_shape(SPConne // Ensure the item's connection_points map // has been updated - sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(item)); - SP_OBJECT_DOCUMENT(item)->ensure_up_to_date(); ++ item->document->ensureUpToDate(); std::set seen; for ( ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end() ;) @@@ -1950,8 -1917,8 +1947,7 @@@ void cc_selection_set_avoid(bool const char const *value = (set_avoid) ? "true" : NULL; if (cc_item_is_shape(item)) { - sp_object_setAttribute(item, "inkscape:connector-avoid", - item->setAttribute("inkscape:connector-avoid", -- value, false); ++ item->setAttribute("inkscape:connector-avoid", value, false); item->avoidRef->handleSettingChange(); changes++; } @@@ -1968,7 -1935,7 +1964,7 @@@ char *event_desc = (set_avoid) ? _("Make connectors avoid selected objects") : _("Make connectors ignore selected objects"); - sp_document_done(document, SP_VERB_CONTEXT_CONNECTOR, event_desc); - SPDocumentUndo::done(document, SP_VERB_CONTEXT_CONNECTOR, event_desc); ++ DocumentUndo::done(document, SP_VERB_CONTEXT_CONNECTOR, event_desc); } diff --cc src/console-output-undo-observer.cpp index 18782c163,9369b5db5..2cbac74f8 --- a/src/console-output-undo-observer.cpp +++ b/src/console-output-undo-observer.cpp @@@ -4,6 -4,6 +4,7 @@@ * * Authors: * David Yip ++ * Abhishek Sharma * * Copyright (c) 2006 Authors * @@@ -19,31 -19,31 +20,31 @@@ namespace Inkscape void ConsoleOutputUndoObserver::notifyUndoEvent(Event* /*log*/) { - // g_message("notifyUndoEvent (sp_document_undo) called; log=%p\n", log->event); - // g_message("notifyUndoEvent (SPDocumentUndo::undo) called; log=%p\n", log->event); ++ // g_message("notifyUndoEvent(SPDocumentUndo::undo) called; log=%p\n", log->event); } void ConsoleOutputUndoObserver::notifyRedoEvent(Event* /*log*/) { - // g_message("notifyRedoEvent (sp_document_redo) called; log=%p\n", log->event); - // g_message("notifyRedoEvent (SPDocumentUndo::redo) called; log=%p\n", log->event); ++ // g_message("notifyRedoEvent(SPDocumentUndo::redo) called; log=%p\n", log->event); } void ConsoleOutputUndoObserver::notifyUndoCommitEvent(Event* /*log*/) { - //g_message("notifyUndoCommitEvent (sp_document_maybe_done) called; log=%p\n", log->event); - //g_message("notifyUndoCommitEvent (SPDocumentUndo::maybe_done) called; log=%p\n", log->event); ++ //g_message("notifyUndoCommitEvent(SPDocumentUndo::maybe_done) called; log=%p\n", log->event); } void ConsoleOutputUndoObserver::notifyClearUndoEvent() { -- //g_message("notifyClearUndoEvent (sp_document_clear_undo) called); ++ //g_message("notifyClearUndoEvent(sp_document_clear_undo) called); } void ConsoleOutputUndoObserver::notifyClearRedoEvent() { -- //g_message("notifyClearRedoEvent (sp_document_clear_redo) called); ++ //g_message("notifyClearRedoEvent(sp_document_clear_redo) called); } } diff --cc src/console-output-undo-observer.h index f7d1c7d29,f8667d567..b5c08a8b5 --- a/src/console-output-undo-observer.h +++ b/src/console-output-undo-observer.h @@@ -4,14 -4,14 +4,15 @@@ * * Authors: * David Yip ++ * Abhishek Sharma * * Copyright (c) 2006 Authors * * Released under GNU GPL, see the file 'COPYING' for more information */ --#ifndef __INKSCAPE_CONSOLE_OUTPUT_UNDO_OBSERVER_H__ --#define __INKSCAPE_CONSOLE_OUTPUT_UNDO_OBSERVER_H__ ++#ifndef SEEN_INKSCAPE_CONSOLE_OUTPUT_UNDO_OBSERVER_H ++#define SEEN_INKSCAPE_CONSOLE_OUTPUT_UNDO_OBSERVER_H #include "undo-stack-observer.h" @@@ -31,7 -31,7 +32,7 @@@ public }; } --#endif ++#endif // SEEN_INKSCAPE_CONSOLE_OUTPUT_UNDO_OBSERVER_H /* Local Variables: diff --cc src/desktop-events.cpp index f7697a6c0,9e97aa432..71c865879 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@@ -3,6 -3,6 +3,7 @@@ */ /* Author: * Lauris Kaplinski ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 1999-2010 Others @@@ -41,6 -41,6 +42,8 @@@ #include "widgets/desktop-widget.h" #include "xml/repr.h" ++using Inkscape::DocumentUndo; ++ static void snoop_extended(GdkEvent* event, SPDesktop *desktop); static void init_extended(); @@@ -75,7 -75,7 +78,6 @@@ static gint sp_dt_ruler_event(GtkWidge int wx, wy; SPDesktop *desktop = dtw->desktop; - Inkscape::XML::Node *repr = SP_OBJECT_REPR(desktop->namedview); - //Inkscape::XML::Node *repr = SP_OBJECT_REPR(desktop->namedview); gdk_window_get_pointer(GTK_WIDGET(dtw->canvas)->window, &wx, &wy, NULL); Geom::Point const event_win(wx, wy); @@@ -92,8 -92,10 +94,7 @@@ Geom::Point const event_dt(desktop->w2d(event_w)); // explicitly show guidelines; if I draw a guide, I want them on - sp_repr_set_boolean(repr, "showguides", TRUE); - sp_repr_set_boolean(repr, "inkscape:guide-bbox", TRUE); - /*sp_repr_set_boolean(repr, "showguides", TRUE); - sp_repr_set_boolean(repr, "inkscape:guide-bbox", TRUE);*/ - - desktop->namedview->setGuides(true); ++ desktop->namedview->setGuides(true); // calculate the normal of the guidelines when dragged from the edges of rulers. Geom::Point normal_bl_to_tr(-1.,1.); //bottomleft to topright @@@ -181,13 -181,14 +182,13 @@@ gtk_object_destroy(GTK_OBJECT(guide)); guide = NULL; if ((horiz ? wy : wx) >= 0) { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide"); sp_repr_set_point(repr, "orientation", normal); sp_repr_set_point(repr, "position", from_2geom(event_dt)); - SP_OBJECT_REPR(desktop->namedview)->appendChild(repr); - //SP_OBJECT_REPR(desktop->namedview)->appendChild(repr); - desktop->namedview->appendChild(repr); ++ desktop->namedview->appendChild(repr); Inkscape::GC::release(repr); - sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create guide")); } desktop->set_coordinate_status(from_2geom(event_dt)); @@@ -400,14 -401,14 +401,14 @@@ gint sp_dt_guide_event(SPCanvasItem *it g_assert_not_reached(); break; } - sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Move guide")); } else { /* Undo movement of any attached shapes. */ sp_guide_moveto(*guide, guide->point_on_line, false); sp_guide_set_normal(*guide, guide->normal_to_line, false); sp_guide_remove(guide); - sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Delete guide")); } moved = false; @@@ -454,7 -455,7 +455,7 @@@ { SPDocument *doc = SP_OBJECT_DOCUMENT(guide); sp_guide_remove(guide); - sp_document_done(doc, SP_VERB_NONE, _("Delete guide")); - SPDocumentUndo::done(doc, SP_VERB_NONE, _("Delete guide")); ++ DocumentUndo::done(doc, SP_VERB_NONE, _("Delete guide")); ret = TRUE; sp_event_context_discard_delayed_snap_event(desktop->event_context); break; diff --cc src/desktop-style.cpp index 5615a8ea9,049b5fcf8..c580d6767 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@@ -1,11 -1,11 +1,11 @@@ --#define __SP_DESKTOP_STYLE_C__ -- /** \file * Desktop style management * * Authors: * bulia byak * verbalshadow ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2004, 2006 authors * @@@ -103,7 -103,7 +103,7 @@@ sp_desktop_apply_css_recursive(SPObjec || SP_IS_FLOWDIV(o) || SP_IS_FLOWPARA(o) || SP_IS_TEXTPATH(o)) - && !SP_OBJECT_REPR(o)->attribute("style")) - && /*!SP_OBJECT_REPR(o)->attribute("style")*/ !o->getAttribute("style")) ++ && !o->getAttribute("style")) && !(SP_IS_FLOWREGION(o) || SP_IS_FLOWREGIONEXCLUDE(o) || @@@ -129,7 -129,8 +129,7 @@@ } } - sp_repr_css_change(SP_OBJECT_REPR(o), css_set, "style"); - //sp_repr_css_change(SP_OBJECT_REPR(o), css_set, "style"); - o->changeCSS(css_set,"style"); ++ o->changeCSS(css_set,"style"); sp_repr_css_attr_unref(css_set); } @@@ -138,7 -139,7 +138,7 @@@ if (SP_IS_USE(o)) return; - for (SPObject *child = sp_object_first_child(SP_OBJECT(o)) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = SP_OBJECT(o)->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = o->firstChild() ; child ; child = child->getNext() ) { if (sp_repr_css_property(css, "opacity", NULL) != NULL) { // Unset properties which are accumulating and thus should not be set recursively. // For example, setting opacity 0.5 on a group recursively would result in the visible opacity of 0.25 for an item in the group. @@@ -420,7 -417,7 +420,7 @@@ stroke_average_width (GSList const *obj if (!SP_IS_ITEM (l->data)) continue; - Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(l->data)); - Geom::Matrix i2d = (SP_ITEM(l->data))->i2d_affine (); ++ Geom::Matrix i2d = SP_ITEM(l->data)->i2d_affine(); SPObject *object = SP_OBJECT(l->data); @@@ -702,11 -706,11 +702,11 @@@ objects_query_strokewidth (GSList *obje if (!style) continue; if ( style->stroke.isNone() && !( -- style->marker[SP_MARKER_LOC].set || // stroke width affects markers, so if there's no stroke but only markers then we should -- style->marker[SP_MARKER_LOC_START].set || // still calculate the stroke width -- style->marker[SP_MARKER_LOC_MID].set || -- style->marker[SP_MARKER_LOC_END].set)) -- { ++ style->marker[SP_MARKER_LOC].set || // stroke width affects markers, so if there's no stroke but only markers then we should ++ style->marker[SP_MARKER_LOC_START].set || // still calculate the stroke width ++ style->marker[SP_MARKER_LOC_MID].set || ++ style->marker[SP_MARKER_LOC_END].set)) ++ { continue; } @@@ -714,7 -718,7 +714,7 @@@ noneSet &= style->stroke.isNone(); - Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj)); - Geom::Matrix i2d = SP_ITEM(obj)->i2d_affine (); ++ Geom::Matrix i2d = SP_ITEM(obj)->i2d_affine(); double sw = style->stroke_width.computed * i2d.descrim(); if (prev_sw != -1 && fabs(sw - prev_sw) > 1e-3) @@@ -1180,11 -1184,11 +1180,12 @@@ objects_query_fontfamily (GSList *objec for (GSList const *i = objects; i != NULL; i = i->next) { SPObject *obj = SP_OBJECT (i->data); -- // std::cout << " " << SP_OBJECT_ID (i->data) << std::endl; ++ // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj) && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj) -- && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj)) ++ && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj)) { continue; ++ } SPStyle *style = SP_OBJECT_STYLE (obj); if (!style) continue; @@@ -1234,11 -1238,11 +1235,12 @@@ objects_query_fontspecification (GSLis for (GSList const *i = objects; i != NULL; i = i->next) { SPObject *obj = SP_OBJECT (i->data); -- // std::cout << " " << SP_OBJECT_ID (i->data) << std::endl; ++ // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj) && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj) -- && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj)) ++ && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj)) { continue; ++ } SPStyle *style = SP_OBJECT_STYLE (obj); if (!style) continue; @@@ -1378,7 -1382,7 +1380,7 @@@ objects_query_blur (GSList *objects, SP if (!style) continue; if (!SP_IS_ITEM(obj)) continue; - Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj)); - Geom::Matrix i2d = SP_ITEM(obj)->i2d_affine (); ++ Geom::Matrix i2d = SP_ITEM(obj)->i2d_affine(); items ++; @@@ -1483,7 -1487,7 +1485,7 @@@ sp_desktop_query_style(SPDesktop *deskt // otherwise, do querying and averaging over selection if (desktop->selection != NULL) { -- return sp_desktop_query_style_from_list ((GSList *) desktop->selection->itemList(), style, property); ++ return sp_desktop_query_style_from_list ((GSList *) desktop->selection->itemList(), style, property); } return QUERY_STYLE_NOTHING; diff --cc src/desktop.cpp index 83a6f4021,e7ef2897e..0b17fb385 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_DESKTOP_C__ -- /** \file * Editable view implementation * @@@ -10,6 -10,6 +8,8 @@@ * Ralf Stephan * John Bintz * Johan Engelen ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2007 Jon A. Cruz * Copyright (C) 2006-2008 Johan Engelen @@@ -185,12 -186,12 +186,12 @@@ SPDesktop::init (SPNamedView *nv, SPCan SPDocument *document = SP_OBJECT_DOCUMENT (namedview); /* Kill flicker */ - sp_document_ensure_up_to_date (document); - document->ensure_up_to_date (); ++ document->ensureUpToDate(); /* Setup Dialog Manager */ _dlg_mgr = &Inkscape::UI::Dialog::DialogManager::getInstance(); - dkey = sp_item_display_key_new (1); - dkey = SPItem::display_key_new (1); ++ dkey = SPItem::display_key_new(1); /* Connect document */ setDocument (document); @@@ -272,12 -273,12 +273,12 @@@ /* Connect event for page resize */ - _doc2dt[5] = sp_document_height (document); - _doc2dt[5] = document->getHeight (); ++ _doc2dt[5] = document->getHeight(); sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (drawing), _doc2dt); _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this)); - NRArenaItem *ai = sp_item_invoke_show (SP_ITEM (sp_document_root (document)), - NRArenaItem *ai = SP_ITEM (sp_document_root (document))->invoke_show ( ++ NRArenaItem *ai = SP_ITEM(document->getRoot())->invoke_show( SP_CANVAS_ARENA (drawing)->arena, dkey, SP_ITEM_SHOW_DISPLAY); @@@ -394,7 -395,7 +395,7 @@@ void SPDesktop::destroy( } if (drawing) { - sp_item_invoke_hide (SP_ITEM (sp_document_root (doc())), dkey); - SP_ITEM (sp_document_root (doc()))->invoke_hide (dkey); ++ SP_ITEM(doc()->getRoot())->invoke_hide(dkey); drawing = NULL; } @@@ -450,7 -451,7 +451,7 @@@ void SPDesktop::_setDisplayMode(Inkscap canvas->rendermode = mode; _display_mode = mode; sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw -- _widget->setTitle(SP_DOCUMENT_NAME(sp_desktop_document(this))); ++ _widget->setTitle( sp_desktop_document(this)->getName() ); } void SPDesktop::displayModeToggle() { @@@ -494,7 -495,7 +495,7 @@@ SPObject *SPDesktop::currentLayer() con void SPDesktop::setCurrentLayer(SPObject *object) { g_return_if_fail(SP_IS_GROUP(object)); g_return_if_fail( currentRoot() == object || (currentRoot() && currentRoot()->isAncestorOf(object)) ); -- // printf("Set Layer to ID: %s\n", SP_OBJECT_ID(object)); ++ // printf("Set Layer to ID: %s\n", object->getId()); _layer_hierarchy->setBottom(object); } @@@ -684,33 -679,33 +685,30 @@@ SPDesktop::set_coordinate_status (Geom: } /** -- * \see sp_document_item_from_list_at_point_bottom() ++ * \see SPDocument::getItemFromListAtPointBottom() */ --SPItem * --SPDesktop::item_from_list_at_point_bottom (const GSList *list, Geom::Point const p) const ++SPItem *SPDesktop::getItemFromListAtPointBottom(const GSList *list, Geom::Point const p) const { g_return_val_if_fail (doc() != NULL, NULL); - return sp_document_item_from_list_at_point_bottom (dkey, SP_GROUP (doc()->root), list, p); - return SPDocument::item_from_list_at_point_bottom (dkey, SP_GROUP (doc()->root), list, p); ++ return SPDocument::getItemFromListAtPointBottom(dkey, SP_GROUP (doc()->root), list, p); } /** -- * \see sp_document_item_at_point() ++ * \see SPDocument::getItemAtPoint() */ --SPItem * --SPDesktop::item_at_point (Geom::Point const p, bool into_groups, SPItem *upto) const ++SPItem *SPDesktop::getItemAtPoint(Geom::Point const p, bool into_groups, SPItem *upto) const { g_return_val_if_fail (doc() != NULL, NULL); - return sp_document_item_at_point (doc(), dkey, p, into_groups, upto); - return doc()->item_at_point ( dkey, p, into_groups, upto); ++ return doc()->getItemAtPoint( dkey, p, into_groups, upto); } /** -- * \see sp_document_group_at_point() ++ * \see SPDocument::getGroupAtPoint() */ --SPItem * --SPDesktop::group_at_point (Geom::Point const p) const ++SPItem *SPDesktop::getGroupAtPoint(Geom::Point const p) const { g_return_val_if_fail (doc() != NULL, NULL); - return sp_document_group_at_point (doc(), dkey, p); - return doc()->group_at_point (dkey, p); ++ return doc()->getGroupAtPoint(dkey, p); } /** @@@ -966,6 -961,29 +964,26 @@@ SPDesktop::zoom_absolute_keep_point (do 0.0); } + /** + * Apply the desktop's current style or the tool style to the object. + */ + void SPDesktop::applyCurrentOrToolStyle(SPObject *obj, Glib::ustring const &tool_path, bool with_text) + { - SPCSSAttr *css_current = sp_desktop_get_style(this, with_text); ++ SPCSSAttr *css_current = sp_desktop_get_style(this, with_text); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + + if (prefs->getBool(tool_path + "/usecurrent") && css_current) { - //sp_repr_css_set(obj->getRepr(), css_current, "style"); - obj->setCSS(css_current,"style"); ++ obj->setCSS(css_current,"style"); + } else { + SPCSSAttr *css = prefs->getInheritedStyle(tool_path + "/style"); - //sp_repr_css_set(obj->getRepr(), css, "style"); - obj->setCSS(css,"style"); ++ obj->setCSS(css,"style"); + sp_repr_css_attr_unref(css); + } + if (css_current) { + sp_repr_css_attr_unref(css_current); + } - + } + /** * Zoom to center with absolute zoom factor. */ @@@ -1078,10 -1096,10 +1096,10 @@@ voi SPDesktop::zoom_drawing() { g_return_if_fail (doc() != NULL); -- SPItem *docitem = SP_ITEM (sp_document_root (doc())); ++ SPItem *docitem = SP_ITEM(doc()->getRoot()); g_return_if_fail (docitem != NULL); - Geom::OptRect d = sp_item_bbox_desktop(docitem); + Geom::OptRect d = docitem->getBboxDesktop(); /* Note that the second condition here indicates that ** there are no items in the drawing. @@@ -1416,8 -1434,9 +1434,7 @@@ void SPDesktop::toggleGrids( } } else { //there is no grid present at the moment. add a rectangular grid and make it visible - Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); - Inkscape::CanvasGrid::writeNewGridToRepr(repr, sp_desktop_document(this), Inkscape::GRID_RECTANGULAR); - //Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); - //Inkscape::CanvasGrid::writeNewGridToRepr(repr, sp_desktop_document(this), Inkscape::GRID_RECTANGULAR); - namedview->writeNewGrid(sp_desktop_document(this), Inkscape::GRID_RECTANGULAR); ++ namedview->writeNewGrid(sp_desktop_document(this), Inkscape::GRID_RECTANGULAR); showGrids(true); } } @@@ -1435,9 -1454,11 +1452,8 @@@ void SPDesktop::showGrids(bool show, bo void SPDesktop::toggleSnapGlobal() { - bool v = namedview->snap_manager.snapprefs.getSnapEnabledGlobally(); - Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); - sp_repr_set_boolean(repr, "inkscape:snap-global", !v); - //bool v = namedview->snap_manager.snapprefs.getSnapEnabledGlobally(); - //Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); - //sp_repr_set_boolean(repr, "inkscape:snap-global", !v); - bool v=namedview->getSnapGlobal(); - namedview->setSnapGlobal(!v); ++ bool v = namedview->getSnapGlobal(); ++ namedview->setSnapGlobal(!v); } //---------------------------------------------------------------------- @@@ -1480,7 -1501,7 +1496,7 @@@ SPDesktop::setDocument (SPDocument *doc { if (this->doc() && doc) { namedview->hide(this); - sp_item_invoke_hide (SP_ITEM (sp_document_root (this->doc())), dkey); - SP_ITEM (sp_document_root (this->doc()))->invoke_hide (dkey); ++ SP_ITEM(this->doc()->getRoot())->invoke_hide(dkey); } if (_layer_hierarchy) { @@@ -1491,7 -1512,7 +1507,7 @@@ _layer_hierarchy->connectAdded(sigc::bind(sigc::ptr_fun(_layer_activated), this)); _layer_hierarchy->connectRemoved(sigc::bind(sigc::ptr_fun(_layer_deactivated), this)); _layer_hierarchy->connectChanged(sigc::bind(sigc::ptr_fun(_layer_hierarchy_changed), this)); -- _layer_hierarchy->setTop(SP_DOCUMENT_ROOT(doc)); ++ _layer_hierarchy->setTop(doc->getRoot()); /* setup EventLog */ event_log = new Inkscape::EventLog(doc); @@@ -1511,7 -1532,7 +1527,7 @@@ _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this)); number = namedview->getViewCount(); - ai = sp_item_invoke_show (SP_ITEM (sp_document_root (doc)), - ai = SP_ITEM (sp_document_root (doc))->invoke_show ( ++ ai = SP_ITEM(doc->getRoot())->invoke_show( SP_CANVAS_ARENA (drawing)->arena, dkey, SP_ITEM_SHOW_DISPLAY); diff --cc src/desktop.h index af2473baf,160a33558..957c3b342 --- a/src/desktop.h +++ b/src/desktop.h @@@ -11,6 -11,6 +11,8 @@@ * Ralf Stephan * John Bintz * Johan Engelen ++ * Jon A. Cruz get ++ * Abhishek Sharma * * Copyright (C) 2007 Johan Engelen * Copyright (C) 2006 John Bintz @@@ -84,8 -84,9 +86,9 @@@ namespace Inkscape * * @see \ref desktop-handles.h for desktop macros. */ - struct SPDesktop : public Inkscape::UI::View::View + class SPDesktop : public Inkscape::UI::View::View { - public: ++public: Inkscape::UI::Dialog::DialogManager *_dlg_mgr; SPNamedView *namedview; SPCanvas *canvas; @@@ -229,9 -230,9 +232,9 @@@ void push_event_context (GtkType type, const gchar *config, unsigned int key); void set_coordinate_status (Geom::Point p); -- SPItem *item_from_list_at_point_bottom (const GSList *list, Geom::Point const p) const; -- SPItem *item_at_point (Geom::Point const p, bool into_groups, SPItem *upto = NULL) const; -- SPItem *group_at_point (Geom::Point const p) const; ++ SPItem *getItemFromListAtPointBottom(const GSList *list, Geom::Point const p) const; ++ SPItem *getItemAtPoint(Geom::Point const p, bool into_groups, SPItem *upto = NULL) const; ++ SPItem *getGroupAtPoint(Geom::Point const p) const; Geom::Point point() const; Geom::Rect get_display_area() const; @@@ -255,8 -256,8 +258,9 @@@ void prev_zoom(); void next_zoom(); void zoom_quick(bool enable = true); -- /** \brief Returns whether the desktop is in quick zoom mode or not */ -- bool quick_zoomed(void) { return _quick_zoom_enabled; } ++ ++ /** \brief Returns whether the desktop is in quick zoom mode or not */ ++ bool quick_zoomed(void) { return _quick_zoom_enabled; } bool scroll_to_point (Geom::Point const &s_dt, gdouble autoscrollspeed = 0); void scroll_world (double dx, double dy, bool is_scrolling = false); @@@ -324,6 -325,8 +328,8 @@@ virtual bool onDeleteUI (GdkEventAny*); virtual bool onWindowStateEvent (GdkEventWindowState* event); - void applyCurrentOrToolStyle(SPObject *obj, Glib::ustring const &tool_path, bool with_text); ++ void applyCurrentOrToolStyle(SPObject *obj, Glib::ustring const &tool_path, bool with_text); + private: Inkscape::UI::View::EditWidgetInterface *_widget; Inkscape::Application *_inkscape; diff --cc src/dialogs/clonetiler.cpp index 864cf8927,e25f2602b..8045675b4 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@@ -4,6 -4,6 +4,8 @@@ /* Authors: * bulia byak * Johan Engelen ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2004-2006 Authors * Released under GNU GPL, read the file 'COPYING' for more information @@@ -45,6 -47,6 +47,8 @@@ #include "widgets/icon.h" #include "xml/repr.h" ++using Inkscape::DocumentUndo; ++ #define MIN_ONSCREEN_DISTANCE 50 static GtkWidget *dlg = NULL; @@@ -110,11 -120,11 +114,6 @@@ clonetiler_dialog_delete (GtkObject */* } --static void on_delete() --{ -- (void)clonetiler_dialog_delete (0, 0, NULL); --} -- static void on_picker_color_changed (guint rgba) { @@@ -839,9 -849,9 +838,9 @@@ clonetiler_trace_hide_tiled_clones_recu if (!trace_arena) return; - for (SPObject *o = sp_object_first_child(from); o != NULL; o = SP_OBJECT_NEXT(o)) { - for (SPObject *o = from->first_child(); o != NULL; o = SP_OBJECT_NEXT(o)) { ++ for (SPObject *o = from->firstChild(); o != NULL; o = o->next) { if (SP_IS_ITEM(o) && clonetiler_is_a_clone_of (o, NULL)) - sp_item_invoke_hide(SP_ITEM(o), trace_visionkey); // FIXME: hide each tiled clone's original too! + SP_ITEM(o)->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too! clonetiler_trace_hide_tiled_clones_recursively (o); } } @@@ -851,17 -861,16 +850,16 @@@ clonetiler_trace_setup (SPDocument *doc { trace_arena = NRArena::create(); /* Create ArenaItem and set transform */ - trace_visionkey = sp_item_display_key_new(1); + trace_visionkey = SPItem::display_key_new(1); trace_doc = doc; - trace_root = sp_item_invoke_show( SP_ITEM(SP_DOCUMENT_ROOT (trace_doc)), - (NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY); - trace_root = SP_ITEM(SP_DOCUMENT_ROOT (trace_doc))->invoke_show((NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY); ++ trace_root = SP_ITEM(trace_doc->getRoot())->invoke_show((NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY); // hide the (current) original and any tiled clones, we only want to pick the background - sp_item_invoke_hide(original, trace_visionkey); - clonetiler_trace_hide_tiled_clones_recursively (SP_OBJECT(SP_DOCUMENT_ROOT (trace_doc))); + original->invoke_hide(trace_visionkey); - clonetiler_trace_hide_tiled_clones_recursively (SP_OBJECT(SP_DOCUMENT_ROOT (trace_doc))); ++ clonetiler_trace_hide_tiled_clones_recursively(SP_OBJECT(trace_doc->getRoot())); -- sp_document_root (trace_doc)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); - sp_document_ensure_up_to_date(trace_doc); - trace_doc->ensure_up_to_date(); ++ trace_doc->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); ++ trace_doc->ensureUpToDate(); trace_zoom = zoom; } @@@ -944,7 -953,7 +942,7 @@@ static voi clonetiler_trace_finish () { if (trace_doc) { - sp_item_invoke_hide(SP_ITEM(sp_document_root(trace_doc)), trace_visionkey); - SP_ITEM(sp_document_root(trace_doc))->invoke_hide(trace_visionkey); ++ SP_ITEM(trace_doc->getRoot())->invoke_hide(trace_visionkey); } if (trace_arena) { ((NRObject *) trace_arena)->unreference(); @@@ -972,20 -981,20 +970,20 @@@ clonetiler_unclump( GtkWidget */*widget GSList *to_unclump = NULL; // not including the original - for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) { - for (SPObject *child = parent->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { ++ for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { if (clonetiler_is_a_clone_of (child, obj)) { to_unclump = g_slist_prepend (to_unclump, child); } } - sp_document_ensure_up_to_date(sp_desktop_document(desktop)); - sp_desktop_document(desktop)->ensure_up_to_date(); ++ sp_desktop_document(desktop)->ensureUpToDate(); unclump (to_unclump); g_slist_free (to_unclump); - sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER, - SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER, -- _("Unclump tiled clones")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER, ++ _("Unclump tiled clones")); } static guint @@@ -995,7 -1004,7 +993,7 @@@ clonetiler_number_of_clones (SPObject * guint n = 0; - for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) { - for (SPObject *child = parent->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { ++ for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { if (clonetiler_is_a_clone_of (child, obj)) { n ++; } @@@ -1024,7 -1033,7 +1022,7 @@@ clonetiler_remove( GtkWidget */*widget* // remove old tiling GSList *to_delete = NULL; - for (SPObject *child = sp_object_first_child(parent); child != NULL; child = SP_OBJECT_NEXT(child)) { - for (SPObject *child = parent->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { ++ for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { if (clonetiler_is_a_clone_of (child, obj)) { to_delete = g_slist_prepend (to_delete, child); } @@@ -1036,9 -1045,9 +1034,10 @@@ clonetiler_change_selection (NULL, selection, dlg); -- if (do_undo) - sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER, - SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_DIALOG_CLONETILER, -- _("Delete tiled clones")); ++ if (do_undo) { ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER, ++ _("Delete tiled clones")); ++ } } static Geom::Rect @@@ -1471,7 -1480,7 +1470,7 @@@ clonetiler_apply( GtkWidget */*widget*/ double radius = blur * perimeter; // this is necessary for all newly added clones to have correct bboxes, // otherwise filters won't work: - sp_document_ensure_up_to_date(sp_desktop_document(desktop)); - sp_desktop_document(desktop)->ensure_up_to_date(); ++ sp_desktop_document(desktop)->ensureUpToDate(); // it's hard to figure out exact width/height of the tile without having an object // that we can take bbox of; however here we only need a lower bound so that blur // margins are not too small, and the perimeter should work @@@ -1501,8 -1510,8 +1500,8 @@@ desktop->clearWaitingCursor(); - sp_document_done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER, -- _("Create tiled clones")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_CLONETILER, ++ _("Create tiled clones")); } static GtkWidget * diff --cc src/dialogs/export.cpp index 82e2d45e1,649918742..7e99c2496 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@@ -5,6 -5,6 +5,8 @@@ * Lauris Kaplinski * bulia byak * Johan Engelen ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 1999-2007 Authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -66,6 -66,6 +68,8 @@@ #include #endif ++using Inkscape::DocumentUndo; ++ #define SP_EXPORT_MIN_SIZE 1.0 #define DPI_BASE PX_PER_IN @@@ -362,9 -362,9 +366,9 @@@ gchar* create_filepath_from_id (const g if (directory == NULL) { /* Grab document directory */ -- if (SP_DOCUMENT_URI(SP_ACTIVE_DOCUMENT)) { ++ if ( SP_ACTIVE_DOCUMENT->getURI() ) { // std::cout << "Directory from document" << std::endl; -- directory = g_dirname(SP_DOCUMENT_URI(SP_ACTIVE_DOCUMENT)); ++ directory = g_dirname( SP_ACTIVE_DOCUMENT->getURI() ); } } @@@ -535,11 -535,11 +539,11 @@@ sp_export_dialog (void * this code sets the name first, it may not be the one users * really see. */ -- if (SP_ACTIVE_DOCUMENT && SP_DOCUMENT_URI (SP_ACTIVE_DOCUMENT)) ++ if ( SP_ACTIVE_DOCUMENT && SP_ACTIVE_DOCUMENT->getURI() ) { gchar *name; SPDocument * doc = SP_ACTIVE_DOCUMENT; -- const gchar *uri = SP_DOCUMENT_URI (doc); ++ const gchar *uri = doc->getURI(); const gchar *text_extension = get_file_save_extension (Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS).c_str(); Inkscape::Extension::Output * oextension = NULL; @@@ -780,7 -780,7 +784,7 @@@ sp_export_selection_modified ( Inkscape if ( SP_ACTIVE_DESKTOP ) { SPDocument *doc; doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - Geom::OptRect bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)), SPItem::RENDERING_BBOX); - Geom::OptRect bbox = SP_ITEM (SP_DOCUMENT_ROOT (doc))->getBboxDesktop (SPItem::RENDERING_BBOX); ++ Geom::OptRect bbox = SP_ITEM(doc->root)->getBboxDesktop(SPItem::RENDERING_BBOX); if (bbox) { sp_export_set_area (base, bbox->min()[Geom::X], bbox->min()[Geom::Y], @@@ -861,7 -861,7 +865,7 @@@ sp_export_area_toggled (GtkToggleButto /** \todo * This returns wrong values if the document has a viewBox. */ - bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)), SPItem::RENDERING_BBOX); - bbox = SP_ITEM (SP_DOCUMENT_ROOT (doc))->getBboxDesktop (SPItem::RENDERING_BBOX); ++ bbox = SP_ITEM(doc->root)->getBboxDesktop(SPItem::RENDERING_BBOX); /* If the drawing is valid, then we'll use it and break otherwise we drop through to the page settings */ if (bbox) { @@@ -1064,8 -1064,8 +1068,8 @@@ gchar *absolutize_path_from_document_lo { gchar *path = 0; //Make relative paths go from the document location, if possible: -- if (!g_path_is_absolute(filename) && doc->uri) { -- gchar *dirname = g_path_get_dirname(doc->uri); ++ if (!g_path_is_absolute(filename) && doc->getURI()) { ++ gchar *dirname = g_path_get_dirname(doc->getURI()); if (dirname) { path = g_build_filename(dirname, filename, NULL); g_free(dirname); @@@ -1105,10 -1105,10 +1109,10 @@@ sp_export_export_clicked (GtkButton */* for (GSList *i = (GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList(); i != NULL; i = i->next) { -- SPItem *item = (SPItem *) i->data; ++ SPItem *item = reinterpret_cast(i->data); // retrieve export filename hint -- const gchar *filename = SP_OBJECT_REPR(item)->attribute("inkscape:export-filename"); ++ const gchar *filename = item->getRepr()->attribute("inkscape:export-filename"); gchar *path = 0; if (!filename) { path = create_filepath_from_id(item->getId(), NULL); @@@ -1117,7 -1117,7 +1121,7 @@@ } // retrieve export dpi hints -- const gchar *dpi_hint = SP_OBJECT_REPR(item)->attribute("inkscape:export-xdpi"); // only xdpi, ydpi is always the same now ++ const gchar *dpi_hint = item->getRepr()->attribute("inkscape:export-xdpi"); // only xdpi, ydpi is always the same now gdouble dpi = 0.0; if (dpi_hint) { dpi = atof(dpi_hint); @@@ -1127,7 -1127,7 +1131,7 @@@ } Geom::OptRect area; - sp_item_invoke_bbox(item, area, sp_item_i2d_affine((SPItem *) item), TRUE); - item->invoke_bbox( area, static_cast(item)->i2d_affine(), TRUE); ++ item->invoke_bbox( area, item->i2d_affine(), TRUE ); if (area) { gint width = (gint) (area->width() * dpi / PX_PER_IN + 0.5); gint height = (gint) (area->height() * dpi / PX_PER_IN + 0.5); @@@ -1239,14 -1239,14 +1243,13 @@@ case SELECTION_PAGE: case SELECTION_DRAWING: { SPDocument * doc = SP_ACTIVE_DOCUMENT; -- Inkscape::XML::Node * repr = sp_document_repr_root(doc); ++ Inkscape::XML::Node * repr = doc->getReprRoot(); bool modified = false; -- const gchar * temp_string; - bool saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive(doc, false); - bool saved = SPDocumentUndo::get_undo_sensitive(doc); - SPDocumentUndo::set_undo_sensitive(doc, false); ++ bool saved = DocumentUndo::getUndoSensitive(doc); ++ DocumentUndo::setUndoSensitive(doc, false); -- temp_string = repr->attribute("inkscape:export-filename"); ++ gchar const *temp_string = repr->attribute("inkscape:export-filename"); if (temp_string == NULL || strcmp(temp_string, filename_ext)) { repr->setAttribute("inkscape:export-filename", filename_ext); modified = true; @@@ -1261,7 -1261,7 +1264,7 @@@ sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi); modified = true; } - sp_document_set_undo_sensitive(doc, saved); - SPDocumentUndo::set_undo_sensitive(doc, saved); ++ DocumentUndo::setUndoSensitive(doc, saved); if (modified) { doc->setModifiedSinceSave(); @@@ -1273,8 -1273,8 +1276,8 @@@ SPDocument * doc = SP_ACTIVE_DOCUMENT; bool modified = false; - bool saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive(doc, false); - bool saved = SPDocumentUndo::get_undo_sensitive(doc); - SPDocumentUndo::set_undo_sensitive(doc, false); ++ bool saved = DocumentUndo::getUndoSensitive(doc); ++ DocumentUndo::setUndoSensitive(doc, false); reprlst = sp_desktop_selection(SP_ACTIVE_DESKTOP)->reprList(); for(; reprlst != NULL; reprlst = reprlst->next) { @@@ -1283,8 -1283,8 +1286,8 @@@ if (repr->attribute("id") == NULL || !(g_strrstr(filename_ext, repr->attribute("id")) != NULL && -- (!SP_DOCUMENT_URI(SP_ACTIVE_DOCUMENT) || -- strcmp(g_dirname(filename), g_dirname(SP_DOCUMENT_URI(SP_ACTIVE_DOCUMENT))) == 0))) { ++ ( !SP_ACTIVE_DOCUMENT->getURI() || ++ strcmp(g_dirname(filename), g_dirname(SP_ACTIVE_DOCUMENT->getURI())) == 0))) { temp_string = repr->attribute("inkscape:export-filename"); if (temp_string == NULL || strcmp(temp_string, filename_ext)) { repr->setAttribute("inkscape:export-filename", filename_ext); @@@ -1302,7 -1302,7 +1305,7 @@@ modified = true; } } - sp_document_set_undo_sensitive(doc, saved); - SPDocumentUndo::set_undo_sensitive(doc, saved); ++ DocumentUndo::setUndoSensitive(doc, saved); if (modified) { doc->setModifiedSinceSave(); @@@ -1498,7 -1498,7 +1501,7 @@@ sp_export_detect_size(GtkObject * base case SELECTION_DRAWING: { SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - Geom::OptRect bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)), SPItem::RENDERING_BBOX); - Geom::OptRect bbox = SP_ITEM (SP_DOCUMENT_ROOT (doc))->getBboxDesktop (SPItem::RENDERING_BBOX); ++ Geom::OptRect bbox = SP_ITEM(doc->root)->getBboxDesktop(SPItem::RENDERING_BBOX); // std::cout << "Drawing " << bbox2; if ( bbox && sp_export_bbox_equal(*bbox,current_bbox) ) { diff --cc src/dialogs/find.cpp index a3612f60e,89b389d44..fe264892a --- a/src/dialogs/find.cpp +++ b/src/dialogs/find.cpp @@@ -3,6 -3,6 +3,8 @@@ */ /* Authors: * bulia byak ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2004 Authors * @@@ -292,7 -292,7 +294,7 @@@ all_items (SPObject *r, GSList *l, boo if (!strcmp (SP_OBJECT_REPR (r)->name(), "svg:metadata")) return l; // we're not interested in metadata - for (SPObject *child = sp_object_first_child(r); child; child = SP_OBJECT_NEXT (child)) { - for (SPObject *child = r->first_child(); child; child = SP_OBJECT_NEXT (child)) { ++ for (SPObject *child = r->firstChild(); child; child = child->next) { if (SP_IS_ITEM (child) && !SP_OBJECT_IS_CLONED (child) && !desktop->isLayer(SP_ITEM(child))) { if ((hidden || !desktop->itemIsHidden(SP_ITEM(child))) && (locked || !SP_ITEM(child)->isLocked())) { l = g_slist_prepend (l, child); @@@ -342,7 -342,7 +344,7 @@@ void sp_find_dialog_find(GObject *, GOb if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inlayer")))) { l = all_items (desktop->currentLayer(), l, hidden, locked); } else { -- l = all_items (SP_DOCUMENT_ROOT (sp_desktop_document (desktop)), l, hidden, locked); ++ l = all_items(sp_desktop_document(desktop)->getRoot(), l, hidden, locked); } } guint all = g_slist_length (l); @@@ -606,8 -606,10 +608,8 @@@ sp_find_types ( { GtkWidget *c = sp_find_types_checkbox_indented (vb, "clones", TRUE, tt, _("Search clones"), - //TRANSLATORS: "Clones" is a noun indicating type of object to find - C_("Find dialog","Clones"), NULL, 10); - //TRANSLATORS: only translate "string" in "context|string". - // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS - // "Clones" is a noun indicating type of object to find - Q_("find|Clones"), NULL, 10); ++ //TRANSLATORS: "Clones" is a noun indicating type of object to find ++ C_("Find dialog","Clones"), NULL, 10); gtk_box_pack_start (GTK_BOX (vb_all), c, FALSE, FALSE, 0); } diff --cc src/dialogs/item-properties.cpp index 40665e08e,d96b364ef..8b5ac1784 --- a/src/dialogs/item-properties.cpp +++ b/src/dialogs/item-properties.cpp @@@ -5,6 -5,6 +5,7 @@@ * Lauris Kaplinski * bulia byak * Johan Engelen ++ * Abhishek Sharma * * Copyright (C) 1999-2006 Authors * Copyright (C) 2001 Ximian, Inc. @@@ -41,6 -41,6 +42,8 @@@ #include "../widgets/sp-attribute-widget.h" #include "../widgets/sp-widget.h" ++using Inkscape::DocumentUndo; ++ #define MIN_ONSCREEN_DISTANCE 50 static GtkWidget *dlg = NULL; @@@ -398,8 -398,8 +401,8 @@@ sp_item_widget_sensitivity_toggled (Gtk item->setLocked(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))); - sp_document_done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, - SPDocumentUndo::done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, -- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))? _("Lock object") : _("Unlock object")); ++ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, ++ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))? _("Lock object") : _("Unlock object")); gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); } @@@ -417,8 -417,8 +420,8 @@@ sp_item_widget_hidden_toggled(GtkWidge item->setExplicitlyHidden(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))); - sp_document_done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, - SPDocumentUndo::done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, -- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))? _("Hide object") : _("Unhide object")); ++ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, ++ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))? _("Hide object") : _("Unhide object")); gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); } @@@ -447,11 -447,11 +450,11 @@@ sp_item_widget_label_changed( GtkWidge gtk_label_set_text (GTK_LABEL (id_label), _("Id exists! ")); } else { SPException ex; - gtk_label_set_markup_with_mnemonic (GTK_LABEL (id_label), _("_Id")); + gtk_label_set_markup_with_mnemonic (GTK_LABEL (id_label), _("_ID:")); SP_EXCEPTION_INIT (&ex); - sp_object_setAttribute (SP_OBJECT (item), "id", id, &ex); - sp_document_done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, - SP_OBJECT (item)->setAttribute ("id", id, &ex); - SPDocumentUndo::done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, -- _("Set object ID")); ++ item->setAttribute("id", id, &ex); ++ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, ++ _("Set object ID")); } /* Retrieve the label widget for the object's label */ @@@ -465,16 -465,16 +468,16 @@@ SPObject *obj = (SPObject*)item; if (strcmp (label, obj->defaultLabel())) { obj->setLabel(label); - sp_document_done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, - SPDocumentUndo::done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, -- _("Set object label")); ++ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, ++ _("Set object label")); } /* Retrieve the title */ GtkWidget *w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "title")); gchar *title = (gchar *)gtk_entry_get_text(GTK_ENTRY (w)); if (obj->setTitle(title)) - sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, - SPDocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, -- _("Set object title")); ++ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, ++ _("Set object title")); /* Retrieve the description */ GtkTextView *tv = GTK_TEXT_VIEW(gtk_object_get_data(GTK_OBJECT(spw), "desc")); @@@ -483,8 -483,8 +486,8 @@@ gtk_text_buffer_get_bounds(buf, &start, &end); gchar *desc = gtk_text_buffer_get_text(buf, &start, &end, TRUE); if (obj->setDesc(desc)) - sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, - SPDocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, -- _("Set object description")); ++ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, ++ _("Set object description")); g_free(desc); gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE)); diff --cc src/dialogs/spellcheck.cpp index 476a551f1,f95dce0e6..12105c8c0 --- a/src/dialogs/spellcheck.cpp +++ b/src/dialogs/spellcheck.cpp @@@ -3,6 -3,6 +3,8 @@@ */ /* Authors: * bulia byak ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2009 Authors * @@@ -200,10 -200,10 +202,11 @@@ all_text_items (SPObject *r, GSList *l if (SP_IS_DEFS(r)) return l; // we're not interested in items in defs -- if (!strcmp (SP_OBJECT_REPR (r)->name(), "svg:metadata")) ++ if (!strcmp(r->getRepr()->name(), "svg:metadata")) { return l; // we're not interested in metadata ++ } - for (SPObject *child = sp_object_first_child(r); child; child = SP_OBJECT_NEXT (child)) { - for (SPObject *child = r->first_child(); child; child = SP_OBJECT_NEXT (child)) { ++ for (SPObject *child = r->firstChild(); child; child = child->next) { if (SP_IS_ITEM (child) && !SP_OBJECT_IS_CLONED (child) && !_desktop->isLayer(SP_ITEM(child))) { if ((hidden || !_desktop->itemIsHidden(SP_ITEM(child))) && (locked || !SP_ITEM(child)->isLocked())) { if (SP_IS_TEXT(child) || SP_IS_FLOWTEXT(child)) @@@ -392,7 -392,7 +395,7 @@@ spellcheck_init(SPDesktop *desktop _speller3 = to_aspell_speller(ret); } -- _root = SP_DOCUMENT_ROOT (sp_desktop_document (desktop)); ++ _root = sp_desktop_document(desktop)->getRoot(); // empty the list of objects we've checked g_slist_free (_seen_objects); @@@ -777,8 -777,8 +780,8 @@@ sp_spellcheck_accept (GObject *, GObjec // find the end of the word anew _end_w = _begin_w; _end_w.nextEndOfWord(); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_CONTEXT_TEXT, -- _("Fix spelling")); ++ SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_TEXT, ++ _("Fix spelling")); } } diff --cc src/dialogs/text-edit.cpp index 8a8fe6a29,ab0de514a..61f56e3f7 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@@ -5,6 -5,6 +5,7 @@@ * Lauris Kaplinski * bulia byak * Johan Engelen ++ * Abhishek Sharma * * Copyright (C) 1999-2007 Authors * Copyright (C) 2000-2001 Ximian, Inc. @@@ -49,6 -49,6 +50,8 @@@ extern "C" #include "widgets/icon.h" #include ++using Inkscape::DocumentUndo; ++ #define VB_MARGIN 4 #define MIN_ONSCREEN_DISTANCE 50 @@@ -638,7 -638,7 +641,7 @@@ sp_text_edit_dialog_apply( GtkButton */ if (SP_IS_TEXT (item_list->data)) { // backwards compatibility: -- SP_OBJECT_REPR(item_list->data)->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); ++ reinterpret_cast(item_list->data)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); ++items; } @@@ -661,8 -661,8 +664,8 @@@ } // complete the transaction - sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, -- _("Set text style")); ++ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, ++ _("Set text style")); gtk_widget_set_sensitive (apply, FALSE); sp_repr_css_attr_unref (css); g_object_set_data (G_OBJECT (dlg), "blocked", GINT_TO_POINTER (FALSE)); @@@ -727,7 -727,7 +730,7 @@@ sp_text_edit_dialog_read_selection ( Gt sp_font_preview_set_phrase (SP_FONT_PREVIEW (preview), NULL); } } // end of if (docontent) -- repr = SP_OBJECT_REPR (text); ++ repr = text->getRepr(); } else { gtk_widget_set_sensitive (textw, FALSE); diff --cc src/dialogs/xml-tree.cpp index bd442b887,515b49360..c90cde490 --- a/src/dialogs/xml-tree.cpp +++ b/src/dialogs/xml-tree.cpp @@@ -7,6 -7,6 +7,8 @@@ * bulia byak * Johan Engelen * David Turner ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 1999-2006 Authors * Released under GNU GPL, read the file 'COPYING' for more information @@@ -40,6 -40,6 +42,8 @@@ #include "../widgets/sp-xmlview-content.h" #include "../widgets/sp-xmlview-tree.h" ++using Inkscape::DocumentUndo; ++ #define MIN_ONSCREEN_DISTANCE 50 struct EditableDest { @@@ -679,9 -679,9 +683,8 @@@ void set_tree_document(SPDocument *docu if (current_document) { document_uri_set_connection = current_document->connectURISet(sigc::bind(sigc::ptr_fun(&on_document_uri_set), current_document)); -- on_document_uri_set(SP_DOCUMENT_URI(current_document), current_document); -- set_tree_repr(sp_document_repr_root(current_document)); -- ++ on_document_uri_set( current_document->getURI(), current_document ); ++ set_tree_repr(current_document->getReprRoot()); } else { set_tree_repr(NULL); } @@@ -870,10 -870,10 +873,10 @@@ void after_tree_move(GtkCTree */*tree*/ if (GTK_CTREE_ROW(node)->parent == new_parent && GTK_CTREE_ROW(node)->sibling == new_sibling) { - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, - SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, -- _("Drag XML subtree")); ++ DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, ++ _("Drag XML subtree")); } else { - sp_document_cancel(current_document); - SPDocumentUndo::cancel(current_document); ++ DocumentUndo::cancel(current_document); } } @@@ -1275,7 -1275,7 +1278,7 @@@ void on_document_uri_set(gchar const */ { gchar title[500]; sp_ui_dialog_title_string(Inkscape::Verb::get(SP_VERB_DIALOG_XML_EDITOR), title); -- gchar *t = g_strdup_printf("%s: %s", SP_DOCUMENT_NAME(document), title); ++ gchar *t = g_strdup_printf("%s: %s", document->getName(), title); gtk_window_set_title(GTK_WINDOW(dlg), t); g_free(t); } @@@ -1362,7 -1362,7 +1365,7 @@@ void cmd_new_element_node(GtkObject */* gtk_main(); if (selected_repr != NULL && name.text) { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_document); ++ Inkscape::XML::Document *xml_doc = current_document->getReprDoc(); Inkscape::XML::Node *new_repr; new_repr = xml_doc->createElement(name.text); Inkscape::GC::release(new_repr); @@@ -1371,8 -1371,8 +1374,8 @@@ set_tree_select(new_repr); set_dt_select(new_repr); - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, - SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, -- _("Create new element node")); ++ DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, ++ _("Create new element node")); } } // end of cmd_new_element_node() @@@ -1383,12 -1383,12 +1386,12 @@@ void cmd_new_text_node(GtkObject */*obj { g_assert(selected_repr != NULL); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_document); ++ Inkscape::XML::Document *xml_doc = current_document->getReprDoc(); Inkscape::XML::Node *text = xml_doc->createTextNode(""); selected_repr->appendChild(text); - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, - SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, -- _("Create new text node")); ++ DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, ++ _("Create new text node")); set_tree_select(text); set_dt_select(text); @@@ -1405,8 -1405,8 +1408,8 @@@ void cmd_duplicate_node(GtkObject */*ob Inkscape::XML::Node *dup = selected_repr->duplicate(parent->document()); parent->addChild(dup, selected_repr); - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, - SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, -- _("Duplicate node")); ++ DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, ++ _("Duplicate node")); GtkCTreeNode *node = sp_xmlview_tree_get_repr_node(SP_XMLVIEW_TREE(tree), dup); @@@ -1422,8 -1422,8 +1425,8 @@@ void cmd_delete_node(GtkObject */*objec g_assert(selected_repr != NULL); sp_repr_unparent(selected_repr); - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, - SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, -- Q_("nodeAsInXMLinHistoryDialog|Delete node")); ++ DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, ++ Q_("nodeAsInXMLinHistoryDialog|Delete node")); } @@@ -1440,8 -1440,8 +1443,8 @@@ void cmd_delete_attr(GtkObject */*objec updated->updateRepr(); } - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, - SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, -- _("Delete attribute")); ++ DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, ++ _("Delete attribute")); } @@@ -1469,8 -1469,8 +1472,8 @@@ void cmd_set_attr(GtkObject */*object*/ updated->updateRepr(); } - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, - SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, -- _("Change attribute")); ++ DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, ++ _("Change attribute")); /* TODO: actually, the row won't have been created yet. why? */ gint row = sp_xmlview_attr_list_find_row_from_key(GTK_CLIST(attributes), @@@ -1499,8 -1499,8 +1502,8 @@@ void cmd_raise_node(GtkObject */*object parent->changeOrder(selected_repr, ref); - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, - SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, -- _("Raise node")); ++ DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, ++ _("Raise node")); set_tree_select(selected_repr); set_dt_select(selected_repr); @@@ -1516,8 -1516,8 +1519,8 @@@ void cmd_lower_node(GtkObject */*object parent->changeOrder(selected_repr, selected_repr->next()); - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, - SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, -- _("Lower node")); ++ DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, ++ _("Lower node")); set_tree_select(selected_repr); set_dt_select(selected_repr); @@@ -1546,8 -1546,8 +1549,8 @@@ void cmd_indent_node(GtkObject */*objec parent->removeChild(repr); prev->addChild(repr, ref); - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, - SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, -- _("Indent node")); ++ DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, ++ _("Indent node")); set_tree_select(repr); set_dt_select(repr); @@@ -1567,8 -1567,8 +1570,8 @@@ void cmd_unindent_node(GtkObject */*obj parent->removeChild(repr); grandparent->addChild(repr, parent); - sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR, - SPDocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, -- _("Unindent node")); ++ DocumentUndo::done(current_document, SP_VERB_DIALOG_XML_EDITOR, ++ _("Unindent node")); set_tree_select(repr); set_dt_select(repr); diff --cc src/display/canvas-grid.cpp index 34c60b140,7a21c19b8..df73eb78e --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@@ -3,6 -3,6 +3,7 @@@ */ /* Copyright (C) Johan Engelen 2006-2007 * Copyright (C) Lauris Kaplinski 2000 ++ * Abhishek Sharma */ /* As a general comment, I am not exactly proud of how things are done. @@@ -11,8 -11,8 +12,6 @@@ * Don't be shy to correct things. */ --#define INKSCAPE_CANVAS_GRID_C -- #include "sp-canvas-util.h" #include "util/mathfns.h" #include "display-forward.h" @@@ -33,6 -33,6 +32,8 @@@ #include "canvas-grid.h" #include "canvas-axonomgrid.h" ++using Inkscape::DocumentUndo; ++ namespace Inkscape { static gchar const *const grid_name[] = { @@@ -247,7 -247,7 +248,7 @@@ CanvasGrid::writeNewGridToRepr(Inkscape // first create the child xml node, then hook it to repr. This order is important, to not set off listeners to repr before the new node is complete. -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *newnode; newnode = xml_doc->createElement("inkscape:grid"); newnode->setAttribute("type", getSVGName(gridtype)); @@@ -255,7 -255,7 +256,7 @@@ repr->appendChild(newnode); Inkscape::GC::release(newnode); - sp_document_done(doc, SP_VERB_DIALOG_NAMEDVIEW, _("Create new grid")); - SPDocumentUndo::done(doc, SP_VERB_DIALOG_NAMEDVIEW, _("Create new grid")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_NAMEDVIEW, _("Create new grid")); } /* diff --cc src/display/nr-filter-image.cpp index b0b3ee184,73082f4c0..9a39168c2 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@@ -4,6 -4,6 +4,7 @@@ * Authors: * Felipe Corrêa da Silva Sanches * Tavmjong Bah ++ * Abhishek Sharma * * Copyright (C) 2007 authors * @@@ -49,10 -49,10 +50,10 @@@ int FilterImage::render(FilterSlot &slo if (!SVGElem) return 0; // prep the document - sp_document_ensure_up_to_date(document); - document->ensure_up_to_date(); ++ document->ensureUpToDate(); NRArena* arena = NRArena::create(); - unsigned const key = sp_item_display_key_new(1); - NRArenaItem* ai = sp_item_invoke_show(SVGElem, arena, key, SP_ITEM_SHOW_DISPLAY); + unsigned const key = SPItem::display_key_new(1); + NRArenaItem* ai = SVGElem->invoke_show(arena, key, SP_ITEM_SHOW_DISPLAY); if (!ai) { g_warning("feImage renderer: error creating NRArenaItem for SVG Element"); nr_object_unref((NRObject *) arena); @@@ -118,7 -118,7 +119,7 @@@ if ( !g_file_test( fullname, G_FILE_TEST_EXISTS ) ) { // Try to load from relative postion combined with document base if( document ) { -- fullname = g_build_filename( document->base, feImageHref, NULL ); ++ fullname = g_build_filename( document->getBase(), feImageHref, NULL ); } } if ( !g_file_test( fullname, G_FILE_TEST_EXISTS ) ) { diff --cc src/document-private.h index fa4754248,fa4754248..61e6bad67 --- a/src/document-private.h +++ b/src/document-private.h @@@ -1,11 -1,11 +1,12 @@@ --#ifndef __SP_DOCUMENT_PRIVATE_H__ --#define __SP_DOCUMENT_PRIVATE_H__ ++#ifndef SEEN_SP_DOCUMENT_PRIVATE_H ++#define SEEN_SP_DOCUMENT_PRIVATE_H /* * Seldom needed document data * * Authors: * Lauris Kaplinski ++ * Jon A. Cruz * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2001-2002 Ximian, Inc. @@@ -27,7 -27,7 +28,7 @@@ // XXX only for testing! #include "console-output-undo-observer.h" --#define SP_DOCUMENT_DEFS(d) ((SPObject *) SP_ROOT (SP_DOCUMENT_ROOT (d))->defs) ++#define SP_DOCUMENT_DEFS(d) ((SPObject *) SP_ROOT(d->getRoot())->defs) namespace Inkscape { namespace XML { @@@ -76,4 -76,4 +77,4 @@@ struct SPDocumentPrivate bool seeking; }; --#endif ++#endif // SEEN_SP_DOCUMENT_PRIVATE_H diff --cc src/document-subset.cpp index 6a7f8822c,a25205db9..e71b9bad5 --- a/src/document-subset.cpp +++ b/src/document-subset.cpp @@@ -3,6 -3,6 +3,7 @@@ * of nodes * * Copyright 2006 MenTaLguY ++ * Abhishek Sharma * * Released under GNU GPL, read the file 'COPYING' for more information */ diff --cc src/document-undo.cpp index e63fe8a52,280eea243..1559dc5ba --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@@ -1,11 -1,11 +1,10 @@@ --#define __SP_DOCUMENT_UNDO_C__ -- /** \file * Undo/Redo stack implementation * * Authors: * Lauris Kaplinski * MenTaLguY ++ * Abhishek Sharma * * Copyright (C) 2007 MenTaLguY * Copyright (C) 1999-2003 authors @@@ -23,8 -23,8 +22,8 @@@ * stack. Two methods exist to indicate that the given action is completed: * * \verbatim -- void sp_document_done (SPDocument *document); -- void sp_document_maybe_done (SPDocument *document, const unsigned char *key) \endverbatim ++ void sp_document_done( SPDocument *document ); ++ void sp_document_maybe_done( SPDocument *document, const unsigned char *key ) \endverbatim * * Both move the recent action list into the undo stack and clear the * list afterwards. While the first method does an unconditional push, @@@ -63,6 -63,7 +62,7 @@@ #include "xml/repr.h" #include "document-private.h" #include "inkscape.h" -//#include "document-undo.h" ++#include "document-undo.h" #include "debug/event-tracker.h" #include "debug/simple-event.h" #include "debug/timestamp.h" @@@ -72,20 -73,20 +72,8 @@@ /* * Undo & redo */ --/** -- * Set undo sensitivity. -- * -- * \note -- * Since undo sensitivity needs to be nested, setting undo sensitivity -- * should be done like this: -- *\verbatim -- bool saved = sp_document_get_undo_sensitive(document); -- sp_document_set_undo_sensitive(document, false); -- ... do stuff ... -- sp_document_set_undo_sensitive(document, saved); \endverbatim -- */ --void - sp_document_set_undo_sensitive (SPDocument *doc, bool sensitive) -SPDocumentUndo::set_undo_sensitive (SPDocument *doc, bool sensitive) ++ ++void Inkscape::DocumentUndo::setUndoSensitive(SPDocument *doc, bool sensitive) { g_assert (doc != NULL); g_assert (doc->priv != NULL); @@@ -112,23 -113,24 +100,22 @@@ * the saved bools in a stack. Perhaps this is why the above solution is better. */ - bool sp_document_get_undo_sensitive(SPDocument const *document) { -bool SPDocumentUndo::get_undo_sensitive(SPDocument const *document) { ++bool Inkscape::DocumentUndo::getUndoSensitive(SPDocument const *document) { g_assert(document != NULL); g_assert(document->priv != NULL); return document->priv->sensitive; } --void - sp_document_done (SPDocument *doc, const unsigned int event_type, Glib::ustring event_description) -SPDocumentUndo::done (SPDocument *doc, const unsigned int event_type, Glib::ustring event_description) ++void Inkscape::DocumentUndo::done(SPDocument *doc, const unsigned int event_type, Glib::ustring const &event_description) { - sp_document_maybe_done (doc, NULL, event_type, event_description); - maybe_done (doc, NULL, event_type, event_description); ++ maybeDone(doc, NULL, event_type, event_description); } - void sp_document_reset_key( Inkscape::Application * /*inkscape*/, SPDesktop * /*desktop*/, GtkObject *base ) -void -SPDocumentUndo::reset_key (Inkscape::Application */*inkscape*/, SPDesktop */*desktop*/, GtkObject *base) ++void Inkscape::DocumentUndo::resetKey( Inkscape::Application * /*inkscape*/, SPDesktop * /*desktop*/, GtkObject *base ) { - SPDocument *doc = (SPDocument *) base; - doc->actionkey = NULL; + SPDocument *doc = reinterpret_cast(base); + doc->actionkey.clear(); } namespace { @@@ -163,9 -165,9 +150,8 @@@ public } --void - sp_document_maybe_done (SPDocument *doc, const gchar *key, const unsigned int event_type, -SPDocumentUndo::maybe_done (SPDocument *doc, const gchar *key, const unsigned int event_type, -- Glib::ustring event_description) ++void Inkscape::DocumentUndo::maybeDone(SPDocument *doc, const gchar *key, const unsigned int event_type, ++ Glib::ustring const &event_description) { g_assert (doc != NULL); g_assert (doc->priv != NULL); @@@ -178,9 -177,9 +164,9 @@@ doc->collectOrphans(); - sp_document_ensure_up_to_date (doc); - doc->ensure_up_to_date (); ++ doc->ensureUpToDate(); - sp_document_clear_redo (doc); - SPDocumentUndo::clear_redo (doc); ++ DocumentUndo::clearRedo(doc); Inkscape::XML::Event *log = sp_repr_coalesce_log (doc->priv->partial, sp_repr_commit_undoable (doc->rdoc)); doc->priv->partial = NULL; @@@ -214,8 -209,8 +200,7 @@@ doc->priv->commit_signal.emit(); } --void - sp_document_cancel (SPDocument *doc) -SPDocumentUndo::cancel (SPDocument *doc) ++void Inkscape::DocumentUndo::cancel(SPDocument *doc) { g_assert (doc != NULL); g_assert (doc->priv != NULL); @@@ -246,8 -241,8 +231,7 @@@ static void finish_incomplete_transacti } } --gboolean - sp_document_undo (SPDocument *doc) -SPDocumentUndo::undo (SPDocument *doc) ++gboolean Inkscape::DocumentUndo::undo(SPDocument *doc) { using Inkscape::Debug::EventTracker; using Inkscape::Debug::SimpleEvent; @@@ -292,8 -287,8 +276,7 @@@ return ret; } --gboolean - sp_document_redo (SPDocument *doc) -SPDocumentUndo::redo (SPDocument *doc) ++gboolean Inkscape::DocumentUndo::redo(SPDocument *doc) { using Inkscape::Debug::EventTracker; using Inkscape::Debug::SimpleEvent; @@@ -338,8 -333,8 +321,7 @@@ return ret; } --void - sp_document_clear_undo (SPDocument *doc) -SPDocumentUndo::clear_undo (SPDocument *doc) ++void Inkscape::DocumentUndo::clearUndo(SPDocument *doc) { if (doc->priv->undo) doc->priv->undoStackObservers.notifyClearUndoEvent(); @@@ -356,8 -351,8 +338,7 @@@ } } --void - sp_document_clear_redo (SPDocument *doc) -SPDocumentUndo::clear_redo (SPDocument *doc) ++void Inkscape::DocumentUndo::clearRedo(SPDocument *doc) { if (doc->priv->redo) doc->priv->undoStackObservers.notifyClearRedoEvent(); diff --cc src/document-undo.h index 000000000,9fc49b112..9be260fa2 mode 000000,100644..100644 --- a/src/document-undo.h +++ b/src/document-undo.h @@@ -1,0 -1,14 +1,57 @@@ -class SPDocumentUndo ++#ifndef SEEN_SP_DOCUMENT_UNDO_H ++#define SEEN_SP_DOCUMENT_UNDO_H ++ ++ ++namespace Inkscape { ++ ++class DocumentUndo + { - public: - static void set_undo_sensitive(SPDocument *doc, bool sensitive); - static bool get_undo_sensitive(SPDocument const *document); - static void clear_undo(SPDocument *document); - static void clear_redo(SPDocument *document); - static void done(SPDocument *document, unsigned int event_type, Glib::ustring event_description); - static void maybe_done(SPDocument *document, const gchar *keyconst, unsigned int event_type, Glib::ustring event_description); - static void reset_key(Inkscape::Application *inkscape, SPDesktop *desktop, GtkObject *base); - static void cancel(SPDocument *document); - static gboolean undo(SPDocument *document); - static gboolean redo(SPDocument *document); ++public: ++ ++ /** ++ * Set undo sensitivity. ++ * ++ * \note ++ * Since undo sensitivity needs to be nested, setting undo sensitivity ++ * should be done like this: ++ *\verbatim ++ bool saved = sp_document_get_undo_sensitive(document); ++ sp_document_set_undo_sensitive(document, false); ++ ... do stuff ... ++ sp_document_set_undo_sensitive(document, saved); \endverbatim ++ */ ++ static void setUndoSensitive(SPDocument *doc, bool sensitive); ++ ++ static bool getUndoSensitive(SPDocument const *document); ++ ++ static void clearUndo(SPDocument *document); ++ ++ static void clearRedo(SPDocument *document); ++ ++ static void done(SPDocument *document, unsigned int event_type, Glib::ustring const &event_description); ++ ++ static void maybeDone(SPDocument *document, const gchar *keyconst, unsigned int event_type, Glib::ustring const &event_description); ++ ++ static void resetKey(Inkscape::Application *inkscape, SPDesktop *desktop, GtkObject *base); ++ ++ static void cancel(SPDocument *document); ++ ++ static gboolean undo(SPDocument *document); ++ ++ static gboolean redo(SPDocument *document); + }; ++ ++} // namespace Inkscape ++ ++#endif // SEEN_SP_DOCUMENT_UNDO_H ++ ++/* ++ Local Variables: ++ mode:c++ ++ c-file-style:"stroustrup" ++ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) ++ indent-tabs-mode:nil ++ fill-column:99 ++ End: ++*/ ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --cc src/document.cpp index 677883112,702c58d5d..a473daa3c --- a/src/document.cpp +++ b/src/document.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_DOCUMENT_C__ -- /** \file * SPDocument manipulation * @@@ -7,6 -7,6 +5,8 @@@ * Lauris Kaplinski * MenTaLguY * bulia byak ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2004-2005 MenTaLguY * Copyright (C) 1999-2002 Lauris Kaplinski @@@ -61,6 -63,6 +61,8 @@@ #include "xml/repr.h" #include "xml/rebase-hrefs.h" ++using Inkscape::DocumentUndo; ++ // Higher number means lower priority. #define SP_DOCUMENT_UPDATE_PRIORITY (G_PRIORITY_HIGH_IDLE - 2) @@@ -148,8 -150,8 +150,8 @@@ SPDocument::~SPDocument() priv->partial = NULL; } - sp_document_clear_redo(this); - sp_document_clear_undo(this); - SPDocumentUndo::clear_redo(this); - SPDocumentUndo::clear_undo(this); ++ DocumentUndo::clearRedo(this); ++ DocumentUndo::clearUndo(this); if (root) { root->releaseReferences(); @@@ -198,7 -200,7 +200,7 @@@ if (oldSignalsConnected) { g_signal_handlers_disconnect_by_func(G_OBJECT(INKSCAPE), - reinterpret_cast(sp_document_reset_key), - reinterpret_cast(SPDocumentUndo::reset_key), ++ reinterpret_cast(DocumentUndo::resetKey), static_cast(this)); } else { _selection_changed_connection.disconnect(); @@@ -239,12 -242,12 +241,13 @@@ SPDocument::setCurrentPersp3D(Persp3D //current_persp3d_impl = persp->perspective_impl; } --void --SPDocument::getPerspectivesInDefs(std::vector &list) { ++void SPDocument::getPerspectivesInDefs(std::vector &list) const ++{ SPDefs *defs = SP_ROOT(this->root)->defs; - for (SPObject *i = sp_object_first_child(SP_OBJECT(defs)); i != NULL; i = SP_OBJECT_NEXT(i) ) { - for (SPObject *i = SP_OBJECT(defs)->first_child(); i != NULL; i = SP_OBJECT_NEXT(i) ) { -- if (SP_IS_PERSP3D(i)) ++ for (SPObject *i = defs->firstChild(); i; i = i->getNext() ) { ++ if (SP_IS_PERSP3D(i)) { list.push_back(SP_PERSP3D(i)); ++ } } } @@@ -285,23 -288,23 +288,19 @@@ void SPDocument::collectOrphans() void SPDocument::reset_key (void */*dummy*/) { - actionkey = NULL; + actionkey.clear(); } --SPDocument * - sp_document_create(Inkscape::XML::Document *rdoc, -SPDocument::createDoc(Inkscape::XML::Document *rdoc, -- gchar const *uri, -- gchar const *base, -- gchar const *name, -- unsigned int keepalive) ++SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, ++ gchar const *uri, ++ gchar const *base, ++ gchar const *name, ++ unsigned int keepalive) { -- SPDocument *document; -- Inkscape::XML::Node *rroot; -- Inkscape::Preferences *prefs = Inkscape::Preferences::get(); -- -- rroot = rdoc->root(); ++ SPDocument *document = new SPDocument(); -- document = new SPDocument(); ++ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); ++ Inkscape::XML::Node *rroot = rdoc->root(); document->keepalive = keepalive; @@@ -318,10 -321,10 +317,11 @@@ // base is simply the part of the path before filename; e.g. when running "inkscape ../file.svg" the base is "../" // which is why we use g_get_current_dir() in calculating the abs path above //This is NULL for a new document -- if (base) ++ if (base) { document->base = g_strdup(base); -- else ++ } else { document->base = NULL; ++ } document->name = g_strdup(name); document->root = sp_object_repr_build_tree(document, rroot); @@@ -413,14 -416,20 +413,14 @@@ document->setCurrentPersp3DImpl(persp_impl); } - sp_document_set_undo_sensitive(document, true); - SPDocumentUndo::set_undo_sensitive(document, true); ++ DocumentUndo::setUndoSensitive(document, true); // reset undo key when selection changes, so that same-key actions on different objects are not coalesced - if (!Inkscape::NSApplication::Application::getNewGui()) { - g_signal_connect(G_OBJECT(INKSCAPE), "change_selection", - G_CALLBACK(SPDocumentUndo::reset_key), document); - g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", - G_CALLBACK(SPDocumentUndo::reset_key), document); - document->oldSignalsConnected = true; - } else { - document->_selection_changed_connection = Inkscape::NSApplication::Editor::connectSelectionChanged (sigc::mem_fun (*document, &SPDocument::reset_key)); - document->_desktop_activated_connection = Inkscape::NSApplication::Editor::connectDesktopActivated (sigc::mem_fun (*document, &SPDocument::reset_key)); - document->oldSignalsConnected = false; - } + g_signal_connect(G_OBJECT(INKSCAPE), "change_selection", - G_CALLBACK(sp_document_reset_key), document); ++ G_CALLBACK(DocumentUndo::resetKey), document); + g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop", - G_CALLBACK(sp_document_reset_key), document); ++ G_CALLBACK(DocumentUndo::resetKey), document); + document->oldSignalsConnected = true; return document; } @@@ -429,8 -438,8 +429,7 @@@ * Fetches document from URI, or creates new, if NULL; public document * appears in document list. */ --SPDocument * - sp_document_new(gchar const *uri, unsigned int keepalive, bool make_new) -SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, bool make_new) ++SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, bool make_new) { SPDocument *doc; Inkscape::XML::Document *rdoc; @@@ -480,8 -489,8 +479,7 @@@ return doc; } --SPDocument * - sp_document_new_from_mem(gchar const *buffer, gint length, unsigned int keepalive) -SPDocument::createNewDocFromMem(gchar const *buffer, gint length, unsigned int keepalive) ++SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, unsigned int keepalive) { SPDocument *doc; Inkscape::XML::Document *rdoc; @@@ -505,39 -514,39 +503,33 @@@ return doc; } --SPDocument * - sp_document_ref(SPDocument *doc) -SPDocument::doRef() ++SPDocument *SPDocument::doRef() { - g_return_val_if_fail(doc != NULL, NULL); - Inkscape::GC::anchor(doc); - return doc; - g_return_val_if_fail(this != NULL, NULL); + Inkscape::GC::anchor(this); + return this; } --SPDocument * - sp_document_unref(SPDocument *doc) -SPDocument::doUnref() ++SPDocument *SPDocument::doUnref() { - g_return_val_if_fail(doc != NULL, NULL); - Inkscape::GC::release(doc); - g_return_val_if_fail(this != NULL, NULL); + Inkscape::GC::release(this); return NULL; } - gdouble sp_document_width(SPDocument *document) -gdouble SPDocument::getWidth() ++gdouble SPDocument::getWidth() const { - g_return_val_if_fail(document != NULL, 0.0); - g_return_val_if_fail(document->priv != NULL, 0.0); - g_return_val_if_fail(document->root != NULL, 0.0); - g_return_val_if_fail(this != NULL, 0.0); + g_return_val_if_fail(this->priv != NULL, 0.0); + g_return_val_if_fail(this->root != NULL, 0.0); - SPRoot *root = SP_ROOT(document->root); + SPRoot *root = SP_ROOT(this->root); if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) return root->viewBox.x1 - root->viewBox.x0; return root->width.computed; } --void - sp_document_set_width (SPDocument *document, gdouble width, const SPUnit *unit) -SPDocument::setWidth (gdouble width, const SPUnit *unit) ++void SPDocument::setWidth(gdouble width, const SPUnit *unit) { - SPRoot *root = SP_ROOT(document->root); + SPRoot *root = SP_ROOT(this->root); if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= root->viewBox.x1 = root->viewBox.x0 + sp_units_get_pixels (width, *unit); @@@ -561,9 -570,9 +553,9 @@@ SP_OBJECT (root)->updateRepr(); } - void sp_document_set_height (SPDocument * document, gdouble height, const SPUnit *unit) -void SPDocument::setHeight (gdouble height, const SPUnit *unit) ++void SPDocument::setHeight(gdouble height, const SPUnit *unit) { - SPRoot *root = SP_ROOT(document->root); + SPRoot *root = SP_ROOT(this->root); if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= root->viewBox.y1 = root->viewBox.y0 + sp_units_get_pixels (height, *unit); @@@ -587,58 -596,61 +579,23 @@@ SP_OBJECT (root)->updateRepr(); } - gdouble sp_document_height(SPDocument *document) -gdouble SPDocument::getHeight() ++gdouble SPDocument::getHeight() const { - g_return_val_if_fail(document != NULL, 0.0); - g_return_val_if_fail(document->priv != NULL, 0.0); - g_return_val_if_fail(document->root != NULL, 0.0); - g_return_val_if_fail(this != NULL, 0.0); + g_return_val_if_fail(this->priv != NULL, 0.0); + g_return_val_if_fail(this->root != NULL, 0.0); - SPRoot *root = SP_ROOT(document->root); + SPRoot *root = SP_ROOT(this->root); if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) return root->viewBox.y1 - root->viewBox.y0; return root->height.computed; } - Geom::Point sp_document_dimensions(SPDocument *doc) - { - return Geom::Point(sp_document_width(doc), sp_document_height(doc)); - } - - /** - * Gets page fitting margin information from the namedview node in the XML. - * \param nv_repr reference to this document's namedview - * \param key the same key used by the RegisteredScalarUnit in - * ui/widget/page-sizer.cpp - * \param margin_units units for the margin - * \param return_units units to return the result in - * \param width width in px (for percentage margins) - * \param height height in px (for percentage margins) - * \param use_width true if the this key is left or right margins, false - * otherwise. Used for percentage margins. - * \return the margin size in px, else 0.0 if anything is invalid. - */ - static double getMarginLength(Inkscape::XML::Node * const nv_repr, - gchar const * const key, - SPUnit const * const margin_units, - SPUnit const * const return_units, - double const width, - double const height, - bool const use_width) -Geom::Point SPDocument::getDimensions() ++Geom::Point SPDocument::getDimensions() const { - double value; - if (!sp_repr_get_double (nv_repr, key, &value)) { - return 0.0; - } - if (margin_units == &sp_unit_get_by_id (SP_UNIT_PERCENT)) { - return (use_width)? width * value : height * value; - } - if (!sp_convert_distance (&value, margin_units, return_units)) { - return 0.0; - } - return value; + return Geom::Point(getWidth(), getHeight()); } -/** - * Gets page fitting margin information from the namedview node in the XML. - * \param nv_repr reference to this document's namedview - * \param key the same key used by the RegisteredScalarUnit in - * ui/widget/page-sizer.cpp - * \param margin_units units for the margin - * \param return_units units to return the result in - * \param width width in px (for percentage margins) - * \param height height in px (for percentage margins) - * \param use_width true if the this key is left or right margins, false - * otherwise. Used for percentage margins. - * \return the margin size in px, else 0.0 if anything is invalid. - */ -//static double getMarginLength(/*Inkscape::XML::Node * const nv_repr*/ -/* gchar const * const key, - SPUnit const * const margin_units, - SPUnit const * const return_units, - double const width, - double const height, - bool const use_width)*/ -//{ - // double value; - /*if (!sp_repr_get_double (nv_repr, key, &value)) { - return 0.0; - }*/ -/* if(!this->storeAsDouble(key,&value)) { - return 0.0; - } - if (margin_units == &sp_unit_get_by_id (SP_UNIT_PERCENT)) { - return (use_width)? width * value : height * value; - } - if (!sp_convert_distance (&value, margin_units, return_units)) { - return 0.0; - } - return value; -}*/ - /** * Given a Geom::Rect that may, for example, correspond to the bbox of an object, * this function fits the canvas to that rect by resizing the canvas @@@ -665,9 -677,10 +622,8 @@@ void SPDocument::fitToRect(Geom::Rect c SPNamedView *nv = sp_document_namedview(this, 0); if (with_margins && nv) { - Inkscape::XML::Node *nv_repr = SP_OBJECT_REPR (nv); - if (nv_repr != NULL) { - gchar const * const units_abbr = nv_repr->attribute("units"); - //Inkscape::XML::Node *nv_repr = SP_OBJECT_REPR (nv); + if (nv != NULL) { - //gchar const * const units_abbr = nv_repr->attribute("units"); + gchar const * const units_abbr = nv->getAttribute("units"); SPUnit const *margin_units = NULL; if (units_abbr != NULL) { margin_units = sp_unit_get_by_abbreviation(units_abbr); @@@ -675,14 -688,21 +631,10 @@@ if (margin_units == NULL) { margin_units = &px; } - /* -- margin_top = getMarginLength(nv_repr, "fit-margin-top", -- margin_units, &px, w, h, false); -- margin_left = getMarginLength(nv_repr, "fit-margin-left", -- margin_units, &px, w, h, true); -- margin_right = getMarginLength(nv_repr, "fit-margin-right", -- margin_units, &px, w, h, true); -- margin_bottom = getMarginLength(nv_repr, "fit-margin-bottom", - margin_units, &px, w, h, false); - margin_units, &px, w, h, false);*/ - margin_top = nv->getMarginLength("fit-margin-top",margin_units, &px, w, h, false); - margin_top = nv->getMarginLength("fit-margin-left",margin_units, &px, w, h, true); - margin_top = nv->getMarginLength("fit-margin-right",margin_units, &px, w, h, true); - margin_top = nv->getMarginLength("fit-margin-bottom",margin_units, &px, w, h, false); - - ++ margin_top = nv->getMarginLength("fit-margin-top",margin_units, &px, w, h, false); ++ margin_top = nv->getMarginLength("fit-margin-left",margin_units, &px, w, h, true); ++ margin_top = nv->getMarginLength("fit-margin-right",margin_units, &px, w, h, true); ++ margin_top = nv->getMarginLength("fit-margin-bottom",margin_units, &px, w, h, false); } } @@@ -708,14 -728,14 +660,22 @@@ } } - static void - do_change_uri(SPDocument *const document, gchar const *const filename, bool const rebase) -void -SPDocument::do_change_uri(gchar const *const filename, bool const rebase) ++void SPDocument::setBase( gchar const* base ) { - g_return_if_fail(document != NULL); - //g_return_if_fail(this != NULL); ++ if (this->base) { ++ g_free(this->base); ++ this->base = 0; ++ } ++ if (base) { ++ this->base = g_strdup(base); ++ } ++} -- gchar *new_base; -- gchar *new_name; -- gchar *new_uri; ++void SPDocument::do_change_uri(gchar const *const filename, bool const rebase) ++{ ++ gchar *new_base = 0; ++ gchar *new_name = 0; ++ gchar *new_uri = 0; if (filename) { #ifndef WIN32 @@@ -734,28 -754,28 +694,28 @@@ } // Update saveable repr attributes. - Inkscape::XML::Node *repr = sp_document_repr_root(document); - Inkscape::XML::Node *repr = sp_document_repr_root(this); ++ Inkscape::XML::Node *repr = getReprRoot(); // Changing uri in the document repr must not be not undoable. - bool const saved = sp_document_get_undo_sensitive(document); - sp_document_set_undo_sensitive(document, false); - bool const saved = SPDocumentUndo::get_undo_sensitive(this); - SPDocumentUndo::set_undo_sensitive(this, false); ++ bool const saved = DocumentUndo::getUndoSensitive(this); ++ DocumentUndo::setUndoSensitive(this, false); if (rebase) { - Inkscape::XML::rebase_hrefs(document, new_base, true); + Inkscape::XML::rebase_hrefs(this, new_base, true); } - repr->setAttribute("sodipodi:docname", document->name); - sp_document_set_undo_sensitive(document, saved); + repr->setAttribute("sodipodi:docname", this->name); - SPDocumentUndo::set_undo_sensitive(this, saved); ++ DocumentUndo::setUndoSensitive(this, saved); - g_free(document->name); - g_free(document->base); - g_free(document->uri); - document->name = new_name; - document->base = new_base; - document->uri = new_uri; + g_free(this->name); + g_free(this->base); + g_free(this->uri); + this->name = new_name; + this->base = new_base; + this->uri = new_uri; - document->priv->uri_set_signal.emit(document->uri); + this->priv->uri_set_signal.emit(this->uri); } /** @@@ -765,11 -785,11 +725,9 @@@ * * \see sp_document_change_uri_and_hrefs */ - void sp_document_set_uri(SPDocument *document, gchar const *filename) + void SPDocument::setUri(gchar const *filename) { - g_return_if_fail(document != NULL); - //g_return_if_fail(this != NULL); -- - do_change_uri(document, filename, false); + do_change_uri(filename, false); } /** @@@ -778,19 -798,19 +736,14 @@@ * * \see sp_document_set_uri */ - void sp_document_change_uri_and_hrefs(SPDocument *document, gchar const *filename) -void SPDocument::change_uri_and_hrefs(gchar const *filename) ++void SPDocument::changeUriAndHrefs(gchar const *filename) { - g_return_if_fail(document != NULL); - //g_return_if_fail(this != NULL); -- - do_change_uri(document, filename, true); + do_change_uri(filename, true); } --void - sp_document_resized_signal_emit(SPDocument *doc, gdouble width, gdouble height) -SPDocument::resized_signal_emit(gdouble width, gdouble height) ++void SPDocument::emitResizedSignal(gdouble width, gdouble height) { - g_return_if_fail(doc != NULL); - //g_return_if_fail(this != NULL); -- - doc->priv->resized_signal.emit(width, height); + this->priv->resized_signal.emit(width, height); } sigc::connection SPDocument::connectModified(SPDocument::ModifiedSignal::slot_type slot) @@@ -890,7 -910,7 +843,8 @@@ SPDocument::removeUndoObserver(Inkscape this->priv->undoStackObservers.remove(observer); } --SPObject *SPDocument::getObjectById(gchar const *id) { ++SPObject *SPDocument::getObjectById(gchar const *id) const ++{ g_return_val_if_fail(id != NULL, NULL); GQuark idq = g_quark_from_string(id); @@@ -903,7 -923,7 +857,8 @@@ sigc::connection SPDocument::connectIdC return priv->id_changed_signals[g_quark_from_string(id)].connect(slot); } --void SPDocument::bindObjectToRepr(Inkscape::XML::Node *repr, SPObject *object) { ++void SPDocument::bindObjectToRepr(Inkscape::XML::Node *repr, SPObject *object) ++{ if (object) { g_assert(g_hash_table_lookup(priv->reprdef, repr) == NULL); g_hash_table_insert(priv->reprdef, repr, object); @@@ -913,12 -933,12 +868,14 @@@ } } --SPObject *SPDocument::getObjectByRepr(Inkscape::XML::Node *repr) { ++SPObject *SPDocument::getObjectByRepr(Inkscape::XML::Node *repr) const ++{ g_return_val_if_fail(repr != NULL, NULL); return (SPObject*)g_hash_table_lookup(priv->reprdef, repr); } --Glib::ustring SPDocument::getLanguage() { ++Glib::ustring SPDocument::getLanguage() const ++{ gchar const *document_language = rdf_get_work_entity(this, rdf_find_entity("language")); if (document_language) { while (isspace(*document_language)) @@@ -949,16 -969,16 +906,15 @@@ /* Object modification root handler */ --void - sp_document_request_modified(SPDocument *doc) -SPDocument::request_modified() ++void SPDocument::requestModified() { - if (!doc->modified_id) { - doc->modified_id = g_idle_add_full(SP_DOCUMENT_UPDATE_PRIORITY, - sp_document_idle_handler, doc, NULL); + if (!modified_id) { + modified_id = g_idle_add_full(SP_DOCUMENT_UPDATE_PRIORITY, + sp_document_idle_handler, this, NULL); } - if (!doc->rerouting_handler_id) { - doc->rerouting_handler_id = g_idle_add_full(SP_DOCUMENT_REROUTING_PRIORITY, - sp_document_rerouting_handler, doc, NULL); + if (!rerouting_handler_id) { + rerouting_handler_id = g_idle_add_full(SP_DOCUMENT_REROUTING_PRIORITY, + sp_document_rerouting_handler, this, NULL); } } @@@ -996,12 -1016,12 +952,12 @@@ SPDocument::_updateDocument( SPItemCtx ctx; sp_document_setup_viewport (this, &ctx); - bool saved = sp_document_get_undo_sensitive(this); - sp_document_set_undo_sensitive(this, false); - bool saved = SPDocumentUndo::get_undo_sensitive(this); - SPDocumentUndo::set_undo_sensitive(this, false); ++ bool saved = DocumentUndo::getUndoSensitive(this); ++ DocumentUndo::setUndoSensitive(this, false); this->root->updateDisplay((SPCtx *)&ctx, 0); - sp_document_set_undo_sensitive(this, saved); - SPDocumentUndo::set_undo_sensitive(this, saved); ++ DocumentUndo::setUndoSensitive(this, saved); } this->_emitModified(); } @@@ -1017,8 -1037,8 +973,7 @@@ * more than 32 iterations. So we bail out if we hit 32 iterations, * since this typically indicates we're stuck in an update loop. */ --gint - sp_document_ensure_up_to_date(SPDocument *doc) -SPDocument::ensure_up_to_date() ++gint SPDocument::ensureUpToDate() { // Bring the document up-to-date, specifically via the following: // 1a) Process all document updates. @@@ -1047,15 -1067,15 +1002,15 @@@ } } - if (doc->modified_id) { - /* Remove handler */ - g_source_remove(doc->modified_id); - doc->modified_id = 0; + if (modified_id) { - /* Remove handler */ ++ // Remove handler + g_source_remove(modified_id); + modified_id = 0; } - if (doc->rerouting_handler_id) { - /* Remove handler */ - g_source_remove(doc->rerouting_handler_id); - doc->rerouting_handler_id = 0; + if (rerouting_handler_id) { - /* Remove handler */ ++ // Remove handler + g_source_remove(rerouting_handler_id); + rerouting_handler_id = 0; } return counter>0; } @@@ -1109,17 -1129,17 +1064,16 @@@ static GSList *find_items_in_area(GSLis { g_return_val_if_fail(SP_IS_GROUP(group), s); - for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { - for (SPObject *o = SP_OBJECT(group)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { -- if (!SP_IS_ITEM(o)) { -- continue; -- } -- if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER ) { -- s = find_items_in_area(s, SP_GROUP(o), dkey, area, test); -- } else { -- SPItem *child = SP_ITEM(o); - Geom::OptRect box = sp_item_bbox_desktop(child); - Geom::OptRect box = child->getBboxDesktop(); -- if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) { -- s = g_slist_append(s, child); ++ for ( SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { ++ if ( SP_IS_ITEM(o) ) { ++ if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER ) { ++ s = find_items_in_area(s, SP_GROUP(o), dkey, area, test); ++ } else { ++ SPItem *child = SP_ITEM(o); ++ Geom::OptRect box = child->getBboxDesktop(); ++ if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) { ++ s = g_slist_append(s, child); ++ } } } } @@@ -1132,48 -1152,47 +1086,45 @@@ Returns true if an item is among the de */ bool item_is_in_group(SPItem *item, SPGroup *group) { - for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { - for (SPObject *o = SP_OBJECT(group)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { -- if (!SP_IS_ITEM(o)) continue; -- if (SP_ITEM(o) == item) -- return true; -- if (SP_IS_GROUP(o)) -- if (item_is_in_group(item, SP_GROUP(o))) -- return true; ++ bool inGroup = false; ++ for ( SPObject *o = group->firstChild() ; o && !inGroup; o = o->getNext() ) { ++ if ( SP_IS_ITEM(o) ) { ++ if (SP_ITEM(o) == item) { ++ inGroup = true; ++ } else if ( SP_IS_GROUP(o) ) { ++ inGroup = item_is_in_group(item, SP_GROUP(o)); ++ } ++ } } -- return false; ++ return inGroup; } --/** --Returns the bottommost item from the list which is at the point, or NULL if none. --*/ --SPItem* - sp_document_item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, GSList const *list, - Geom::Point const p, bool take_insensitive) -SPDocument::item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, GSList const *list,Geom::Point const p, bool take_insensitive) ++SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, GSList const *list,Geom::Point const p, bool take_insensitive) { g_return_val_if_fail(group, NULL); ++ SPItem *bottomMost = 0; ++ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0); - for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { - for (SPObject *o = SP_OBJECT(group)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { -- -- if (!SP_IS_ITEM(o)) continue; -- -- SPItem *item = SP_ITEM(o); - NRArenaItem *arenaitem = sp_item_get_arenaitem(item, dkey); - NRArenaItem *arenaitem = item->get_arenaitem(dkey); -- if (arenaitem && nr_arena_item_invoke_pick(arenaitem, p, delta, 1) != NULL -- && (take_insensitive || item->isVisibleAndUnlocked(dkey))) { -- if (g_slist_find((GSList *) list, item) != NULL) -- return item; -- } ++ for ( SPObject *o = group->firstChild() ; o && !bottomMost; o = o->getNext() ) { ++ if ( SP_IS_ITEM(o) ) { ++ SPItem *item = SP_ITEM(o); ++ NRArenaItem *arenaitem = item->get_arenaitem(dkey); ++ if (arenaitem && nr_arena_item_invoke_pick(arenaitem, p, delta, 1) != NULL ++ && (take_insensitive || item->isVisibleAndUnlocked(dkey))) { ++ if (g_slist_find((GSList *) list, item) != NULL) { ++ bottomMost = item; ++ } ++ } -- if (SP_IS_GROUP(o)) { - SPItem *found = sp_document_item_from_list_at_point_bottom(dkey, SP_GROUP(o), list, p, take_insensitive); - SPItem *found = item_from_list_at_point_bottom(dkey, SP_GROUP(o), list, p, take_insensitive); -- if (found) -- return found; ++ if ( !bottomMost && SP_IS_GROUP(o) ) { ++ // return null if not found: ++ bottomMost = getItemFromListAtPointBottom(dkey, SP_GROUP(o), list, p, take_insensitive); ++ } } -- } -- return NULL; ++ return bottomMost; } /** @@@ -1184,18 -1203,18 +1135,21 @@@ items. If upto != NULL, then if item up upwards in z-order and returns what it has found so far (i.e. the found item is guaranteed to be lower than upto). */ --SPItem* --find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL) ++SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL) { -- SPItem *seen = NULL, *newseen = NULL; ++ SPItem *seen = NULL; ++ SPItem *newseen = NULL; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0); - for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { - for (SPObject *o = SP_OBJECT(group)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { -- if (!SP_IS_ITEM(o)) continue; ++ for ( SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { ++ if (!SP_IS_ITEM(o)) { ++ continue; ++ } -- if (upto && SP_ITEM(o) == upto) ++ if (upto && SP_ITEM(o) == upto) { break; ++ } if (SP_IS_GROUP(o) && (SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) { // if nothing found yet, recurse into the group @@@ -1205,12 -1224,12 +1159,12 @@@ newseen = NULL; } -- if (item_is_in_group(upto, SP_GROUP(o))) ++ if (item_is_in_group(upto, SP_GROUP(o))) { break; -- ++ } } else { SPItem *child = SP_ITEM(o); - NRArenaItem *arenaitem = sp_item_get_arenaitem(child, dkey); + NRArenaItem *arenaitem = child->get_arenaitem(dkey); // seen remembers the last (topmost) of items pickable at this point if (arenaitem && nr_arena_item_invoke_pick(arenaitem, p, delta, 1) != NULL @@@ -1226,15 -1245,15 +1180,16 @@@ Returns the topmost non-layer group from the descendants of group which is at point p, or NULL if none. Recurses into layers but not into groups. */ --SPItem* --find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) ++SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) { SPItem *seen = NULL; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0); - for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { - for (SPObject *o = SP_OBJECT(group)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { -- if (!SP_IS_ITEM(o)) continue; ++ for ( SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { ++ if (!SP_IS_ITEM(o)) { ++ continue; ++ } if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER) { SPItem *newseen = find_group_at_point(dkey, SP_GROUP(o), p); if (newseen) { @@@ -1260,13 -1279,13 +1215,11 @@@ * Assumes box is normalized (and g_asserts it!) * */ -- - GSList *sp_document_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box) -GSList *SPDocument::items_in_box(unsigned int dkey, Geom::Rect const &box) ++GSList *SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const { - g_return_val_if_fail(document != NULL, NULL); - g_return_val_if_fail(document->priv != NULL, NULL); - //g_return_val_if_fail(this != NULL, NULL); + g_return_val_if_fail(this->priv != NULL, NULL); - return find_items_in_area(NULL, SP_GROUP(document->root), dkey, box, is_within); + return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, is_within); } /* @@@ -1276,16 -1295,16 +1229,14 @@@ * */ - GSList *sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box) -GSList *SPDocument::partial_items_in_box(unsigned int dkey, Geom::Rect const &box) ++GSList *SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const { - g_return_val_if_fail(document != NULL, NULL); - g_return_val_if_fail(document->priv != NULL, NULL); - //g_return_val_if_fail(this != NULL, NULL); + g_return_val_if_fail(this->priv != NULL, NULL); - return find_items_in_area(NULL, SP_GROUP(document->root), dkey, box, overlaps); + return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, overlaps); } --GSList * - sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector points) -SPDocument::items_at_points(unsigned const key, std::vector points) ++GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vector points) const { GSList *items = NULL; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@@ -1297,7 -1316,7 +1248,7 @@@ prefs->setDouble("/options/cursortolerance/value", 0.25); for(unsigned int i = 0; i < points.size(); i++) { - SPItem *item = sp_document_item_at_point(document, key, points[i], - SPItem *item = item_at_point(key, points[i], ++ SPItem *item = getItemAtPoint(key, points[i], false, NULL); if (item && !g_slist_find(items, item)) items = g_slist_prepend (items, item); @@@ -1309,95 -1328,94 +1260,86 @@@ return items; } --SPItem * - sp_document_item_at_point(SPDocument *document, unsigned const key, Geom::Point const p, -SPDocument::item_at_point( unsigned const key, Geom::Point const p, -- gboolean const into_groups, SPItem *upto) ++SPItem *SPDocument::getItemAtPoint( unsigned const key, Geom::Point const p, ++ gboolean const into_groups, SPItem *upto) const { - g_return_val_if_fail(document != NULL, NULL); - g_return_val_if_fail(document->priv != NULL, NULL); - //g_return_val_if_fail(this != NULL, NULL); + g_return_val_if_fail(this->priv != NULL, NULL); - return find_item_at_point(key, SP_GROUP(document->root), p, into_groups, false, upto); + return find_item_at_point(key, SP_GROUP(this->root), p, into_groups, false, upto); } --SPItem* - sp_document_group_at_point(SPDocument *document, unsigned int key, Geom::Point const p) -SPDocument::group_at_point(unsigned int key, Geom::Point const p) ++SPItem *SPDocument::getGroupAtPoint(unsigned int key, Geom::Point const p) const { - g_return_val_if_fail(document != NULL, NULL); - g_return_val_if_fail(document->priv != NULL, NULL); - //g_return_val_if_fail(this != NULL, NULL); + g_return_val_if_fail(this->priv != NULL, NULL); - return find_group_at_point(key, SP_GROUP(document->root), p); + return find_group_at_point(key, SP_GROUP(this->root), p); } --/* Resource management */ ++// Resource management --gboolean - sp_document_add_resource(SPDocument *document, gchar const *key, SPObject *object) -SPDocument::add_resource(gchar const *key, SPObject *object) ++bool SPDocument::addResource(gchar const *key, SPObject *object) { -- GSList *rlist; -- GQuark q = g_quark_from_string(key); ++ g_return_val_if_fail(key != NULL, false); ++ g_return_val_if_fail(*key != '\0', false); ++ g_return_val_if_fail(object != NULL, false); ++ g_return_val_if_fail(SP_IS_OBJECT(object), false); - g_return_val_if_fail(document != NULL, FALSE); - //g_return_val_if_fail(this != NULL, FALSE); -- g_return_val_if_fail(key != NULL, FALSE); -- g_return_val_if_fail(*key != '\0', FALSE); -- g_return_val_if_fail(object != NULL, FALSE); -- g_return_val_if_fail(SP_IS_OBJECT(object), FALSE); ++ bool result = false; -- if (SP_OBJECT_IS_CLONED(object)) -- return FALSE; ++ if ( !object->cloned ) { ++ GSList *rlist = (GSList*)g_hash_table_lookup(priv->resources, key); ++ g_return_val_if_fail(!g_slist_find(rlist, object), false); ++ rlist = g_slist_prepend(rlist, object); ++ g_hash_table_insert(priv->resources, (gpointer) key, rlist); - rlist = (GSList*)g_hash_table_lookup(document->priv->resources, key); - rlist = (GSList*)g_hash_table_lookup(this->priv->resources, key); -- g_return_val_if_fail(!g_slist_find(rlist, object), FALSE); -- rlist = g_slist_prepend(rlist, object); - g_hash_table_insert(document->priv->resources, (gpointer) key, rlist); - g_hash_table_insert(this->priv->resources, (gpointer) key, rlist); ++ GQuark q = g_quark_from_string(key); ++ priv->resources_changed_signals[q].emit(); - document->priv->resources_changed_signals[q].emit(); - this->priv->resources_changed_signals[q].emit(); ++ result = true; ++ } -- return TRUE; ++ return result; } --gboolean - sp_document_remove_resource(SPDocument *document, gchar const *key, SPObject *object) -SPDocument::remove_resource(gchar const *key, SPObject *object) ++bool SPDocument::removeResource(gchar const *key, SPObject *object) { -- GSList *rlist; -- GQuark q = g_quark_from_string(key); ++ g_return_val_if_fail(key != NULL, false); ++ g_return_val_if_fail(*key != '\0', false); ++ g_return_val_if_fail(object != NULL, false); ++ g_return_val_if_fail(SP_IS_OBJECT(object), false); - g_return_val_if_fail(document != NULL, FALSE); - //g_return_val_if_fail(this != NULL, FALSE); -- g_return_val_if_fail(key != NULL, FALSE); -- g_return_val_if_fail(*key != '\0', FALSE); -- g_return_val_if_fail(object != NULL, FALSE); -- g_return_val_if_fail(SP_IS_OBJECT(object), FALSE); ++ bool result = false; -- if (SP_OBJECT_IS_CLONED(object)) -- return FALSE; ++ if ( !object->cloned ) { ++ GSList *rlist = (GSList*)g_hash_table_lookup(priv->resources, key); ++ g_return_val_if_fail(rlist != NULL, false); ++ g_return_val_if_fail(g_slist_find(rlist, object), false); ++ rlist = g_slist_remove(rlist, object); ++ g_hash_table_insert(priv->resources, (gpointer) key, rlist); - rlist = (GSList*)g_hash_table_lookup(document->priv->resources, key); - rlist = (GSList*)g_hash_table_lookup(this->priv->resources, key); -- g_return_val_if_fail(rlist != NULL, FALSE); -- g_return_val_if_fail(g_slist_find(rlist, object), FALSE); -- rlist = g_slist_remove(rlist, object); - g_hash_table_insert(document->priv->resources, (gpointer) key, rlist); - g_hash_table_insert(this->priv->resources, (gpointer) key, rlist); ++ GQuark q = g_quark_from_string(key); ++ priv->resources_changed_signals[q].emit(); - document->priv->resources_changed_signals[q].emit(); - this->priv->resources_changed_signals[q].emit(); ++ result = true; ++ } -- return TRUE; ++ return result; } --GSList const * - sp_document_get_resource_list(SPDocument *document, gchar const *key) -SPDocument::get_resource_list(gchar const *key) ++GSList const *SPDocument::getResourceList(gchar const *key) const { - g_return_val_if_fail(document != NULL, NULL); - //g_return_val_if_fail(this != NULL, NULL); g_return_val_if_fail(key != NULL, NULL); g_return_val_if_fail(*key != '\0', NULL); - return (GSList*)g_hash_table_lookup(document->priv->resources, key); + return (GSList*)g_hash_table_lookup(this->priv->resources, key); } - sigc::connection sp_document_resources_changed_connect(SPDocument *document, - gchar const *key, -sigc::connection SPDocument::resources_changed_connect(gchar const *key, -- SPDocument::ResourcesChangedSignal::slot_type slot) ++sigc::connection SPDocument::connectResourcesChanged(gchar const *key, ++ SPDocument::ResourcesChangedSignal::slot_type slot) { GQuark q = g_quark_from_string(key); - return document->priv->resources_changed_signals[q].connect(slot); + return this->priv->resources_changed_signals[q].connect(slot); } /* Helpers */ @@@ -1409,44 -1427,44 +1351,40 @@@ sp_document_resource_list_free(gpointe return TRUE; } --unsigned int --count_objects_recursive(SPObject *obj, unsigned int count) ++unsigned int count_objects_recursive(SPObject *obj, unsigned int count) { count++; // obj itself - for (SPObject *i = sp_object_first_child(obj); i != NULL; i = SP_OBJECT_NEXT(i)) { - for (SPObject *i = obj->first_child(); i != NULL; i = SP_OBJECT_NEXT(i)) { ++ for ( SPObject *i = obj->firstChild(); i; i = i->getNext() ) { count = count_objects_recursive(i, count); } return count; } --unsigned int --objects_in_document(SPDocument *document) ++unsigned int objects_in_document(SPDocument *document) { -- return count_objects_recursive(SP_DOCUMENT_ROOT(document), 0); ++ return count_objects_recursive(document->getRoot(), 0); } --void --vacuum_document_recursive(SPObject *obj) ++void vacuum_document_recursive(SPObject *obj) { if (SP_IS_DEFS(obj)) { -- for (SPObject *def = obj->firstChild(); def; def = SP_OBJECT_NEXT(def)) { -- /* fixme: some inkscape-internal nodes in the future might not be collectable */ ++ for ( SPObject *def = obj->firstChild(); def; def = def->getNext()) { ++ // fixme: some inkscape-internal nodes in the future might not be collectable def->requestOrphanCollection(); } } else { - for (SPObject *i = sp_object_first_child(obj); i != NULL; i = SP_OBJECT_NEXT(i)) { - for (SPObject *i = obj->first_child(); i != NULL; i = SP_OBJECT_NEXT(i)) { ++ for ( SPObject *i = obj->firstChild(); i; i = i->getNext() ) { vacuum_document_recursive(i); } } } --unsigned int - vacuum_document(SPDocument *document) -SPDocument::vacuum_document() ++unsigned int SPDocument::vacuumDocument() { - unsigned int start = objects_in_document(document); - unsigned int end; + unsigned int start = objects_in_document(this); - unsigned int end; ++ unsigned int end = start; unsigned int newend = start; unsigned int iterations = 0; @@@ -1454,11 -1472,11 +1392,11 @@@ do { end = newend; - vacuum_document_recursive(SP_DOCUMENT_ROOT(document)); - document->collectOrphans(); - vacuum_document_recursive(SP_DOCUMENT_ROOT(this)); ++ vacuum_document_recursive(root); + this->collectOrphans(); iterations++; - newend = objects_in_document(document); + newend = objects_in_document(this); } while (iterations < 100 && newend < end); diff --cc src/document.h index 4f5f045c5,a91d1e57f..82c874cb7 --- a/src/document.h +++ b/src/document.h @@@ -1,5 -1,5 +1,5 @@@ --#ifndef __SP_DOCUMENT_H__ --#define __SP_DOCUMENT_H__ ++#ifndef SEEN_SP_DOCUMENT_H ++#define SEEN_SP_DOCUMENT_H /** \file * SPDocument: Typed SVG document implementation @@@ -7,6 -7,6 +7,8 @@@ /* Authors: * Lauris Kaplinski * MenTaLguY ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2004-2005 MenTaLguY * Copyright (C) 1999-2002 Lauris Kaplinski @@@ -68,6 -69,7 +71,7 @@@ class SPDocument : public Inkscape::GC: public Inkscape::GC::Finalized, public Inkscape::GC::Anchored { - public: ++public: typedef sigc::signal IDChangedSignal; typedef sigc::signal ResourcesChangedSignal; typedef sigc::signal ModifiedSignal; @@@ -89,10 -91,10 +93,13 @@@ SPObject *root; ///< Our SPRoot CRCascade *style_cascade; ++protected: gchar *uri; ///< A filename (not a URI yet), or NULL gchar *base; ///< To be used for resolving relative hrefs. gchar *name; ///< basename(uri) or other human-readable label for the document. ++public: ++ SPDocumentPrivate *priv; /// Last action key @@@ -113,6 -114,6 +120,27 @@@ bool oldSignalsConnected; ++ /** Returns our SPRoot */ ++ SPObject *getRoot() { return root; } ++ ++ Inkscape::XML::Node *getReprRoot() { return rroot; } ++ ++ /** Our Inkscape::XML::Document. */ ++ Inkscape::XML::Document *getReprDoc() { return rdoc; } ++ Inkscape::XML::Document const *getReprDoc() const { return rdoc; } ++ ++ /** A filename (not a URI yet), or NULL */ ++ gchar const *getURI() const { return uri; } ++ void setUri(gchar const *uri); ++ ++ /** To be used for resolving relative hrefs. */ ++ gchar const *getBase() const { return base; }; ++ void setBase( gchar const* base ); ++ ++ /** basename(uri) or other human-readable label for the document. */ ++ gchar const* getName() const { return name; } ++ ++ void setCurrentPersp3D(Persp3D * const persp); inline void setCurrentPersp3DImpl(Persp3DImpl * const persp_impl) { current_persp3d_impl = persp_impl; } /* @@@ -121,28 -122,28 +149,28 @@@ */ Persp3D * getCurrentPersp3D(); Persp3DImpl * getCurrentPersp3DImpl(); -- void getPerspectivesInDefs(std::vector &list); -- unsigned int numPerspectivesInDefs() { ++ ++ void getPerspectivesInDefs(std::vector &list) const; ++ ++ unsigned int numPerspectivesInDefs() const { std::vector list; getPerspectivesInDefs(list); return list.size(); } -- //void initialize_current_persp3d(); -- sigc::connection connectModified(ModifiedSignal::slot_type slot); sigc::connection connectURISet(URISetSignal::slot_type slot); sigc::connection connectResized(ResizedSignal::slot_type slot); --sigc::connection connectCommit(CommitSignal::slot_type slot); ++ sigc::connection connectCommit(CommitSignal::slot_type slot); void bindObjectToId(gchar const *id, SPObject *object); -- SPObject *getObjectById(gchar const *id); ++ SPObject *getObjectById(gchar const *id) const; sigc::connection connectIdChanged(const gchar *id, IDChangedSignal::slot_type slot); void bindObjectToRepr(Inkscape::XML::Node *repr, SPObject *object); -- SPObject *getObjectByRepr(Inkscape::XML::Node *repr); ++ SPObject *getObjectByRepr(Inkscape::XML::Node *repr) const; -- Glib::ustring getLanguage(); ++ Glib::ustring getLanguage() const; void queueForOrphanCollection(SPObject *object); void collectOrphans(); @@@ -180,83 -183,118 +208,49 @@@ public sigc::connection _selection_changed_connection; sigc::connection _desktop_activated_connection; - void fitToRect(Geom::Rect const &rect, bool with_margins = false); - }; - - SPDocument *sp_document_new(const gchar *uri, unsigned int keepalive, bool make_new = false); - SPDocument *sp_document_new_from_mem(const gchar *buffer, gint length, unsigned int keepalive); - - SPDocument *sp_document_ref(SPDocument *doc); - SPDocument *sp_document_unref(SPDocument *doc); - - - SPDocument *sp_document_create(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, unsigned int keepalive); ++ sigc::connection connectResourcesChanged(const gchar *key, SPDocument::ResourcesChangedSignal::slot_type slot); + - /* - * Access methods - */ + void fitToRect(Geom::Rect const &rect, bool with_margins = false); - static SPDocument *createNewDoc(const gchar *uri, unsigned int keepalive, bool make_new = false); - static SPDocument *createNewDocFromMem(const gchar *buffer, gint length, unsigned int keepalive); - - /* ToDo - Merge createDoc with createNewDoc */ - static SPDocument *createDoc(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, unsigned int keepalive); - - SPDocument *doRef(); - SPDocument *doUnref(); - gdouble getWidth(); - gdouble getHeight(); - Geom::Point getDimensions(); - void setWidth(gdouble width, const SPUnit *unit); - void setHeight(gdouble height, const SPUnit *unit); - //void setUndoSensitive(bool sensitive); - void request_modified(); - gint ensure_up_to_date(); - gboolean add_resource(const gchar *key, SPObject *object); - gboolean remove_resource(const gchar *key, SPObject *object); - const GSList *get_resource_list(const gchar *key); - sigc::connection resources_changed_connect(const gchar *key, SPDocument::ResourcesChangedSignal::slot_type slot); - GSList * items_in_box(unsigned int dkey, Geom::Rect const &box); - GSList *partial_items_in_box(unsigned int dkey, Geom::Rect const &box); - static SPItem *item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const p, bool take_insensitive = false); - SPItem *item_at_point (unsigned int key, Geom::Point const p, gboolean into_groups, SPItem *upto = NULL); - GSList *items_at_points(unsigned const key, std::vector points); - SPItem *group_at_point (unsigned int key, Geom::Point const p); - - void setUri(gchar const *uri); - void change_uri_and_hrefs(gchar const *uri); - void resized_signal_emit(gdouble width, gdouble height); ++ static SPDocument *createNewDoc(const gchar *uri, unsigned int keepalive, bool make_new = false); ++ static SPDocument *createNewDocFromMem(const gchar *buffer, gint length, unsigned int keepalive); + - #define sp_document_repr_doc(d) (d->rdoc) - #define sp_document_repr_root(d) (d->rroot) - #define sp_document_root(d) (d->root) - #define SP_DOCUMENT_ROOT(d) (d->root) ++ /** ++ * Returns the bottommost item from the list which is at the point, or NULL if none. ++ */ ++ static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const p, bool take_insensitive = false); ++ ++ // ToDo - Merge createDoc with createNewDoc ++ static SPDocument *createDoc(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, unsigned int keepalive); ++ ++ SPDocument *doRef(); ++ SPDocument *doUnref(); ++ gdouble getWidth() const; ++ gdouble getHeight() const; ++ Geom::Point getDimensions() const; ++ void setWidth(gdouble width, const SPUnit *unit); ++ void setHeight(gdouble height, const SPUnit *unit); ++ void requestModified(); ++ gint ensureUpToDate(); ++ bool addResource(const gchar *key, SPObject *object); ++ bool removeResource(const gchar *key, SPObject *object); ++ const GSList *getResourceList(const gchar *key) const; ++ GSList *getItemsInBox(unsigned int dkey, Geom::Rect const &box) const; ++ GSList *getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const; ++ SPItem *getItemAtPoint(unsigned int key, Geom::Point const p, gboolean into_groups, SPItem *upto = NULL) const; ++ GSList *getItemsAtPoints(unsigned const key, std::vector points) const; ++ SPItem *getGroupAtPoint(unsigned int key, Geom::Point const p) const; ++ ++ void changeUriAndHrefs(gchar const *uri); ++ void emitResizedSignal(gdouble width, gdouble height); + - unsigned int vacuum_document(); ++ unsigned int vacuumDocument(); - gdouble sp_document_width(SPDocument *document); - gdouble sp_document_height(SPDocument *document); - Geom::Point sp_document_dimensions(SPDocument *document); - private: - void do_change_uri(gchar const *const filename, bool const rebase); ++private: ++ void do_change_uri(gchar const *const filename, bool const rebase); + }; -//SPDocument *sp_document_new(const gchar *uri, unsigned int keepalive, bool make_new = false); -//SPDocument *sp_document_new_from_mem(const gchar *buffer, gint length, unsigned int keepalive); - -//SPDocument *sp_document_ref(SPDocument *doc); -//SPDocument *sp_document_unref(SPDocument *doc); - - -//SPDocument *sp_document_create(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, unsigned int keepalive); - -/* - * Access methods - */ - -#define sp_document_repr_doc(d) (d->rdoc) -#define sp_document_repr_root(d) (d->rroot) -#define sp_document_root(d) (d->root) -#define SP_DOCUMENT_ROOT(d) (d->root) - -//gdouble sp_document_width(SPDocument *document); -//gdouble sp_document_height(SPDocument *document); -//Geom::Point sp_document_dimensions(SPDocument *document); - struct SPUnit; - void sp_document_set_width(SPDocument *document, gdouble width, const SPUnit *unit); - void sp_document_set_height(SPDocument *document, gdouble height, const SPUnit *unit); -//void sp_document_set_width(SPDocument *document, gdouble width, const SPUnit *unit); -//void sp_document_set_height(SPDocument *document, gdouble height, const SPUnit *unit); -- --#define SP_DOCUMENT_URI(d) (d->uri) --#define SP_DOCUMENT_NAME(d) (d->name) --#define SP_DOCUMENT_BASE(d) (d->base) -- --/* -- * Dictionary -- */ -- --/* -- * Undo & redo -- */ -- - void sp_document_set_undo_sensitive(SPDocument *document, bool sensitive); - bool sp_document_get_undo_sensitive(SPDocument const *document); -//void sp_document_set_undo_sensitive(SPDocument *document, bool sensitive); -//bool sp_document_get_undo_sensitive(SPDocument const *document); -- - void sp_document_clear_undo(SPDocument *document); - void sp_document_clear_redo(SPDocument *document); -//void sp_document_clear_undo(SPDocument *document); -//void sp_document_clear_redo(SPDocument *document); -- - void sp_document_child_added(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); - void sp_document_child_removed(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); - void sp_document_attr_changed(SPDocument *doc, SPObject *object, const gchar *key, const gchar *oldval, const gchar *newval); - void sp_document_content_changed(SPDocument *doc, SPObject *object, const gchar *oldcontent, const gchar *newcontent); - void sp_document_order_changed(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *oldref, Inkscape::XML::Node *newref); -//void sp_document_child_added(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); -//void sp_document_child_removed(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); -//void sp_document_attr_changed(SPDocument *doc, SPObject *object, const gchar *key, const gchar *oldval, const gchar *newval); -//void sp_document_content_changed(SPDocument *doc, SPObject *object, const gchar *oldcontent, const gchar *newcontent); -//void sp_document_order_changed(SPDocument *doc, SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *oldref, Inkscape::XML::Node *newref); -- --/* Object modification root handler */ - void sp_document_request_modified(SPDocument *doc); - gint sp_document_ensure_up_to_date(SPDocument *doc); -//void sp_document_request_modified(SPDocument *doc); -//gint sp_document_ensure_up_to_date(SPDocument *doc); -- --/* Save all previous actions to stack, as one undo step */ - void sp_document_done(SPDocument *document, unsigned int event_type, Glib::ustring event_description); - void sp_document_maybe_done(SPDocument *document, const gchar *keyconst, unsigned int event_type, Glib::ustring event_description); - void sp_document_reset_key(Inkscape::Application *inkscape, SPDesktop *desktop, GtkObject *base); -//void sp_document_done(SPDocument *document, unsigned int event_type, Glib::ustring event_description); -//void sp_document_maybe_done(SPDocument *document, const gchar *keyconst, unsigned int event_type, Glib::ustring event_description); -//void sp_document_reset_key(Inkscape::Application *inkscape, SPDesktop *desktop, GtkObject *base); -- --/* Cancel (and revert) current unsaved actions */ - void sp_document_cancel(SPDocument *document); -//void sp_document_cancel(SPDocument *document); -- --/* Undo and redo */ - gboolean sp_document_undo(SPDocument *document); - gboolean sp_document_redo(SPDocument *document); -//gboolean sp_document_undo(SPDocument *document); -//gboolean sp_document_redo(SPDocument *document); -- --/* Resource management */ - gboolean sp_document_add_resource(SPDocument *document, const gchar *key, SPObject *object); - gboolean sp_document_remove_resource(SPDocument *document, const gchar *key, SPObject *object); - const GSList *sp_document_get_resource_list(SPDocument *document, const gchar *key); - sigc::connection sp_document_resources_changed_connect(SPDocument *document, const gchar *key, SPDocument::ResourcesChangedSignal::slot_type slot); -//gboolean sp_document_add_resource(SPDocument *document, const gchar *key, SPObject *object); -//gboolean sp_document_remove_resource(SPDocument *document, const gchar *key, SPObject *object); -//const GSList *sp_document_get_resource_list(SPDocument *document, const gchar *key); -//sigc::connection sp_document_resources_changed_connect(SPDocument *document, const gchar *key, SPDocument::ResourcesChangedSignal::slot_type slot); -- -- /* * Ideas: How to overcome style invalidation nightmare * @@@ -271,26 -309,26 +265,7 @@@ * */ --/* -- * Misc -- */ -- - GSList *sp_document_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box); - GSList *sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box); - SPItem *sp_document_item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const p, bool take_insensitive = false); - SPItem *sp_document_item_at_point (SPDocument *document, unsigned int key, Geom::Point const p, gboolean into_groups, SPItem *upto = NULL); - GSList *sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector points); - SPItem *sp_document_group_at_point (SPDocument *document, unsigned int key, Geom::Point const p); -//GSList *sp_document_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box); -//GSList *sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box); -//SPItem *sp_document_item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const p, bool take_insensitive = false); -//SPItem *sp_document_item_at_point (SPDocument *document, unsigned int key, Geom::Point const p, gboolean into_groups, SPItem *upto = NULL); -//GSList *sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector points); -//SPItem *sp_document_group_at_point (SPDocument *document, unsigned int key, Geom::Point const p); -- - void sp_document_set_uri(SPDocument *document, gchar const *uri); - void sp_document_change_uri_and_hrefs(SPDocument *document, gchar const *uri); -//void sp_document_set_uri(SPDocument *document, gchar const *uri); -//void sp_document_change_uri_and_hrefs(SPDocument *document, gchar const *uri); -- - void sp_document_resized_signal_emit(SPDocument *doc, gdouble width, gdouble height); -//void sp_document_resized_signal_emit(SPDocument *doc, gdouble width, gdouble height); -- - unsigned int vacuum_document(SPDocument *document); -//unsigned int vacuum_document(SPDocument *document); -- -- --#endif ++#endif // SEEN_SP_DOCUMENT_H /* Local Variables: diff --cc src/draw-context.cpp index 3f33f9499,a3c3601cc..62ae67336 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@@ -1,10 -1,10 +1,9 @@@ --#define __SP_DRAW_CONTEXT_C__ -- /* * Generic drawing context * * Author: * Lauris Kaplinski ++ * Abhishek Sharma * * Copyright (C) 2000 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -43,6 -43,6 +42,8 @@@ #include "live_effects/lpe-patternalongpath.h" #include "style.h" ++using Inkscape::DocumentUndo; ++ static void sp_draw_context_class_init(SPDrawContextClass *klass); static void sp_draw_context_init(SPDrawContext *dc); static void sp_draw_context_dispose(GObject *object); @@@ -644,7 -661,7 +645,7 @@@ spdc_flush_white(SPDrawContext *dc, SPC SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(dc); SPDocument *doc = sp_desktop_document(desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); if ( c && !c->is_empty() ) { /* We actually have something to write */ @@@ -681,7 -698,7 +682,7 @@@ item->updateRepr(); } - sp_document_done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL, - SPDocumentUndo::done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL, ++ DocumentUndo::done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL, _("Draw path")); // When quickly drawing several subpaths with Shift, the next subpath may be finished and @@@ -695,7 -712,7 +696,7 @@@ c->unref(); /* Flush pending updates */ - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); } /** @@@ -789,7 -806,7 +790,7 @@@ void spdc_create_single_dot(SPEventCont Glib::ustring tool_path = tool; SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(ec); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); repr->setAttribute("sodipodi:type", "arc"); SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); @@@ -843,7 -861,7 +845,7 @@@ sp_desktop_selection(desktop)->set(item); desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating single dot")); - sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create single dot")); - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create single dot")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create single dot")); } /* diff --cc src/dropper-context.cpp index 5415fdc80,513963692..b7344889f --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@@ -1,11 -1,11 +1,10 @@@ --#define __SP_DROPPER_CONTEXT_C__ -- /* * Tool for picking colors from drawing * * Authors: * Lauris Kaplinski * bulia byak ++ * Abhishek Sharma * * Copyright (C) 1999-2005 Authors * @@@ -43,6 -43,6 +42,8 @@@ #include "message-context.h" //#include "libnr/nr-scale-translate-ops.h" ++using Inkscape::DocumentUndo; ++ static void sp_dropper_context_class_init(SPDropperContextClass *klass); static void sp_dropper_context_init(SPDropperContext *dc); @@@ -350,8 -350,8 +351,8 @@@ static gint sp_dropper_context_root_han if (!(sp_desktop_selection(desktop)->isEmpty())) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_DROPPER, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_DROPPER, -- _("Set picked color")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_DROPPER, ++ _("Set picked color")); } ret = TRUE; diff --cc src/dyna-draw-context.cpp index 98f57b5bc,ab57872cd..93d4262cd --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_DYNA_DRAW_CONTEXT_C__ -- /* * Handwriting-like drawing mode * @@@ -8,6 -8,6 +6,7 @@@ * Lauris Kaplinski * bulia byak * MenTaLguY ++ * Abhishek Sharma * * The original dynadraw code: * Paul Haeberli @@@ -65,6 -65,6 +64,8 @@@ #include "dyna-draw-context.h" ++using Inkscape::DocumentUndo; ++ #define DDC_RED_RGBA 0xff0000ff #define TOLERANCE_CALLIGRAPHIC 0.1 @@@ -1002,7 -1002,7 +1003,7 @@@ set_to_accumulated(SPDynaDrawContext *d if (!dc->accumulated->is_empty()) { if (!dc->repr) { /* Create object */ -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); /* Set style */ @@@ -1040,8 -1040,8 +1041,8 @@@ dc->repr = NULL; } - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_CALLIGRAPHIC, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_CALLIGRAPHIC, -- _("Draw calligraphic stroke")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_CALLIGRAPHIC, ++ _("Draw calligraphic stroke")); } static void diff --cc src/eraser-context.cpp index 9b00dcd03,fdb0813ce..68c0989bc --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@@ -7,6 -7,6 +7,7 @@@ * bulia byak * MenTaLguY * Jon A. Cruz ++ * Abhishek Sharma * * The original dynadraw code: * Paul Haeberli @@@ -65,6 -65,6 +66,8 @@@ #include "eraser-context.h" ++using Inkscape::DocumentUndo; ++ #define ERC_RED_RGBA 0xff0000ff #define TOLERANCE_ERASER 0.1 @@@ -716,7 -713,7 +719,7 @@@ set_to_accumulated(SPEraserContext *dc if (!dc->accumulated->is_empty()) { if (!dc->repr) { /* Create object */ -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); /* Set style */ @@@ -741,7 -738,7 +744,7 @@@ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0; -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(dc->repr)); Geom::OptRect eraserBbox = acid->getBounds(Geom::identity()); @@@ -750,10 -747,10 +753,10 @@@ GSList* toWorkOn = 0; if (selection->isEmpty()) { if ( eraserMode ) { - toWorkOn = sp_document_partial_items_in_box(sp_desktop_document(desktop), desktop->dkey, bounds); - toWorkOn = sp_desktop_document(desktop)->partial_items_in_box(desktop->dkey, bounds); ++ toWorkOn = sp_desktop_document(desktop)->getItemsPartiallyInBox(desktop->dkey, bounds); } else { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); - toWorkOn = sp_document_items_at_points(sp_desktop_document(desktop), desktop->dkey, r->getPoints()); - toWorkOn = sp_desktop_document(desktop)->items_at_points(desktop->dkey, r->getPoints()); ++ toWorkOn = sp_desktop_document(desktop)->getItemsAtPoints(desktop->dkey, r->getPoints()); } toWorkOn = g_slist_remove( toWorkOn, acid ); } else { @@@ -829,10 -826,10 +832,10 @@@ if ( workDone ) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ERASER, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ERASER, -- _("Draw eraser stroke")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ERASER, ++ _("Draw eraser stroke")); } else { - sp_document_cancel(sp_desktop_document(desktop)); - SPDocumentUndo::cancel(sp_desktop_document(desktop)); ++ DocumentUndo::cancel(sp_desktop_document(desktop)); } } diff --cc src/event-context.cpp index a4109a91c,6184fb4c7..828ce3d5b --- a/src/event-context.cpp +++ b/src/event-context.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_EVENT_CONTEXT_C__ -- /** \file * Main event handling, and related helper functions. * @@@ -7,6 -7,6 +5,7 @@@ * Lauris Kaplinski * Frank Felfe * bulia byak ++ * Jon A. Cruz * * Copyright (C) 1999-2010 authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -1103,20 -1072,20 +1102,21 @@@ guint get_group0_keyval(GdkEventKey *ev * If state includes alt key mask, cyclically selects under; honors * into_groups. */ --SPItem * --sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p, -- bool select_under, bool into_groups) { -- SPItem *item; ++SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p, ++ bool select_under, bool into_groups) ++{ ++ SPItem *item = 0; if (select_under) { -- SPItem *selected_at_point = desktop->item_from_list_at_point_bottom( ++ SPItem *selected_at_point = desktop->getItemFromListAtPointBottom( desktop->selection->itemList(), p); -- item = desktop->item_at_point(p, into_groups, selected_at_point); ++ item = desktop->getItemAtPoint(p, into_groups, selected_at_point); if (item == NULL) { // we may have reached bottom, flip over to the top -- item = desktop->item_at_point(p, into_groups, NULL); ++ item = desktop->getItemAtPoint(p, into_groups, NULL); } -- } else -- item = desktop->item_at_point(p, into_groups, NULL); ++ } else { ++ item = desktop->getItemAtPoint(p, into_groups, NULL); ++ } return item; } @@@ -1131,7 -1100,7 +1131,7 @@@ sp_event_context_over_item(SPDesktop *d Geom::Point const &p) { GSList *temp = NULL; temp = g_slist_prepend(temp, item); -- SPItem *item_at_point = desktop->item_from_list_at_point_bottom(temp, p); ++ SPItem *item_at_point = desktop->getItemFromListAtPointBottom(temp, p); g_slist_free(temp); return item_at_point; diff --cc src/extension/dbus/application-interface.cpp index b183be93c,000000000..a652b7c96 mode 100644,000000..100644 --- a/src/extension/dbus/application-interface.cpp +++ b/src/extension/dbus/application-interface.cpp @@@ -1,129 -1,0 +1,129 @@@ +/* + * This is where the implementation of the DBus based application API lives. + * All the methods in here are designed to be called remotly via DBus. + * document-interface.cpp has all of the actual manipulation methods. + * This interface is just for creating new document interfaces. + * + * Documentation for these methods is in application-interface.xml + * which is the "gold standard" as to how the interface should work. + * + * Authors: + * Soren Berg + * + * Copyright (C) 2009 Soren Berg + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "application-interface.h" +#include +#include "dbus-init.h" + +G_DEFINE_TYPE(ApplicationInterface, application_interface, G_TYPE_OBJECT) + +static void +application_interface_finalize (GObject *object) +{ + G_OBJECT_CLASS (application_interface_parent_class)->finalize (object); +} + + +static void +application_interface_class_init (ApplicationInterfaceClass *klass) +{ + GObjectClass *object_class; + object_class = G_OBJECT_CLASS (klass); + object_class->finalize = application_interface_finalize; +} + +static void +application_interface_init (ApplicationInterface *object) +{ +} + + +ApplicationInterface * +application_interface_new (void) +{ + return (ApplicationInterface*)g_object_new (TYPE_APPLICATION_INTERFACE, NULL); +} + +/**************************************************************************** + DESKTOP FUNCTIONS +****************************************************************************/ + +gchar* +application_interface_desktop_new (ApplicationInterface *object, + GError **error) +{ + return (gchar*)Inkscape::Extension::Dbus::init_desktop(); +} + +gchar** +application_interface_get_desktop_list (ApplicationInterface *object) +{ + return NULL; +} + +gchar* +application_interface_get_active_desktop (ApplicationInterface *object, + GError **error) +{ + return NULL; +} + +gboolean +application_interface_set_active_desktop (ApplicationInterface *object, + gchar* document_name, + GError **error) +{ + return TRUE; +} + +gboolean +application_interface_desktop_close_all (ApplicationInterface *object, + GError **error) +{ + return TRUE; +} + +gboolean +application_interface_exit (ApplicationInterface *object, GError **error) +{ + return TRUE; +} + +/**************************************************************************** + DOCUMENT FUNCTIONS +****************************************************************************/ + +gchar* application_interface_document_new (ApplicationInterface *object, + GError **error) +{ + return (gchar*)Inkscape::Extension::Dbus::init_document(); +} + +gchar** +application_interface_get_document_list (ApplicationInterface *object) +{ + return NULL; +} + +gboolean +application_interface_document_close_all (ApplicationInterface *object, + GError **error) +{ + return TRUE; +} + +/* INTERESTING FUNCTIONS + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + g_assert(desktop != NULL); + + SPDocument *doc = sp_desktop_document(desktop); + g_assert(doc != NULL); + - Inkscape::XML::Node *repr = sp_document_repr_root(doc); ++ Inkscape::XML::Node *repr = doc->getReprRoot(); + g_assert(repr != NULL); +*/ + diff --cc src/extension/dbus/document-interface.cpp index b8b0c2ade,000000000..836ad3397 mode 100644,000000..100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@@ -1,1336 -1,0 +1,1335 @@@ +/* + * This is where the implementation of the DBus based document API lives. + * All the methods in here (except in the helper section) are + * designed to be called remotly via DBus. application-interface.cpp + * has the methods used to connect to the bus and get a document instance. + * + * Documentation for these methods is in document-interface.xml + * which is the "gold standard" as to how the interface should work. + * + * Authors: + * Soren Berg + * + * Copyright (C) 2009 Soren Berg + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "document-interface.h" +#include + +#include "verbs.h" +#include "helper/action.h" //sp_action_perform + +#include "inkscape.h" //inkscape_find_desktop_by_dkey, activate desktops + +#include "desktop-handles.h" //sp_desktop_document() +#include "xml/repr.h" //sp_repr_document_new + +#include "sp-object.h" + - #include "document.h" // sp_document_repr_doc ++#include "document.h" // getReprDoc() + +#include "desktop-style.h" //sp_desktop_get_style + +#include "selection.h" //selection struct +#include "selection-chemistry.h"// lots of selection functions + +#include "sp-ellipse.h" + +#include "layer-fns.h" //LPOS_BELOW + +#include "style.h" //style_write + +#include "file.h" //IO + +#include "extension/system.h" //IO + +#include "extension/output.h" //IO + +#include "print.h" //IO + +#include "live_effects/parameter/text.h" //text +#include "display/canvas-text.h" //text + +//#include "2geom/svg-path-parser.h" //get_node_coordinates + +/**************************************************************************** + HELPER / SHORTCUT FUNCTIONS +****************************************************************************/ + +/* + * This function or the one below it translates the user input for an object + * into Inkscapes internal representation. It is called by almost every + * method so it should be as fast as possible. + * + * (eg turns "rect2234" to an SPObject or Inkscape::XML::Node) + * + * If the internal representation changes (No more 'id' attributes) this is the + * place to adjust things. + */ +Inkscape::XML::Node * +get_repr_by_name (SPDesktop *desk, gchar *name, GError **error) +{ + /* ALTERNATIVE (is this faster if only repr is needed?) + Inkscape::XML::Node *node = sp_repr_lookup_name((doc->root)->repr, name); + */ + Inkscape::XML::Node * node = sp_desktop_document(desk)->getObjectById(name)->repr; + if (!node) + { + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OBJECT, "Object '%s' not found in document.", name); + return NULL; + } + return node; +} + +/* + * See comment for get_repr_by_name, above. + */ +SPObject * +get_object_by_name (SPDesktop *desk, gchar *name, GError **error) +{ + SPObject * obj = sp_desktop_document(desk)->getObjectById(name); + if (!obj) + { + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OBJECT, "Object '%s' not found in document.", name); + return NULL; + } + return obj; +} + +/* + * Tests for NULL strings and throws an appropriate error. + * Every method that takes a string parameter (other than the + * name of an object, that's tested seperatly) should call this. + */ +gboolean +dbus_check_string (gchar *string, GError ** error, const gchar * errorstr) +{ + if (string == NULL) + { + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "%s", errorstr); + return FALSE; + } + return TRUE; +} + +/* + * This is used to return object values to the user + */ +const gchar * +get_name_from_object (SPObject * obj) +{ + return obj->repr->attribute("id"); +} + +/* + * Some verbs (cut, paste) only work on the active layer. + * This makes sure that the document that is about to recive a command is active. + */ +void +desktop_ensure_active (SPDesktop* desk) { + if (desk != SP_ACTIVE_DESKTOP) + inkscape_activate_desktop (desk); + return; +} + +gdouble +selection_get_center_x (Inkscape::Selection *sel){ + NRRect *box = g_new(NRRect, 1);; + box = sel->boundsInDocument(box); + return box->x0 + ((box->x1 - box->x0)/2); +} + +gdouble +selection_get_center_y (Inkscape::Selection *sel){ + NRRect *box = g_new(NRRect, 1);; + box = sel->boundsInDocument(box); + return box->y0 + ((box->y1 - box->y0)/2); +} + +/* + * This function is used along with selection_restore to + * take advantage of functionality provided by a selection + * for a single object. + * + * It saves the current selection and sets the selection to + * the object specified. Any selection verb can be used on the + * object and then selection_restore is called, restoring the + * original selection. + * + * This should be mostly transparent to the user who need never + * know we never bothered to implement it seperatly. Although + * they might see the selection box flicker if used in a loop. + */ +const GSList * +selection_swap(SPDesktop *desk, gchar *name, GError **error) +{ + Inkscape::Selection *sel = sp_desktop_selection(desk); + const GSList *oldsel = g_slist_copy((GSList *)sel->list()); + + sel->set(get_object_by_name(desk, name, error)); + return oldsel; +} + +/* + * See selection_swap, above + */ +void +selection_restore(SPDesktop *desk, const GSList * oldsel) +{ + Inkscape::Selection *sel = sp_desktop_selection(desk); + sel->setList(oldsel); +} + +/* + * Shortcut for creating a Node. + */ +Inkscape::XML::Node * +dbus_create_node (SPDesktop *desk, const gchar *type) +{ + SPDocument * doc = sp_desktop_document (desk); - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); + + return xml_doc->createElement(type); +} + +/* + * Called by the shape creation functions. Gets the default style for the doc + * or sets it arbitrarily if none. + * + * There is probably a better way to do this (use the shape tools default styles) + * but I'm not sure how. + */ +gchar * +finish_create_shape (DocumentInterface *object, GError **error, Inkscape::XML::Node *newNode, gchar *desc) +{ + + SPCSSAttr *style = sp_desktop_get_style(object->desk, TRUE); + + if (style) { + newNode->setAttribute("style", sp_repr_css_write_string(style), TRUE); + } + else { + newNode->setAttribute("style", "fill:#0000ff;fill-opacity:1;stroke:#c900b9;stroke-width:0;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none", TRUE); + } + + object->desk->currentLayer()->appendChildRepr(newNode); + object->desk->currentLayer()->updateRepr(); + + if (object->updates) + sp_document_done(sp_desktop_document(object->desk), 0, (gchar *)desc); + //else + //document_interface_pause_updates(object, error); + + return strdup(newNode->attribute("id")); +} + +/* + * This is the code used internally to call all the verbs. + * + * It handles error reporting and update pausing (which needs some work.) + * This is a good place to improve efficiency as it is called a lot. + * + * document_interface_call_verb is similar but is called by the user. + */ +gboolean +dbus_call_verb (DocumentInterface *object, int verbid, GError **error) +{ + SPDesktop *desk2 = object->desk; + desktop_ensure_active (desk2); + + if ( desk2 ) { + Inkscape::Verb *verb = Inkscape::Verb::get( verbid ); + if ( verb ) { + SPAction *action = verb->get_action(desk2); + if ( action ) { + //if (!object->updates) + //document_interface_pause_updates (object, error); + sp_action_perform( action, NULL ); + if (object->updates) + sp_document_done(sp_desktop_document(desk2), verb->get_code(), g_strdup(verb->get_tip())); + //if (!object->updates) + //document_interface_pause_updates (object, error); + return TRUE; + } + } + } + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_VERB, "Verb failed to execute"); + return FALSE; +} + +/**************************************************************************** + DOCUMENT INTERFACE CLASS STUFF +****************************************************************************/ + +G_DEFINE_TYPE(DocumentInterface, document_interface, G_TYPE_OBJECT) + +static void +document_interface_finalize (GObject *object) +{ + G_OBJECT_CLASS (document_interface_parent_class)->finalize (object); +} + + +static void +document_interface_class_init (DocumentInterfaceClass *klass) +{ + GObjectClass *object_class; + object_class = G_OBJECT_CLASS (klass); + object_class->finalize = document_interface_finalize; +} + +static void +document_interface_init (DocumentInterface *object) +{ + object->desk = NULL; +} + + +DocumentInterface * +document_interface_new (void) +{ + return (DocumentInterface*)g_object_new (TYPE_DOCUMENT_INTERFACE, NULL); +} + +/* + * Error stuff... + * + * To add a new error type, edit here and in the .h InkscapeError enum. + */ +GQuark +inkscape_error_quark (void) +{ + static GQuark quark = 0; + if (!quark) + quark = g_quark_from_static_string ("inkscape_error"); + + return quark; +} + +#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } + +GType +inkscape_error_get_type (void) +{ + static GType etype = 0; + + if (etype == 0) + { + static const GEnumValue values[] = + { + + ENUM_ENTRY (INKSCAPE_ERROR_SELECTION, "Incompatible_Selection"), + ENUM_ENTRY (INKSCAPE_ERROR_OBJECT, "Incompatible_Object"), + ENUM_ENTRY (INKSCAPE_ERROR_VERB, "Failed_Verb"), + ENUM_ENTRY (INKSCAPE_ERROR_OTHER, "Generic_Error"), + { 0, 0, 0 } + }; + + etype = g_enum_register_static ("InkscapeError", values); + } + + return etype; +} + +/**************************************************************************** + MISC FUNCTIONS +****************************************************************************/ + +gboolean +document_interface_delete_all (DocumentInterface *object, GError **error) +{ + sp_edit_clear_all (object->desk); + return TRUE; +} + +gboolean +document_interface_call_verb (DocumentInterface *object, gchar *verbid, GError **error) +{ + SPDesktop *desk2 = object->desk; + desktop_ensure_active (object->desk); + if ( desk2 ) { + Inkscape::Verb *verb = Inkscape::Verb::getbyid( verbid ); + if ( verb ) { + SPAction *action = verb->get_action(desk2); + if ( action ) { + sp_action_perform( action, NULL ); + if (object->updates) { + sp_document_done(sp_desktop_document(desk2), verb->get_code(), g_strdup(verb->get_tip())); + } + } + } + } + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_VERB, "Verb '%s' failed to execute or was not found.", verbid); + return FALSE; +} + + +/**************************************************************************** + CREATION FUNCTIONS +****************************************************************************/ + +gchar* +document_interface_rectangle (DocumentInterface *object, int x, int y, + int width, int height, GError **error) +{ + + + Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:rect"); + sp_repr_set_int(newNode, "x", x); //could also use newNode->setAttribute() + sp_repr_set_int(newNode, "y", y); + sp_repr_set_int(newNode, "width", width); + sp_repr_set_int(newNode, "height", height); + return finish_create_shape (object, error, newNode, (gchar *)"create rectangle"); +} + +gchar* +document_interface_ellipse_center (DocumentInterface *object, int cx, int cy, + int rx, int ry, GError **error) +{ + Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path"); + newNode->setAttribute("sodipodi:type", "arc"); + sp_repr_set_int(newNode, "sodipodi:cx", cx); + sp_repr_set_int(newNode, "sodipodi:cy", cy); + sp_repr_set_int(newNode, "sodipodi:rx", rx); + sp_repr_set_int(newNode, "sodipodi:ry", ry); + return finish_create_shape (object, error, newNode, (gchar *)"create circle"); +} + +gchar* +document_interface_polygon (DocumentInterface *object, int cx, int cy, + int radius, int rotation, int sides, + GError **error) +{ + gdouble rot = ((rotation / 180.0) * 3.14159265) - ( 3.14159265 / 2.0); + Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path"); + newNode->setAttribute("inkscape:flatsided", "true"); + newNode->setAttribute("sodipodi:type", "star"); + sp_repr_set_int(newNode, "sodipodi:cx", cx); + sp_repr_set_int(newNode, "sodipodi:cy", cy); + sp_repr_set_int(newNode, "sodipodi:r1", radius); + sp_repr_set_int(newNode, "sodipodi:r2", radius); + sp_repr_set_int(newNode, "sodipodi:sides", sides); + sp_repr_set_int(newNode, "inkscape:randomized", 0); + sp_repr_set_svg_double(newNode, "sodipodi:arg1", rot); + sp_repr_set_svg_double(newNode, "sodipodi:arg2", rot); + sp_repr_set_svg_double(newNode, "inkscape:rounded", 0); + + return finish_create_shape (object, error, newNode, (gchar *)"create polygon"); +} + +gchar* +document_interface_star (DocumentInterface *object, int cx, int cy, + int r1, int r2, int sides, gdouble rounded, + gdouble arg1, gdouble arg2, GError **error) +{ + Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path"); + newNode->setAttribute("inkscape:flatsided", "false"); + newNode->setAttribute("sodipodi:type", "star"); + sp_repr_set_int(newNode, "sodipodi:cx", cx); + sp_repr_set_int(newNode, "sodipodi:cy", cy); + sp_repr_set_int(newNode, "sodipodi:r1", r1); + sp_repr_set_int(newNode, "sodipodi:r2", r2); + sp_repr_set_int(newNode, "sodipodi:sides", sides); + sp_repr_set_int(newNode, "inkscape:randomized", 0); + sp_repr_set_svg_double(newNode, "sodipodi:arg1", arg1); + sp_repr_set_svg_double(newNode, "sodipodi:arg2", arg2); + sp_repr_set_svg_double(newNode, "inkscape:rounded", rounded); + + return finish_create_shape (object, error, newNode, (gchar *)"create star"); +} + +gchar* +document_interface_ellipse (DocumentInterface *object, int x, int y, + int width, int height, GError **error) +{ + int rx = width/2; + int ry = height/2; + return document_interface_ellipse_center (object, x+rx, y+ry, rx, ry, error); +} + +gchar* +document_interface_line (DocumentInterface *object, int x, int y, + int x2, int y2, GError **error) +{ + Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path"); + std::stringstream out; + // Not sure why this works. + out << "m " << x << "," << y << " " << x2 - x << "," << y2 - y; + newNode->setAttribute("d", out.str().c_str()); + return finish_create_shape (object, error, newNode, (gchar *)"create line"); +} + +gchar* +document_interface_spiral (DocumentInterface *object, int cx, int cy, + int r, int revolutions, GError **error) +{ + Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:path"); + newNode->setAttribute("sodipodi:type", "spiral"); + sp_repr_set_int(newNode, "sodipodi:cx", cx); + sp_repr_set_int(newNode, "sodipodi:cy", cy); + sp_repr_set_int(newNode, "sodipodi:radius", r); + sp_repr_set_int(newNode, "sodipodi:revolution", revolutions); + sp_repr_set_int(newNode, "sodipodi:t0", 0); + sp_repr_set_int(newNode, "sodipodi:argument", 0); + sp_repr_set_int(newNode, "sodipodi:expansion", 1); + gchar * retval = finish_create_shape (object, error, newNode, (gchar *)"create spiral"); + //Makes sure there is no fill for spirals by default. + gchar* newString = g_strconcat(newNode->attribute("style"), ";fill:none", NULL); + newNode->setAttribute("style", newString); + g_free(newString); + return retval; +} + +gboolean +document_interface_text (DocumentInterface *object, int x, int y, gchar *text, GError **error) +{ + //FIXME: Not selectable (aka broken). Needs to be rewritten completely. + + SPDesktop *desktop = object->desk; + SPCanvasText * canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, Geom::Point(0,0), ""); + sp_canvastext_set_text (canvas_text, text); + sp_canvastext_set_coords (canvas_text, x, y); + + return TRUE; +} + +gchar * +document_interface_image (DocumentInterface *object, int x, int y, gchar *filename, GError **error) +{ + gchar * uri = g_filename_to_uri (filename, FALSE, error); + if (!uri) + return FALSE; + + Inkscape::XML::Node *newNode = dbus_create_node(object->desk, "svg:image"); + sp_repr_set_int(newNode, "x", x); + sp_repr_set_int(newNode, "y", y); + newNode->setAttribute("xlink:href", uri); + + object->desk->currentLayer()->appendChildRepr(newNode); + object->desk->currentLayer()->updateRepr(); + + if (object->updates) + sp_document_done(sp_desktop_document(object->desk), 0, "Imported bitmap."); + + //g_free(uri); + return strdup(newNode->attribute("id")); +} + - gchar* - document_interface_node (DocumentInterface *object, gchar *type, GError **error) ++gchar *document_interface_node (DocumentInterface *object, gchar *type, GError **error) +{ + SPDocument * doc = sp_desktop_document (object->desk); - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); + + Inkscape::XML::Node *newNode = xml_doc->createElement(type); + + object->desk->currentLayer()->appendChildRepr(newNode); + object->desk->currentLayer()->updateRepr(); + + if (object->updates) + sp_document_done(sp_desktop_document(object->desk), 0, (gchar *)"created empty node"); + //else + //document_interface_pause_updates(object, error); + + return strdup(newNode->attribute("id")); +} + +/**************************************************************************** + ENVIORNMENT FUNCTIONS +****************************************************************************/ +gdouble +document_interface_document_get_width (DocumentInterface *object) +{ + return sp_document_width(sp_desktop_document(object->desk)); +} + +gdouble +document_interface_document_get_height (DocumentInterface *object) +{ + return sp_document_height(sp_desktop_document(object->desk)); +} + +gchar * +document_interface_document_get_css (DocumentInterface *object, GError **error) +{ + SPCSSAttr *current = (object->desk)->current; + return sp_repr_css_write_string(current); +} + +gboolean +document_interface_document_merge_css (DocumentInterface *object, + gchar *stylestring, GError **error) +{ + SPCSSAttr * style = sp_repr_css_attr_new(); + sp_repr_css_attr_add_from_string (style, stylestring); + sp_desktop_set_style (object->desk, style); + return TRUE; +} + +gboolean +document_interface_document_set_css (DocumentInterface *object, + gchar *stylestring, GError **error) +{ + SPCSSAttr * style = sp_repr_css_attr_new(); + sp_repr_css_attr_add_from_string (style, stylestring); + //Memory leak? + object->desk->current = style; + return TRUE; +} + +gboolean +document_interface_document_resize_to_fit_selection (DocumentInterface *object, + GError **error) +{ + return dbus_call_verb (object, SP_VERB_FIT_CANVAS_TO_SELECTION, error); + return TRUE; +} + +/**************************************************************************** + OBJECT FUNCTIONS +****************************************************************************/ + +gboolean +document_interface_set_attribute (DocumentInterface *object, char *shape, + char *attribute, char *newval, GError **error) +{ + Inkscape::XML::Node *newNode = get_repr_by_name(object->desk, shape, error); + + /* ALTERNATIVE (is this faster?) + Inkscape::XML::Node *newnode = sp_repr_lookup_name((doc->root)->repr, name); + */ + if (!dbus_check_string(newval, error, "New value string was empty.")) + return FALSE; + + if (!newNode) + return FALSE; + + newNode->setAttribute(attribute, newval, TRUE); + return TRUE; +} + +gboolean +document_interface_set_int_attribute (DocumentInterface *object, + char *shape, char *attribute, + int newval, GError **error) +{ + Inkscape::XML::Node *newNode = get_repr_by_name (object->desk, shape, error); + if (!newNode) + return FALSE; + + sp_repr_set_int (newNode, attribute, newval); + return TRUE; +} + + +gboolean +document_interface_set_double_attribute (DocumentInterface *object, + char *shape, char *attribute, + double newval, GError **error) +{ + Inkscape::XML::Node *newNode = get_repr_by_name (object->desk, shape, error); + + if (!dbus_check_string (attribute, error, "New value string was empty.")) + return FALSE; + if (!newNode) + return FALSE; + + sp_repr_set_svg_double (newNode, attribute, newval); + return TRUE; +} + +gchar * +document_interface_get_attribute (DocumentInterface *object, char *shape, + char *attribute, GError **error) +{ + Inkscape::XML::Node *newNode = get_repr_by_name(object->desk, shape, error); + + if (!dbus_check_string (attribute, error, "Attribute name empty.")) + return NULL; + if (!newNode) + return NULL; + + return g_strdup(newNode->attribute(attribute)); +} + +gboolean +document_interface_move (DocumentInterface *object, gchar *name, gdouble x, + gdouble y, GError **error) +{ + const GSList *oldsel = selection_swap(object->desk, name, error); + if (!oldsel) + return FALSE; + sp_selection_move (object->desk, x, 0 - y); + selection_restore(object->desk, oldsel); + return TRUE; +} + +gboolean +document_interface_move_to (DocumentInterface *object, gchar *name, gdouble x, + gdouble y, GError **error) +{ + const GSList *oldsel = selection_swap(object->desk, name, error); + if (!oldsel) + return FALSE; + Inkscape::Selection * sel = sp_desktop_selection(object->desk); + sp_selection_move (object->desk, x - selection_get_center_x(sel), + 0 - (y - selection_get_center_y(sel))); + selection_restore(object->desk, oldsel); + return TRUE; +} + +gboolean +document_interface_object_to_path (DocumentInterface *object, + char *shape, GError **error) +{ + const GSList *oldsel = selection_swap(object->desk, shape, error); + if (!oldsel) + return FALSE; + dbus_call_verb (object, SP_VERB_OBJECT_TO_CURVE, error); + selection_restore(object->desk, oldsel); + return TRUE; +} + +gchar * +document_interface_get_path (DocumentInterface *object, char *pathname, GError **error) +{ + Inkscape::XML::Node *node = get_repr_by_name(object->desk, pathname, error); + + if (!node) + return NULL; + + if (node->attribute("d") == NULL) + { + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OBJECT, "Object is not a path."); + return NULL; + } + return strdup(node->attribute("d")); +} + +gboolean +document_interface_transform (DocumentInterface *object, gchar *shape, + gchar *transformstr, GError **error) +{ + //FIXME: This should merge transformations. + gchar trans[] = "transform"; + document_interface_set_attribute (object, shape, trans, transformstr, error); + return TRUE; +} + +gchar * +document_interface_get_css (DocumentInterface *object, gchar *shape, + GError **error) +{ + gchar style[] = "style"; + return document_interface_get_attribute (object, shape, style, error); +} + +gboolean +document_interface_modify_css (DocumentInterface *object, gchar *shape, + gchar *cssattrb, gchar *newval, GError **error) +{ + // Doesn't like non-variable strings for some reason. + gchar style[] = "style"; + Inkscape::XML::Node *node = get_repr_by_name(object->desk, shape, error); + + if (!dbus_check_string (cssattrb, error, "Attribute string empty.")) + return FALSE; + if (!node) + return FALSE; + + SPCSSAttr * oldstyle = sp_repr_css_attr (node, style); + sp_repr_css_set_property(oldstyle, cssattrb, newval); + node->setAttribute (style, sp_repr_css_write_string (oldstyle), TRUE); + return TRUE; +} + +gboolean +document_interface_merge_css (DocumentInterface *object, gchar *shape, + gchar *stylestring, GError **error) +{ + gchar style[] = "style"; + + Inkscape::XML::Node *node = get_repr_by_name(object->desk, shape, error); + + if (!dbus_check_string (stylestring, error, "Style string empty.")) + return FALSE; + if (!node) + return FALSE; + + SPCSSAttr * newstyle = sp_repr_css_attr_new(); + sp_repr_css_attr_add_from_string (newstyle, stylestring); + + SPCSSAttr * oldstyle = sp_repr_css_attr (node, style); + + sp_repr_css_merge(oldstyle, newstyle); + node->setAttribute (style, sp_repr_css_write_string (oldstyle), TRUE); + return TRUE; +} + +gboolean +document_interface_set_color (DocumentInterface *object, gchar *shape, + int r, int g, int b, gboolean fill, GError **error) +{ + gchar style[15]; + if (r<0 || r>255 || g<0 || g>255 || b<0 || b>255) + { + g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OTHER, "Given (%d,%d,%d). All values must be between 0-255 inclusive.", r, g, b); + return FALSE; + } + + if (fill) + snprintf(style, 15, "fill:#%.2x%.2x%.2x", r, g, b); + else + snprintf(style, 15, "stroke:#%.2x%.2x%.2x", r, g, b); + + if (strcmp(shape, "document") == 0) + return document_interface_document_merge_css (object, style, error); + + return document_interface_merge_css (object, shape, style, error); +} + +gboolean +document_interface_move_to_layer (DocumentInterface *object, gchar *shape, + gchar *layerstr, GError **error) +{ + const GSList *oldsel = selection_swap(object->desk, shape, error); + if (!oldsel) + return FALSE; + + document_interface_selection_move_to_layer(object, layerstr, error); + selection_restore(object->desk, oldsel); + return TRUE; +} + +GArray * +document_interface_get_node_coordinates (DocumentInterface *object, gchar *shape) +{ + //FIXME: Needs lot's of work. +/* + Inkscape::XML::Node *shapenode = get_repr_by_name (object->desk, shape, error); + if (shapenode == NULL || shapenode->attribute("d") == NULL) { + return FALSE; + } + char * path = strdup(shapenode->attribute("d")); + printf("PATH: %s\n", path); + + Geom::parse_svg_path (path); + return NULL; + */ + return NULL; +} + + +/**************************************************************************** + FILE I/O FUNCTIONS +****************************************************************************/ + +gboolean +document_interface_save (DocumentInterface *object, GError **error) +{ + SPDocument * doc = sp_desktop_document(object->desk); + printf("1: %s\n2: %s\n3: %s\n", doc->uri, doc->base, doc->name); + if (doc->uri) + return document_interface_save_as (object, doc->uri, error); + return FALSE; +} + +gboolean +document_interface_load (DocumentInterface *object, + gchar *filename, GError **error) +{ + desktop_ensure_active (object->desk); + const Glib::ustring file(filename); + sp_file_open(file, NULL, TRUE, TRUE); + if (object->updates) + sp_document_done(sp_desktop_document(object->desk), SP_VERB_FILE_OPEN, "Opened File"); + return TRUE; +} + +gboolean +document_interface_save_as (DocumentInterface *object, + gchar *filename, GError **error) +{ + SPDocument * doc = sp_desktop_document(object->desk); + #ifdef WITH_GNOME_VFS + const Glib::ustring file(filename); + return file_save_remote(doc, file, NULL, TRUE, TRUE); + #endif + if (!doc || strlen(filename)<1) //Safety check + return false; + + try { + Inkscape::Extension::save(NULL, doc, filename, + false, false, true, Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS); + } catch (...) { + //SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved.")); + return false; + } + + //SP_ACTIVE_DESKTOP->event_log->rememberFileSave(); + //SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::NORMAL_MESSAGE, "Document saved."); + return true; +} + +gboolean +document_interface_mark_as_unmodified (DocumentInterface *object, GError **error) +{ + SPDocument * doc = sp_desktop_document(object->desk); + if (doc) + doc->modified_since_save = FALSE; + return TRUE; +} + +/* +gboolean +document_interface_print_to_file (DocumentInterface *object, GError **error) +{ + SPDocument * doc = sp_desktop_document(object->desk); + sp_print_document_to_file (doc, g_strdup("/home/soren/test.pdf")); + + return TRUE; +} +*/ +/**************************************************************************** + PROGRAM CONTROL FUNCTIONS +****************************************************************************/ + +gboolean +document_interface_close (DocumentInterface *object, GError **error) +{ + return dbus_call_verb (object, SP_VERB_FILE_CLOSE_VIEW, error); +} + +gboolean +document_interface_exit (DocumentInterface *object, GError **error) +{ + return dbus_call_verb (object, SP_VERB_FILE_QUIT, error); +} + +gboolean +document_interface_undo (DocumentInterface *object, GError **error) +{ + return dbus_call_verb (object, SP_VERB_EDIT_UNDO, error); +} + +gboolean +document_interface_redo (DocumentInterface *object, GError **error) +{ + return dbus_call_verb (object, SP_VERB_EDIT_REDO, error); +} + + + +/**************************************************************************** + UPDATE FUNCTIONS + FIXME: This would work better by adding a flag to SPDesktop to prevent + updating but that would be very intrusive so for now there is a workaround. + Need to make sure it plays well with verbs because they are used so much. +****************************************************************************/ + +void +document_interface_pause_updates (DocumentInterface *object, GError **error) +{ + object->updates = FALSE; + object->desk->canvas->drawing_disabled = 1; + //object->desk->canvas->need_redraw = 0; + //object->desk->canvas->need_repick = 0; + //sp_desktop_document(object->desk)->root->uflags = FALSE; + //sp_desktop_document(object->desk)->root->mflags = FALSE; +} + +void +document_interface_resume_updates (DocumentInterface *object, GError **error) +{ + object->updates = TRUE; + object->desk->canvas->drawing_disabled = 0; + //object->desk->canvas->need_redraw = 1; + //object->desk->canvas->need_repick = 1; + //sp_desktop_document(object->desk)->root->uflags = TRUE; + //sp_desktop_document(object->desk)->root->mflags = TRUE; + //sp_desktop_document(object->desk)->_updateDocument(); + //FIXME: use better verb than rect. + sp_document_done(sp_desktop_document(object->desk), SP_VERB_CONTEXT_RECT, "Multiple actions"); +} + +void +document_interface_update (DocumentInterface *object, GError **error) +{ + sp_desktop_document(object->desk)->root->uflags = TRUE; + sp_desktop_document(object->desk)->root->mflags = TRUE; + object->desk->enableInteraction(); + sp_desktop_document(object->desk)->_updateDocument(); + object->desk->disableInteraction(); + sp_desktop_document(object->desk)->root->uflags = FALSE; + sp_desktop_document(object->desk)->root->mflags = FALSE; + //sp_document_done(sp_desktop_document(object->desk), SP_VERB_CONTEXT_RECT, "Multiple actions"); +} + +/**************************************************************************** + SELECTION FUNCTIONS FIXME: use call_verb where appropriate (once update system is tested.) +****************************************************************************/ + +gboolean +document_interface_selection_get (DocumentInterface *object, char ***out, GError **error) +{ + Inkscape::Selection * sel = sp_desktop_selection(object->desk); + GSList const *oldsel = sel->list(); + + int size = g_slist_length((GSList *) oldsel); + + *out = g_new0 (char *, size + 1); + + int i = 0; + for (GSList const *iter = oldsel; iter != NULL; iter = iter->next) { + (*out)[i] = g_strdup(SP_OBJECT(iter->data)->repr->attribute("id")); + i++; + } + (*out)[i] = NULL; + + return TRUE; +} + +gboolean +document_interface_selection_add (DocumentInterface *object, char *name, GError **error) +{ + SPObject * obj = get_object_by_name(object->desk, name, error); + if (!obj) + return FALSE; + + Inkscape::Selection *selection = sp_desktop_selection(object->desk); + + selection->add(obj); + return TRUE; +} + +gboolean +document_interface_selection_add_list (DocumentInterface *object, + char **names, GError **error) +{ + int i; + for (i=0;names[i] != NULL;i++) { + document_interface_selection_add(object, names[i], error); + } + return TRUE; +} + +gboolean +document_interface_selection_set (DocumentInterface *object, char *name, GError **error) +{ + SPDocument * doc = sp_desktop_document (object->desk); + Inkscape::Selection *selection = sp_desktop_selection(object->desk); + selection->set(doc->getObjectById(name)); + return TRUE; +} + +gboolean +document_interface_selection_set_list (DocumentInterface *object, + gchar **names, GError **error) +{ + sp_desktop_selection(object->desk)->clear(); + int i; + for (i=0;names[i] != NULL;i++) { + document_interface_selection_add(object, names[i], error); + } + return TRUE; +} + +gboolean +document_interface_selection_rotate (DocumentInterface *object, int angle, GError **error) +{ + Inkscape::Selection *selection = sp_desktop_selection(object->desk); + sp_selection_rotate(selection, angle); + return TRUE; +} + +gboolean +document_interface_selection_delete (DocumentInterface *object, GError **error) +{ + //sp_selection_delete (object->desk); + return dbus_call_verb (object, SP_VERB_EDIT_DELETE, error); +} + +gboolean +document_interface_selection_clear (DocumentInterface *object, GError **error) +{ + sp_desktop_selection(object->desk)->clear(); + return TRUE; +} + +gboolean +document_interface_select_all (DocumentInterface *object, GError **error) +{ + //sp_edit_select_all (object->desk); + return dbus_call_verb (object, SP_VERB_EDIT_SELECT_ALL, error); +} + +gboolean +document_interface_select_all_in_all_layers(DocumentInterface *object, + GError **error) +{ + //sp_edit_select_all_in_all_layers (object->desk); + return dbus_call_verb (object, SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, error); +} + +gboolean +document_interface_selection_box (DocumentInterface *object, int x, int y, + int x2, int y2, gboolean replace, + GError **error) +{ + //FIXME: implement. + return FALSE; +} + +gboolean +document_interface_selection_invert (DocumentInterface *object, GError **error) +{ + //sp_edit_invert (object->desk); + return dbus_call_verb (object, SP_VERB_EDIT_INVERT, error); +} + +gboolean +document_interface_selection_group (DocumentInterface *object, GError **error) +{ + //sp_selection_group (object->desk); + return dbus_call_verb (object, SP_VERB_SELECTION_GROUP, error); +} +gboolean +document_interface_selection_ungroup (DocumentInterface *object, GError **error) +{ + //sp_selection_ungroup (object->desk); + return dbus_call_verb (object, SP_VERB_SELECTION_UNGROUP, error); +} + +gboolean +document_interface_selection_cut (DocumentInterface *object, GError **error) +{ + //desktop_ensure_active (object->desk); + //sp_selection_cut (object->desk); + return dbus_call_verb (object, SP_VERB_EDIT_CUT, error); +} + +gboolean +document_interface_selection_copy (DocumentInterface *object, GError **error) +{ + //desktop_ensure_active (object->desk); + //sp_selection_copy (); + return dbus_call_verb (object, SP_VERB_EDIT_COPY, error); +} +/* +gboolean +document_interface_selection_paste (DocumentInterface *object, GError **error) +{ + desktop_ensure_active (object->desk); + if (!object->updates) + document_interface_pause_updates (object, error); + sp_selection_paste (object->desk, TRUE); + if (!object->updates) + document_interface_pause_updates (object, error); + return TRUE; + //return dbus_call_verb (object, SP_VERB_EDIT_PASTE, error); +} +*/ +gboolean +document_interface_selection_paste (DocumentInterface *object, GError **error) +{ + return dbus_call_verb (object, SP_VERB_EDIT_PASTE, error); +} + +gboolean +document_interface_selection_scale (DocumentInterface *object, gdouble grow, GError **error) +{ + Inkscape::Selection *selection = sp_desktop_selection(object->desk); + if (!selection) + { + return FALSE; + } + sp_selection_scale (selection, grow); + return TRUE; +} + +gboolean +document_interface_selection_move (DocumentInterface *object, gdouble x, gdouble y, GError **error) +{ + sp_selection_move (object->desk, x, 0 - y); //switching coordinate systems. + return TRUE; +} + +gboolean +document_interface_selection_move_to (DocumentInterface *object, gdouble x, gdouble y, GError **error) +{ + Inkscape::Selection * sel = sp_desktop_selection(object->desk); + + Geom::OptRect sel_bbox = sel->bounds(); + if (sel_bbox) { + Geom::Point m( x - selection_get_center_x(sel) , 0 - (y - selection_get_center_y(sel)) ); + sp_selection_move_relative(sel, m, true); + } + return TRUE; +} + +//FIXME: does not paste in new layer. +// This needs to use lower level cut_impl and paste_impl (messy) +// See the built-in sp_selection_to_next_layer and duplicate. +gboolean +document_interface_selection_move_to_layer (DocumentInterface *object, + gchar *layerstr, GError **error) +{ + SPDesktop * dt = object->desk; + + Inkscape::Selection *selection = sp_desktop_selection(dt); + + // check if something is selected + if (selection->isEmpty()) + return FALSE; + + SPObject *next = get_object_by_name(object->desk, layerstr, error); + + if (!next) + return FALSE; + + if (strcmp("layer", (next->repr)->attribute("inkscape:groupmode")) == 0) { + + sp_selection_cut(dt); + + dt->setCurrentLayer(next); + + sp_selection_paste(dt, TRUE); + } + return TRUE; +} + +GArray * +document_interface_selection_get_center (DocumentInterface *object) +{ + Inkscape::Selection * sel = sp_desktop_selection(object->desk); + + if (sel) + { + gdouble x = selection_get_center_x(sel); + gdouble y = selection_get_center_y(sel); + GArray * intArr = g_array_new (TRUE, TRUE, sizeof(double)); + + g_array_append_val (intArr, x); + g_array_append_val (intArr, y); + return intArr; + } + + return NULL; +} + +gboolean +document_interface_selection_to_path (DocumentInterface *object, GError **error) +{ + return dbus_call_verb (object, SP_VERB_OBJECT_TO_CURVE, error); +} + + +gchar * +document_interface_selection_combine (DocumentInterface *object, gchar *cmd, + GError **error) +{ + if (strcmp(cmd, "union") == 0) + dbus_call_verb (object, SP_VERB_SELECTION_UNION, error); + else if (strcmp(cmd, "intersection") == 0) + dbus_call_verb (object, SP_VERB_SELECTION_INTERSECT, error); + else if (strcmp(cmd, "difference") == 0) + dbus_call_verb (object, SP_VERB_SELECTION_DIFF, error); + else if (strcmp(cmd, "exclusion") == 0) + dbus_call_verb (object, SP_VERB_SELECTION_SYMDIFF, error); + else + return NULL; + + if (sp_desktop_selection(object->desk)->singleRepr() != NULL) + return g_strdup((sp_desktop_selection(object->desk)->singleRepr())->attribute("id")); + return NULL; +} + +gboolean +document_interface_selection_divide (DocumentInterface *object, char ***out, GError **error) +{ + dbus_call_verb (object, SP_VERB_SELECTION_CUT, error); + + return document_interface_selection_get (object, out, error); +} + +gboolean +document_interface_selection_change_level (DocumentInterface *object, gchar *cmd, + GError **error) +{ + if (strcmp(cmd, "raise") == 0) + return dbus_call_verb (object, SP_VERB_SELECTION_RAISE, error); + if (strcmp(cmd, "lower") == 0) + return dbus_call_verb (object, SP_VERB_SELECTION_LOWER, error); + if ((strcmp(cmd, "to_top") == 0) || (strcmp(cmd, "to_front") == 0)) + return dbus_call_verb (object, SP_VERB_SELECTION_TO_FRONT, error); + if ((strcmp(cmd, "to_bottom") == 0) || (strcmp(cmd, "to_back") == 0)) + return dbus_call_verb (object, SP_VERB_SELECTION_TO_BACK, error); + return TRUE; +} + +/**************************************************************************** + LAYER FUNCTIONS +****************************************************************************/ + +gchar * +document_interface_layer_new (DocumentInterface *object, GError **error) +{ + SPDesktop * dt = object->desk; + SPObject *new_layer = Inkscape::create_layer(dt->currentRoot(), dt->currentLayer(), Inkscape::LPOS_BELOW); + dt->setCurrentLayer(new_layer); + return g_strdup(get_name_from_object (new_layer)); +} + +gboolean +document_interface_layer_set (DocumentInterface *object, + gchar *layerstr, GError **error) +{ + SPObject * obj = get_object_by_name (object->desk, layerstr, error); + + if (!obj) + return FALSE; + + object->desk->setCurrentLayer (obj); + return TRUE; +} + +gchar ** +document_interface_layer_get_all (DocumentInterface *object) +{ + //FIXME: implement. + return NULL; +} + +gboolean +document_interface_layer_change_level (DocumentInterface *object, + gchar *cmd, GError **error) +{ + if (strcmp(cmd, "raise") == 0) + return dbus_call_verb (object, SP_VERB_LAYER_RAISE, error); + if (strcmp(cmd, "lower") == 0) + return dbus_call_verb (object, SP_VERB_LAYER_LOWER, error); + if ((strcmp(cmd, "to_top") == 0) || (strcmp(cmd, "to_front") == 0)) + return dbus_call_verb (object, SP_VERB_LAYER_TO_TOP, error); + if ((strcmp(cmd, "to_bottom") == 0) || (strcmp(cmd, "to_back") == 0)) + return dbus_call_verb (object, SP_VERB_LAYER_TO_BOTTOM, error); + return TRUE; +} + +gboolean +document_interface_layer_next (DocumentInterface *object, GError **error) +{ + return dbus_call_verb (object, SP_VERB_LAYER_NEXT, error); +} + +gboolean +document_interface_layer_previous (DocumentInterface *object, GError **error) +{ + return dbus_call_verb (object, SP_VERB_LAYER_PREV, error); +} + + + + + + diff --cc src/extension/effect.cpp index 9a22c07b7,79bd96a7e..51aa42da6 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@@ -1,6 -1,6 +1,7 @@@ /* * Authors: * Ted Gould ++ * Abhishek Sharma * * Copyright (C) 2002-2007 Authors * diff --cc src/extension/execution-env.cpp index 7ed389195,d97c8c6de..f9e099c26 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@@ -1,6 -1,6 +1,7 @@@ /* * Authors: * Ted Gould ++ * Abhishek Sharma * * Copyright (C) 2007-2008 Authors * @@@ -162,14 -162,14 +163,14 @@@ ExecutionEnv::cancel (void) void ExecutionEnv::undo (void) { - sp_document_cancel(_doc->doc()); - SPDocumentUndo::cancel(_doc->doc()); ++ DocumentUndo::cancel(_doc->doc()); reselect(); return; } void ExecutionEnv::commit (void) { - sp_document_done(_doc->doc(), SP_VERB_NONE, _(_effect->get_name())); - SPDocumentUndo::done(_doc->doc(), SP_VERB_NONE, _(_effect->get_name())); ++ DocumentUndo::done(_doc->doc(), SP_VERB_NONE, _(_effect->get_name())); Effect::set_last_effect(_effect); _effect->get_imp()->commitDocument(); killDocCache(); diff --cc src/extension/implementation/script.cpp index 04c7c15a6,36cc5787b..bc143fd14 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@@ -6,6 -6,6 +6,7 @@@ * Bryce Harrington * Ted Gould * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2002-2005,2007 Authors * @@@ -532,9 -532,9 +533,8 @@@ SPDocument *Script::open(Inkscape::Exte } // data_read if (mydoc != NULL) { -- g_free(mydoc->base); -- mydoc->base = NULL; - sp_document_change_uri_and_hrefs(mydoc, filenameArg); - mydoc->change_uri_and_hrefs(filenameArg); ++ mydoc->setBase(0); ++ mydoc->changeUriAndHrefs(filenameArg); } // make sure we don't leak file descriptors from g_file_open_tmp diff --cc src/extension/implementation/xslt.cpp index 2ab821e44,75edacdb7..c929ba19a --- a/src/extension/implementation/xslt.cpp +++ b/src/extension/implementation/xslt.cpp @@@ -4,6 -4,6 +4,8 @@@ /* * Authors: * Ted Gould ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2006-2007 Authors * @@@ -189,8 -189,8 +191,7 @@@ XSLT::save(Inkscape::Extension::Output g_return_if_fail(doc != NULL); g_return_if_fail(filename != NULL); -- Inkscape::XML::Node *repr = NULL; -- repr = sp_document_repr_root (doc); ++ Inkscape::XML::Node *repr = doc->getReprRoot(); std::string tempfilename_out; int tempfd_out = 0; @@@ -202,7 -202,7 +203,7 @@@ } if (!sp_repr_save_rebased_file(repr->document(), tempfilename_out.c_str(), SP_SVG_NS_URI, -- doc->base, filename)) { ++ doc->getBase(), filename)) { throw Inkscape::Extension::Output::save_failed(); } diff --cc src/extension/internal/bluredge.cpp index a82c7ba77,e32012070..ba6b8383c --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@@ -72,7 -72,7 +72,7 @@@ BlurEdge::effect (Inkscape::Extension:: SPItem * spitem = *item; std::vector new_items(steps); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node * new_group = xml_doc->createElement("svg:g"); (SP_OBJECT_REPR(spitem)->parent())->appendChild(new_group); diff --cc src/extension/internal/cairo-png-out.cpp index c81fdd029,14a2f1b17..eb26fc581 --- a/src/extension/internal/cairo-png-out.cpp +++ b/src/extension/internal/cairo-png-out.cpp @@@ -5,6 -5,6 +5,8 @@@ * Authors: * Ted Gould * Ulf Erikson ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2004-2006 Authors * @@@ -53,14 -53,14 +55,14 @@@ png_render_document_to_file(SPDocument CairoRenderer *renderer; CairoRenderContext *ctx; - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); /* Start */ /* Create new arena */ -- SPItem *base = SP_ITEM(sp_document_root(doc)); ++ SPItem *base = SP_ITEM(doc->getRoot()); NRArena *arena = NRArena::create(); - unsigned dkey = sp_item_display_key_new(1); - NRArenaItem *root = sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY); + unsigned dkey = SPItem::display_key_new(1); + NRArenaItem *root = base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); /* Create renderer and context */ renderer = new CairoRenderer(); diff --cc src/extension/internal/cairo-ps-out.cpp index d9fd51ffd,76b68bf2c..07312aab1 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@@ -6,6 -6,6 +6,8 @@@ * Ted Gould * Ulf Erikson * Adib Taraben ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2004-2006 Authors * @@@ -65,7 -65,7 +67,7 @@@ static boo ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool omittext, bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas, bool eps = false) { - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); SPItem *base = NULL; @@@ -77,7 -77,7 +79,7 @@@ } else { // we want to export the entire document from root -- base = SP_ITEM(sp_document_root(doc)); ++ base = SP_ITEM(doc->getRoot()); pageBoundingBox = !exportDrawing; } diff --cc src/extension/internal/cairo-ps-out.h index 368d827b1,40c7bf7e3..7eda3c510 --- a/src/extension/internal/cairo-ps-out.h +++ b/src/extension/internal/cairo-ps-out.h @@@ -6,6 -6,6 +6,7 @@@ * Ted Gould * Ulf Erikson * Adib Taraben ++ * Abhishek Sharma * * Copyright (C) 2004-2006 Authors * diff --cc src/extension/internal/cairo-render-context.cpp index 6caa21d24,b6b411e0e..18a654e27 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@@ -1,11 -1,11 +1,11 @@@ --#define __SP_CAIRO_RENDER_CONTEXT_C__ -- /** \file * Rendering with Cairo. */ /* * Author: * Miklos Erdelyi ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2006 Miklos Erdelyi * @@@ -983,14 -960,14 +983,15 @@@ CairoRenderContext::popState(void g_assert( g_slist_length(_state_stack) > 0 ); } --static bool pattern_hasItemChildren (SPPattern *pat) ++static bool pattern_hasItemChildren(SPPattern *pat) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(pat)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = SP_OBJECT(pat)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ bool hasItems = false; ++ for ( SPObject *child = pat->firstChild() ; child && !hasItems; child = child->getNext() ) { if (SP_IS_ITEM (child)) { -- return true; ++ hasItems = true; } } -- return false; ++ return hasItems; } cairo_pattern_t* @@@ -1091,9 -1068,9 +1092,9 @@@ CairoRenderContext::_createPatternPaint // show items and render them for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children - for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = SP_OBJECT(pat_i)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM (child)) { - sp_item_invoke_show (SP_ITEM (child), arena, dkey, SP_ITEM_REFERENCE_FLAGS); + SP_ITEM (child)->invoke_show (arena, dkey, SP_ITEM_REFERENCE_FLAGS); _renderer->renderItem(pattern_ctx, SP_ITEM (child)); } } @@@ -1120,9 -1097,9 +1121,9 @@@ // hide all items for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children - for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = SP_OBJECT(pat_i)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM (child)) { - sp_item_invoke_hide (SP_ITEM (child), dkey); + SP_ITEM (child)->invoke_hide (dkey); } } break; // do not go further up the chain if children are found diff --cc src/extension/internal/cairo-renderer-pdf-out.cpp index 32df1193b,6536361bd..8406e2a3b --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@@ -6,6 -6,6 +6,8 @@@ * Ted Gould * Ulf Erikson * Johan Engelen ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2004-2010 Authors * @@@ -55,7 -55,7 +57,7 @@@ pdf_render_document_to_file(SPDocument bool texttopath, bool omittext, bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas) { - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); /* Start */ @@@ -69,12 -69,12 +71,13 @@@ } else { // we want to export the entire document from root -- base = SP_ITEM(sp_document_root(doc)); ++ base = SP_ITEM(doc->getRoot()); pageBoundingBox = !exportDrawing; } -- if (!base) ++ if (!base) { return false; ++ } /* Create new arena */ NRArena *arena = NRArena::create(); diff --cc src/extension/internal/cairo-renderer.cpp index 988f61263,3c5cfc7c1..67f9354d8 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@@ -1,11 -1,11 +1,11 @@@ --#define __SP_CAIRO_RENDERER_C__ -- /** \file * Rendering with Cairo. */ /* * Author: * Miklos Erdelyi ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2006 Miklos Erdelyi * @@@ -603,8 -602,8 +603,9 @@@ CairoRenderer::setupDocument(CairoRende g_assert( ctx != NULL ); -- if (!base) -- base = SP_ITEM(sp_document_root(doc)); ++ if (!base) { ++ base = SP_ITEM(doc->getRoot()); ++ } NRRect d; if (pageBoundingBox) { @@@ -672,7 -671,7 +673,7 @@@ CairoRenderer::applyClipPath(CairoRende TRACE(("BEGIN clip\n")); SPObject *co = SP_OBJECT(cp); - for (SPObject *child = sp_object_first_child(co) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = co->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = co->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM(child)) { SPItem *item = SP_ITEM(child); @@@ -730,7 -729,7 +731,7 @@@ CairoRenderer::applyMask(CairoRenderCon TRACE(("BEGIN mask\n")); SPObject *co = SP_OBJECT(mask); - for (SPObject *child = sp_object_first_child(co) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = co->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = co->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM(child)) { SPItem *item = SP_ITEM(child); renderItem(ctx, item); diff --cc src/extension/internal/cairo-renderer.h index f1a26a313,094922bbf..7fa7c7ff5 --- a/src/extension/internal/cairo-renderer.h +++ b/src/extension/internal/cairo-renderer.h @@@ -7,6 -7,6 +7,7 @@@ /* * Authors: * Miklos Erdelyi ++ * Abhishek Sharma * * Copyright (C) 2006 Miklos Erdelyi * diff --cc src/extension/internal/emf-win32-inout.cpp index 474dd1793,aa856e910..7d379477b --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@@ -3,6 -3,6 +3,8 @@@ */ /* Authors: * Ulf Erikson ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2006-2008 Authors * @@@ -109,7 -109,7 +111,7 @@@ emf_print_document_to_file(SPDocument * gchar *oldoutput; unsigned int ret; - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); mod = Inkscape::Extension::get_print(PRINT_EMF_WIN32); oldconst = mod->get_param_string("destination"); @@@ -120,7 -120,7 +122,7 @@@ context.module = mod; /* fixme: This has to go into module constructor somehow */ /* Create new arena */ -- mod->base = SP_ITEM(sp_document_root(doc)); ++ mod->base = SP_ITEM(doc->getRoot()); mod->arena = NRArena::create(); mod->dkey = sp_item_display_key_new(1); mod->root = sp_item_invoke_show(mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); diff --cc src/extension/internal/emf-win32-print.cpp index bd42b0eb6,e8e6b3187..58249620b --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@@ -3,6 -3,6 +3,8 @@@ */ /* Authors: * Ulf Erikson ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2006-2009 Authors * @@@ -146,8 -146,8 +148,8 @@@ PrintEmfWin32::begin (Inkscape::Extensi d.x1 = _width; d.y1 = _height; } else { -- SPItem* doc_item = SP_ITEM(sp_document_root(doc)); - sp_item_invoke_bbox(doc_item, &d, sp_item_i2d_affine(doc_item), TRUE); ++ SPItem* doc_item = SP_ITEM(doc->getRoot()); + sp_item_invoke_bbox(doc_item, &d, doc_item->i2d_affine(), TRUE); } d.x0 *= IN_PER_PX; diff --cc src/extension/internal/filter/filter.cpp index c2d80b28b,c2d80b28b..90dc5dd6f --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@@ -132,7 -132,7 +132,7 @@@ Filter::effect (Inkscape::Extension::Ef std::list items; items.insert >(items.end(), selection->itemList(), NULL); -- Inkscape::XML::Document * xmldoc = sp_document_repr_doc(document->doc()); ++ Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); Inkscape::XML::Node * defsrepr = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(document->doc())); for(std::list::iterator item = items.begin(); diff --cc src/extension/internal/gdkpixbuf-input.cpp index ff272d28d,69fdbcfd1..c3a30a2f0 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@@ -55,9 -54,9 +55,9 @@@ GdkpixbufInput::open(Inkscape::Extensio mime_type = "image/png"; } - doc = sp_document_new(NULL, TRUE, TRUE); - bool saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive(doc, false); // no need to undo in this temporary document + doc = SPDocument::createNewDoc(NULL, TRUE, TRUE); - bool saved = SPDocumentUndo::get_undo_sensitive(doc); - SPDocumentUndo::set_undo_sensitive(doc, false); // no need to undo in this temporary document ++ bool saved = DocumentUndo::getUndoSensitive(doc); ++ DocumentUndo::setUndoSensitive(doc, false); // no need to undo in this temporary document double width = gdk_pixbuf_get_width(pb); double height = gdk_pixbuf_get_height(pb); @@@ -79,7 -78,7 +79,7 @@@ } // Create image node -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *image_node = xml_doc->createElement("svg:image"); sp_repr_set_svg_double(image_node, "width", width); sp_repr_set_svg_double(image_node, "height", height); @@@ -100,11 -99,11 +100,11 @@@ g_object_unref(pb); // Add it to the current layer -- SP_DOCUMENT_ROOT(doc)->appendChildRepr(image_node); ++ doc->getRoot()->appendChildRepr(image_node); Inkscape::GC::release(image_node); fit_canvas_to_drawing(doc); // restore undo, as now this document may be shown to the user if a bitmap was opened - sp_document_set_undo_sensitive(doc, saved); - SPDocumentUndo::set_undo_sensitive(doc, saved); ++ DocumentUndo::setUndoSensitive(doc, saved); } else { printf("GdkPixbuf loader failed\n"); } diff --cc src/extension/internal/gimpgrad.cpp index 5b3e0c16e,6b11aa994..e92a4e17e --- a/src/extension/internal/gimpgrad.cpp +++ b/src/extension/internal/gimpgrad.cpp @@@ -5,6 -5,6 +5,7 @@@ /* * Authors: * Ted Gould ++ * Abhishek Sharma * * Copyright (C) 2004-2005 Authors * diff --cc src/extension/internal/grid.cpp index ed41dd97b,4d07e401d..a19ab7538 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@@ -6,6 -6,6 +6,7 @@@ /* * Copyright (C) 2004-2005 Ted Gould * Copyright (C) 2007 MenTaLguY ++ * Abhishek Sharma * * Released under GNU GPL, read the file 'COPYING' for more information */ @@@ -111,8 -111,10 +112,10 @@@ Grid::effect (Inkscape::Extension::Effe path_data = build_lines(bounding_area, offsets, spacings); -- Inkscape::XML::Document * xml_doc = sp_document_repr_doc(document->doc()); - Inkscape::XML::Node * current_layer = static_cast(document)->currentLayer()->repr; ++ Inkscape::XML::Document * xml_doc = document->doc()->getReprDoc(); + - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + Inkscape::XML::Node * current_layer = static_cast(document)->currentLayer()->getRepr(); Inkscape::XML::Node * path = xml_doc->createElement("svg:path"); path->setAttribute("d", path_data.c_str()); diff --cc src/extension/internal/javafx-out.cpp index b371b0105,813a17264..7098027c7 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@@ -9,6 -9,6 +9,7 @@@ * Silveira Neto * Jim Clarke * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2008,2009 Authors * diff --cc src/extension/internal/latex-pstricks-out.cpp index 4a469a750,a47419365..1477d5daf --- a/src/extension/internal/latex-pstricks-out.cpp +++ b/src/extension/internal/latex-pstricks-out.cpp @@@ -1,6 -1,6 +1,8 @@@ /* * Authors: * Michael Forbes ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2004 Authors * @@@ -55,7 -55,7 +57,7 @@@ LatexOutput::save(Inkscape::Extension:: gchar * oldoutput; unsigned int ret; - sp_document_ensure_up_to_date (doc); - doc->ensure_up_to_date (); ++ doc->ensureUpToDate(); mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_LATEX); oldconst = mod->get_param_string("destination"); @@@ -66,16 -66,16 +68,16 @@@ context.module = mod; /* fixme: This has to go into module constructor somehow */ /* Create new arena */ -- mod->base = SP_ITEM (sp_document_root (doc)); ++ mod->base = SP_ITEM(doc->getRoot()); mod->arena = NRArena::create(); - mod->dkey = sp_item_display_key_new (1); - mod->root = sp_item_invoke_show (mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); + mod->dkey = SPItem::display_key_new (1); + mod->root = (mod->base)->invoke_show (mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); /* Print document */ ret = mod->begin (doc); - sp_item_invoke_print (mod->base, &context); + (mod->base)->invoke_print (&context); ret = mod->finish (); /* Release arena */ - sp_item_invoke_hide (mod->base, mod->dkey); + (mod->base)->invoke_hide (mod->dkey); mod->base = NULL; mod->root = NULL; nr_object_unref ((NRObject *) mod->arena); diff --cc src/extension/internal/latex-pstricks.cpp index ed6024adf,63e9d3803..44b64c5f8 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@@ -1,10 -1,10 +1,9 @@@ --#define __SP_LATEX_C__ -- /* * LaTeX Printing * * Author: * Michael Forbes ++ * Abhishek Sharma * * Copyright (C) 2004 Authors * diff --cc src/extension/internal/latex-text-renderer.cpp index b37316d8f,d944de71a..fd99afe31 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define EXTENSION_INTERNAL_LATEX_TEXT_RENDERER_CPP -- /** \file * Rendering LaTeX file (pdf/eps/ps+latex output) * @@@ -9,6 -9,6 +7,8 @@@ * Authors: * Johan Engelen * Miklos Erdelyi ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2006-2010 Authors * @@@ -58,7 -58,7 +58,7 @@@ latex_render_document_text_to_file( SPD const gchar * const exportId, bool exportDrawing, bool exportCanvas, bool pdflatex) { - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); SPItem *base = NULL; @@@ -70,7 -70,7 +70,7 @@@ } else { // we want to export the entire document from root -- base = SP_ITEM(sp_document_root(doc)); ++ base = SP_ITEM(doc->getRoot()); pageBoundingBox = !exportDrawing; } @@@ -490,8 -490,8 +490,9 @@@ LaTeXTextRenderer::setupDocument(SPDocu { // The boundingbox calculation here should be exactly the same as the one by CairoRenderer::setupDocument ! -- if (!base) -- base = SP_ITEM(sp_document_root(doc)); ++ if (!base) { ++ base = SP_ITEM(doc->getRoot()); ++ } Geom::OptRect d; if (pageBoundingBox) { diff --cc src/extension/internal/odf.cpp index 4f3f1ac89,bf8a70a14..b5c842a40 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@@ -14,6 -14,6 +14,7 @@@ * * Authors: * Bob Jamison ++ * Abhishek Sharma * * Copyright (C) 2006, 2007 Bob Jamison * diff --cc src/extension/internal/odf.h index 3854ddfe1,08eda3767..9ad261098 --- a/src/extension/internal/odf.h +++ b/src/extension/internal/odf.h @@@ -11,6 -11,6 +11,7 @@@ * * Authors: * Bob Jamison ++ * Abhishek Sharma * * Copyright (C) 2006 Bob Jamison * diff --cc src/extension/internal/pdf-input-cairo.cpp index 937fefb11,62c6b7f36..2c7ea3b33 --- a/src/extension/internal/pdf-input-cairo.cpp +++ b/src/extension/internal/pdf-input-cairo.cpp @@@ -3,6 -3,6 +3,7 @@@ * * Authors: * miklos erdelyi ++ * Abhishek Sharma * * Copyright (C) 2007 Authors * diff --cc src/extension/internal/pdfinput/pdf-input.cpp index 8dd4698b5,b50711803..ae3e473a5 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@@ -3,6 -3,6 +3,7 @@@ * * Authors: * miklos erdelyi ++ * Abhishek Sharma * * Copyright (C) 2007 Authors * @@@ -659,9 -661,9 +660,9 @@@ PdfInput::open(::Inkscape::Extension::I Catalog *catalog = pdf_doc->getCatalog(); Page *page = catalog->getPage(page_num); - SPDocument *doc = sp_document_new(NULL, TRUE, TRUE); - bool saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive(doc, false); // No need to undo in this temporary document + SPDocument *doc = SPDocument::createNewDoc(NULL, TRUE, TRUE); - bool saved = SPDocumentUndo::get_undo_sensitive(doc); - SPDocumentUndo::set_undo_sensitive(doc, false); // No need to undo in this temporary document ++ bool saved = DocumentUndo::getUndoSensitive(doc); ++ DocumentUndo::setUndoSensitive(doc, false); // No need to undo in this temporary document // Create builder gchar *docname = g_path_get_basename(uri); @@@ -735,7 -737,7 +736,7 @@@ delete dlg; // Restore undo - sp_document_set_undo_sensitive(doc, saved); - SPDocumentUndo::set_undo_sensitive(doc, saved); ++ DocumentUndo::setUndoSensitive(doc, saved); return doc; } diff --cc src/extension/internal/pdfinput/svg-builder.cpp index e343dbf33,b9583545f..8b414239a --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@@ -3,6 -3,6 +3,7 @@@ * * Authors: * miklos erdelyi ++ * Jon A. Cruz * * Copyright (C) 2007 Authors * @@@ -77,12 -77,12 +78,13 @@@ struct SvgTransparencyGroup * */ --SvgBuilder::SvgBuilder(SPDocument *document, gchar *docname, XRef *xref) { ++SvgBuilder::SvgBuilder(SPDocument *document, gchar *docname, XRef *xref) ++{ _is_top_level = true; _doc = document; _docname = docname; _xref = xref; -- _xml_doc = sp_document_repr_doc(_doc); ++ _xml_doc = _doc->getReprDoc(); _container = _root = _doc->rroot; _root->setAttribute("xml:space", "preserve"); _init(); diff --cc src/extension/internal/pov-out.cpp index 7b1fe8b87,fc8c1a666..a130b6923 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@@ -10,6 -10,6 +10,7 @@@ * * Authors: * Bob Jamison ++ * Abhishek Sharma * * Copyright (C) 2004-2008 Authors * diff --cc src/extension/internal/svg.cpp index b10aa87ec,e80e316cf..946ff22fe --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@@ -6,6 -6,6 +6,8 @@@ * Authors: * Lauris Kaplinski * Ted Gould ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2002-2003 Authors * @@@ -237,17 -237,17 +239,17 @@@ Svg::save(Inkscape::Extension::Output * Inkscape::XML::Document *rdoc = NULL; Inkscape::XML::Node *repr = NULL; if (exportExtensions) { -- repr = sp_document_repr_root (doc); ++ repr = doc->getReprRoot(); } else { rdoc = sp_repr_document_new ("svg:svg"); repr = rdoc->root(); -- repr = sp_document_root (doc)->updateRepr(rdoc, repr, SP_OBJECT_WRITE_BUILD); ++ repr = doc->getRoot()->updateRepr(rdoc, repr, SP_OBJECT_WRITE_BUILD); pruneExtendedAttributes(repr); } if (!sp_repr_save_rebased_file(repr->document(), filename, SP_SVG_NS_URI, -- doc->base, filename)) { ++ doc->getBase(), filename)) { throw Inkscape::Extension::Output::save_failed(); } diff --cc src/extension/internal/win32.cpp index 0c711824c,3522ab247..8b4ff13c8 --- a/src/extension/internal/win32.cpp +++ b/src/extension/internal/win32.cpp @@@ -3,6 -3,6 +3,7 @@@ */ /* Author: * Lauris Kaplinski ++ * Abhishek Sharma * * This code is in public domain */ @@@ -226,10 -226,10 +227,10 @@@ PrintWin32::begin (Inkscape::Extension: }; int res; - _PageWidth = sp_document_width (doc); - _PageHeight = sp_document_height (doc); + _PageWidth = doc->getWidth (); + _PageHeight = doc->getHeight (); -- di.lpszDocName = SP_DOCUMENT_NAME (doc); ++ di.lpszDocName = doc->getName(); SPWin32Modal = TRUE; diff --cc src/extension/internal/wpg-input.cpp index c37d5705b,02247ffa0..70fa28967 --- a/src/extension/internal/wpg-input.cpp +++ b/src/extension/internal/wpg-input.cpp @@@ -6,6 -6,6 +6,7 @@@ * * Authors: * Ted Gould ++ * Abhishek Sharma * * Copyright (C) 2006 Authors * diff --cc src/extension/param/parameter.cpp index 94260cc56,3320cddca..ac7c8b8dd --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@@ -4,6 -4,6 +4,7 @@@ /* Author: * Ted Gould * Johan Engelen ++ * Jon A. Cruz * * Copyright (C) 2005-2007 Authors * @@@ -345,10 -343,10 +346,9 @@@ Parameter::new_child (Inkscape::XML::No return retval; } --Inkscape::XML::Node * --Parameter::document_param_node (SPDocument * doc) ++Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc) { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node * defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(doc)); Inkscape::XML::Node * params = NULL; diff --cc src/extension/print.h index 8ae71b8e6,bc275b3b5..0f0435c0f --- a/src/extension/print.h +++ b/src/extension/print.h @@@ -1,6 -1,6 +1,7 @@@ /* * Authors: * Ted Gould ++ * Abhishek Sharma * * Copyright (C) 2002-2004 Authors * diff --cc src/extension/system.cpp index 5412a5cc0,8cfc58797..cf58f2733 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@@ -7,6 -7,6 +7,8 @@@ * Authors: * Ted Gould * Johan Engelen ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2006-2007 Johan Engelen * Copyright (C) 2002-2004 Ted Gould @@@ -256,11 -256,11 +258,11 @@@ save(Extension *key, SPDocument *doc, g throw Output::file_read_only(); } -- Inkscape::XML::Node *repr = sp_document_repr_root(doc); ++ Inkscape::XML::Node *repr = doc->getReprRoot(); // remember attributes in case this is an unofficial save and/or overwrite fails -- gchar *saved_uri = g_strdup(doc->uri); ++ gchar *saved_uri = g_strdup(doc->getURI()); bool saved_modified = false; gchar *saved_output_extension = NULL; gchar *saved_dataloss = NULL; @@@ -268,14 -268,14 +270,14 @@@ saved_output_extension = g_strdup(get_file_save_extension(save_method).c_str()); saved_dataloss = g_strdup(repr->attribute("inkscape:dataloss")); if (official) { -- /* The document is changing name/uri. */ - sp_document_change_uri_and_hrefs(doc, fileName); - doc->change_uri_and_hrefs(fileName); ++ // The document is changing name/uri. ++ doc->changeUriAndHrefs(fileName); } // Update attributes: { - bool const saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive(doc, false); - bool const saved = SPDocumentUndo::get_undo_sensitive(doc); - SPDocumentUndo::set_undo_sensitive(doc, false); ++ bool const saved = DocumentUndo::getUndoSensitive(doc); ++ DocumentUndo::setUndoSensitive(doc, false); { // also save the extension for next use store_file_extension_in_prefs (omod->get_id(), save_method); @@@ -285,7 -285,7 +287,7 @@@ repr->setAttribute("inkscape:dataloss", "true"); } } - sp_document_set_undo_sensitive(doc, saved); - SPDocumentUndo::set_undo_sensitive(doc, saved); ++ DocumentUndo::setUndoSensitive(doc, saved); doc->setModifiedSinceSave(false); } @@@ -295,14 -295,14 +297,14 @@@ catch(...) { // revert attributes in case of official and overwrite if(check_overwrite && official) { - bool const saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive(doc, false); - bool const saved = SPDocumentUndo::get_undo_sensitive(doc); - SPDocumentUndo::set_undo_sensitive(doc, false); ++ bool const saved = DocumentUndo::getUndoSensitive(doc); ++ DocumentUndo::setUndoSensitive(doc, false); { store_file_extension_in_prefs (saved_output_extension, save_method); repr->setAttribute("inkscape:dataloss", saved_dataloss); } - sp_document_set_undo_sensitive(doc, saved); - sp_document_change_uri_and_hrefs(doc, saved_uri); - SPDocumentUndo::set_undo_sensitive(doc, saved); - doc->change_uri_and_hrefs(saved_uri); ++ DocumentUndo::setUndoSensitive(doc, saved); ++ doc->changeUriAndHrefs(saved_uri); } doc->setModifiedSinceSave(saved_modified); // free used ressources @@@ -317,13 -317,13 +319,13 @@@ // If it is an unofficial save, set the modified attributes back to what they were. if ( !official) { - bool const saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive(doc, false); - bool const saved = SPDocumentUndo::get_undo_sensitive(doc); - SPDocumentUndo::set_undo_sensitive(doc, false); ++ bool const saved = DocumentUndo::getUndoSensitive(doc); ++ DocumentUndo::setUndoSensitive(doc, false); { store_file_extension_in_prefs (saved_output_extension, save_method); repr->setAttribute("inkscape:dataloss", saved_dataloss); } - sp_document_set_undo_sensitive(doc, saved); - SPDocumentUndo::set_undo_sensitive(doc, saved); ++ DocumentUndo::setUndoSensitive(doc, saved); doc->setModifiedSinceSave(saved_modified); g_free(saved_output_extension); @@@ -589,9 -589,9 +591,9 @@@ get_file_save_path (SPDocument *doc, Fi switch (method) { case FILE_SAVE_METHOD_SAVE_AS: { - bool use_current_dir = prefs->getBool("/dialogs/save_as/use_current_dir"); - if (doc->uri && use_current_dir) { - path = Glib::path_get_dirname(doc->uri); + bool use_current_dir = prefs->getBool("/dialogs/save_as/use_current_dir", true); - if (doc->uri && use_current_dir) { - path = Glib::path_get_dirname(doc->uri); ++ if (doc->getURI() && use_current_dir) { ++ path = Glib::path_get_dirname(doc->getURI()); } else { path = prefs->getString("/dialogs/save_as/path"); } @@@ -604,8 -604,8 +606,8 @@@ path = prefs->getString("/dialogs/save_copy/path"); break; case FILE_SAVE_METHOD_INKSCAPE_SVG: -- if (doc->uri) { -- path = Glib::path_get_dirname(doc->uri); ++ if (doc->getURI()) { ++ path = Glib::path_get_dirname(doc->getURI()); } else { // FIXME: should we use the save_as path here or something else? Maybe we should // leave this as a choice to the user. diff --cc src/file.cpp index f7cd6a09a,15e5bbe72..bde985ea5 --- a/src/file.cpp +++ b/src/file.cpp @@@ -7,6 -7,6 +7,8 @@@ * bulia byak * Bruno Dilly * Stephen Silver ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2006 Johan Engelen * Copyright (C) 1999-2008 Authors @@@ -62,6 -64,6 +64,8 @@@ #include "uri.h" #include "xml/rebase-hrefs.h" ++using Inkscape::DocumentUndo; ++ #ifdef WITH_GNOME_VFS # include #endif @@@ -114,29 -112,29 +118,24 @@@ static void sp_file_add_recent(gchar co /** * Create a blank document and add it to the desktop */ --SPDesktop* --sp_file_new(const Glib::ustring &templ) ++SPDesktop *sp_file_new(const Glib::ustring &templ) { -- char *templName = NULL; -- if (templ.size()>0) -- templName = (char *)templ.c_str(); - SPDocument *doc = sp_document_new(templName, TRUE, true); - SPDocument *doc = SPDocument::createNewDoc(templName, TRUE, true); ++ SPDocument *doc = SPDocument::createNewDoc( !templ.empty() ? templ.c_str() : 0 , TRUE, true ); g_return_val_if_fail(doc != NULL, NULL); -- SPDesktop *dt; - if (Inkscape::NSApplication::Application::getNewGui()) - { - dt = Inkscape::NSApplication::Editor::createDesktop (doc); - } else { - SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); - g_return_val_if_fail(dtw != NULL, NULL); - doc->doUnref(); + SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); + g_return_val_if_fail(dtw != NULL, NULL); - sp_document_unref(doc); ++ doc->doUnref(); + + sp_create_window(dtw, TRUE); - dt = static_cast(dtw->view); ++ SPDesktop *dt = static_cast(dtw->view); + sp_namedview_window_from_document(dt); + sp_namedview_update_layers_from_document(dt); + +#ifdef WITH_DBUS + Inkscape::Extension::Dbus::dbus_init_desktop_interface(dt); +#endif - sp_create_window(dtw, TRUE); - dt = static_cast(dtw->view); - sp_namedview_window_from_document(dt); - sp_namedview_update_layers_from_document(dt); - } return dt; } @@@ -236,14 -234,18 +235,14 @@@ sp_file_open(const Glib::ustring &uri if (existing && existing->virgin && replace_empty) { // If the current desktop is empty, open the document there - sp_document_ensure_up_to_date (doc); - doc->ensure_up_to_date (); ++ doc->ensureUpToDate(); desktop->change_document(doc); - sp_document_resized_signal_emit (doc, sp_document_width(doc), sp_document_height(doc)); - doc->resized_signal_emit (doc->getWidth(), doc->getHeight()); ++ doc->emitResizedSignal(doc->getWidth(), doc->getHeight()); } else { - if (!Inkscape::NSApplication::Application::getNewGui()) { - // create a whole new desktop and window - SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); - sp_create_window(dtw, TRUE); - desktop = static_cast(dtw->view); - } else { - desktop = Inkscape::NSApplication::Editor::createDesktop (doc); - } + // create a whole new desktop and window + SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); + sp_create_window(dtw, TRUE); + desktop = static_cast(dtw->view); } doc->virgin = FALSE; @@@ -254,7 -256,7 +253,7 @@@ sp_namedview_update_layers_from_document(desktop); if (add_to_recent) { -- sp_file_add_recent(SP_DOCUMENT_URI(doc)); ++ sp_file_add_recent( doc->getURI() ); } return TRUE; @@@ -271,8 -273,8 +270,7 @@@ /** * Handle prompting user for "do you want to revert"? Revert on "OK" */ --void --sp_file_revert_dialog() ++void sp_file_revert_dialog() { SPDesktop *desktop = SP_ACTIVE_DESKTOP; g_assert(desktop != NULL); @@@ -280,10 -282,10 +278,10 @@@ SPDocument *doc = sp_desktop_document(desktop); g_assert(doc != NULL); -- Inkscape::XML::Node *repr = sp_document_repr_root(doc); ++ Inkscape::XML::Node *repr = doc->getReprRoot(); g_assert(repr != NULL); -- gchar const *uri = doc->uri; ++ gchar const *uri = doc->getURI(); if (!uri) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Document not saved yet. Cannot revert.")); return; @@@ -549,17 -551,17 +547,14 @@@ sp_file_open_dialog(Gtk::Window &parent /** * Remove unreferenced defs from the defs section of the document. */ -- -- --void --sp_file_vacuum() ++void sp_file_vacuum() { SPDocument *doc = SP_ACTIVE_DOCUMENT; - unsigned int diff = vacuum_document (doc); - unsigned int diff = doc->vacuum_document (); ++ unsigned int diff = doc->vacuumDocument(); - sp_document_done(doc, SP_VERB_FILE_VACUUM, - SPDocumentUndo::done(doc, SP_VERB_FILE_VACUUM, -- _("Vacuum <defs>")); ++ DocumentUndo::done(doc, SP_VERB_FILE_VACUUM, ++ _("Vacuum <defs>")); SPDesktop *dt = SP_ACTIVE_DESKTOP; if (diff > 0) { @@@ -761,9 -763,9 +756,10 @@@ sp_file_save_dialog(Gtk::Window &parent save_loc = save_path; save_loc.append(G_DIR_SEPARATOR_S); ++ // TODO fixed buffer is bad: char formatBuf[256]; int i = 1; -- if (!doc->uri) { ++ if ( !doc->getURI() ) { // We are saving for the first time; create a unique default filename snprintf(formatBuf, 255, _("drawing%s"), filename_extension.c_str()); save_loc.append(formatBuf); @@@ -775,7 -777,7 +771,7 @@@ save_loc.append(formatBuf); } } else { -- snprintf(formatBuf, 255, _("%s"), Glib::path_get_basename(doc->uri).c_str()); ++ snprintf(formatBuf, 255, _("%s"), Glib::path_get_basename(doc->getURI()).c_str()); save_loc.append(formatBuf); } @@@ -837,8 -839,8 +833,8 @@@ // FIXME: does the argument !is_copy really convey the correct meaning here? success = file_save(parentWindow, doc, fileName, selectionType, TRUE, !is_copy, save_method); -- if (success && SP_DOCUMENT_URI(doc)) { -- sp_file_add_recent(SP_DOCUMENT_URI(doc)); ++ if (success && doc->getURI()) { ++ sp_file_add_recent( doc->getURI() ); } save_path = Glib::path_get_dirname(fileName); @@@ -861,7 -863,7 +857,7 @@@ sp_file_save_document(Gtk::Window &pare bool success = true; if (doc->isModifiedSinceSave()) { -- if ( doc->uri == NULL ) ++ if ( doc->getURI() == NULL ) { // Hier sollte in Argument mitgegeben werden, das anzeigt, da� das Dokument das erste // Mal gespeichert wird, so da� als default .svg ausgew�hlt wird und nicht die zuletzt @@@ -869,7 -871,7 +865,7 @@@ return sp_file_save_dialog(parentWindow, doc, Inkscape::Extension::FILE_SAVE_METHOD_INKSCAPE_SVG); } else { Glib::ustring extension = Inkscape::Extension::get_file_save_extension(Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS); -- Glib::ustring fn = g_strdup(doc->uri); ++ Glib::ustring fn = g_strdup(doc->getURI()); // Try to determine the extension from the uri; this may not lead to a valid extension, // but this case is caught in the file_save method below (or rather in Extension::save() // further down the line). @@@ -962,22 -964,22 +958,22 @@@ file_import(SPDocument *in_doc, const G } if (doc != NULL) { -- Inkscape::XML::rebase_hrefs(doc, in_doc->base, true); -- Inkscape::XML::Document *xml_in_doc = sp_document_repr_doc(in_doc); ++ Inkscape::XML::rebase_hrefs(doc, in_doc->getBase(), true); ++ Inkscape::XML::Document *xml_in_doc = in_doc->getReprDoc(); prevent_id_clashes(doc, in_doc); SPObject *in_defs = SP_DOCUMENT_DEFS(in_doc); Inkscape::XML::Node *last_def = SP_OBJECT_REPR(in_defs)->lastChild(); -- SPCSSAttr *style = sp_css_attr_from_object(SP_DOCUMENT_ROOT(doc)); ++ SPCSSAttr *style = sp_css_attr_from_object(doc->getRoot()); // Count the number of top-level items in the imported document. guint items_count = 0; - for (SPObject *child = sp_object_first_child(SP_DOCUMENT_ROOT(doc)); - for (SPObject *child = SP_DOCUMENT_ROOT(doc)->first_child(); -- child != NULL; child = SP_OBJECT_NEXT(child)) -- { -- if (SP_IS_ITEM(child)) items_count++; ++ for ( SPObject *child = doc->getRoot()->firstChild(); child; child = child->getNext()) { ++ if (SP_IS_ITEM(child)) { ++ items_count++; ++ } } // Create a new group if necessary. @@@ -996,15 -998,15 +992,13 @@@ if (desktop) { place_to_insert = desktop->currentLayer(); } else { -- place_to_insert = SP_DOCUMENT_ROOT(in_doc); ++ place_to_insert = in_doc->getRoot(); } // Construct a new object representing the imported image, // and insert it into the current document. SPObject *new_obj = NULL; - for (SPObject *child = sp_object_first_child(SP_DOCUMENT_ROOT(doc)); - for (SPObject *child = SP_DOCUMENT_ROOT(doc)->first_child(); -- child != NULL; child = SP_OBJECT_NEXT(child) ) -- { ++ for ( SPObject *child = doc->getRoot()->firstChild(); child; child = child->getNext() ) { if (SP_IS_ITEM(child)) { Inkscape::XML::Node *newitem = SP_OBJECT_REPR(child)->duplicate(xml_in_doc); @@@ -1022,14 -1024,14 +1016,12 @@@ else if (SP_OBJECT_REPR(child)->type() == Inkscape::XML::ELEMENT_NODE) { const gchar *tag = SP_OBJECT_REPR(child)->name(); if (!strcmp(tag, "svg:defs")) { - for (SPObject *x = sp_object_first_child(child); - for (SPObject *x = child->first_child(); -- x != NULL; x = SP_OBJECT_NEXT(x)) -- { ++ for ( SPObject *x = child->firstChild(); x; x = x->getNext() ) { SP_OBJECT_REPR(in_defs)->addChild(SP_OBJECT_REPR(x)->duplicate(xml_in_doc), last_def); } } else if (!strcmp(tag, "svg:style")) { -- SP_DOCUMENT_ROOT(in_doc)->appendChildRepr(SP_OBJECT_REPR(child)->duplicate(xml_in_doc)); ++ in_doc->getRoot()->appendChildRepr(SP_OBJECT_REPR(child)->duplicate(xml_in_doc)); } } } @@@ -1045,14 -1047,14 +1037,14 @@@ selection->set(SP_ITEM(new_obj)); // preserve parent and viewBox transformations -- // c2p is identity matrix at this point unless sp_document_ensure_up_to_date is called - sp_document_ensure_up_to_date(doc); - Geom::Matrix affine = SP_ROOT(SP_DOCUMENT_ROOT(doc))->c2p * sp_item_i2doc_affine(SP_ITEM(place_to_insert)).inverse(); - doc->ensure_up_to_date(); - Geom::Matrix affine = SP_ROOT(SP_DOCUMENT_ROOT(doc))->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); ++ // c2p is identity matrix at this point unless ensureUpToDate is called ++ doc->ensureUpToDate(); ++ Geom::Matrix affine = SP_ROOT(doc->getRoot())->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); sp_selection_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false); // move to mouse pointer { - sp_document_ensure_up_to_date(sp_desktop_document(desktop)); - sp_desktop_document(desktop)->ensure_up_to_date(); ++ sp_desktop_document(desktop)->ensureUpToDate(); Geom::OptRect sel_bbox = selection->bounds(); if (sel_bbox) { Geom::Point m( desktop->point() - sel_bbox->midpoint() ); @@@ -1061,9 -1063,9 +1053,9 @@@ } } - sp_document_unref(doc); - sp_document_done(in_doc, SP_VERB_FILE_IMPORT, - _("Import")); + doc->doUnref(); - SPDocumentUndo::done(in_doc, SP_VERB_FILE_IMPORT, - _("Import")); ++ DocumentUndo::done(in_doc, SP_VERB_FILE_IMPORT, ++ _("Import")); } else { gchar *text = g_strdup_printf(_("Failed to load the requested file %s"), uri.c_str()); @@@ -1255,7 -1257,7 +1247,7 @@@ sp_file_export_dialog(Gtk::Window &pare if (success) { Glib::RefPtr recent = Gtk::RecentManager::get_default(); -- recent->add_item(SP_DOCUMENT_URI(doc)); ++ recent->add_item( doc->getURI() ); } export_path = fileName; @@@ -1308,7 -1310,7 +1300,7 @@@ sp_file_export_to_ocal_dialog(Gtk::Wind static bool gotSuccess = false; -- Inkscape::XML::Node *repr = sp_document_repr_root(doc); ++ Inkscape::XML::Node *repr = doc->getReprRoot(); (void)repr; if (!doc->uri && !doc->isModifiedSinceSave()) diff --cc src/filter-chemistry.cpp index 63e618dcf,9e0ee8383..d6900b1f6 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FILTER_CHEMISTRY_C__ -- /* * Various utility methods for filters * @@@ -7,6 -7,6 +5,8 @@@ * Hugo Rodrigues * bulia byak * Niko Kiirala ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2006-2008 authors * @@@ -34,8 -34,8 +34,7 @@@ * Count how many times the filter is used by the styles of o and its * descendants */ --static guint --count_filter_hrefs(SPObject *o, SPFilter *filter) ++static guint count_filter_hrefs(SPObject *o, SPFilter *filter) { if (!o) return 1; @@@ -50,8 -50,8 +49,7 @@@ i ++; } - for (SPObject *child = sp_object_first_child(o); - for (SPObject *child = o->first_child(); -- child != NULL; child = SP_OBJECT_NEXT(child)) { ++ for ( SPObject *child = o->firstChild(); child; child = child->getNext() ) { i += count_filter_hrefs(child, filter); } @@@ -94,14 -94,15 +92,14 @@@ SPFilter *new_filter(SPDocument *docume SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); // create a new filter Inkscape::XML::Node *repr; repr = xml_doc->createElement("svg:filter"); // Append the new filter node to defs - SP_OBJECT_REPR(defs)->appendChild(repr); - //SP_OBJECT_REPR(defs)->appendChild(repr); - defs->appendChild(repr); ++ defs->appendChild(repr); Inkscape::GC::release(repr); // get corresponding object @@@ -117,7 -118,7 +115,7 @@@ SPFilterPrimitive * filter_add_primitive(SPFilter *filter, const Inkscape::Filters::FilterPrimitiveType type) { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(filter->document); ++ Inkscape::XML::Document *xml_doc = filter->document->getReprDoc(); //create filter primitive node Inkscape::XML::Node *repr; @@@ -168,7 -169,9 +166,8 @@@ } //set primitive as child of filter node - filter->repr->appendChild(repr); - // XML tree being used directly while/where it shouldn't be... - //filter->getRepr()->appendChild(repr); - filter->appendChild(repr); ++ // XML tree being used directly while/where it shouldn't be... ++ filter->appendChild(repr); Inkscape::GC::release(repr); // get corresponding object @@@ -190,7 -193,7 +189,7 @@@ new_filter_gaussian_blur (SPDocument *d SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); // create a new filter Inkscape::XML::Node *repr; @@@ -217,7 -220,8 +216,7 @@@ Inkscape::GC::release(b_repr); // Append the new filter node to defs - SP_OBJECT_REPR(defs)->appendChild(repr); - //SP_OBJECT_REPR(defs)->appendChild(repr); - defs->appendChild(repr); ++ defs->appendChild(repr); Inkscape::GC::release(repr); // get corresponding object @@@ -245,7 -249,7 +244,7 @@@ new_filter_blend_gaussian_blur (SPDocum SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); // create a new filter Inkscape::XML::Node *repr; @@@ -253,7 -257,8 +252,7 @@@ repr->setAttribute("inkscape:collect", "always"); // Append the new filter node to defs - SP_OBJECT_REPR(defs)->appendChild(repr); - //SP_OBJECT_REPR(defs)->appendChild(repr); - defs->appendChild(repr); ++ defs->appendChild(repr); Inkscape::GC::release(repr); // get corresponding object @@@ -344,23 -349,24 +343,21 @@@ new_filter_simple_from_item (SPDocumen * duplicated, so that other elements referring that filter are not modified. */ /* TODO: this should be made more generic, not just for blurs */ --SPFilter * --modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *item, -- gdouble radius) ++SPFilter *modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *item, ++ gdouble radius) { if (!item->style || !item->style->filter.set) { return new_filter_simple_from_item(document, item, "normal", radius); } SPFilter *filter = SP_FILTER(item->style->getFilter()); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); // If there are more users for this filter, duplicate it -- if (SP_OBJECT_HREFCOUNT(filter) > count_filter_hrefs(item, filter)) { -- Inkscape::XML::Node *repr; -- repr = SP_OBJECT_REPR(item->style->getFilter())->duplicate(xml_doc); ++ if (filter->hrefcount > count_filter_hrefs(item, filter)) { ++ Inkscape::XML::Node *repr = SP_OBJECT_REPR(item->style->getFilter())->duplicate(xml_doc); SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); - SP_OBJECT_REPR(defs)->appendChild(repr); - //SP_OBJECT_REPR(defs)->appendChild(repr); - defs->appendChild(repr); ++ defs->appendChild(repr); filter = SP_FILTER( document->getObjectByRepr(repr) ); Inkscape::GC::release(repr); diff --cc src/filters/blend.cpp index 4c41184db,f297ac199..9a52d86f7 --- a/src/filters/blend.cpp +++ b/src/filters/blend.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FEBLEND_CPP__ -- /** \file * SVG implementation. * @@@ -8,6 -8,6 +6,7 @@@ * Authors: * Hugo Rodrigues * Niko Kiirala ++ * Abhishek Sharma * * Copyright (C) 2006,2007 authors * @@@ -103,8 -103,8 +102,8 @@@ sp_feBlend_build(SPObject *object, SPDo } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "mode"); - sp_object_read_attr(object, "in2"); - object->readAttr( "mode"); - object->readAttr( "in2"); ++ object->readAttr( "mode" ); ++ object->readAttr( "in2" ); /* Unlike normal in, in2 is required attribute. Make sure, we can call * it by some name. */ @@@ -202,8 -202,8 +201,8 @@@ sp_feBlend_update(SPObject *object, SPC SPFeBlend *blend = SP_FEBLEND(object); if (flags & SP_OBJECT_MODIFIED_FLAG) { - sp_object_read_attr(object, "mode"); - sp_object_read_attr(object, "in2"); - object->readAttr( "mode"); - object->readAttr( "in2"); ++ object->readAttr( "mode" ); ++ object->readAttr( "in2" ); } /* Unlike normal in, in2 is required attribute. Make sure, we can call @@@ -213,7 -213,9 +212,9 @@@ { SPFilter *parent = SP_FILTER(object->parent); blend->in2 = sp_filter_primitive_name_previous_out(blend); - object->repr->setAttribute("in2", sp_filter_name_for_image(parent, blend->in2)); + - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + object->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, blend->in2)); } if (((SPObjectClass *) feBlend_parent_class)->update) { diff --cc src/filters/colormatrix.cpp index da1c91632,1b189ef37..6018afe09 --- a/src/filters/colormatrix.cpp +++ b/src/filters/colormatrix.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FECOLORMATRIX_CPP__ -- /** \file * SVG implementation. * @@@ -8,6 -8,6 +6,7 @@@ * Authors: * Felipe Sanches * hugo Rodrigues ++ * Abhishek Sharma * * Copyright (C) 2007 Felipe C. da S. Sanches * Copyright (C) 2006 Hugo Rodrigues @@@ -98,8 -98,8 +97,8 @@@ sp_feColorMatrix_build(SPObject *object } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "type"); - sp_object_read_attr(object, "values"); - object->readAttr( "type"); - object->readAttr( "values"); ++ object->readAttr( "type" ); ++ object->readAttr( "values" ); } /** diff --cc src/filters/componenttransfer-funcnode.cpp index 2fad81797,a45716e08..a245e1c89 --- a/src/filters/componenttransfer-funcnode.cpp +++ b/src/filters/componenttransfer-funcnode.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FEFUNCNODE_CPP__ -- /** \file * SVG , , and implementations. */ @@@ -8,6 -8,6 +6,7 @@@ * Hugo Rodrigues * Niko Kiirala * Felipe Corrêa da Silva Sanches ++ * Abhishek Sharma * * Copyright (C) 2006, 2007, 2008 Authors * @@@ -168,17 -168,17 +167,17 @@@ sp_fefuncnode_build(SPObject *object, S } //Read values of key attributes from XML nodes into object. - sp_object_read_attr(object, "type"); - sp_object_read_attr(object, "tableValues"); - sp_object_read_attr(object, "slope"); - sp_object_read_attr(object, "intercept"); - sp_object_read_attr(object, "amplitude"); - sp_object_read_attr(object, "exponent"); - sp_object_read_attr(object, "offset"); - object->readAttr( "type"); - object->readAttr( "tableValues"); - object->readAttr( "slope"); - object->readAttr( "intercept"); - object->readAttr( "amplitude"); - object->readAttr( "exponent"); - object->readAttr( "offset"); ++ object->readAttr( "type" ); ++ object->readAttr( "tableValues" ); ++ object->readAttr( "slope" ); ++ object->readAttr( "intercept" ); ++ object->readAttr( "amplitude" ); ++ object->readAttr( "exponent" ); ++ object->readAttr( "offset" ); //is this necessary? - sp_document_add_resource(document, "fefuncnode", object); //maybe feFuncR, fefuncG, feFuncB and fefuncA ? - document->add_resource("fefuncnode", object); //maybe feFuncR, fefuncG, feFuncB and fefuncA ? ++ document->addResource("fefuncnode", object); //maybe feFuncR, fefuncG, feFuncB and fefuncA ? } /** @@@ -191,7 -191,7 +190,7 @@@ sp_fefuncnode_release(SPObject *object if (SP_OBJECT_DOCUMENT(object)) { /* Unregister ourselves */ - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "fefuncnode", SP_OBJECT(object)); - SP_OBJECT_DOCUMENT(object)->remove_resource("fefuncnode", SP_OBJECT(object)); ++ SP_OBJECT_DOCUMENT(object)->removeResource("fefuncnode", SP_OBJECT(object)); } //TODO: release resources here @@@ -296,8 -296,8 +295,8 @@@ sp_fefuncnode_update(SPObject *object, if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ //TODO - //sp_object_read_attr(object, "azimuth"); - //sp_object_read_attr(object, "elevation"); - //object->readAttr( "azimuth"); - //object->readAttr( "elevation"); ++ //object->readAttr( "azimuth" ); ++ //object->readAttr( "elevation" ); } if (((SPObjectClass *) feFuncNode_parent_class)->update) { diff --cc src/filters/componenttransfer.cpp index f1d4a709b,e8a573998..c6ff4f5f2 --- a/src/filters/componenttransfer.cpp +++ b/src/filters/componenttransfer.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FECOMPONENTTRANSFER_CPP__ -- /** \file * SVG implementation. * @@@ -7,6 -7,6 +5,7 @@@ /* * Authors: * hugo Rodrigues ++ * Abhishek Sharma * * Copyright (C) 2006 Hugo Rodrigues * @@@ -100,7 -100,7 +99,7 @@@ sp_feComponentTransfer_build(SPObject * /*LOAD ATTRIBUTES FROM REPR HERE*/ //do we need this? - sp_document_add_resource(document, "feComponentTransfer", object); - document->add_resource("feComponentTransfer", object); ++ document->addResource("feComponentTransfer", object); } static void sp_feComponentTransfer_children_modified(SPFeComponentTransfer *sp_componenttransfer) diff --cc src/filters/composite.cpp index 9398aeea7,ae5be1a81..c2b47c4c2 --- a/src/filters/composite.cpp +++ b/src/filters/composite.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FECOMPOSITE_CPP__ -- /** \file * SVG implementation. * @@@ -7,6 -7,6 +5,7 @@@ /* * Authors: * hugo Rodrigues ++ * Abhishek Sharma * * Copyright (C) 2006 Hugo Rodrigues * @@@ -101,14 -101,14 +100,14 @@@ sp_feComposite_build(SPObject *object, SPFeComposite *comp = SP_FECOMPOSITE(object); - sp_object_read_attr(object, "operator"); - object->readAttr( "operator"); ++ object->readAttr( "operator" ); if (comp->composite_operator == COMPOSITE_ARITHMETIC) { - sp_object_read_attr(object, "k1"); - sp_object_read_attr(object, "k2"); - sp_object_read_attr(object, "k3"); - sp_object_read_attr(object, "k4"); - object->readAttr( "k1"); - object->readAttr( "k2"); - object->readAttr( "k3"); - object->readAttr( "k4"); ++ object->readAttr( "k1" ); ++ object->readAttr( "k2" ); ++ object->readAttr( "k3" ); ++ object->readAttr( "k4" ); } - sp_object_read_attr(object, "in2"); - object->readAttr( "in2"); ++ object->readAttr( "in2" ); /* Unlike normal in, in2 is required attribute. Make sure, we can call * it by some name. */ diff --cc src/filters/convolvematrix.cpp index 45c0a080e,2f91c9db5..3f1419967 --- a/src/filters/convolvematrix.cpp +++ b/src/filters/convolvematrix.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FECONVOLVEMATRIX_CPP__ -- /** \file * SVG implementation. * @@@ -8,6 -8,6 +6,7 @@@ * Authors: * Felipe Corrêa da Silva Sanches * hugo Rodrigues ++ * Abhishek Sharma * * Copyright (C) 2006 Hugo Rodrigues * @@@ -110,15 -110,15 +109,15 @@@ sp_feConvolveMatrix_build(SPObject *obj } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "order"); - sp_object_read_attr(object, "kernelMatrix"); - sp_object_read_attr(object, "divisor"); - sp_object_read_attr(object, "bias"); - sp_object_read_attr(object, "targetX"); - sp_object_read_attr(object, "targetY"); - sp_object_read_attr(object, "edgeMode"); - sp_object_read_attr(object, "kernelUnitLength"); - sp_object_read_attr(object, "preserveAlpha"); - object->readAttr( "order"); - object->readAttr( "kernelMatrix"); - object->readAttr( "divisor"); - object->readAttr( "bias"); - object->readAttr( "targetX"); - object->readAttr( "targetY"); - object->readAttr( "edgeMode"); - object->readAttr( "kernelUnitLength"); - object->readAttr( "preserveAlpha"); ++ object->readAttr( "order" ); ++ object->readAttr( "kernelMatrix" ); ++ object->readAttr( "divisor" ); ++ object->readAttr( "bias" ); ++ object->readAttr( "targetX" ); ++ object->readAttr( "targetY" ); ++ object->readAttr( "edgeMode" ); ++ object->readAttr( "kernelUnitLength" ); ++ object->readAttr( "preserveAlpha" ); } /** diff --cc src/filters/diffuselighting.cpp index ca7a8423c,5681bddc1..95faa4a29 --- a/src/filters/diffuselighting.cpp +++ b/src/filters/diffuselighting.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FEDIFFUSELIGHTING_CPP__ -- /** \file * SVG implementation. * @@@ -8,6 -8,6 +6,7 @@@ * Authors: * hugo Rodrigues * Jean-Rene Reinhard ++ * Abhishek Sharma * * Copyright (C) 2006 Hugo Rodrigues * 2007 authors @@@ -118,10 -118,10 +117,10 @@@ sp_feDiffuseLighting_build(SPObject *ob } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "surfaceScale"); - sp_object_read_attr(object, "diffuseConstant"); - sp_object_read_attr(object, "kernelUnitLength"); - sp_object_read_attr(object, "lighting-color"); - object->readAttr( "surfaceScale"); - object->readAttr( "diffuseConstant"); - object->readAttr( "kernelUnitLength"); - object->readAttr( "lighting-color"); ++ object->readAttr( "surfaceScale" ); ++ object->readAttr( "diffuseConstant" ); ++ object->readAttr( "kernelUnitLength" ); ++ object->readAttr( "lighting-color" ); } @@@ -224,10 -224,10 +223,10 @@@ static voi sp_feDiffuseLighting_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG)) { - sp_object_read_attr(object, "surfaceScale"); - sp_object_read_attr(object, "diffuseConstant"); - sp_object_read_attr(object, "kernelUnit"); - sp_object_read_attr(object, "lighting-color"); - object->readAttr( "surfaceScale"); - object->readAttr( "diffuseConstant"); - object->readAttr( "kernelUnit"); - object->readAttr( "lighting-color"); ++ object->readAttr( "surfaceScale" ); ++ object->readAttr( "diffuseConstant" ); ++ object->readAttr( "kernelUnit" ); ++ object->readAttr( "lighting-color" ); } if (((SPObjectClass *) feDiffuseLighting_parent_class)->update) { diff --cc src/filters/displacementmap.cpp index 956719d10,ded7aab45..a6ad8b81a --- a/src/filters/displacementmap.cpp +++ b/src/filters/displacementmap.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FEDISPLACEMENTMAP_CPP__ -- /** \file * SVG implementation. * @@@ -7,6 -7,6 +5,7 @@@ /* * Authors: * hugo Rodrigues ++ * Abhishek Sharma * * Copyright (C) 2006 Hugo Rodrigues * @@@ -97,10 -97,10 +96,10 @@@ sp_feDisplacementMap_build(SPObject *ob } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "scale"); - sp_object_read_attr(object, "in2"); - sp_object_read_attr(object, "xChannelSelector"); - sp_object_read_attr(object, "yChannelSelector"); - object->readAttr( "scale"); - object->readAttr( "in2"); - object->readAttr( "xChannelSelector"); - object->readAttr( "yChannelSelector"); ++ object->readAttr( "scale" ); ++ object->readAttr( "in2" ); ++ object->readAttr( "xChannelSelector" ); ++ object->readAttr( "yChannelSelector" ); /* Unlike normal in, in2 is required attribute. Make sure, we can call * it by some name. */ @@@ -218,7 -218,9 +217,9 @@@ sp_feDisplacementMap_update(SPObject *o { SPFilter *parent = SP_FILTER(object->parent); disp->in2 = sp_filter_primitive_name_previous_out(disp); - object->repr->setAttribute("in2", sp_filter_name_for_image(parent, disp->in2)); + - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + object->getRepr()->setAttribute("in2", sp_filter_name_for_image(parent, disp->in2)); } if (((SPObjectClass *) feDisplacementMap_parent_class)->update) { diff --cc src/filters/distantlight.cpp index ee366a23d,3a56f682b..2207bc8e4 --- a/src/filters/distantlight.cpp +++ b/src/filters/distantlight.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FEDISTANTLIGHT_CPP__ -- /** \file * SVG implementation. */ @@@ -8,6 -8,6 +6,7 @@@ * Hugo Rodrigues * Niko Kiirala * Jean-Rene Reinhard ++ * Abhishek Sharma * * Copyright (C) 2006,2007 Authors * @@@ -101,11 -101,11 +100,11 @@@ sp_fedistantlight_build(SPObject *objec } //Read values of key attributes from XML nodes into object. - sp_object_read_attr(object, "azimuth"); - sp_object_read_attr(object, "elevation"); - object->readAttr( "azimuth"); - object->readAttr( "elevation"); ++ object->readAttr( "azimuth" ); ++ object->readAttr( "elevation" ); //is this necessary? - sp_document_add_resource(document, "fedistantlight", object); - document->add_resource("fedistantlight", object); ++ document->addResource("fedistantlight", object); } /** @@@ -118,7 -118,7 +117,7 @@@ sp_fedistantlight_release(SPObject *obj if (SP_OBJECT_DOCUMENT(object)) { /* Unregister ourselves */ - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "fedistantlight", SP_OBJECT(object)); - SP_OBJECT_DOCUMENT(object)->remove_resource("fedistantlight", SP_OBJECT(object)); ++ SP_OBJECT_DOCUMENT(object)->removeResource("fedistantlight", SP_OBJECT(object)); } //TODO: release resources here @@@ -189,8 -189,8 +188,8 @@@ sp_fedistantlight_update(SPObject *obje if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ - sp_object_read_attr(object, "azimuth"); - sp_object_read_attr(object, "elevation"); - object->readAttr( "azimuth"); - object->readAttr( "elevation"); ++ object->readAttr( "azimuth" ); ++ object->readAttr( "elevation" ); } if (((SPObjectClass *) feDistantLight_parent_class)->update) { diff --cc src/filters/flood.cpp index cf7ce662f,f5179cb41..25780c1ae --- a/src/filters/flood.cpp +++ b/src/filters/flood.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FEFLOOD_CPP__ -- /** \file * SVG implementation. * @@@ -7,6 -7,6 +5,7 @@@ /* * Authors: * hugo Rodrigues ++ * Abhishek Sharma * * Copyright (C) 2006 Hugo Rodrigues * @@@ -96,8 -96,8 +95,8 @@@ sp_feFlood_build(SPObject *object, SPDo } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "flood-opacity"); - sp_object_read_attr(object, "flood-color"); - object->readAttr( "flood-opacity"); - object->readAttr( "flood-color"); ++ object->readAttr( "flood-opacity" ); ++ object->readAttr( "flood-color" ); } /** diff --cc src/filters/image.cpp index 69a4b6018,1180799f4..bbe775c18 --- a/src/filters/image.cpp +++ b/src/filters/image.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FEIMAGE_CPP__ -- /** \file * SVG implementation. * @@@ -8,6 -8,6 +6,7 @@@ * Authors: * Felipe Corrêa da Silva Sanches * hugo Rodrigues ++ * Abhishek Sharma * * Copyright (C) 2007 Felipe Sanches * Copyright (C) 2006 Hugo Rodrigues @@@ -100,11 -100,11 +99,11 @@@ static void sp_feImage_build(SPObject * /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "width"); - sp_object_read_attr(object, "height"); - sp_object_read_attr(object, "xlink:href"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "width"); - object->readAttr( "height"); - object->readAttr( "xlink:href"); ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "width" ); ++ object->readAttr( "height" ); ++ object->readAttr( "xlink:href" ); } diff --cc src/filters/mergenode.cpp index 1f92df4d6,c135c06fb..b7b06a94a --- a/src/filters/mergenode.cpp +++ b/src/filters/mergenode.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FEMERGENODE_CPP__ -- /** \file * feMergeNode implementation. A feMergeNode contains the name of one * input image for feMerge. @@@ -8,6 -8,6 +6,7 @@@ * Authors: * Kees Cook * Niko Kiirala ++ * Abhishek Sharma * * Copyright (C) 2004,2007 authors * @@@ -84,7 -84,7 +83,7 @@@ sp_feMergeNode_init(SPFeMergeNode *feMe static void sp_feMergeNode_build(SPObject *object, SPDocument */*document*/, Inkscape::XML::Node */*repr*/) { - sp_object_read_attr(object, "in"); - object->readAttr( "in"); ++ object->readAttr( "in" ); } /** diff --cc src/filters/morphology.cpp index 668f94c4c,2724dc5b6..7ae65c48d --- a/src/filters/morphology.cpp +++ b/src/filters/morphology.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FEMORPHOLOGY_CPP__ -- /** \file * SVG implementation. * @@@ -8,6 -8,6 +6,7 @@@ * Authors: * Felipe Sanches * Hugo Rodrigues ++ * Abhishek Sharma * * Copyright (C) 2006 Hugo Rodrigues * @@@ -97,8 -97,8 +96,8 @@@ sp_feMorphology_build(SPObject *object } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "operator"); - sp_object_read_attr(object, "radius"); - object->readAttr( "operator"); - object->readAttr( "radius"); ++ object->readAttr( "operator" ); ++ object->readAttr( "radius" ); } /** diff --cc src/filters/offset.cpp index 2db931650,64f6661fe..48ee895dc --- a/src/filters/offset.cpp +++ b/src/filters/offset.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FEOFFSET_CPP__ -- /** \file * SVG implementation. * @@@ -8,6 -8,6 +6,7 @@@ * Authors: * hugo Rodrigues * Niko Kiirala ++ * Abhishek Sharma * * Copyright (C) 2006,2007 authors * @@@ -96,8 -96,8 +95,8 @@@ sp_feOffset_build(SPObject *object, SPD ((SPObjectClass *) feOffset_parent_class)->build(object, document, repr); } - sp_object_read_attr(object, "dx"); - sp_object_read_attr(object, "dy"); - object->readAttr( "dx"); - object->readAttr( "dy"); ++ object->readAttr( "dx" ); ++ object->readAttr( "dy" ); } /** @@@ -151,8 -151,8 +150,8 @@@ static voi sp_feOffset_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { - sp_object_read_attr(object, "dx"); - sp_object_read_attr(object, "dy"); - object->readAttr( "dx"); - object->readAttr( "dy"); ++ object->readAttr( "dx" ); ++ object->readAttr( "dy" ); } if (((SPObjectClass *) feOffset_parent_class)->update) { diff --cc src/filters/pointlight.cpp index a4939023e,55513ccb8..c9eebcb18 --- a/src/filters/pointlight.cpp +++ b/src/filters/pointlight.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FEPOINTLIGHT_CPP__ -- /** \file * SVG implementation. */ @@@ -8,6 -8,6 +6,7 @@@ * Hugo Rodrigues * Niko Kiirala * Jean-Rene Reinhard ++ * Abhishek Sharma * * Copyright (C) 2006,2007 Authors * @@@ -104,12 -104,12 +103,12 @@@ sp_fepointlight_build(SPObject *object } //Read values of key attributes from XML nodes into object. - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "z"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "z"); ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "z" ); //is this necessary? - sp_document_add_resource(document, "fepointlight", object); - document->add_resource("fepointlight", object); ++ document->addResource("fepointlight", object); } /** @@@ -122,7 -122,7 +121,7 @@@ sp_fepointlight_release(SPObject *objec if (SP_OBJECT_DOCUMENT(object)) { /* Unregister ourselves */ - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "fepointlight", SP_OBJECT(object)); - SP_OBJECT_DOCUMENT(object)->remove_resource("fepointlight", SP_OBJECT(object)); ++ SP_OBJECT_DOCUMENT(object)->removeResource("fepointlight", SP_OBJECT(object)); } //TODO: release resources here @@@ -211,9 -211,9 +210,9 @@@ sp_fepointlight_update(SPObject *object if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "z"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "z"); ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "z" ); } if (((SPObjectClass *) fePointLight_parent_class)->update) { diff --cc src/filters/specularlighting.cpp index 6ed540892,fcc6c697a..41eb38e61 --- a/src/filters/specularlighting.cpp +++ b/src/filters/specularlighting.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FESPECULARLIGHTING_CPP__ -- /** \file * SVG implementation. * @@@ -8,6 -8,6 +6,7 @@@ * Authors: * hugo Rodrigues * Jean-Rene Reinhard ++ * Abhishek Sharma * * Copyright (C) 2006 Hugo Rodrigues * 2007 authors @@@ -120,11 -120,11 +119,11 @@@ sp_feSpecularLighting_build(SPObject *o } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "surfaceScale"); - sp_object_read_attr(object, "specularConstant"); - sp_object_read_attr(object, "specularExponent"); - sp_object_read_attr(object, "kernelUnitLength"); - sp_object_read_attr(object, "lighting-color"); - object->readAttr( "surfaceScale"); - object->readAttr( "specularConstant"); - object->readAttr( "specularExponent"); - object->readAttr( "kernelUnitLength"); - object->readAttr( "lighting-color"); ++ object->readAttr( "surfaceScale" ); ++ object->readAttr( "specularConstant" ); ++ object->readAttr( "specularExponent" ); ++ object->readAttr( "kernelUnitLength" ); ++ object->readAttr( "lighting-color" ); } @@@ -250,11 -250,11 +249,11 @@@ static voi sp_feSpecularLighting_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG)) { - sp_object_read_attr(object, "surfaceScale"); - sp_object_read_attr(object, "specularConstant"); - sp_object_read_attr(object, "specularExponent"); - sp_object_read_attr(object, "kernelUnitLength"); - sp_object_read_attr(object, "lighting-color"); - object->readAttr( "surfaceScale"); - object->readAttr( "specularConstant"); - object->readAttr( "specularExponent"); - object->readAttr( "kernelUnitLength"); - object->readAttr( "lighting-color"); ++ object->readAttr( "surfaceScale" ); ++ object->readAttr( "specularConstant" ); ++ object->readAttr( "specularExponent" ); ++ object->readAttr( "kernelUnitLength" ); ++ object->readAttr( "lighting-color" ); } if (((SPObjectClass *) feSpecularLighting_parent_class)->update) { diff --cc src/filters/spotlight.cpp index 6d1347975,6e0c0cbd0..dac9b87e7 --- a/src/filters/spotlight.cpp +++ b/src/filters/spotlight.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FESPOTLIGHT_CPP__ -- /** \file * SVG implementation. */ @@@ -8,6 -8,6 +6,7 @@@ * Hugo Rodrigues * Niko Kiirala * Jean-Rene Reinhard ++ * Abhishek Sharma * * Copyright (C) 2006,2007 Authors * @@@ -114,17 -114,17 +113,17 @@@ sp_fespotlight_build(SPObject *object, } //Read values of key attributes from XML nodes into object. - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "z"); - sp_object_read_attr(object, "pointsAtX"); - sp_object_read_attr(object, "pointsAtY"); - sp_object_read_attr(object, "pointsAtZ"); - sp_object_read_attr(object, "specularExponent"); - sp_object_read_attr(object, "limitingConeAngle"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "z"); - object->readAttr( "pointsAtX"); - object->readAttr( "pointsAtY"); - object->readAttr( "pointsAtZ"); - object->readAttr( "specularExponent"); - object->readAttr( "limitingConeAngle"); ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "z" ); ++ object->readAttr( "pointsAtX" ); ++ object->readAttr( "pointsAtY" ); ++ object->readAttr( "pointsAtZ" ); ++ object->readAttr( "specularExponent" ); ++ object->readAttr( "limitingConeAngle" ); //is this necessary? - sp_document_add_resource(document, "fespotlight", object); - document->add_resource("fespotlight", object); ++ document->addResource("fespotlight", object); } /** @@@ -137,7 -137,7 +136,7 @@@ sp_fespotlight_release(SPObject *object if (SP_OBJECT_DOCUMENT(object)) { /* Unregister ourselves */ - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "fespotlight", SP_OBJECT(object)); - SP_OBJECT_DOCUMENT(object)->remove_resource("fespotlight", SP_OBJECT(object)); ++ SP_OBJECT_DOCUMENT(object)->removeResource("fespotlight", SP_OBJECT(object)); } //TODO: release resources here @@@ -309,14 -309,14 +308,14 @@@ sp_fespotlight_update(SPObject *object if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "z"); - sp_object_read_attr(object, "pointsAtX"); - sp_object_read_attr(object, "pointsAtY"); - sp_object_read_attr(object, "pointsAtZ"); - sp_object_read_attr(object, "specularExponent"); - sp_object_read_attr(object, "limitingConeAngle"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "z"); - object->readAttr( "pointsAtX"); - object->readAttr( "pointsAtY"); - object->readAttr( "pointsAtZ"); - object->readAttr( "specularExponent"); - object->readAttr( "limitingConeAngle"); ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "z" ); ++ object->readAttr( "pointsAtX" ); ++ object->readAttr( "pointsAtY" ); ++ object->readAttr( "pointsAtZ" ); ++ object->readAttr( "specularExponent" ); ++ object->readAttr( "limitingConeAngle" ); } if (((SPObjectClass *) feSpotLight_parent_class)->update) { diff --cc src/filters/turbulence.cpp index 268eca643,8c2d0387e..739001311 --- a/src/filters/turbulence.cpp +++ b/src/filters/turbulence.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FETURBULENCE_CPP__ -- /** \file * SVG implementation. * @@@ -8,6 -8,6 +6,7 @@@ * Authors: * Felipe Corrêa da Silva Sanches * hugo Rodrigues ++ * Abhishek Sharma * * Copyright (C) 2007 Felipe Sanches * Copyright (C) 2006 Hugo Rodrigues @@@ -100,11 -100,11 +99,11 @@@ sp_feTurbulence_build(SPObject *object } /*LOAD ATTRIBUTES FROM REPR HERE*/ - sp_object_read_attr(object, "baseFrequency"); - sp_object_read_attr(object, "numOctaves"); - sp_object_read_attr(object, "seed"); - sp_object_read_attr(object, "stitchTiles"); - sp_object_read_attr(object, "type"); - object->readAttr( "baseFrequency"); - object->readAttr( "numOctaves"); - object->readAttr( "seed"); - object->readAttr( "stitchTiles"); - object->readAttr( "type"); ++ object->readAttr( "baseFrequency" ); ++ object->readAttr( "numOctaves" ); ++ object->readAttr( "seed" ); ++ object->readAttr( "stitchTiles" ); ++ object->readAttr( "type" ); } /** diff --cc src/flood-context.cpp index 282ccbeb6,b9aaf902e..dd26782a3 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FLOOD_CONTEXT_C__ -- /** @file * @brief Bucket fill drawing context, works by bitmap filling an area on a rendered version * of the current display and then tracing the result using potrace. @@@ -8,6 -8,6 +6,8 @@@ * Lauris Kaplinski * bulia byak * John Bintz ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2006 Johan Engelen * Copyright (C) 2000-2005 authors @@@ -74,6 -74,6 +74,8 @@@ #include "trace/imagemap.h" #include "trace/potrace/inkscape-potrace.h" ++using Inkscape::DocumentUndo; ++ static void sp_flood_context_class_init(SPFloodContextClass *klass); static void sp_flood_context_init(SPFloodContext *flood_context); static void sp_flood_context_dispose(GObject *object); @@@ -417,8 -417,9 +419,8 @@@ static void do_trace(bitmap_coords_inf std::vector results = pte.traceGrayMap(gray_map); gray_map->destroy(gray_map); - Inkscape::XML::Node *layer_repr = SP_GROUP(desktop->currentLayer())->repr; - //XML Tree being used here directly while it shouldn't be...." - //Inkscape::XML::Node *layer_repr = SP_GROUP(desktop->currentLayer())->getRepr(); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ //XML Tree being used here directly while it shouldn't be...." ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); long totalNodeCount = 0L; @@@ -481,7 -482,8 +483,7 @@@ g_free(str); } - layer_repr->addChild(pathRepr, NULL); - //layer_repr->addChild(pathRepr, NULL); - desktop->currentLayer()->addChild(pathRepr,NULL); ++ desktop->currentLayer()->addChild(pathRepr,NULL); SPObject *reprobj = document->getObjectByRepr(pathRepr); if (reprobj) { @@@ -774,11 -776,11 +776,11 @@@ static void sp_flood_do_flood_fill(SPEv /* Create new arena */ NRArena *arena = NRArena::create(); - unsigned dkey = sp_item_display_key_new(1); + unsigned dkey = SPItem::display_key_new(1); - sp_document_ensure_up_to_date (document); - document->ensure_up_to_date (); ++ document->ensureUpToDate(); -- SPItem *document_root = SP_ITEM(SP_DOCUMENT_ROOT(document)); ++ SPItem *document_root = SP_ITEM(document->getRoot()); Geom::OptRect bbox = document_root->getBounds(Geom::identity()); if (!bbox) { @@@ -807,7 -809,7 +809,7 @@@ Geom::Matrix affine = scale * Geom::Translate(-origin * scale); /* Create ArenaItems and set transform */ - NRArenaItem *root = sp_item_invoke_show(SP_ITEM(sp_document_root(document)), arena, dkey, SP_ITEM_SHOW_DISPLAY); - NRArenaItem *root = SP_ITEM(sp_document_root(document))->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); ++ NRArenaItem *root = SP_ITEM(document->getRoot())->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); NRGC gc(NULL); @@@ -850,7 -852,7 +852,7 @@@ nr_pixblock_release(&B); // Hide items - sp_item_invoke_hide(SP_ITEM(sp_document_root(document)), dkey); - SP_ITEM(sp_document_root(document))->invoke_hide(dkey); ++ SP_ITEM(document->getRoot())->invoke_hide(dkey); nr_object_unref((NRObject *) arena); @@@ -1119,7 -1121,7 +1121,7 @@@ g_free(trace_px); - sp_document_done(document, SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); - SPDocumentUndo::done(document, SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); ++ DocumentUndo::done(document, SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); } static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) @@@ -1136,10 -1138,11 +1138,9 @@@ SPItem *item = sp_event_context_find_item (desktop, button_w, TRUE, TRUE); - Inkscape::XML::Node *pathRepr = SP_OBJECT_REPR(item); - //Inkscape::XML::Node *pathRepr = SP_OBJECT_REPR(item); -- /* Set style */ - sp_desktop_apply_style_tool (desktop, pathRepr, "/tools/paintbucket", false); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Set style on object")); - //sp_desktop_apply_style_tool (desktop, pathRepr, "/tools/paintbucket", false); - desktop->applyCurrentOrToolStyle(item, "/tools/paintbucket", false); - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Set style on object")); ++ // Set style ++ desktop->applyCurrentOrToolStyle(item, "/tools/paintbucket", false); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Set style on object")); ret = TRUE; } break; @@@ -1278,7 -1281,7 +1279,7 @@@ static void sp_flood_finish(SPFloodCont sp_canvas_end_forced_full_redraws(desktop->canvas); sp_desktop_selection(desktop)->set(rc->item); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); rc->item = NULL; diff --cc src/forward.h index d4a98fbff,e090b68b7..97d2c15ed --- a/src/forward.h +++ b/src/forward.h @@@ -6,6 -6,6 +6,7 @@@ * * Author: * Lauris Kaplinski ++ * Abhishek Sharma * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. @@@ -46,34 -46,33 +47,8 @@@ GType sp_event_context_get_type () class SPDocument; class SPDocumentClass; - #define SP_TYPE_DOCUMENT (sp_document_get_type ()) - #define SP_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_DOCUMENT, SPDocument)) - #define SP_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_DOCUMENT)) -//#define SP_TYPE_DOCUMENT (sp_document_get_type ()) -//#define SP_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_DOCUMENT, SPDocument)) -//#define SP_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_DOCUMENT)) -- - GType sp_document_get_type (); -//GType sp_document_get_type (); -- /* Objects */ - class SPObject; - class SPObjectClass; -//class SPObject; -//class SPObjectClass; -- - #define SP_TYPE_OBJECT (sp_object_get_type ()) - #define SP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_OBJECT, SPObject)) - #define SP_OBJECT_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_OBJECT, SPObjectClass)) - #define SP_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_OBJECT)) -//#define SP_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_OBJECT, SPObject)) -//#define SP_OBJECT_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_OBJECT, SPObjectClass)) -//#define SP_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_OBJECT)) -- - GType sp_object_get_type (); -//GType sp_object_get_type (); -- - class SPItem; - class SPItemClass; -//class SPItem; -//class SPItemClass; -- - #define SP_TYPE_ITEM (sp_item_get_type ()) - #define SP_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ITEM, SPItem)) - #define SP_ITEM_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_ITEM, SPItemClass)) - #define SP_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ITEM)) -//#define SP_TYPE_ITEM (sp_item_get_type ()) -//#define SP_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ITEM, SPItem)) -//#define SP_ITEM_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_ITEM, SPItemClass)) -//#define SP_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ITEM)) -- - GType sp_item_get_type (); -//GType sp_item_get_type (); -- class SPGroup; class SPGroupClass; diff --cc src/gradient-chemistry.cpp index d5b3ddb09,0d99e7fa6..fb5dab648 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@@ -6,6 -6,6 +6,7 @@@ * bulia byak * Johan Engelen * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2010 Authors * Copyright (C) 2007 Johan Engelen @@@ -107,7 -101,7 +108,7 @@@ static SPGradient *sp_gradient_get_priv SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); // create a new private gradient of the requested type Inkscape::XML::Node *repr; if (type == SP_GRADIENT_TYPE_LINEAR) { @@@ -160,8 -155,8 +161,7 @@@ guint count_gradient_hrefs(SPObject *o i ++; } - for (SPObject *child = sp_object_first_child(o); - for (SPObject *child = o->first_child(); -- child != NULL; child = SP_OBJECT_NEXT(child)) { ++ for ( SPObject *child = o->firstChild(); child; child = child->getNext() ) { i += count_gradient_hrefs(child, gr); } @@@ -198,7 -191,7 +198,7 @@@ SPGradient *sp_gradient_fork_private_if // Check the number of uses of the gradient within this object; // if we are private and there are no other users, -- if (!vector->isSwatch() && (SP_OBJECT_HREFCOUNT(gr) <= count_gradient_hrefs(user, gr))) { ++ if (!vector->isSwatch() && (gr->hrefcount <= count_gradient_hrefs(user, gr))) { // check vector if ( gr != vector && gr->ref->getObject() != vector ) { /* our href is not the vector, and vector is different from gr; relink */ @@@ -213,7 -206,7 +213,7 @@@ if ((gr->hasStops()) || (gr->state != SP_GRADIENT_STATE_UNKNOWN) || (SP_OBJECT_PARENT(gr) != SP_OBJECT(defs)) || -- (SP_OBJECT_HREFCOUNT(gr) > 1)) { ++ (gr->hrefcount > 1)) { // we have to clone a fresh new private gradient for the given vector // create an empty one @@@ -254,9 -245,9 +254,9 @@@ SPGradient *sp_gradient_fork_vector_if_ if (!prefs->getBool("/options/forkgradientvectors/value", true)) return gr; -- if (SP_OBJECT_HREFCOUNT(gr) > 1) { ++ if (gr->hrefcount > 1) { SPDocument *doc = SP_OBJECT_DOCUMENT(gr); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *repr = SP_OBJECT_REPR (gr)->duplicate(xml_doc); SP_OBJECT_REPR (SP_DOCUMENT_DEFS (doc))->addChild(repr, NULL); @@@ -298,7 -285,7 +298,7 @@@ SPGradient *sp_gradient_reset_to_usersp Inkscape::XML::Node *repr = SP_OBJECT_REPR(gr); // calculate the bbox of the item - sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(item)); - SP_OBJECT_DOCUMENT(item)->ensure_up_to_date(); ++ SP_OBJECT_DOCUMENT(item)->ensureUpToDate(); Geom::OptRect bbox = item->getBounds(Geom::identity()); // we need "true" bbox without item_i2d_affine if (!bbox) @@@ -364,7 -345,7 +364,7 @@@ SPGradient *sp_gradient_convert_to_user Inkscape::XML::Node *repr = SP_OBJECT_REPR(gr); // calculate the bbox of the item - sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(item)); - SP_OBJECT_DOCUMENT(item)->ensure_up_to_date(); ++ SP_OBJECT_DOCUMENT(item)->ensureUpToDate(); Geom::Matrix bbox2user; Geom::OptRect bbox = item->getBounds(Geom::identity()); // we need "true" bbox without item_i2d_affine if ( bbox ) { @@@ -741,8 -718,8 +741,7 @@@ void sp_item_gradient_reverse_vector(SP GSList *child_reprs = NULL; GSList *child_objects = NULL; std::vector offsets; - for (SPObject *child = sp_object_first_child(vector); - for (SPObject *child = vector->first_child(); -- child != NULL; child = SP_OBJECT_NEXT(child)) { ++ for ( SPObject *child = vector->firstChild(); child; child = child->getNext()) { child_reprs = g_slist_prepend (child_reprs, SP_OBJECT_REPR(child)); child_objects = g_slist_prepend (child_objects, child); offsets.push_back(sp_repr_get_double_attribute(SP_OBJECT_REPR(child), "offset", 0)); @@@ -1065,7 -1040,7 +1064,7 @@@ Geom::Point sp_item_gradient_get_coords } if (SP_GRADIENT(gradient)->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { - sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(item)); - SP_OBJECT_DOCUMENT(item)->ensure_up_to_date(); ++ SP_OBJECT_DOCUMENT(item)->ensureUpToDate(); Geom::OptRect bbox = item->getBounds(Geom::identity()); // we need "true" bbox without item_i2d_affine if (bbox) { p *= Geom::Matrix(bbox->dimensions()[Geom::X], 0, @@@ -1110,11 -1083,11 +1109,11 @@@ SPGradient *sp_item_set_gradient(SPIte /* Current fill style is the gradient of the required type */ SPGradient *current = SP_GRADIENT(ps); -- //g_message("hrefcount %d count %d\n", SP_OBJECT_HREFCOUNT(current), count_gradient_hrefs(SP_OBJECT(item), current)); ++ //g_message("hrefcount %d count %d\n", current->hrefcount, count_gradient_hrefs(SP_OBJECT(item), current)); if (!current->isSwatch() -- && (SP_OBJECT_HREFCOUNT(current) == 1 || -- SP_OBJECT_HREFCOUNT(current) == count_gradient_hrefs(SP_OBJECT(item), current))) { ++ && (current->hrefcount == 1 || ++ current->hrefcount == count_gradient_hrefs(SP_OBJECT(item), current))) { // current is private and it's either used once, or all its uses are by children of item; // so just change its href to vector diff --cc src/gradient-context.cpp index f104bbd41,2e6544b63..d37e9b022 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@@ -4,6 -6,6 +4,7 @@@ * Authors: * bulia byak * Johan Engelen ++ * Abhishek Sharma * * Copyright (C) 2007 Johan Engelen * Copyright (C) 2005 Authors @@@ -45,6 -47,6 +46,7 @@@ #include "sp-namedview.h" #include "rubberband.h" ++using Inkscape::DocumentUndo; static void sp_gradient_context_class_init(SPGradientContextClass *klass); @@@ -384,7 -386,7 +386,7 @@@ sp_gradient_context_add_stops_between_s } if (g_slist_length(these_stops) > 0 && doc) { - sp_document_done (doc, SP_VERB_CONTEXT_GRADIENT, _("Add gradient stop")); - SPDocumentUndo::done (doc, SP_VERB_CONTEXT_GRADIENT, _("Add gradient stop")); ++ DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, _("Add gradient stop")); drag->updateDraggers(); // so that it does not automatically update draggers in idle loop, as this would deselect drag->local_change = true; @@@ -452,7 -454,7 +454,7 @@@ sp_gradient_simplify(SPGradientContext } if (g_slist_length(todel) > 0) { - sp_document_done (doc, SP_VERB_CONTEXT_GRADIENT, _("Simplify gradient")); - SPDocumentUndo::done (doc, SP_VERB_CONTEXT_GRADIENT, _("Simplify gradient")); ++ DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, _("Simplify gradient")); drag->local_change = true; drag->updateDraggers(); drag->selectByCoords(coords); @@@ -476,8 -478,8 +478,8 @@@ sp_gradient_context_add_stop_near_poin ec->get_drag()->addStopNearPoint (item, mouse_p, tolerance/desktop->current_zoom()); - sp_document_done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, - SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, -- _("Add gradient stop")); ++ DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, ++ _("Add gradient stop")); ec->get_drag()->updateDraggers(); } @@@ -528,8 -530,8 +530,8 @@@ sp_gradient_context_root_handler(SPEven sp_gradient_reset_to_userspace(priv, item); } - sp_document_done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, - SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, -- _("Create default gradient")); ++ DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, ++ _("Create default gradient")); } ret = TRUE; } @@@ -813,8 -812,8 +815,8 @@@ } } // we did an undoable action - sp_document_done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, - SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, -- _("Invert gradient")); ++ DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, ++ _("Invert gradient")); ret = TRUE; } break; diff --cc src/gradient-drag.cpp index d5ab64794,e6dc22cea..2e9a21acf --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@@ -5,6 -7,6 +5,7 @@@ * bulia byak * Johan Engelen * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2007 Johan Engelen * Copyright (C) 2005,2010 Authors @@@ -44,6 -46,6 +45,8 @@@ #include "sp-namedview.h" #include "selection-chemistry.h" ++using Inkscape::DocumentUndo; ++ #define GR_KNOT_COLOR_NORMAL 0xffffff00 #define GR_KNOT_COLOR_MOUSEOVER 0xff000000 #define GR_KNOT_COLOR_SELECTED 0x0000ff00 @@@ -176,50 -178,15 +179,50 @@@ gr_drag_style_query (SPStyle *style, in } } -bool -gr_drag_style_set (const SPCSSAttr *css, gpointer data) +Glib::ustring GrDrag::makeStopSafeColor( gchar const *str, bool &isNull ) { - GrDrag *drag = (GrDrag *) data; + Glib::ustring colorStr; + if ( str ) { + isNull = false; + colorStr = str; + Glib::ustring::size_type pos = colorStr.find("url(#"); + if ( pos != Glib::ustring::npos ) { + Glib::ustring targetName = colorStr.substr(pos + 5, colorStr.length() - 6); - const GSList *gradients = sp_document_get_resource_list(desktop->doc(), "gradient"); ++ const GSList *gradients = desktop->doc()->getResourceList("gradient"); + for (const GSList *item = gradients; item; item = item->next) { + SPGradient* grad = SP_GRADIENT(item->data); + if ( targetName == grad->getId() ) { + SPGradient *vect = grad->getVector(); + SPStop *firstStop = (vect) ? vect->getFirstStop() : grad->getFirstStop(); + if (firstStop) { + Glib::ustring stopColorStr; + if (firstStop->currentColor) { - stopColorStr = sp_object_get_style_property(firstStop, "color", NULL); ++ stopColorStr = firstStop->getStyleProperty("color", NULL); + } else { + stopColorStr = firstStop->specified_color.toString(); + } + if ( !stopColorStr.empty() ) { + colorStr = stopColorStr; + } + } + break; + } + } + } + } else { + isNull = true; + } + + return colorStr; +} - if (!drag->selected) +bool GrDrag::styleSet( const SPCSSAttr *css ) +{ + if (!selected) { return false; + } - SPCSSAttr *stop = sp_repr_css_attr_new (); + SPCSSAttr *stop = sp_repr_css_attr_new(); // See if the css contains interesting properties, and if so, translate them into the format // acceptable for gradient stops @@@ -622,8 -588,8 +625,8 @@@ gr_knot_moved_handler(SPKnot *knot, Geo d_new->updateKnotShape (); d_new->updateTip (); d_new->updateDependencies(true); - sp_document_done (sp_desktop_document (d_new->parent->desktop), SP_VERB_CONTEXT_GRADIENT, - SPDocumentUndo::done (sp_desktop_document (d_new->parent->desktop), SP_VERB_CONTEXT_GRADIENT, -- _("Merge gradient handles")); ++ DocumentUndo::done(sp_desktop_document (d_new->parent->desktop), SP_VERB_CONTEXT_GRADIENT, ++ _("Merge gradient handles")); return; } } @@@ -927,8 -887,8 +930,8 @@@ gr_knot_ungrabbed_handler (SPKnot *knot dragger->updateDependencies(true); // we did an undoable action - sp_document_done (sp_desktop_document (dragger->parent->desktop), SP_VERB_CONTEXT_GRADIENT, - SPDocumentUndo::done (sp_desktop_document (dragger->parent->desktop), SP_VERB_CONTEXT_GRADIENT, -- _("Move gradient handle")); ++ DocumentUndo::done(sp_desktop_document (dragger->parent->desktop), SP_VERB_CONTEXT_GRADIENT, ++ _("Move gradient handle")); } /** @@@ -980,8 -940,8 +983,8 @@@ gr_knot_clicked_handler(SPKnot */*knot* } SP_OBJECT_REPR(gradient)->removeChild(SP_OBJECT_REPR(stop)); - sp_document_done (SP_OBJECT_DOCUMENT (gradient), SP_VERB_CONTEXT_GRADIENT, - SPDocumentUndo::done (SP_OBJECT_DOCUMENT (gradient), SP_VERB_CONTEXT_GRADIENT, -- _("Delete gradient stop")); ++ DocumentUndo::done(SP_OBJECT_DOCUMENT (gradient), SP_VERB_CONTEXT_GRADIENT, ++ _("Delete gradient stop")); } } else { // select the dragger @@@ -1863,7 -1817,7 +1866,7 @@@ GrDrag::selected_move (double x, doubl if (write_repr && did) { // we did an undoable action - sp_document_maybe_done (sp_desktop_document (desktop), "grmoveh", SP_VERB_CONTEXT_GRADIENT, - SPDocumentUndo::maybe_done (sp_desktop_document (desktop), "grmoveh", SP_VERB_CONTEXT_GRADIENT, ++ DocumentUndo::maybeDone(sp_desktop_document (desktop), "grmoveh", SP_VERB_CONTEXT_GRADIENT, _("Move gradient handle(s)")); return; } @@@ -1899,7 -1853,7 +1902,7 @@@ if (write_repr && did) { // we did an undoable action - sp_document_maybe_done (sp_desktop_document (desktop), "grmovem", SP_VERB_CONTEXT_GRADIENT, - SPDocumentUndo::maybe_done (sp_desktop_document (desktop), "grmovem", SP_VERB_CONTEXT_GRADIENT, ++ DocumentUndo::maybeDone(sp_desktop_document (desktop), "grmovem", SP_VERB_CONTEXT_GRADIENT, _("Move gradient mid stop(s)")); } } @@@ -2047,11 -2001,11 +2050,11 @@@ GrDrag::deleteSelected (bool just_one // cannot use vector->vector.stops.size() because the vector might be invalidated by deletion of a midstop // manually count the children, don't know if there already exists a function for this... int len = 0; - for ( SPObject *child = sp_object_first_child(stopinfo->vector) ; - for ( SPObject *child = (stopinfo->vector)->first_child() ; -- child != NULL ; -- child = SP_OBJECT_NEXT(child) ) ++ for ( SPObject *child = (stopinfo->vector)->firstChild() ; child ; child = child->getNext() ) { -- if ( SP_IS_STOP(child) ) len ++; ++ if ( SP_IS_STOP(child) ) { ++ len ++; ++ } } if (len > 2) { @@@ -2188,7 -2142,7 +2191,7 @@@ } if (document) { - sp_document_done ( document, SP_VERB_CONTEXT_GRADIENT, _("Delete gradient stop(s)") ); - SPDocumentUndo::done ( document, SP_VERB_CONTEXT_GRADIENT, _("Delete gradient stop(s)") ); ++ DocumentUndo::done( document, SP_VERB_CONTEXT_GRADIENT, _("Delete gradient stop(s)") ); } } diff --cc src/graphlayout.cpp index 0905cd94c,13838d4cf..4f536beb3 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@@ -4,6 -4,6 +4,7 @@@ /* * Authors: * Tim Dwyer ++ * Abhishek Sharma * * Copyright (C) 2005 Authors * diff --cc src/helper/pixbuf-ops.cpp index f50062d2d,b5630edd3..69becad5d --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@@ -1,10 -1,10 +1,10 @@@ --#define __SP_PIXBUF_OPS_C__ -- /* * Helpers for SPItem -> gdk_pixbuf related stuff * * Authors: * John Cliff ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2008 John Cliff * @@@ -38,11 -38,11 +38,11 @@@ #include "pixbuf-ops.h" ++// TODO look for copy-n-past duplication of this function: /** * Hide all items that are not listed in list, recursively, skipping groups and defs. */ --static void --hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) ++static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) { if ( SP_IS_ITEM(o) && !SP_IS_DEFS(o) @@@ -56,7 -56,7 +56,7 @@@ // recurse if (!g_slist_find(list, o)) { - for (SPObject *child = sp_object_first_child(o) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = o->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) { hide_other_items_recursively(child, list, dkey); } } @@@ -104,9 -104,9 +104,9 @@@ sp_generate_internal_bitmap(SPDocument /* Create new arena for offscreen rendering*/ NRArena *arena = NRArena::create(); nr_arena_set_renderoffscreen(arena); - unsigned dkey = sp_item_display_key_new(1); + unsigned dkey = SPItem::display_key_new(1); - sp_document_ensure_up_to_date (doc); - doc->ensure_up_to_date (); ++ doc->ensureUpToDate(); Geom::Rect screen=Geom::Rect(Geom::Point(x0,y0), Geom::Point(x1, y1)); @@@ -122,7 -122,7 +122,7 @@@ Geom::Matrix affine = scale * Geom::Translate(-origin * scale); /* Create ArenaItems and set transform */ - NRArenaItem *root = sp_item_invoke_show(SP_ITEM(sp_document_root(doc)), arena, dkey, SP_ITEM_SHOW_DISPLAY); - NRArenaItem *root = SP_ITEM(sp_document_root(doc))->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); ++ NRArenaItem *root = SP_ITEM(doc->getRoot())->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); NRGC gc(NULL); @@@ -131,7 -131,7 +131,7 @@@ // We show all and then hide all items we don't want, instead of showing only requested items, // because that would not work if the shown item references something in defs if (items_only) { -- hide_other_items_recursively(sp_document_root(doc), items_only, dkey); ++ hide_other_items_recursively(doc->getRoot(), items_only, dkey); } NRRectL final_bbox; @@@ -186,7 -186,7 +186,7 @@@ { g_warning("sp_generate_internal_bitmap: not enough memory to create pixel buffer. Need %lld.", size); } - sp_item_invoke_hide (SP_ITEM(sp_document_root(doc)), dkey); - SP_ITEM(sp_document_root(doc))->invoke_hide (dkey); ++ SP_ITEM(doc->getRoot())->invoke_hide(dkey); nr_object_unref((NRObject *) arena); // gdk_pixbuf_save (pixbuf, "C:\\temp\\internal.jpg", "jpeg", NULL, "quality","100", NULL); diff --cc src/helper/png-write.cpp index 754372f23,5ccb6c7fa..d3fe2771f --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@@ -1,11 -1,11 +1,11 @@@ --#define __SP_PNG_WRITE_C__ -- /* * PNG file format utilities * * Authors: * Lauris Kaplinski * Whoever wrote this example in libpng documentation ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 1999-2002 authors * @@@ -362,8 -362,8 +362,7 @@@ sp_export_get_rows(guchar const **rows /** * Hide all items that are not listed in list, recursively, skipping groups and defs. */ --static void --hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) ++static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) { if ( SP_IS_ITEM(o) && !SP_IS_DEFS(o) @@@ -376,7 -376,7 +375,7 @@@ // recurse if (!g_slist_find(list, o)) { - for (SPObject *child = sp_object_first_child(o) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = o->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) { hide_other_items_recursively(child, list, dkey); } } @@@ -422,10 -422,10 +421,10 @@@ sp_export_png_file(SPDocument *doc, gch return true; } - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); /* Calculate translation by transforming to document coordinates (flipping Y)*/ - Geom::Point translation = Geom::Point(-area[Geom::X][0], area[Geom::Y][1] - sp_document_height(doc)); + Geom::Point translation = Geom::Point(-area[Geom::X][0], area[Geom::Y][1] - doc->getHeight()); /* This calculation is only valid when assumed that (x0,y0)= area.corner(0) and (x1,y1) = area.corner(2) * 1) a[0] * x0 + a[2] * y1 + a[4] = 0.0 @@@ -461,16 -461,16 +460,16 @@@ NRArena *const arena = NRArena::create(); // export with maximum blur rendering quality nr_arena_set_renderoffscreen(arena); - unsigned const dkey = sp_item_display_key_new(1); + unsigned const dkey = SPItem::display_key_new(1); /* Create ArenaItems and set transform */ - ebp.root = sp_item_invoke_show(SP_ITEM(sp_document_root(doc)), arena, dkey, SP_ITEM_SHOW_DISPLAY); - ebp.root = SP_ITEM(sp_document_root(doc))->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); ++ ebp.root = SP_ITEM(doc->getRoot())->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(ebp.root), affine); // We show all and then hide all items we don't want, instead of showing only requested items, // because that would not work if the shown item references something in defs if (items_only) { -- hide_other_items_recursively(sp_document_root(doc), items_only, dkey); ++ hide_other_items_recursively(doc->getRoot(), items_only, dkey); } ebp.status = status; @@@ -490,7 -490,7 +489,7 @@@ } // Hide items, this releases arenaitem - sp_item_invoke_hide(SP_ITEM(sp_document_root(doc)), dkey); - SP_ITEM(sp_document_root(doc))->invoke_hide(dkey); ++ SP_ITEM(doc->getRoot())->invoke_hide(dkey); /* Free arena */ nr_object_unref((NRObject *) arena); diff --cc src/helper/stock-items.cpp index 1c184da72,6cdb50c35..4ec61c54a --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __INK_STOCK_ITEMS__ -- /* * Stock-items * @@@ -7,6 -7,6 +5,8 @@@ * * Authors: * John Cliff ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright 2004 John Cliff * @@@ -60,7 -60,7 +60,7 @@@ static SPObject * sp_marker_load_from_s } g_free(markers); if (doc) { - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); } else { edoc = TRUE; } @@@ -70,7 -70,7 +70,7 @@@ SPObject *object = doc->getObjectById(name); if (object && SP_IS_MARKER(object)) { SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_doc); ++ Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *mark_repr = SP_OBJECT_REPR(object)->duplicate(xml_doc); SP_OBJECT_REPR(defs)->addChild(mark_repr, NULL); SPObject *cloned_item = current_doc->getObjectByRepr(mark_repr); @@@ -103,7 -103,7 +103,7 @@@ sp_pattern_load_from_svg(gchar const *n } g_free(patterns); if (doc) { - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); } else { edoc = TRUE; } @@@ -114,7 -114,7 +114,7 @@@ SPObject *object = doc->getObjectById(name); if (object && SP_IS_PATTERN(object)) { SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_doc); ++ Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *pat_repr = SP_OBJECT_REPR(object)->duplicate(xml_doc); SP_OBJECT_REPR(defs)->addChild(pat_repr, NULL); Inkscape::GC::release(pat_repr); @@@ -146,7 -146,7 +146,7 @@@ sp_gradient_load_from_svg(gchar const * } g_free(gradients); if (doc) { - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); } else { edoc = TRUE; } @@@ -157,7 -157,7 +157,7 @@@ SPObject *object = doc->getObjectById(name); if (object && SP_IS_GRADIENT(object)) { SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(current_doc); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(current_doc); ++ Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *pat_repr = SP_OBJECT_REPR(object)->duplicate(xml_doc); SP_OBJECT_REPR(defs)->addChild(pat_repr, NULL); Inkscape::GC::release(pat_repr); @@@ -195,13 -195,13 +195,11 @@@ SPObject *get_stock_item(gchar const *u SPDesktop *desktop = inkscape_active_desktop(); SPDocument *doc = sp_desktop_document(desktop); -- SPDefs *defs= (SPDefs *) SP_DOCUMENT_DEFS(doc); ++ SPDefs *defs = reinterpret_cast(SP_DOCUMENT_DEFS(doc)); SPObject *object = NULL; if (!strcmp(base, "marker")) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(defs)); - for (SPObject *child = SP_OBJECT(defs)->first_child(); -- child != NULL; -- child = SP_OBJECT_NEXT(child)) ++ for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) { if (SP_OBJECT_REPR(child)->attribute("inkscape:stockid") && !strcmp(name_p, SP_OBJECT_REPR(child)->attribute("inkscape:stockid")) && @@@ -213,11 -213,11 +211,9 @@@ } else if (!strcmp(base,"pattern")) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(defs)) ; - for (SPObject *child = SP_OBJECT(defs)->first_child() ; -- child != NULL; -- child = SP_OBJECT_NEXT(child) ) ++ for ( SPObject *child = defs->firstChild() ; child; child = child->getNext() ) { -- if (SP_OBJECT_REPR(child)->attribute("inkscape:stockid") && ++ if (child->getRepr()->attribute("inkscape:stockid") && !strcmp(name_p, SP_OBJECT_REPR(child)->attribute("inkscape:stockid")) && SP_IS_PATTERN(child)) { @@@ -227,9 -227,9 +223,7 @@@ } else if (!strcmp(base,"gradient")) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(defs)); - for (SPObject *child = SP_OBJECT(defs)->first_child(); -- child != NULL; -- child = SP_OBJECT_NEXT(child)) ++ for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) { if (SP_OBJECT_REPR(child)->attribute("inkscape:stockid") && !strcmp(name_p, SP_OBJECT_REPR(child)->attribute("inkscape:stockid")) && diff --cc src/id-clash.cpp index 43ce393dd,7572e6a42..0594fe8e6 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@@ -1,9 -1,9 +1,10 @@@ --#define __ID_CLASH_C__ /** \file * Routines for resolving ID clashes when importing or pasting. * * Authors: * Stephen Silver ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2008 authors * @@@ -164,9 -164,9 +165,8 @@@ find_references(SPObject *elem, refmap_ } } -- /* recurse */ - for (SPObject *child = sp_object_first_child(elem); - for (SPObject *child = elem->first_child(); -- child; child = SP_OBJECT_NEXT(child) ) ++ // recurse ++ for (SPObject *child = elem->firstChild(); child; child = child->getNext() ) { find_references(child, refmap); } @@@ -203,9 -203,9 +203,8 @@@ change_clashing_ids(SPDocument *importe id_changes->push_back(id_changeitem_type(elem, old_id)); } -- /* recurse */ - for (SPObject *child = sp_object_first_child(elem); - for (SPObject *child = elem->first_child(); -- child; child = SP_OBJECT_NEXT(child) ) ++ // recurse ++ for (SPObject *child = elem->firstChild(); child; child = child->getNext() ) { change_clashing_ids(imported_doc, current_doc, child, refmap, id_changes); } @@@ -263,7 -263,7 +262,7 @@@ prevent_id_clashes(SPDocument *imported { refmap_type *refmap = new refmap_type; id_changelist_type id_changes; -- SPObject *imported_root = SP_DOCUMENT_ROOT(imported_doc); ++ SPObject *imported_root = imported_doc->getRoot(); find_references(imported_root, refmap); change_clashing_ids(imported_doc, current_doc, imported_root, refmap, diff --cc src/inkscape.cpp index e4edb9d10,c10581a91..430977567 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@@ -330,8 -334,8 +330,8 @@@ static gint inkscape_autosave(gpointer ++docnum; -- Inkscape::XML::Node *repr = sp_document_repr_root(doc); -- // g_debug("Document %d: \"%s\" %s", docnum, doc ? doc->name : "(null)", doc ? (doc->isModifiedSinceSave() ? "(dirty)" : "(clean)") : "(null)"); ++ Inkscape::XML::Node *repr = doc->getReprRoot(); ++ // g_debug("Document %d: \"%s\" %s", docnum, doc ? doc->getName() : "(null)", doc ? (doc->isModifiedSinceSave() ? "(dirty)" : "(clean)") : "(null)"); if (doc->isModifiedSinceSave()) { gchar *oldest_autosave = 0; @@@ -530,7 -534,7 +530,7 @@@ inkscape_trackalt() void inkscape_trackalt(guint trackvalue) { -- inkscape->trackalt = trackvalue; ++ inkscape->trackalt = trackvalue; } @@@ -609,13 -604,13 +609,13 @@@ inkscape_crash_handler (int /*signum*/ ++iter) { SPDocument *doc = iter->first; Inkscape::XML::Node *repr; -- repr = sp_document_repr_root (doc); ++ repr = doc->getReprRoot(); if (doc->isModifiedSinceSave()) { const gchar *docname; /* originally, the document name was retrieved from * the sodipod:docname attribute */ -- docname = doc->name; ++ docname = doc->getName(); if (docname) { /* Removes an emergency save suffix if present: /(.*)\.[0-9_]*\.[0-9_]*\.[~\.]*$/\1/ */ const char* d0 = strrchr ((char*)docname, '.'); @@@ -643,7 -638,7 +643,7 @@@ // Find a location const char* locations[] = { -- doc->base, ++ doc->getBase(), g_get_home_dir(), g_get_tmp_dir(), curdir, @@@ -667,7 -662,7 +667,7 @@@ savednames = g_slist_prepend (savednames, g_strdup (c)); fclose (file); } else { -- failednames = g_slist_prepend (failednames, (doc->name) ? g_strdup (doc->name) : g_strdup (_("Untitled document"))); ++ failednames = g_slist_prepend (failednames, (doc->getName()) ? g_strdup(doc->getName()) : g_strdup (_("Untitled document"))); } count++; } diff --cc src/inkview.cpp index c151991dd,35f150707..09adb8c2d --- a/src/inkview.cpp +++ b/src/inkview.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SPSVGVIEW_C__ -- /* * Inkscape - an ambitious vector drawing program * @@@ -14,6 -14,6 +12,7 @@@ * Chema Celorio * Pawel Palucha * ... and various people who have worked with various projects ++ * Abhishek Sharma * * Copyright (C) 1999-2002 authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -167,7 -167,7 +166,7 @@@ sp_svgview_main_key_press (GtkWidget */ default: break; } -- gtk_window_set_title(GTK_WINDOW(ss->window), SP_DOCUMENT_NAME(ss->doc)); ++ gtk_window_set_title(GTK_WINDOW(ss->window), ss->doc->getName()); return TRUE; } @@@ -313,21 -313,21 +312,21 @@@ main (int argc, const char **argv return 1; /* none of the slides loadable */ w = gtk_window_new (GTK_WINDOW_TOPLEVEL); -- gtk_window_set_title (GTK_WINDOW (w), SP_DOCUMENT_NAME (ss.doc)); ++ gtk_window_set_title( GTK_WINDOW(w), ss.doc->getName() ); gtk_window_set_default_size (GTK_WINDOW (w), - MIN ((int)sp_document_width (ss.doc), (int)gdk_screen_width () - 64), - MIN ((int)sp_document_height (ss.doc), (int)gdk_screen_height () - 64)); + MIN ((int)(ss.doc)->getWidth (), (int)gdk_screen_width () - 64), + MIN ((int)(ss.doc)->getHeight (), (int)gdk_screen_height () - 64)); gtk_window_set_policy (GTK_WINDOW (w), TRUE, TRUE, FALSE); ss.window = w; g_signal_connect (G_OBJECT (w), "delete_event", (GCallback) sp_svgview_main_delete, &ss); g_signal_connect (G_OBJECT (w), "key_press_event", (GCallback) sp_svgview_main_key_press, &ss); - sp_document_ensure_up_to_date (ss.doc); - (ss.doc)->ensure_up_to_date (); ++ (ss.doc)->ensureUpToDate(); ss.view = sp_svg_view_widget_new (ss.doc); - sp_document_unref (ss.doc); + (ss.doc)->doUnref (); sp_svg_view_widget_set_resize (SP_SVG_VIEW_WIDGET (ss.view), FALSE, - sp_document_width (ss.doc), sp_document_height (ss.doc)); + (ss.doc)->getWidth (), (ss.doc)->getHeight ()); gtk_widget_show (ss.view); gtk_container_add (GTK_CONTAINER (w), ss.view); @@@ -444,7 -444,7 +443,7 @@@ static voi sp_svgview_set_document(struct SPSlideShow *ss, SPDocument *doc, int current) { if (doc && doc != ss->doc) { - sp_document_ensure_up_to_date (doc); - doc->ensure_up_to_date (); ++ doc->ensureUpToDate(); reinterpret_cast(SP_VIEW_WIDGET_VIEW (ss->view))->setDocument (doc); ss->doc = doc; ss->current = current; diff --cc src/interface.cpp index b51178eb8,4b95e8de6..0fd2b65ea --- a/src/interface.cpp +++ b/src/interface.cpp @@@ -5,6 -7,6 +5,8 @@@ * Lauris Kaplinski * Frank Felfe * bulia byak ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 1999-2005 authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -71,6 -73,6 +73,8 @@@ #include "ige-mac-menu.h" #endif ++using Inkscape::DocumentUndo; ++ /* Drag and Drop */ typedef enum { URI_LIST, @@@ -1125,7 -1192,7 +1129,7 @@@ sp_ui_drag_data_received(GtkWidget *wid gtk_widget_translate_coordinates( widget, &(desktop->canvas->widget), x, y, &destX, &destY ); Geom::Point where( sp_canvas_window_to_world( desktop->canvas, Geom::Point( destX, destY ) ) ); -- SPItem *item = desktop->item_at_point( where, true ); ++ SPItem *item = desktop->getItemAtPoint( where, true ); if ( item ) { bool fillnotstroke = (drag_context->action != GDK_ACTION_MOVE); @@@ -1216,13 -1283,13 +1220,13 @@@ //0x0ff & (data->data[3] >> 8), )); -- SPItem *item = desktop->item_at_point( where, true ); ++ SPItem *item = desktop->getItemAtPoint( where, true ); bool consumed = false; if (desktop->event_context && desktop->event_context->get_drag()) { consumed = desktop->event_context->get_drag()->dropColor(item, colorspec, button_dt); if (consumed) { - sp_document_done( doc , SP_VERB_NONE, _("Drop color on gradient")); - SPDocumentUndo::done( doc , SP_VERB_NONE, _("Drop color on gradient")); ++ DocumentUndo::done( doc , SP_VERB_NONE, _("Drop color on gradient") ); desktop->event_context->get_drag()->updateDraggers(); } } @@@ -1268,8 -1335,8 +1272,8 @@@ sp_desktop_apply_css_recursive( item, css, true ); item->updateRepr(); - sp_document_done( doc , SP_VERB_NONE, - SPDocumentUndo::done( doc , SP_VERB_NONE, -- _("Drop color")); ++ DocumentUndo::done( doc , SP_VERB_NONE, ++ _("Drop color") ); } } } @@@ -1296,7 -1363,7 +1300,7 @@@ unsigned int b = color.getB(); SPGradient* matches = 0; - const GSList *gradients = sp_document_get_resource_list(doc, "gradient"); - const GSList *gradients = doc->get_resource_list("gradient"); ++ const GSList *gradients = doc->getResourceList("gradient"); for (const GSList *item = gradients; item; item = item->next) { SPGradient* grad = SP_GRADIENT(item->data); if ( color.descr == grad->getId() ) { @@@ -1326,13 -1393,13 +1330,13 @@@ Geom::Point const button_dt(desktop->w2d(where)); Geom::Point const button_doc(desktop->dt2doc(button_dt)); -- SPItem *item = desktop->item_at_point( where, true ); ++ SPItem *item = desktop->getItemAtPoint( where, true ); bool consumed = false; if (desktop->event_context && desktop->event_context->get_drag()) { consumed = desktop->event_context->get_drag()->dropColor(item, colorspec.c_str(), button_dt); if (consumed) { - sp_document_done( doc , SP_VERB_NONE, _("Drop color on gradient")); - SPDocumentUndo::done( doc , SP_VERB_NONE, _("Drop color on gradient")); ++ DocumentUndo::done( doc , SP_VERB_NONE, _("Drop color on gradient") ); desktop->event_context->get_drag()->updateDraggers(); } } @@@ -1371,8 -1438,8 +1375,8 @@@ sp_desktop_apply_css_recursive( item, css, true ); item->updateRepr(); - sp_document_done( doc , SP_VERB_NONE, - SPDocumentUndo::done( doc , SP_VERB_NONE, -- _("Drop color")); ++ DocumentUndo::done( doc , SP_VERB_NONE, ++ _("Drop color") ); } } } @@@ -1395,7 -1462,7 +1399,7 @@@ Inkscape::XML::Node *newgroup = rnewdoc->createElement("svg:g"); newgroup->setAttribute("style", style); -- Inkscape::XML::Document * xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document * xml_doc = doc->getReprDoc(); for (Inkscape::XML::Node *child = repr->firstChild(); child != NULL; child = child->next()) { Inkscape::XML::Node *newchild = child->duplicate(xml_doc); newgroup->appendChild(newchild); @@@ -1414,7 -1481,7 +1418,7 @@@ // move to mouse pointer { - sp_document_ensure_up_to_date(sp_desktop_document(desktop)); - sp_desktop_document(desktop)->ensure_up_to_date(); ++ sp_desktop_document(desktop)->ensureUpToDate(); Geom::OptRect sel_bbox = selection->bounds(); if (sel_bbox) { Geom::Point m( desktop->point() - sel_bbox->midpoint() ); @@@ -1423,8 -1490,8 +1427,8 @@@ } Inkscape::GC::release(newgroup); - sp_document_done(doc, SP_VERB_NONE, - SPDocumentUndo::done(doc, SP_VERB_NONE, -- _("Drop SVG")); ++ DocumentUndo::done( doc, SP_VERB_NONE, ++ _("Drop SVG") ); break; } @@@ -1457,8 -1524,8 +1461,8 @@@ ext->set_param_optiongroup("link", save ? "embed" : "link"); ext->set_gui(true); - sp_document_done( doc , SP_VERB_NONE, - SPDocumentUndo::done( doc , SP_VERB_NONE, -- _("Drop bitmap image")); ++ DocumentUndo::done( doc , SP_VERB_NONE, ++ _("Drop bitmap image") ); break; } } diff --cc src/interface.h index 30fda6a39,a9cf58471..01732e911 --- a/src/interface.h +++ b/src/interface.h @@@ -1,5 -1,5 +1,5 @@@ --#ifndef __SP_INTERFACE_H__ --#define __SP_INTERFACE_H__ ++#ifndef SEEN_SP_INTERFACE_H ++#define SEEN_SP_INTERFACE_H /* * Main UI stuff @@@ -7,6 -7,6 +7,7 @@@ * Authors: * Lauris Kaplinski * Frank Felfe ++ * Abhishek Sharma * * Copyright (C) 1999-2002 authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -69,7 -69,9 +70,7 @@@ void sp_ui_dialog_title_string (Inkscap void sp_ui_error_dialog (const gchar * message); bool sp_ui_overwrite_file (const gchar * filename); -void sp_ui_shortcut_string (unsigned int shortcut, gchar* c); - --#endif ++#endif // SEEN_SP_INTERFACE_H /* Local Variables: diff --cc src/jabber_whiteboard/node-tracker.cpp index a506d472a,a506d472a..9f40a7dc6 --- a/src/jabber_whiteboard/node-tracker.cpp +++ b/src/jabber_whiteboard/node-tracker.cpp @@@ -37,8 -37,8 +37,8 @@@ namespace Whiteboard * A special node is a node that can only appear once in a document. */ char const* specialnodekeys[] = { -- DOCUMENT_ROOT_NODE, -- DOCUMENT_NAMEDVIEW_NODE, ++ DOCUMENT_ROOT_NODE, ++ DOCUMENT_NAMEDVIEW_NODE, }; /** @@@ -47,8 -47,8 +47,8 @@@ * A special node is a node that can only appear once in a document. */ char const* specialnodenames[] = { -- DOCUMENT_ROOT_NAME, -- DOCUMENT_NAMEDVIEW_NAME, ++ DOCUMENT_ROOT_NAME, ++ DOCUMENT_NAMEDVIEW_NAME, }; XMLNodeTracker::XMLNodeTracker(SessionManager* sm) : @@@ -94,7 -94,7 +94,7 @@@ XMLNodeTracker::setSessionManager(cons void XMLNodeTracker::put(const Glib::ustring &key, const XML::Node &nodeArg) --{ ++{ keyNodeTable.put(key, &nodeArg); } @@@ -159,7 -159,7 +159,7 @@@ XMLNodeTracker::isTracking(const XML::N bool XMLNodeTracker::isRootNode(const XML::Node &node) { -- XML::Node* docroot = sp_document_repr_root(_sm->getDocument()); ++ XML::Node* docroot = _sm->getDocument()->getReprRoot(); return (docroot == &node); } @@@ -182,7 -182,7 +182,7 @@@ XMLNodeTracker::remove(const XML::Node bool XMLNodeTracker::isSpecialNode(const Glib::ustring &name) { -- return (_specialnodes.find(name.data()) != _specialnodes.end()); ++ return (_specialnodes.find(name.data()) != _specialnodes.end()); } Glib::ustring @@@ -273,23 -273,23 +273,22 @@@ XMLNodeTracker::dump( } } --void --XMLNodeTracker::reset() ++void XMLNodeTracker::reset() { _clear(); // Find and insert special nodes // root node -- put(_rootKey, *(sp_document_repr_root(_sm->getDocument()))); ++ put(_rootKey, *(_sm->getDocument()->getReprRoot())); // namedview node SPObject* namedview = sp_item_group_get_child_by_name( (SPGroup *)_sm->getDocument()->root, NULL, DOCUMENT_NAMEDVIEW_NAME); if (!namedview) { -- g_warning("namedview node does not exist; it will be created during synchronization"); ++ g_warning("namedview node does not exist; it will be created during synchronization"); } else { -- put(_namedviewKey, *(SP_OBJECT_REPR(namedview))); ++ put(_namedviewKey, *(SP_OBJECT_REPR(namedview))); } } diff --cc src/jabber_whiteboard/session-manager.cpp index 0dcd744c3,b46aacaae..60d0b7378 --- a/src/jabber_whiteboard/session-manager.cpp +++ b/src/jabber_whiteboard/session-manager.cpp @@@ -4,6 -4,6 +4,7 @@@ * Authors: * David Yip * Bob Jamison (Pedro port) ++ * Abhishek Sharma * * Copyright (c) 2005 Authors * @@@ -56,15 -59,15 +57,15 @@@ SessionManager *sessionManagerInstance void SessionManager::showClient() { -- SessionManager::instance().gui.show(); ++ SessionManager::instance().gui.show(); } --SessionManager& --SessionManager::instance() ++SessionManager &SessionManager::instance() { -- if (!sessionManagerInstance) ++ if (!sessionManagerInstance) { sessionManagerInstance = new SessionManager(); -- return *sessionManagerInstance; ++ } ++ return *sessionManagerInstance; } SessionManager::SessionManager() @@@ -226,8 -229,8 +227,8 @@@ SessionManager::processWhiteboardEvent( { Pedro::Element* root = event.getDOM(); if (root == NULL) { -- g_warning("Received null DOM; ignoring message."); -- return; ++ g_warning("Received null DOM; ignoring message."); ++ return; } Pedro::DOMString session = root->getTagAttribute("wb", "session"); @@@ -296,11 -299,11 +297,11 @@@ SessionManager::checkInvitationQueue( if (invitations.size() > 0) { // There's an invitation to process; process it. -- Invitation invitation = invitations.front(); ++ Invitation invitation = invitations.front(); Glib::ustring from = invitation.first; Glib::ustring sessionId = invitation.second; -- Glib::ustring primary = ++ Glib::ustring primary = "" + String::ucompose(_("%1 has invited you to a whiteboard session."), from) + "\n\n" + @@@ -378,19 -381,25 +379,16 @@@ makeInkboardDocument(int code, gchar co // in file.cpp. // // \see sp_file_new --SPDesktop* --makeInkboardDesktop(SPDocument* doc) ++SPDesktop *makeInkboardDesktop(SPDocument* doc) { -- SPDesktop* dt; - + SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); + g_return_val_if_fail(dtw != NULL, NULL); - sp_document_unref(doc); ++ doc->doUnref(); - if (NSApplication::Application::getNewGui()) - dt = NSApplication::Editor::createDesktop(doc); - - else - { - SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); - g_return_val_if_fail(dtw != NULL, NULL); - doc->doUnref(); - - sp_create_window(dtw, TRUE); - dt = static_cast(dtw->view); - sp_namedview_window_from_document(dt); - sp_namedview_update_layers_from_document(dt); - } + sp_create_window(dtw, TRUE); - dt = static_cast(dtw->view); ++ SPDesktop *dt = static_cast(dtw->view); + sp_namedview_window_from_document(dt); + sp_namedview_update_layers_from_document(dt); return dt; } diff --cc src/knot-holder-entity.cpp index f8f486663,9e3a3babc..005ca24c7 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@@ -1,11 -1,11 +1,10 @@@ --#define __KNOT_HOLDER_ENTITY_C__ -- /** \file * KnotHolderEntity definition. * * Authors: * Mitsuru Oka * Maximilian Albert ++ * Abhishek Sharma * * Copyright (C) 1999-2001 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -101,9 -101,9 +100,9 @@@ KnotHolderEntity::snap_knot_position(Ge } Geom::Point -KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::ConstraintLine const &constraint) +KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint) { - Geom::Matrix const i2d (sp_item_i2d_affine(item)); + Geom::Matrix const i2d (item->i2d_affine()); Geom::Point s = p * i2d; SnapManager &m = desktop->namedview->snap_manager; diff --cc src/knot.cpp index 824f16c3e,95a9ec148..28c991fde --- a/src/knot.cpp +++ b/src/knot.cpp @@@ -1,11 -1,11 +1,10 @@@ --#define __SP_KNOT_C__ -- /** \file * SPKnot implementation * * Authors: * Lauris Kaplinski * bulia byak ++ * Abhishek Sharma * * Copyright (C) 1999-2005 authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -29,6 -29,6 +28,8 @@@ #include "message-context.h" #include "event-context.h" ++using Inkscape::DocumentUndo; ++ #define KNOT_EVENT_MASK (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | \ GDK_POINTER_MOTION_MASK | \ GDK_POINTER_MOTION_HINT_MASK | \ @@@ -427,7 -427,7 +428,7 @@@ static int sp_knot_handler(SPCanvasIte g_signal_emit(knot, knot_signals[UNGRABBED], 0, event->button.state); - sp_document_undo(sp_desktop_document(knot->desktop)); - SPDocumentUndo::undo(sp_desktop_document(knot->desktop)); ++ DocumentUndo::undo(sp_desktop_document(knot->desktop)); knot->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Node or handle drag canceled.")); transform_escaped = true; consumed = TRUE; diff --cc src/knotholder.cpp index df5c1cad9,23d610ad0..f5e28618e --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __KNOT_HOLDER_C__ -- /* * Container for SPKnot visual handles * @@@ -7,12 -7,12 +5,15 @@@ * Mitsuru Oka * bulia byak * Maximilian Albert ++ * Abhishek Sharma * * Copyright (C) 2001-2008 authors * * Released under GNU GPL, read the file 'COPYING' for more information */ ++#include ++ #include "document.h" #include "sp-shape.h" #include "knot.h" @@@ -36,13 -36,14 +37,14 @@@ #include "xml/repr.h" // for debugging only --#include ++using Inkscape::DocumentUndo; class SPDesktop; KnotHolder::KnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) { - Inkscape::XML::Node *repr = SP_OBJECT(item)->repr; - //XML Tree being used directly here while it shouldn't be... ++ //XML Tree being used directly here while it shouldn't be... + Inkscape::XML::Node *repr = SP_OBJECT(item)->getRepr(); if (!desktop || !item || !SP_IS_ITEM(item)) { g_print ("Error! Throw an exception, please!\n"); @@@ -146,8 -147,8 +148,8 @@@ KnotHolder::knot_clicked_handler(SPKno } // for drag, this is done by ungrabbed_handler, but for click we must do it here - sp_document_done(SP_OBJECT_DOCUMENT(item), object_verb, - SPDocumentUndo::done(SP_OBJECT_DOCUMENT(item), object_verb, -- _("Change handle")); ++ DocumentUndo::done(SP_OBJECT_DOCUMENT(item), object_verb, ++ _("Change handle")); } void @@@ -225,8 -226,8 +227,8 @@@ KnotHolder::knot_ungrabbed_handler(SPKn object_verb = SP_VERB_SELECTION_DYNAMIC_OFFSET; } - sp_document_done(SP_OBJECT_DOCUMENT (object), object_verb, - SPDocumentUndo::done(SP_OBJECT_DOCUMENT (object), object_verb, -- _("Move handle")); ++ DocumentUndo::done(SP_OBJECT_DOCUMENT (object), object_verb, ++ _("Move handle")); } } diff --cc src/layer-fns.cpp index 7cf582f7a,ca7c1c493..84f21cd97 --- a/src/layer-fns.cpp +++ b/src/layer-fns.cpp @@@ -3,6 -3,6 +3,7 @@@ * * Authors: * MenTaLguY ++ * Jon A. Cruz * * Copyright (C) 2004 MenTaLguY * @@@ -19,6 -19,6 +20,8 @@@ #include "util/find-last-if.h" #include "layer-fns.h" ++// TODO move the documentation comments into the .h file ++ namespace Inkscape { namespace { @@@ -36,7 -36,7 +39,7 @@@ SPObject *next_sibling_layer(SPObject * using std::find_if; return find_if( -- SP_OBJECT_NEXT(layer), NULL, &is_layer ++ layer->getNext(), NULL, &is_layer ); } @@@ -174,7 -174,7 +177,7 @@@ SPObject *create_layer(SPObject *root, id = g_strdup_printf("layer%d", layer_suffix++); } while (document->getObjectById(id)); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:g"); repr->setAttribute("inkscape:groupmode", "layer"); repr->setAttribute("id", id); diff --cc src/layer-manager.cpp index 1e1bb8c33,0ee7f76a9..95cefc229 --- a/src/layer-manager.cpp +++ b/src/layer-manager.cpp @@@ -3,6 -3,6 +3,7 @@@ * to a particular desktop * * Copyright 2006 MenTaLguY ++ * Abhishek Sharma * * Released under GNU GPL, read the file 'COPYING' for more information */ @@@ -183,7 -183,7 +184,7 @@@ void LayerManager::renameLayer( SPObjec } std::set currentNames; - GSList const *layers=sp_document_get_resource_list(_document, "layer"); - GSList const *layers=_document->get_resource_list("layer"); ++ GSList const *layers=_document->getResourceList("layer"); SPObject *root=_desktop->currentRoot(); if ( root ) { for ( GSList const *iter=layers ; iter ; iter = iter->next ) { @@@ -218,7 -218,7 +219,7 @@@ void LayerManager::_setDocument(SPDocum } _document = document; if (document) { - _resource_connection = sp_document_resources_changed_connect(document, "layer", sigc::mem_fun(*this, &LayerManager::_rebuild)); - _resource_connection = document->resources_changed_connect("layer", sigc::mem_fun(*this, &LayerManager::_rebuild)); ++ _resource_connection = document->connectResourcesChanged("layer", sigc::mem_fun(*this, &LayerManager::_rebuild)); } _rebuild(); } @@@ -248,7 -248,7 +249,7 @@@ void LayerManager::_rebuild() if (!_document) // http://sourceforge.net/mailarchive/forum.php?thread_name=5747bce9a7ed077c1b4fc9f0f4f8a5e0%40localhost&forum_name=inkscape-devel return; - GSList const *layers = sp_document_get_resource_list(_document, "layer"); - GSList const *layers = _document->get_resource_list("layer"); ++ GSList const *layers = _document->getResourceList("layer"); SPObject *root=_desktop->currentRoot(); if ( root ) { _addOne(root); diff --cc src/live_effects/effect.cpp index 9dbd27b50,2cc26e4e1..3ea57de23 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@@ -1,7 -1,7 +1,6 @@@ --#define INKSCAPE_LIVEPATHEFFECT_CPP -- /* * Copyright (C) Johan Engelen 2007 ++ * Abhishek Sharma * * Released under GNU GPL, read the file 'COPYING' for more information */ @@@ -256,11 -250,11 +255,10 @@@ Effect::New(EffectType lpenr, LivePathE return neweffect; } --void --Effect::createAndApply(const char* name, SPDocument *doc, SPItem *item) ++void Effect::createAndApply(const char* name, SPDocument *doc, SPItem *item) { // Path effect definition -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect"); repr->setAttribute("effect", name); diff --cc src/live_effects/lpe-knot.cpp index 86d0907a1,d43213fe9..fef4e1f87 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@@ -3,6 -3,6 +3,7 @@@ */ /* Authors: * Jean-Francois Barraud ++ * Abhishek Sharma * * Copyright (C) 2007 Authors * @@@ -647,8 -636,8 +648,8 @@@ KnotHolderEntityCrossingSwitcher::knot_ //std::cout<<"crossing set to"<crossing_points[s].sign<<".\n"; } lpe->crossing_points_vector.param_set_and_write_new_value(lpe->crossing_points.to_vector()); - sp_document_done(lpe->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, /// @todo Is this the right verb? - SPDocumentUndo::done(lpe->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, /// @todo Is this the right verb? -- _("Change knot crossing")); ++ DocumentUndo::done(lpe->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, /// @todo Is this the right verb? ++ _("Change knot crossing")); // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating. // sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); diff --cc src/live_effects/lpe-mirror_symmetry.cpp index a3a0faf37,dabeb5682..1af2ed6ca --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@@ -1,4 -1,4 +1,3 @@@ --#define INKSCAPE_LPE_MIRROR_SYMMETRY_CPP /** \file * LPE implementation: mirrors a path with respect to a given line. */ @@@ -6,6 -6,6 +5,7 @@@ * Authors: * Maximilian Albert * Johan Engelen ++ * Abhishek Sharma * * Copyright (C) Johan Engelen 2007 * Copyright (C) Maximilin Albert 2008 diff --cc src/live_effects/lpegroupbbox.cpp index 3820b5ba7,6eac43c43..e6fc95f86 --- a/src/live_effects/lpegroupbbox.cpp +++ b/src/live_effects/lpegroupbbox.cpp @@@ -1,7 -1,7 +1,6 @@@ --#define INKSCAPE_LPEGROUPBBOX_CPP -- /* * Copyright (C) Steren Giannini 2008 ++ * Abhishek Sharma * * Released under GNU GPL, read the file 'COPYING' for more information */ diff --cc src/live_effects/lpeobject.cpp index aa916318d,a77b9817a..389e18d20 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@@ -1,7 -1,7 +1,6 @@@ --#define INKSCAPE_LIVEPATHEFFECT_OBJECT_CPP -- /* * Copyright (C) Johan Engelen 2007-2008 ++ * Abhishek Sharma * * Released under GNU GPL, read the file 'COPYING' for more information */ @@@ -104,14 -104,14 +103,14 @@@ LivePathEffectObject::livepatheffect_bu if (((SPObjectClass *) livepatheffect_parent_class)->build) (* ((SPObjectClass *) livepatheffect_parent_class)->build)(object, document, repr); - sp_object_read_attr(object, "effect"); - object->readAttr( "effect"); ++ object->readAttr( "effect" ); if (repr) { repr->addListener (&livepatheffect_repr_events, object); } /* Register ourselves, is this necessary? */ --// sp_document_add_resource(document, "path-effect", object); ++// document->addResource("path-effect", object); } /** @@@ -132,7 -132,7 +131,7 @@@ LivePathEffectObject::livepatheffect_re /* if (SP_OBJECT_DOCUMENT(object)) { // Unregister ourselves -- sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "livepatheffect", SP_OBJECT(object)); ++ sp_document_removeResource(SP_OBJECT_DOCUMENT(object), "livepatheffect", SP_OBJECT(object)); } if (gradient->ref) { @@@ -247,12 -247,12 +246,11 @@@ livepatheffect_on_repr_attr_changed ( I * returns 'this' when no forking was necessary (and therefore no duplicate was made) * Check out sp_lpe_item_fork_path_effects_if_necessary ! */ --LivePathEffectObject * --LivePathEffectObject::fork_private_if_necessary(unsigned int nr_of_allowed_users) ++LivePathEffectObject *LivePathEffectObject::fork_private_if_necessary(unsigned int nr_of_allowed_users) { -- if (SP_OBJECT_HREFCOUNT(this) > nr_of_allowed_users) { ++ if (hrefcount > nr_of_allowed_users) { SPDocument *doc = SP_OBJECT_DOCUMENT(this); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *dup_repr = SP_OBJECT_REPR (this)->duplicate(xml_doc); SP_OBJECT_REPR (SP_DOCUMENT_DEFS (doc))->addChild(dup_repr, NULL); diff --cc src/live_effects/parameter/path-reference.h index 67508e531,53b9ade04..3bedecccb --- a/src/live_effects/parameter/path-reference.h +++ b/src/live_effects/parameter/path-reference.h @@@ -5,6 -5,6 +5,7 @@@ * The reference corresponding to href of LPE PathParam. * * Copyright (C) 2008 Johan Engelen ++ * Abhishek Sharma * * Released under GNU GPL, read the file 'COPYING' for more information. */ diff --cc src/live_effects/parameter/path.cpp index d8d5b0a7c,bdbe126e2..8d9b2376f --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@@ -1,7 -1,7 +1,6 @@@ --#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_PATH_CPP -- /* * Copyright (C) Johan Engelen 2007 ++ * Abhishek Sharma * * Released under GNU GPL, read the file 'COPYING' for more information */ @@@ -414,8 -414,8 +413,8 @@@ PathParam::on_paste_button_click( Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); Glib::ustring svgd = cm->getPathParameter(SP_ACTIVE_DESKTOP); paste_param_path(svgd.data()); - sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, - SPDocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, -- _("Paste path parameter")); ++ DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, ++ _("Paste path parameter")); } void @@@ -446,8 -446,8 +445,8 @@@ PathParam::on_link_button_click( // check if linking to object to which LPE is applied (maybe delegated to PathReference param_write_to_repr(pathid.c_str()); - sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, - SPDocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, -- _("Link path parameter to path")); ++ DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, ++ _("Link path parameter to path")); } } diff --cc src/lpe-tool-context.cpp index 8aa350d86,1459cb460..f25949296 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@@ -4,6 -4,6 +4,7 @@@ * Authors: * Maximilian Albert * Lauris Kaplinski ++ * Abhishek Sharma * * Copyright (C) 1998 The Free Software Foundation * Copyright (C) 1999-2005 authors diff --cc src/main.cpp index eda6d0b03,a25343991..a1b21cc4d --- a/src/main.cpp +++ b/src/main.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __MAIN_C__ -- /** \file * Inkscape - an ambitious vector drawing program * @@@ -15,6 -15,6 +13,8 @@@ * Pawel Palucha * Bryce Harrington * ... and various people who have worked with various projects ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 1999-2004 authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -1023,7 -1020,7 +1023,7 @@@ void sp_process_file_list(GSList *fl g_warning("Specified document %s cannot be opened (does not exist or not a valid SVG file)", filename); } else { if (sp_vacuum_defs) { - vacuum_document(doc); - doc->vacuum_document(); ++ doc->vacuumDocument(); } if (sp_vacuum_defs && !sp_export_svg) { // save under the name given in the command line @@@ -1040,9 -1037,9 +1040,9 @@@ Inkscape::XML::Node *repr; rdoc = sp_repr_document_new("svg:svg"); repr = rdoc->root(); -- repr = sp_document_root(doc)->updateRepr(rdoc, repr, SP_OBJECT_WRITE_BUILD); ++ repr = doc->getRoot()->updateRepr(rdoc, repr, SP_OBJECT_WRITE_BUILD); sp_repr_save_rebased_file(repr->document(), sp_export_svg, SP_SVG_NS_URI, -- doc->base, sp_export_svg); ++ doc->getBase(), sp_export_svg); } if (sp_export_ps) { do_export_ps_pdf(doc, sp_export_ps, "image/x-postscript"); @@@ -1196,11 -1193,11 +1196,11 @@@ do_query_dimension (SPDocument *doc, bo return; } } else { -- o = SP_DOCUMENT_ROOT(doc); ++ o = doc->getRoot(); } if (o) { - sp_document_ensure_up_to_date (doc); - doc->ensure_up_to_date (); ++ doc->ensureUpToDate(); SPItem *item = ((SPItem *) o); // "true" SVG bbox for scripting @@@ -1219,15 -1216,15 +1219,12 @@@ } } --static void --do_query_all (SPDocument *doc) ++static void do_query_all(SPDocument *doc) { -- SPObject *o = NULL; -- -- o = SP_DOCUMENT_ROOT(doc); ++ SPObject *o = doc->getRoot(); if (o) { - sp_document_ensure_up_to_date (doc); - doc->ensure_up_to_date (); ++ doc->ensureUpToDate(); do_query_all_recurse(o); } } @@@ -1277,12 -1274,12 +1274,12 @@@ sp_do_export_png(SPDocument *doc SPObject *o_area = NULL; if (sp_export_id && sp_export_area_drawing) { o = doc->getObjectById(sp_export_id); -- o_area = SP_DOCUMENT_ROOT (doc); ++ o_area = doc->getRoot(); } else if (sp_export_id) { o = doc->getObjectById(sp_export_id); o_area = o; } else if (sp_export_area_drawing) { -- o = SP_DOCUMENT_ROOT (doc); ++ o = doc->getRoot(); o_area = o; } @@@ -1330,9 -1327,9 +1327,9 @@@ } // write object bbox to area - sp_document_ensure_up_to_date (doc); - doc->ensure_up_to_date (); ++ doc->ensureUpToDate(); Geom::OptRect areaMaybe; - sp_item_invoke_bbox((SPItem *) o_area, areaMaybe, sp_item_i2d_affine((SPItem *) o_area), TRUE); + static_cast(o_area)->invoke_bbox( areaMaybe, static_cast(o_area)->i2d_affine(), TRUE); if (areaMaybe) { area = *areaMaybe; } else { @@@ -1355,9 -1352,9 +1352,9 @@@ area = Geom::Rect(Geom::Interval(x0,x1), Geom::Interval(y0,y1)); } else if (sp_export_area_page || !(sp_export_id || sp_export_area_drawing)) { /* Export the whole page: note: Inkscape uses 'page' in all menus and dialogs, not 'canvas' */ - sp_document_ensure_up_to_date (doc); - doc->ensure_up_to_date (); ++ doc->ensureUpToDate(); Geom::Point origin (SP_ROOT(doc->root)->x.computed, SP_ROOT(doc->root)->y.computed); - area = Geom::Rect(origin, origin + sp_document_dimensions(doc)); + area = Geom::Rect(origin, origin + doc->getDimensions()); } // set filename and dpi from options, if not yet set from the hints @@@ -1451,8 -1448,8 +1448,8 @@@ gchar *path = 0; if (filename_from_hint) { //Make relative paths go from the document location, if possible: -- if (!g_path_is_absolute(filename) && doc->uri) { -- gchar *dirname = g_path_get_dirname(doc->uri); ++ if (!g_path_is_absolute(filename) && doc->getURI()) { ++ gchar *dirname = g_path_get_dirname(doc->getURI()); if (dirname) { path = g_build_filename(dirname, filename, NULL); g_free(dirname); diff --cc src/marker.cpp index e4c2e0c30,376b4fa28..0ec92a1ff --- a/src/marker.cpp +++ b/src/marker.cpp @@@ -1,11 -1,11 +1,10 @@@ --#define __MARKER_C__ -- /* * SVG implementation * * Authors: * Lauris Kaplinski * Bryce Harrington ++ * Abhishek Sharma * * Copyright (C) 1999-2003 Lauris Kaplinski * 2004-2006 Bryce Harrington @@@ -141,14 -141,14 +140,14 @@@ sp_marker_build (SPObject *object, SPDo group = (SPGroup *) object; marker = (SPMarker *) object; - sp_object_read_attr (object, "markerUnits"); - sp_object_read_attr (object, "refX"); - sp_object_read_attr (object, "refY"); - sp_object_read_attr (object, "markerWidth"); - sp_object_read_attr (object, "markerHeight"); - sp_object_read_attr (object, "orient"); - sp_object_read_attr (object, "viewBox"); - sp_object_read_attr (object, "preserveAspectRatio"); - object->readAttr( "markerUnits"); - object->readAttr( "refX"); - object->readAttr( "refY"); - object->readAttr( "markerWidth"); - object->readAttr( "markerHeight"); - object->readAttr( "orient"); - object->readAttr( "viewBox"); - object->readAttr( "preserveAspectRatio"); ++ object->readAttr( "markerUnits" ); ++ object->readAttr( "refX" ); ++ object->readAttr( "refY" ); ++ object->readAttr( "markerWidth" ); ++ object->readAttr( "markerHeight" ); ++ object->readAttr( "orient" ); ++ object->readAttr( "viewBox" ); ++ object->readAttr( "preserveAspectRatio" ); if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build (object, document, repr); @@@ -709,11 -711,11 +710,10 @@@ sp_marker_view_remove (SPMarker *marker delete view; } --const gchar * --generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Matrix /*transform*/, Geom::Matrix move) ++const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Matrix /*transform*/, Geom::Matrix move) { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); -- Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document)); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); ++ Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:marker"); diff --cc src/object-edit.cpp index 9c0b61b9c,4cd365bb8..27e75afab --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_OBJECT_EDIT_C__ -- /* * Node editing extension to objects * @@@ -7,6 -7,6 +5,7 @@@ * Lauris Kaplinski * Mitsuru Oka * Maximilian Albert ++ * Abhishek Sharma * * Licensed under GNU GPL */ diff --cc src/object-snapper.cpp index 51b494498,00bd10fe2..43651f002 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@@ -5,8 -5,8 +5,10 @@@ * Authors: * Carl Hetherington * Diederik van Lierop ++ * Jon A. Cruz ++ * Abhishek Sharma * - * Copyright (C) 2005 - 2008 Authors + * Copyright (C) 2005 - 2010 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@@ -100,7 -98,8 +102,8 @@@ void Inkscape::ObjectSnapper::_findCand Geom::Rect bbox_to_snap_incl = bbox_to_snap; // _incl means: will include the snapper tolerance bbox_to_snap_incl.expandBy(getSnapperTolerance()); // see? - for (SPObject* o = sp_object_first_child(parent); o != NULL; o = SP_OBJECT_NEXT(o)) { - for (SPObject* o = parent->first_child(); o != NULL; o = SP_OBJECT_NEXT(o)) { ++ for ( SPObject *o = parent->firstChild(); o; o = o->getNext() ) { + g_assert(_snapmanager->getDesktop() != NULL); if (SP_IS_ITEM(o) && !(_snapmanager->getDesktop()->itemIsHidden(SP_ITEM(o)) && !clip_or_mask)) { // Snapping to items in a locked layer is allowed // Don't snap to hidden objects, unless they're a clipped path or a mask @@@ -123,11 -122,11 +126,11 @@@ // we should also consider that path or mask for snapping to obj = SP_OBJECT(item->clip_ref->getObject()); if (obj) { - _findCandidates(obj, it, false, bbox_to_snap, true, sp_item_i2doc_affine(item)); - _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, item->i2doc_affine()); ++ _findCandidates(obj, it, false, bbox_to_snap, true, item->i2doc_affine()); } obj = SP_OBJECT(item->mask_ref->getObject()); if (obj) { - _findCandidates(obj, it, false, bbox_to_snap, true, sp_item_i2doc_affine(item)); - _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, item->i2doc_affine()); ++ _findCandidates(obj, it, false, bbox_to_snap, true, item->i2doc_affine()); } } } @@@ -229,24 -226,11 +231,24 @@@ void Inkscape::ObjectSnapper::_collectN _snapmanager->snapprefs.setSnapIntersectionCS(false); } + // We should not snap a transformation center to any of the centers of the items in the + // current selection (see the comment in SelTrans::centerRequest()) + bool old_pref2 = _snapmanager->snapprefs.getIncludeItemCenter(); + if (old_pref2) { + for ( GSList const *itemlist = _snapmanager->getRotationCenterSource(); itemlist != NULL; itemlist = g_slist_next(itemlist) ) { + if ((*i).item == reinterpret_cast(itemlist->data)) { + // don't snap to this item's rotation center + _snapmanager->snapprefs.setIncludeItemCenter(false); + break; + } + } + } + - sp_item_snappoints(root_item, *_points_to_snap_to, &_snapmanager->snapprefs); + root_item->getSnappoints(*_points_to_snap_to, &_snapmanager->snapprefs); - if (_snapmanager->snapprefs.getSnapToItemPath()) { - _snapmanager->snapprefs.setSnapIntersectionCS(old_pref); - } + // restore the original snap preferences + _snapmanager->snapprefs.setSnapIntersectionCS(old_pref); + _snapmanager->snapprefs.setIncludeItemCenter(old_pref2); } //Collect the bounding box's corners so we can snap to them @@@ -342,8 -309,7 +344,8 @@@ void Inkscape::ObjectSnapper::_snapTran * Returns index of first NR_END bpath in array. */ - void Inkscape::ObjectSnapper::_collectPaths(Geom::Point p, -void Inkscape::ObjectSnapper::_collectPaths(Inkscape::SnapCandidatePoint const &p, ++void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, + Inkscape::SnapSourceType const source_type, bool const &first_point) const { // Now, let's first collect all paths to snap to. If we have a whole bunch of points to snap, @@@ -415,14 -381,9 +417,14 @@@ if (!very_lenghty_prose && !very_complex_path) { SPCurve *curve = curve_for_item(root_item); if (curve) { - // We will get our own copy of the path, which must be freed at some point - Geom::PathVector *borderpathv = pathvector_for_curve(root_item, curve, true, true, Geom::identity(), (*i).additional_affine); - _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(borderpathv, SNAPTARGET_PATH, Geom::OptRect())); // Perhaps for speed, get a reference to the Geom::pathvector, and store the transformation besides it. + // We will get our own copy of the pathvector, which must be freed at some point + + // Geom::PathVector *pv = pathvector_for_curve(root_item, curve, true, true, Geom::identity(), (*i).additional_affine); + + Geom::PathVector *pv = new Geom::PathVector(curve->get_pathvector()); - (*pv) *= sp_item_i2d_affine(root_item) * (*i).additional_affine * _snapmanager->getDesktop()->doc2dt(); // (_edit_transform * _i2d_transform); ++ (*pv) *= root_item->i2d_affine() * (*i).additional_affine * _snapmanager->getDesktop()->doc2dt(); // (_edit_transform * _i2d_transform); + + _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(pv, SNAPTARGET_PATH, Geom::OptRect())); // Perhaps for speed, get a reference to the Geom::pathvector, and store the transformation besides it. curve->unref(); } } @@@ -657,27 -578,16 +659,27 @@@ void Inkscape::ObjectSnapper::freeSnap( } /* Get a list of all the SPItems that we will try to snap to */ - if (p.getSourceNum() == 0) { + if (p.getSourceNum() <= 0) { Geom::Rect const local_bbox_to_snap = bbox_to_snap ? *bbox_to_snap : Geom::Rect(p.getPoint(), p.getPoint()); - _findCandidates(sp_document_root(_snapmanager->getDocument()), it, p.getSourceNum() <= 0, local_bbox_to_snap, false, Geom::identity()); - _findCandidates(sp_document_root(_snapmanager->getDocument()), it, p.getSourceNum() == 0, local_bbox_to_snap, TRANSL_SNAP_XY, false, Geom::identity()); ++ _findCandidates(_snapmanager->getDocument()->getRoot(), it, p.getSourceNum() <= 0, local_bbox_to_snap, false, Geom::identity()); } - if (_snapmanager->snapprefs.getSnapToItemNode() || _snapmanager->snapprefs.getSnapSmoothNodes() - || _snapmanager->snapprefs.getSnapToBBoxNode() || _snapmanager->snapprefs.getSnapToPageBorder() - || _snapmanager->snapprefs.getSnapLineMidpoints() || _snapmanager->snapprefs.getSnapObjectMidpoints() - || _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || _snapmanager->snapprefs.getSnapBBoxMidpoints() - || _snapmanager->snapprefs.getIncludeItemCenter()) { + // TODO: Argh, UGLY! Get rid of this here, move this logic to the snap manager + bool snap_nodes = (_snapmanager->snapprefs.getSnapModeNode() && ( + _snapmanager->snapprefs.getSnapToItemNode() || + _snapmanager->snapprefs.getSnapSmoothNodes() || + _snapmanager->snapprefs.getSnapLineMidpoints() || + _snapmanager->snapprefs.getSnapObjectMidpoints() + )) || (_snapmanager->snapprefs.getSnapModeBBox() && ( + _snapmanager->snapprefs.getSnapToBBoxNode() || + _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints() || + _snapmanager->snapprefs.getSnapBBoxMidpoints() + )) || (_snapmanager->snapprefs.getSnapModeBBoxOrNodes() && ( + _snapmanager->snapprefs.getIncludeItemCenter() || + _snapmanager->snapprefs.getSnapToPageBorder() + )); + + if (snap_nodes) { _snapNodes(sc, p, unselected_nodes); } @@@ -716,13 -623,10 +718,13 @@@ void Inkscape::ObjectSnapper::constrain return; } + // project the mouse pointer onto the constraint. Only the projected point will be considered for snapping + Geom::Point pp = c.projection(p.getPoint()); + /* Get a list of all the SPItems that we will try to snap to */ - if (p.getSourceNum() == 0) { - Geom::Rect const local_bbox_to_snap = bbox_to_snap ? *bbox_to_snap : Geom::Rect(p.getPoint(), p.getPoint()); - _findCandidates(sp_document_root(_snapmanager->getDocument()), it, p.getSourceNum() == 0, local_bbox_to_snap, TRANSL_SNAP_XY, false, Geom::identity()); + if (p.getSourceNum() <= 0) { + Geom::Rect const local_bbox_to_snap = bbox_to_snap ? *bbox_to_snap : Geom::Rect(pp, pp); - _findCandidates(sp_document_root(_snapmanager->getDocument()), it, p.getSourceNum() <= 0, local_bbox_to_snap, false, Geom::identity()); ++ _findCandidates(_snapmanager->getDocument()->getRoot(), it, p.getSourceNum() <= 0, local_bbox_to_snap, false, Geom::identity()); } // A constrained snap, is a snap in only one degree of freedom (specified by the constraint line). @@@ -763,8 -653,17 +765,8 @@@ void Inkscape::ObjectSnapper::guideFree std::vector cand; std::vector const it; //just an empty list - _findCandidates(sp_document_root(_snapmanager->getDocument()), &it, true, Geom::Rect(p, p), false, Geom::identity()); - DimensionToSnap snap_dim; - if (guide_normal == to_2geom(component_vectors[Geom::Y])) { - snap_dim = GUIDE_TRANSL_SNAP_Y; - } else if (guide_normal == to_2geom(component_vectors[Geom::X])) { - snap_dim = GUIDE_TRANSL_SNAP_X; - } else { - snap_dim = ANGLED_GUIDE_TRANSL_SNAP; - } - - _findCandidates(sp_document_root(_snapmanager->getDocument()), &it, true, Geom::Rect(p, p), snap_dim, false, Geom::identity()); - _snapTranslatingGuideToNodes(sc, p, guide_normal); ++ _findCandidates(_snapmanager->getDocument()->getRoot(), &it, true, Geom::Rect(p, p), false, Geom::identity()); + _snapTranslatingGuide(sc, p, guide_normal); } @@@ -778,8 -677,17 +780,8 @@@ void Inkscape::ObjectSnapper::guideCons std::vector cand; std::vector const it; //just an empty list - _findCandidates(sp_document_root(_snapmanager->getDocument()), &it, true, Geom::Rect(p, p), false, Geom::identity()); - DimensionToSnap snap_dim; - if (guide_normal == to_2geom(component_vectors[Geom::Y])) { - snap_dim = GUIDE_TRANSL_SNAP_Y; - } else if (guide_normal == to_2geom(component_vectors[Geom::X])) { - snap_dim = GUIDE_TRANSL_SNAP_X; - } else { - snap_dim = ANGLED_GUIDE_TRANSL_SNAP; - } - - _findCandidates(sp_document_root(_snapmanager->getDocument()), &it, true, Geom::Rect(p, p), snap_dim, false, Geom::identity()); - _snapTranslatingGuideToNodes(sc, p, guide_normal); ++ _findCandidates(_snapmanager->getDocument()->getRoot(), &it, true, Geom::Rect(p, p), false, Geom::identity()); + _snapTranslatingGuide(sc, p, guide_normal); } diff --cc src/path-chemistry.cpp index 6a796b2ed,12913fd85..bec3c5cbf --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_PATH_CHEMISTRY_C__ -- /* * Here are handlers for modifying selections, specific to paths * @@@ -7,6 -7,6 +5,8 @@@ * Lauris Kaplinski * bulia byak * Jasper van de Gronde ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 1999-2008 Authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -39,6 -39,6 +39,8 @@@ #include "selection-chemistry.h" #include "path-chemistry.h" ++using Inkscape::DocumentUndo; ++ void sp_selected_path_combine(SPDesktop *desktop) { @@@ -135,12 -135,12 +137,14 @@@ SP_OBJECT(first)->deleteObject(false); // delete the topmost. -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); // restore id, transform, path effect, and style repr->setAttribute("id", id); -- if (transform) repr->setAttribute("transform", transform); ++ if (transform) { ++ repr->setAttribute("transform", transform); ++ } repr->setAttribute("style", style); g_free(style); @@@ -150,10 -150,10 +154,11 @@@ // set path data corresponding to new curve gchar *dstring = sp_svg_write_path(curve->get_pathvector()); curve->unref(); -- if (path_effect) ++ if (path_effect) { repr->setAttribute("inkscape:original-d", dstring); -- else ++ } else { repr->setAttribute("d", dstring); ++ } g_free(dstring); // add the new group to the parent of the topmost @@@ -162,8 -162,8 +167,8 @@@ // move to the position of the topmost, reduced by the number of deleted items repr->setPosition(position > 0 ? position : 0); - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_COMBINE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_COMBINE, -- _("Combine")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_COMBINE, ++ _("Combine")); selection->set(repr); @@@ -213,8 -213,10 +218,10 @@@ sp_selected_path_break_apart(SPDesktop gint pos = SP_OBJECT_REPR(item)->position(); char const *id = SP_OBJECT_REPR(item)->attribute("id"); - gchar *style = g_strdup(SP_OBJECT(item)->repr->attribute("style")); - gchar *path_effect = g_strdup(SP_OBJECT(item)->repr->attribute("inkscape:path-effect")); - // XML Tree being used directly here while it shouldn't be... ++ // XML Tree being used directly here while it shouldn't be... + gchar *style = g_strdup(SP_OBJECT(item)->getRepr()->attribute("style")); - // XML Tree being used directly here while it shouldn't be... ++ // XML Tree being used directly here while it shouldn't be... + gchar *path_effect = g_strdup(SP_OBJECT(item)->getRepr()->attribute("inkscape:path-effect")); Geom::PathVector apv = curve->get_pathvector() * SP_ITEM(path)->transform; @@@ -272,8 -274,8 +279,8 @@@ desktop->clearWaitingCursor(); if (did) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_BREAK_APART, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_BREAK_APART, -- _("Break apart")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_BREAK_APART, ++ _("Break apart")); } else { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("No path(s) to break apart in the selection.")); } @@@ -314,8 -316,8 +321,8 @@@ sp_selected_path_to_curves(SPDesktop *d if (interactive) { desktop->clearWaitingCursor(); if (did) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_OBJECT_TO_CURVE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_OBJECT_TO_CURVE, -- _("Object to path")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_OBJECT_TO_CURVE, ++ _("Object to path")); } else { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("No objects to convert to path in the selection.")); return; @@@ -627,8 -629,8 +634,8 @@@ sp_selected_path_reverse(SPDesktop *des desktop->clearWaitingCursor(); if (did) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_REVERSE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_REVERSE, -- _("Reverse path")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_REVERSE, ++ _("Reverse path")); } else { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("No paths to reverse in the selection.")); } diff --cc src/persp3d.cpp index 543d7efde,60bfa765a..74208444b --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@@ -1,10 -1,10 +1,10 @@@ --#define __PERSP3D_C__ -- /* * Class modelling a 3D perspective as an SPObject * * Authors: * Maximilian Albert ++ * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2007 authors * @@@ -23,6 -23,6 +23,8 @@@ #include "desktop-handles.h" #include ++using Inkscape::DocumentUndo; ++ static void persp3d_class_init(Persp3DClass *klass); static void persp3d_init(Persp3D *persp); @@@ -116,10 -116,10 +118,10 @@@ static void persp3d_build(SPObject *obj /* calls sp_object_set for the respective attributes */ // The transformation matrix is updated according to the values we read for the VPs - sp_object_read_attr(object, "inkscape:vp_x"); - sp_object_read_attr(object, "inkscape:vp_y"); - sp_object_read_attr(object, "inkscape:vp_z"); - sp_object_read_attr(object, "inkscape:persp3d-origin"); - object->readAttr( "inkscape:vp_x"); - object->readAttr( "inkscape:vp_y"); - object->readAttr( "inkscape:vp_z"); - object->readAttr( "inkscape:persp3d-origin"); ++ object->readAttr( "inkscape:vp_x" ); ++ object->readAttr( "inkscape:vp_y" ); ++ object->readAttr( "inkscape:vp_z" ); ++ object->readAttr( "inkscape:persp3d-origin" ); if (repr) { repr->addListener (&persp3d_repr_events, object); @@@ -206,10 -206,10 +208,9 @@@ persp3d_update(SPObject *object, SPCtx ((SPObjectClass *) persp3d_parent_class)->update(object, ctx, flags); } --Persp3D * --persp3d_create_xml_element (SPDocument *document, Persp3DImpl *dup) {// if dup is given, copy the attributes over ++Persp3D *persp3d_create_xml_element(SPDocument *document, Persp3DImpl *dup) {// if dup is given, copy the attributes over SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *repr; /* if no perspective is given, create a default one */ @@@ -246,20 -246,20 +247,18 @@@ SP_OBJECT_REPR(defs)->addChild(repr, NULL); Inkscape::GC::release(repr); - return (Persp3D *) sp_object_get_child_by_repr (SP_OBJECT(defs), repr); + return (Persp3D *) SP_OBJECT(defs)->get_child_by_repr (repr); } --Persp3D * --persp3d_document_first_persp (SPDocument *document) { -- SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); -- Inkscape::XML::Node *repr; - for (SPObject *child = sp_object_first_child(defs); child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = defs->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { -- repr = SP_OBJECT_REPR(child); ++Persp3D *persp3d_document_first_persp(SPDocument *document) ++{ ++ Persp3D *first = 0; ++ for ( SPObject *child = SP_DOCUMENT_DEFS(document)->firstChild(); child && !first; child = child->getNext() ) { if (SP_IS_PERSP3D(child)) { -- return SP_PERSP3D(child); ++ first = SP_PERSP3D(child); } } -- return NULL; ++ return first; } /** @@@ -341,8 -341,8 +340,8 @@@ persp3d_toggle_VP (Persp3D *persp, Proj persp3d_update_box_reprs (persp); SP_OBJECT(persp)->updateRepr(SP_OBJECT_WRITE_EXT); if (set_undo) { - sp_document_done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, - SPDocumentUndo::done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, -- _("Toggle vanishing point")); ++ DocumentUndo::done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, ++ _("Toggle vanishing point")); } } @@@ -352,8 -352,8 +351,8 @@@ persp3d_toggle_VPs (std::list::iterator i = p.begin(); i != p.end(); ++i) { persp3d_toggle_VP((*i), axis, false); } - sp_document_done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, - SPDocumentUndo::done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, -- _("Toggle multiple vanishing points")); ++ DocumentUndo::done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, ++ _("Toggle multiple vanishing points")); } void @@@ -564,12 -564,12 +563,9 @@@ persp3d_print_debugging_info (Persp3D * g_print ("========================\n"); } --void --persp3d_print_debugging_info_all(SPDocument *document) { -- SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); -- Inkscape::XML::Node *repr; - for (SPObject *child = sp_object_first_child(defs); child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = defs->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { -- repr = SP_OBJECT_REPR(child); ++void persp3d_print_debugging_info_all(SPDocument *document) ++{ ++ for ( SPObject *child = SP_DOCUMENT_DEFS(document)->firstChild(); child; child = child->getNext() ) { if (SP_IS_PERSP3D(child)) { persp3d_print_debugging_info(SP_PERSP3D(child)); } diff --cc src/print.cpp index ba29b17ad,43f0113a0..e0601aa33 --- a/src/print.cpp +++ b/src/print.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_PRINT_C__ -- /** \file * Frontend to printing */ @@@ -7,6 -7,6 +5,8 @@@ * Author: * Lauris Kaplinski * Kees Cook ++ * Jon A. Cruz ++ * Abhishek Sharma * * This code is in public domain */ @@@ -90,7 -90,7 +90,7 @@@ sp_print_preview_document(SPDocument *d Inkscape::Extension::Print *mod; unsigned int ret; - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_DEFAULT); @@@ -102,16 -102,16 +102,16 @@@ /* fixme: This has to go into module constructor somehow */ /* Create new arena */ -- mod->base = SP_ITEM(sp_document_root(doc)); ++ mod->base = SP_ITEM(doc->getRoot()); mod->arena = NRArena::create(); - mod->dkey = sp_item_display_key_new(1); - mod->root = sp_item_invoke_show(mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); + mod->dkey = SPItem::display_key_new(1); + mod->root = (mod->base)->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); /* Print document */ ret = mod->begin(doc); - sp_item_invoke_print(mod->base, &context); + (mod->base)->invoke_print(&context); ret = mod->finish(); /* Release arena */ - sp_item_invoke_hide(mod->base, mod->dkey); + (mod->base)->invoke_hide(mod->dkey); mod->base = NULL; mod->root = NULL; nr_object_unref((NRObject *) mod->arena); @@@ -124,14 -124,14 +124,14 @@@ void sp_print_document(Gtk::Window& parentWindow, SPDocument *doc) { - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); // Build arena -- SPItem *base = SP_ITEM(sp_document_root(doc)); ++ SPItem *base = SP_ITEM(doc->getRoot()); NRArena *arena = NRArena::create(); - unsigned int dkey = sp_item_display_key_new(1); + unsigned int dkey = SPItem::display_key_new(1); // TODO investigate why we are grabbing root and then ignoring it. - NRArenaItem *root = sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY); + NRArenaItem *root = base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); // Run print dialog Inkscape::UI::Dialog::Print printop(doc,base); @@@ -152,7 -152,7 +152,7 @@@ sp_print_document_to_file(SPDocument *d gchar *oldoutput; unsigned int ret; - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_PS); oldconst = mod->get_param_string("destination"); @@@ -163,16 -163,16 +163,16 @@@ context.module = mod; /* fixme: This has to go into module constructor somehow */ /* Create new arena */ -- mod->base = SP_ITEM(sp_document_root(doc)); ++ mod->base = SP_ITEM(doc->getRoot()); mod->arena = NRArena::create(); - mod->dkey = sp_item_display_key_new(1); - mod->root = sp_item_invoke_show(mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); + mod->dkey = SPItem::display_key_new(1); + mod->root = (mod->base)->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); /* Print document */ ret = mod->begin(doc); - sp_item_invoke_print(mod->base, &context); + (mod->base)->invoke_print(&context); ret = mod->finish(); /* Release arena */ - sp_item_invoke_hide(mod->base, mod->dkey); + (mod->base)->invoke_hide(mod->dkey); mod->base = NULL; mod->root = NULL; nr_object_unref((NRObject *) mod->arena); diff --cc src/profile-manager.cpp index b70926947,d557fdd39..27ab75497 --- a/src/profile-manager.cpp +++ b/src/profile-manager.cpp @@@ -2,6 -2,6 +2,7 @@@ * Inkscape::ProfileManager - a view of a document's color profiles. * * Copyright 2007 Jon A. Cruz ++ * Abhishek Sharma * * Released under GNU GPL, read the file 'COPYING' for more information */ @@@ -18,7 -18,7 +19,7 @@@ ProfileManager::ProfileManager(SPDocume _doc(document), _knownProfiles() { - _resource_connection = sp_document_resources_changed_connect( _doc, "iccprofile", sigc::mem_fun(*this, &ProfileManager::_resourcesChanged) ); - _resource_connection = _doc->resources_changed_connect( "iccprofile", sigc::mem_fun(*this, &ProfileManager::_resourcesChanged) ); ++ _resource_connection = _doc->connectResourcesChanged( "iccprofile", sigc::mem_fun(*this, &ProfileManager::_resourcesChanged) ); } ProfileManager::~ProfileManager() @@@ -31,7 -29,7 +32,7 @@@ void ProfileManager::_resourcesChanged( { std::vector newList; if (_doc) { - const GSList *current = sp_document_get_resource_list( _doc, "iccprofile" ); - const GSList *current = _doc->get_resource_list( "iccprofile" ); ++ const GSList *current = _doc->getResourceList( "iccprofile" ); while ( current ) { newList.push_back(SP_OBJECT(current->data)); current = g_slist_next(current); diff --cc src/rdf.cpp index 99b56a103,0a8fd51f6..c9378cf53 --- a/src/rdf.cpp +++ b/src/rdf.cpp @@@ -6,6 -6,6 +6,7 @@@ /* Authors: * Kees Cook * Jon Phillips ++ * Jon A. Cruz * * Copyright (C) 2004 Kees Cook * Copyright (C) 2006 Jon Phillips @@@ -295,6 -295,6 +296,50 @@@ struct rdf_work_entity_t rdf_work_entit } }; ++ ++// Simple start of C++-ification: ++class RDFImpl ++{ ++public: ++ /** ++ * Some implementations do not put RDF stuff inside , ++ * so we need to check for it and add it if we don't see it. ++ */ ++ static void ensureParentIsMetadata( SPDocument *doc, Inkscape::XML::Node *node ); ++ ++ static Inkscape::XML::Node const *getRdfRootRepr( SPDocument const * doc ); ++ static Inkscape::XML::Node *ensureRdfRootRepr( SPDocument * doc ); ++ ++ static Inkscape::XML::Node const *getXmlRepr( SPDocument const * doc, gchar const * name ); ++ static Inkscape::XML::Node *getXmlRepr( SPDocument * doc, gchar const * name ); ++ static Inkscape::XML::Node *ensureXmlRepr( SPDocument * doc, gchar const * name ); ++ ++ static Inkscape::XML::Node const *getWorkRepr( SPDocument const * doc, gchar const * name ); ++ static Inkscape::XML::Node *ensureWorkRepr( SPDocument * doc, gchar const * name ); ++ ++ static const gchar *getWorkEntity(SPDocument const * doc, struct rdf_work_entity_t & entity); ++ static unsigned int setWorkEntity(SPDocument * doc, struct rdf_work_entity_t & entity, gchar const * text); ++ ++ static void setDefaults( SPDocument * doc ); ++ ++ /** ++ * \brief Pull the text out of an RDF entity, depends on how it's stored ++ * \return A pointer to the entity's static contents as a string ++ * \param repr The XML element to extract from ++ * \param entity The desired RDF/Work entity ++ * ++ */ ++ static const gchar *getReprText( Inkscape::XML::Node const * repr, struct rdf_work_entity_t const & entity ); ++ ++ static unsigned int setReprText( Inkscape::XML::Node * repr, ++ struct rdf_work_entity_t const & entity, ++ gchar const * text ); ++ ++ static struct rdf_license_t *getLicense(SPDocument const * document); ++ ++ static void setLicense(SPDocument * doc, struct rdf_license_t const * license); ++}; ++ /** * \brief Retrieves a known RDF/Work entity by name * \return A pointer to an RDF/Work entity @@@ -431,23 -431,23 +476,14 @@@ rdf_string(struct rdf_t * rdf */ --/** -- * \brief Pull the text out of an RDF entity, depends on how it's stored -- * \return A pointer to the entity's static contents as a string -- * \param repr The XML element to extract from -- * \param entity The desired RDF/Work entity -- * -- */ --const gchar * --rdf_get_repr_text ( Inkscape::XML::Node * repr, struct rdf_work_entity_t * entity ) ++const gchar *RDFImpl::getReprText( Inkscape::XML::Node const * repr, struct rdf_work_entity_t const & entity ) { g_return_val_if_fail (repr != NULL, NULL); -- g_return_val_if_fail (entity != NULL, NULL); static gchar * bag = NULL; gchar * holder = NULL; -- Inkscape::XML::Node * temp=NULL; -- switch (entity->datatype) { ++ Inkscape::XML::Node const * temp = NULL; ++ switch (entity.datatype) { case RDF_CONTENT: temp = sp_repr_children(repr); if ( temp == NULL ) return NULL; @@@ -510,13 -510,13 +546,11 @@@ return NULL; } --unsigned int --rdf_set_repr_text ( Inkscape::XML::Node * repr, -- struct rdf_work_entity_t * entity, -- gchar const * text ) ++unsigned int RDFImpl::setReprText( Inkscape::XML::Node * repr, ++ struct rdf_work_entity_t const & entity, ++ gchar const * text ) { g_return_val_if_fail ( repr != NULL, 0); -- g_return_val_if_fail ( entity != NULL, 0); g_return_val_if_fail ( text != NULL, 0); gchar * str = NULL; gchar** strlist = NULL; @@@ -530,12 -530,12 +564,12 @@@ g_return_val_if_fail (xmldoc != NULL, FALSE); // set document's title element to the RDF title -- if (!strcmp(entity->name, "title")) { ++ if (!strcmp(entity.name, "title")) { SPDocument *doc = SP_ACTIVE_DOCUMENT; if(doc && doc->root) doc->root->setTitle(text); } -- switch (entity->datatype) { ++ switch (entity.datatype) { case RDF_CONTENT: temp = sp_repr_children(parent); if ( temp == NULL ) { @@@ -643,187 -643,187 +677,263 @@@ return 0; } --Inkscape::XML::Node * --rdf_get_rdf_root_repr ( SPDocument * doc, bool build ) ++void RDFImpl::ensureParentIsMetadata( SPDocument *doc, Inkscape::XML::Node *node ) { -- g_return_val_if_fail (doc != NULL, NULL); -- g_return_val_if_fail (doc->rroot != NULL, NULL); -- -- Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc); -- g_return_val_if_fail (xmldoc != NULL, NULL); -- -- Inkscape::XML::Node * rdf = sp_repr_lookup_name ( doc->rroot, XML_TAG_NAME_RDF ); ++ if ( !node ) { ++ g_critical("Null node passed to ensureParentIsMetadata()."); ++ } else if ( !node->parent() ) { ++ g_critical( "No parent node when verifying placement." ); ++ } else { ++ Inkscape::XML::Node * currentParent = node->parent(); ++ if ( strcmp( currentParent->name(), XML_TAG_NAME_METADATA ) != 0 ) { ++ Inkscape::XML::Node * metadata = doc->getReprDoc()->createElement( XML_TAG_NAME_METADATA ); ++ if ( !metadata ) { ++ g_critical("Unable to create metadata element."); ++ } else { ++ // attach the metadata node ++ currentParent->appendChild( metadata ); ++ Inkscape::GC::release( metadata ); ++ ++ // move the node into it ++ Inkscape::GC::anchor( node ); ++ sp_repr_unparent( node ); ++ metadata->appendChild( node ); ++ Inkscape::GC::release( node ); ++ } ++ } ++ } ++} -- if (rdf == NULL) { -- //printf("missing XML '%s'\n",XML_TAG_NAME_RDF); -- if (!build) return NULL; ++Inkscape::XML::Node const *RDFImpl::getRdfRootRepr( SPDocument const * doc ) ++{ ++ Inkscape::XML::Node const *rdf = 0; ++ if ( !doc ) { ++ g_critical("Null doc passed to getRdfRootRepr()"); ++ } else if ( !doc->getReprDoc() ) { ++ g_critical("XML doc is null."); ++ } else { ++ rdf = sp_repr_lookup_name( doc->getReprDoc(), XML_TAG_NAME_RDF ); ++ } -- Inkscape::XML::Node * svg = sp_repr_lookup_name ( doc->rroot, XML_TAG_NAME_SVG ); -- g_return_val_if_fail ( svg != NULL, NULL ); ++ return rdf; ++} -- Inkscape::XML::Node * parent = sp_repr_lookup_name ( svg, XML_TAG_NAME_METADATA ); -- if ( parent == NULL ) { -- parent = xmldoc->createElement( XML_TAG_NAME_METADATA ); -- g_return_val_if_fail ( parent != NULL, NULL); ++Inkscape::XML::Node *RDFImpl::ensureRdfRootRepr( SPDocument * doc ) ++{ ++ Inkscape::XML::Node *rdf = 0; ++ if ( !doc ) { ++ g_critical("Null doc passed to ensureRdfRootRepr()"); ++ } else if ( !doc->getReprDoc() ) { ++ g_critical("XML doc is null."); ++ } else { ++ rdf = sp_repr_lookup_name( doc->getReprDoc(), XML_TAG_NAME_RDF ); ++ if ( !rdf ) { ++ Inkscape::XML::Node * svg = sp_repr_lookup_name( doc->getReprRoot(), XML_TAG_NAME_SVG ); ++ if ( !svg ) { ++ g_critical("Unable to locate svg element."); ++ } else { ++ Inkscape::XML::Node * parent = sp_repr_lookup_name( svg, XML_TAG_NAME_METADATA ); ++ if ( parent == NULL ) { ++ parent = doc->getReprDoc()->createElement( XML_TAG_NAME_METADATA ); ++ if ( !parent ) { ++ g_critical("Unable to create metadata element"); ++ } else { ++ svg->appendChild(parent); ++ Inkscape::GC::release(parent); ++ } ++ } -- svg->appendChild(parent); -- Inkscape::GC::release(parent); ++ if ( parent && !parent->document() ) { ++ g_critical("Parent has no document"); ++ } else if ( parent ) { ++ rdf = parent->document()->createElement( XML_TAG_NAME_RDF ); ++ if ( !rdf ) { ++ g_critical("Unable to create root RDF element."); ++ } else { ++ parent->appendChild(rdf); ++ Inkscape::GC::release(rdf); ++ } ++ } ++ } } -- -- Inkscape::XML::Document * xmldoc = parent->document(); -- g_return_val_if_fail (xmldoc != NULL, FALSE); -- -- rdf = xmldoc->createElement( XML_TAG_NAME_RDF ); -- g_return_val_if_fail (rdf != NULL, NULL); -- -- parent->appendChild(rdf); -- Inkscape::GC::release(rdf); } -- /* -- * some implementations do not put RDF stuff inside , -- * so we need to check for it and add it if we don't see it -- */ -- Inkscape::XML::Node * want_metadata = sp_repr_parent ( rdf ); -- g_return_val_if_fail (want_metadata != NULL, NULL); -- if (strcmp( want_metadata->name(), XML_TAG_NAME_METADATA )) { -- Inkscape::XML::Node * metadata = xmldoc->createElement( XML_TAG_NAME_METADATA ); -- g_return_val_if_fail (metadata != NULL, NULL); -- -- /* attach the metadata node */ -- want_metadata->appendChild(metadata); -- Inkscape::GC::release(metadata); -- -- /* move the RDF into it */ -- Inkscape::GC::anchor(rdf); -- sp_repr_unparent ( rdf ); -- metadata->appendChild(rdf); -- Inkscape::GC::release(rdf); ++ if ( rdf ) { ++ ensureParentIsMetadata( doc, rdf ); } -- ++ return rdf; } --Inkscape::XML::Node * --rdf_get_xml_repr( SPDocument * doc, gchar const * name, bool build ) ++Inkscape::XML::Node const *RDFImpl::getXmlRepr( SPDocument const * doc, gchar const * name ) { -- g_return_val_if_fail (name != NULL, NULL); -- g_return_val_if_fail (doc != NULL, NULL); -- g_return_val_if_fail (doc->rroot != NULL, NULL); -- -- Inkscape::XML::Node * rdf = rdf_get_rdf_root_repr ( doc, build ); -- if (!rdf) return NULL; -- -- Inkscape::XML::Node * xml = sp_repr_lookup_name ( rdf, name ); -- if (xml == NULL) { -- //printf("missing XML '%s'\n",name); -- if (!build) return NULL; -- -- Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc); -- g_return_val_if_fail (xmldoc != NULL, NULL); ++ Inkscape::XML::Node const * xml = 0; ++ if ( !doc ) { ++ g_critical("Null doc passed to getXmlRepr()"); ++ } else if ( !doc->getReprDoc() ) { ++ g_critical("XML doc is null."); ++ } else if (!name) { ++ g_critical("Null name passed to getXmlRepr()"); ++ } else { ++ Inkscape::XML::Node const * rdf = getRdfRootRepr( doc ); ++ if ( rdf ) { ++ xml = sp_repr_lookup_name( rdf, name ); ++ } ++ } ++ return xml; ++} -- xml = xmldoc->createElement( name ); -- g_return_val_if_fail (xml != NULL, NULL); ++Inkscape::XML::Node *RDFImpl::getXmlRepr( SPDocument * doc, gchar const * name ) ++{ ++ Inkscape::XML::Node const *xml = getXmlRepr( const_cast(doc), name ); -- xml->setAttribute("rdf:about", "" ); ++ return const_cast(xml); ++} -- rdf->appendChild(xml); -- Inkscape::GC::release(xml); ++Inkscape::XML::Node *RDFImpl::ensureXmlRepr( SPDocument * doc, gchar const * name ) ++{ ++ Inkscape::XML::Node * xml = 0; ++ if ( !doc ) { ++ g_critical("Null doc passed to ensureXmlRepr()"); ++ } else if ( !doc->getReprDoc() ) { ++ g_critical("XML doc is null."); ++ } else if (!name) { ++ g_critical("Null name passed to ensureXmlRepr()"); ++ } else { ++ Inkscape::XML::Node * rdf = ensureRdfRootRepr( doc ); ++ if ( rdf ) { ++ xml = sp_repr_lookup_name( rdf, name ); ++ if ( !xml ) { ++ xml = doc->getReprDoc()->createElement( name ); ++ if ( !xml ) { ++ g_critical("Unable to create xml element <%s>.", name); ++ } else { ++ xml->setAttribute("rdf:about", "" ); ++ ++ rdf->appendChild(xml); ++ Inkscape::GC::release(xml); ++ } ++ } ++ } } -- return xml; } --Inkscape::XML::Node * --rdf_get_work_repr( SPDocument * doc, gchar const * name, bool build ) ++Inkscape::XML::Node const *RDFImpl::getWorkRepr( SPDocument const * doc, gchar const * name ) { -- g_return_val_if_fail (name != NULL, NULL); -- g_return_val_if_fail (doc != NULL, NULL); -- g_return_val_if_fail (doc->rroot != NULL, NULL); ++ Inkscape::XML::Node const * item = 0; ++ if ( !doc ) { ++ g_critical("Null doc passed to getWorkRepr()"); ++ } else if ( !doc->getReprDoc() ) { ++ g_critical("XML doc is null."); ++ } else if (!name) { ++ g_critical("Null name passed to getWorkRepr()"); ++ } else { ++ Inkscape::XML::Node const* work = getXmlRepr( doc, XML_TAG_NAME_WORK ); ++ if ( work ) { ++ item = sp_repr_lookup_name( work, name, 1 ); ++ } ++ } ++ return item; ++} -- Inkscape::XML::Node * work = rdf_get_xml_repr ( doc, XML_TAG_NAME_WORK, build ); -- if (!work) return NULL; ++Inkscape::XML::Node *RDFImpl::ensureWorkRepr( SPDocument * doc, gchar const * name ) ++{ ++ Inkscape::XML::Node * item = 0; ++ if ( !doc ) { ++ g_critical("Null doc passed to ensureWorkRepr()"); ++ } else if ( !doc->getReprDoc() ) { ++ g_critical("XML doc is null."); ++ } else if (!name) { ++ g_critical("Null name passed to ensureWorkRepr()"); ++ } else { ++ Inkscape::XML::Node * work = ensureXmlRepr( doc, XML_TAG_NAME_WORK ); ++ if ( work ) { ++ item = sp_repr_lookup_name( work, name, 1 ); ++ if ( !item ) { ++ //printf("missing XML '%s'\n",name); ++ item = doc->getReprDoc()->createElement( name ); ++ if ( !item ) { ++ g_critical("Unable to create xml element <%s>", name); ++ } else { ++ work->appendChild(item); ++ Inkscape::GC::release(item); ++ } ++ } ++ } ++ } ++ return item; ++} -- Inkscape::XML::Node * item = sp_repr_lookup_name ( work, name, 1 ); -- if (item == NULL) { -- //printf("missing XML '%s'\n",name); -- if (!build) return NULL; -- Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc); -- g_return_val_if_fail (xmldoc != NULL, NULL); ++// Public API: ++const gchar *rdf_get_work_entity(SPDocument const * doc, struct rdf_work_entity_t * entity) ++{ ++ const gchar *result = 0; ++ if ( !doc ) { ++ g_critical("Null doc passed to rdf_get_work_entity()"); ++ } else if ( entity ) { ++ //g_message("want '%s'\n",entity->title); -- item = xmldoc->createElement( name ); -- g_return_val_if_fail (item != NULL, NULL); ++ result = RDFImpl::getWorkEntity( doc, *entity ); -- work->appendChild(item); -- Inkscape::GC::release(item); ++ //g_message("found '%s' == '%s'\n", entity->title, result ); } -- -- return item; ++ return result; } -- -- --/** -- * \brief Retrieves a known RDF/Work entity's contents from the document XML by name -- * \return A pointer to the entity's static contents as a string, or NULL if no entity exists -- * \param entity The desired RDF/Work entity -- * -- */ --const gchar * --rdf_get_work_entity(SPDocument * doc, struct rdf_work_entity_t * entity) ++const gchar *RDFImpl::getWorkEntity(SPDocument const * doc, struct rdf_work_entity_t & entity) { -- g_return_val_if_fail (doc != NULL, NULL); -- if ( entity == NULL ) return NULL; -- //printf("want '%s'\n",entity->title); -- bool bIsTitle = !strcmp(entity->name, "title"); ++ gchar const *result = 0; -- Inkscape::XML::Node * item; -- if ( entity->datatype == RDF_XML ) { -- item = rdf_get_xml_repr ( doc, entity->tag, FALSE ); -- } -- else { -- item = rdf_get_work_repr( doc, entity->tag, bIsTitle ); // build title if necessary ++ Inkscape::XML::Node const * item = getWorkRepr( doc, entity.tag ); ++ if ( item ) { ++ result = getReprText( item, entity ); ++ // TODO note that this is the location that used to set the title if needed. Ensure code it not required. } -- if ( item == NULL ) return NULL; -- const gchar * result = rdf_get_repr_text ( item, entity ); -- if(!result && bIsTitle && doc->root) { // if RDF title not set -- result = doc->root->title(); // get the document's -- rdf_set_work_entity(doc, entity, result); // and set the RDF ++ ++ return result; ++} ++ ++// Public API: ++unsigned int rdf_set_work_entity(SPDocument * doc, struct rdf_work_entity_t * entity, ++ const gchar * text) ++{ ++ unsigned int result = 0; ++ if ( !doc ) { ++ g_critical("Null doc passed to rdf_set_work_entity()"); ++ } else if ( entity ) { ++ result = RDFImpl::setWorkEntity( doc, *entity, text ); } -- //printf("found '%s' == '%s'\n", entity->title, result ); ++ return result; } --/** -- * \brief Stores a string into a named RDF/Work entity in the document XML -- * \param entity The desired RDF/Work entity to replace -- * \param string The string to replace the entity contents with -- * -- */ --unsigned int --rdf_set_work_entity(SPDocument * doc, struct rdf_work_entity_t * entity, -- const gchar * text) ++unsigned int RDFImpl::setWorkEntity(SPDocument * doc, struct rdf_work_entity_t & entity, const gchar * text) { -- g_return_val_if_fail ( entity != NULL, 0 ); -- if (text == NULL) { ++ int result = 0; ++ if ( !text ) { // FIXME: on a "NULL" text, delete the entity. For now, blank it. -- text=""; ++ text = ""; } /* -- printf("changing '%s' (%s) to '%s'\n", -- entity->title, -- entity->tag, -- text); ++ printf("changing '%s' (%s) to '%s'\n", ++ entity->title, ++ entity->tag, ++ text); */ -- Inkscape::XML::Node * item = rdf_get_work_repr( doc, entity->tag, TRUE ); -- g_return_val_if_fail ( item != NULL, 0 ); -- -- return rdf_set_repr_text ( item, entity, text ); ++ Inkscape::XML::Node * item = ensureWorkRepr( doc, entity.tag ); ++ if ( !item ) { ++ g_critical("Unable to get work element"); ++ } else { ++ result = setReprText( item, entity, text ); ++ } ++ return result; } ++ #undef DEBUG_MATCH static bool @@@ -912,19 -912,19 +1022,20 @@@ rdf_match_license(Inkscape::XML::Node c return result; } --/** -- * \brief Attempts to match and retrieve a known RDF/License from the document XML -- * \return A pointer to the static RDF license structure -- * -- */ --struct rdf_license_t * --rdf_get_license(SPDocument * document) ++// Public API: ++struct rdf_license_t *rdf_get_license(SPDocument const * document) { -- Inkscape::XML::Node const *repr = rdf_get_xml_repr ( document, XML_TAG_NAME_LICENSE, FALSE ); ++ return RDFImpl::getLicense(document); ++} ++ ++struct rdf_license_t *RDFImpl::getLicense(SPDocument const *document) ++{ ++ Inkscape::XML::Node const *repr = getXmlRepr( document, XML_TAG_NAME_LICENSE ); if (repr) { -- for (struct rdf_license_t * license = rdf_licenses; -- license->name; license++ ) { -- if ( rdf_match_license ( repr, license ) ) return license; ++ for ( struct rdf_license_t * license = rdf_licenses; license->name; license++ ) { ++ if ( rdf_match_license( repr, license ) ) { ++ return license; ++ } } } #ifdef DEBUG_MATCH @@@ -935,38 -935,38 +1046,39 @@@ return NULL; } --/** -- * \brief Stores an RDF/License XML in the document XML -- * \param document Which document to update -- * \param license The desired RDF/License structure to store; NULL drops old license, so can be used for proprietary license. -- * -- */ --void --rdf_set_license(SPDocument * doc, struct rdf_license_t const * license) ++// Public API: ++void rdf_set_license(SPDocument * doc, struct rdf_license_t const * license) { -- // drop old license section -- Inkscape::XML::Node * repr = rdf_get_xml_repr ( doc, XML_TAG_NAME_LICENSE, FALSE ); -- if (repr) sp_repr_unparent(repr); -- -- if (!license) return; ++ RDFImpl::setLicense( doc, license ); ++} -- // build new license section -- repr = rdf_get_xml_repr ( doc, XML_TAG_NAME_LICENSE, TRUE ); -- g_assert ( repr ); ++void RDFImpl::setLicense(SPDocument * doc, struct rdf_license_t const * license) ++{ ++ // drop old license section ++ Inkscape::XML::Node * repr = getXmlRepr( doc, XML_TAG_NAME_LICENSE ); ++ if (repr) { ++ sp_repr_unparent(repr); ++ } -- repr->setAttribute("rdf:about", license->uri ); ++ if ( !license ) { ++ // All done ++ } else if ( !doc->getReprDoc() ) { ++ g_critical("XML doc is null."); ++ } else { ++ // build new license section ++ repr = ensureXmlRepr( doc, XML_TAG_NAME_LICENSE ); ++ g_assert( repr ); -- Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc); -- g_return_if_fail (xmldoc != NULL); ++ repr->setAttribute("rdf:about", license->uri ); -- for (struct rdf_double_t const * detail = license->details; -- detail->name; detail++) { -- Inkscape::XML::Node * child = xmldoc->createElement( detail->name ); -- g_assert ( child != NULL ); ++ for (struct rdf_double_t const * detail = license->details; detail->name; detail++) { ++ Inkscape::XML::Node * child = doc->getReprDoc()->createElement( detail->name ); ++ g_assert ( child != NULL ); -- child->setAttribute("rdf:resource", detail->resource ); -- repr->appendChild(child); -- Inkscape::GC::release(child); ++ child->setAttribute("rdf:resource", detail->resource ); ++ repr->appendChild(child); ++ Inkscape::GC::release(child); ++ } } } @@@ -980,37 -980,37 +1092,46 @@@ struct rdf_entity_default_t rdf_default { NULL, NULL, } }; --void --rdf_set_defaults ( SPDocument * doc ) ++// Public API: ++void rdf_set_defaults( SPDocument * doc ) ++{ ++ RDFImpl::setDefaults( doc ); ++ ++} ++ ++void RDFImpl::setDefaults( SPDocument * doc ) { -- g_assert ( doc != NULL ); ++ g_assert( doc != NULL ); // Create metadata node if it doesn't already exist -- if (!sp_item_group_get_child_by_name ((SPGroup *) doc->root, NULL, ++ if (!sp_item_group_get_child_by_name((SPGroup *) doc->root, NULL, XML_TAG_NAME_METADATA)) { -- // create repr -- Inkscape::XML::Document * xmldoc = sp_document_repr_doc(doc); -- g_return_if_fail (xmldoc != NULL); -- Inkscape::XML::Node * rnew = xmldoc->createElement (XML_TAG_NAME_METADATA); -- // insert into the document -- doc->rroot->addChild(rnew, NULL); -- // clean up -- Inkscape::GC::release(rnew); -- } -- -- /* install defaults */ -- for ( struct rdf_entity_default_t * rdf_default = rdf_defaults; -- rdf_default->name; -- rdf_default++) { -- struct rdf_work_entity_t * entity = rdf_find_entity ( rdf_default->name ); -- g_assert ( entity != NULL ); -- -- if ( rdf_get_work_entity ( doc, entity ) == NULL ) { -- rdf_set_work_entity ( doc, entity, rdf_default->text ); ++ if ( !doc->getReprDoc()) { ++ g_critical("XML doc is null."); ++ } else { ++ // create repr ++ Inkscape::XML::Node * rnew = doc->getReprDoc()->createElement(XML_TAG_NAME_METADATA); ++ ++ // insert into the document ++ doc->getReprRoot()->addChild(rnew, NULL); ++ ++ // clean up ++ Inkscape::GC::release(rnew); ++ } ++ } ++ ++ // install defaults ++ for ( struct rdf_entity_default_t * rdf_default = rdf_defaults; rdf_default->name; rdf_default++) { ++ struct rdf_work_entity_t * entity = rdf_find_entity( rdf_default->name ); ++ g_assert( entity != NULL ); ++ ++ if ( getWorkEntity( doc, *entity ) == NULL ) { ++ setWorkEntity( doc, *entity, rdf_default->text ); } } } ++ /* Local Variables: mode:c++ diff --cc src/rdf.h index e7a1f946f,a98f5a1e4..bed01aed0 --- a/src/rdf.h +++ b/src/rdf.h @@@ -3,12 -3,12 +3,13 @@@ */ /* Authors: * Kees Cook <kees@outflux.net> ++ * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2004 Authors * Released under GNU GPL, read the file 'COPYING' for more information */ --#ifndef _RDF_H_ --#define _RDF_H_ ++#ifndef SEEN_RDF_H ++#define SEEN_RDF_H #include <glib.h> #include <glibmm/i18n.h> @@@ -94,19 -94,19 +95,44 @@@ struct rdf_t struct rdf_work_entity_t * rdf_find_entity(gchar const * name); --const gchar * rdf_get_work_entity(SPDocument * doc, ++/** ++ * \brief Retrieves a known RDF/Work entity's contents from the document XML by name ++ * \return A pointer to the entity's static contents as a string, or NULL if no entity exists ++ * \param entity The desired RDF/Work entity ++ * ++ */ ++const gchar * rdf_get_work_entity(SPDocument const * doc, struct rdf_work_entity_t * entity); ++ ++/** ++ * \brief Stores a string into a named RDF/Work entity in the document XML ++ * \param entity The desired RDF/Work entity to replace ++ * \param string The string to replace the entity contents with ++ * ++ */ unsigned int rdf_set_work_entity(SPDocument * doc, struct rdf_work_entity_t * entity, const gchar * text); --struct rdf_license_t * rdf_get_license(SPDocument * doc); ++/** ++ * \brief Attempts to match and retrieve a known RDF/License from the document XML ++ * \return A pointer to the static RDF license structure ++ * ++ */ ++struct rdf_license_t * rdf_get_license(SPDocument const * doc); ++ ++/** ++ * \brief Stores an RDF/License XML in the document XML ++ * \param document Which document to update ++ * \param license The desired RDF/License structure to store; NULL drops old license, so can be used for proprietary license. ++ * ++ */ void rdf_set_license(SPDocument * doc, struct rdf_license_t const * license); void rdf_set_defaults ( SPDocument * doc ); --#endif // _RDF_H_ ++#endif // SEEN_RDF_H /* Local Variables: diff --cc src/rect-context.cpp index 86f0b54a3,69a9bc2f0..bcb1bf734 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@@ -1,11 -1,11 +1,11 @@@ --#define __SP_RECT_CONTEXT_C__ -- /* * Rectangle drawing context * * Author: * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> * Copyright (C) 2000-2005 authors @@@ -43,6 -43,6 +43,8 @@@ #include "context-fns.h" #include "shape-editor.h" ++using Inkscape::DocumentUndo; ++ //static const double goldenratio = 1.61803398874989484820; // golden ratio static void sp_rect_context_class_init(SPRectContextClass *klass); @@@ -466,11 -462,11 +468,11 @@@ static void sp_rect_drag(SPRectContext return; } -- /* Create object */ -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&rc)); ++ // Create object ++ Inkscape::XML::Document *xml_doc = SP_EVENT_CONTEXT_DOCUMENT(&rc)->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:rect"); -- /* Set style */ ++ // Set style sp_desktop_apply_style_tool (desktop, repr, "/tools/shapes/rect", false); rc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr); @@@ -549,8 -545,8 +551,8 @@@ static void sp_rect_finish(SPRectContex sp_canvas_end_forced_full_redraws(desktop->canvas); sp_desktop_selection(desktop)->set(rc->item); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT, -- _("Create rectangle")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT, ++ _("Create rectangle")); rc->item = NULL; } @@@ -575,7 -571,7 +577,7 @@@ static void sp_rect_cancel(SPRectContex sp_canvas_end_forced_full_redraws(desktop->canvas); - sp_document_cancel(sp_desktop_document(desktop)); - SPDocumentUndo::cancel(sp_desktop_document(desktop)); ++ DocumentUndo::cancel(sp_desktop_document(desktop)); } diff --cc src/removeoverlap.cpp index 975b4becb,a804ceb5f..b01ae5228 --- a/src/removeoverlap.cpp +++ b/src/removeoverlap.cpp @@@ -4,6 -4,6 +4,7 @@@ /* * Authors: * Tim Dwyer <tgdwyer@gmail.com> ++ * Abhishek Sharma * * Copyright (C) 2005 Authors * diff --cc src/selcue.cpp index 8756524dd,0b28a8aef..171178c41 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@@ -1,11 -1,11 +1,10 @@@ --#define __SELCUE_C__ -- /* * Helper object for showing selected items * * Authors: * bulia byak <bulia@users.sf.net> * Carl Hetherington <inkscape@carlh.net> ++ * Abhishek Sharma * * Copyright (C) 2004 Authors * diff --cc src/select-context.cpp index 028c8634b,215436f38..febcc282d --- a/src/select-context.cpp +++ b/src/select-context.cpp @@@ -1,11 -1,11 +1,10 @@@ --#define __SP_SELECT_CONTEXT_C__ -- /* * Selection and transformation context * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> ++ * Abhishek Sharma * * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> * Copyright (C) 1999-2005 Authors @@@ -42,6 -42,6 +41,8 @@@ #include "seltrans.h" #include "box3d.h" ++using Inkscape::DocumentUndo; ++ static void sp_select_context_class_init(SPSelectContextClass *klass); static void sp_select_context_init(SPSelectContext *select_context); static void sp_select_context_dispose(GObject *object); @@@ -222,7 -222,7 +223,7 @@@ sp_select_context_abort(SPEventContext if (sc->item) { // only undo if the item is still valid if (SP_OBJECT_DOCUMENT( SP_OBJECT(sc->item))) { - sp_document_undo(sp_desktop_document(desktop)); - SPDocumentUndo::undo(sp_desktop_document(desktop)); ++ DocumentUndo::undo(sp_desktop_document(desktop)); } sp_object_unref( SP_OBJECT(sc->item), NULL); @@@ -230,7 -230,7 +231,7 @@@ // NOTE: This is a workaround to a bug. // When the ctrl key is held, sc->item is not defined // so in this case (only), we skip the object doc check - sp_document_undo(sp_desktop_document(desktop)); - SPDocumentUndo::undo(sp_desktop_document(desktop)); ++ DocumentUndo::undo(sp_desktop_document(desktop)); } sc->item = NULL; @@@ -510,14 -510,14 +511,14 @@@ sp_select_context_root_handler(SPEventC // and also when we started within tolerance, but trespassed tolerance outside of item Inkscape::Rubberband::get(desktop)->stop(); SP_EVENT_CONTEXT(sc)->defaultMessageContext()->clear(); -- item_at_point = desktop->item_at_point(Geom::Point(event->button.x, event->button.y), FALSE); ++ item_at_point = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), FALSE); if (!item_at_point) // if no item at this point, try at the click point (bug 1012200) -- item_at_point = desktop->item_at_point(Geom::Point(xp, yp), FALSE); ++ item_at_point = desktop->getItemAtPoint(Geom::Point(xp, yp), FALSE); if (item_at_point || sc->moved || sc->button_press_alt) { // drag only if starting from an item, or if something is already grabbed, or if alt-dragging if (!sc->moved) { -- item_in_group = desktop->item_at_point(Geom::Point(event->button.x, event->button.y), TRUE); -- group_at_point = desktop->group_at_point(Geom::Point(event->button.x, event->button.y)); ++ item_in_group = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), TRUE); ++ group_at_point = desktop->getGroupAtPoint(Geom::Point(event->button.x, event->button.y)); if (SP_IS_LAYER(selection->single())) group_at_point = SP_GROUP(selection->single()); @@@ -614,9 -614,9 +615,9 @@@ GSList *items = NULL; if (r->getMode() == RUBBERBAND_MODE_RECT) { Geom::OptRect const b = r->getRectangle(); - items = sp_document_items_in_box(sp_desktop_document(desktop), desktop->dkey, *b); - items = sp_desktop_document(desktop)->items_in_box(desktop->dkey, *b); ++ items = sp_desktop_document(desktop)->getItemsInBox(desktop->dkey, *b); } else if (r->getMode() == RUBBERBAND_MODE_TOUCHPATH) { - items = sp_document_items_at_points(sp_desktop_document(desktop), desktop->dkey, r->getPoints()); - items = sp_desktop_document(desktop)->items_at_points(desktop->dkey, r->getPoints()); ++ items = sp_desktop_document(desktop)->getItemsAtPoints(desktop->dkey, r->getPoints()); } seltrans->resetState(); diff --cc src/selection-chemistry.cpp index 8b917de55,bd2d2768c..d63ee7e83 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@@ -9,6 -9,6 +9,7 @@@ * Andrius R. <knutux@gmail.com> * Jon A. Cruz <jon@joncruz.org> * Martin Sucha <martin.sucha-inkscape@jts-sro.sk> ++ * Abhishek Sharma * * Copyright (C) 1999-2010 authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -105,6 -105,6 +106,7 @@@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS #include "ui/clipboard.h" ++using Inkscape::DocumentUndo; using Geom::X; using Geom::Y; @@@ -250,7 -250,7 +252,7 @@@ void sp_selection_copy_impl(GSList cons GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList **clip) { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); GSList *copied = NULL; // add objects to document @@@ -300,8 -300,8 +302,8 @@@ void sp_selection_delete(SPDesktop *des if (tools_isactive(desktop, TOOLS_TEXT)) if (sp_text_delete_selection(desktop->event_context)) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, -- _("Delete text")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, ++ _("Delete text")); return; } @@@ -326,31 -326,31 +328,31 @@@ */ tools_switch( desktop, tools_active( desktop ) ); - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_DELETE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_DELETE, -- _("Delete")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_DELETE, ++ _("Delete")); } void add_ids_recursive(std::vector<const gchar *> &ids, SPObject *obj) { -- if (!obj) -- return; -- -- ids.push_back(obj->getId()); ++ if (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) ) { - for (SPObject *child = obj->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { -- add_ids_recursive(ids, child); ++ if (SP_IS_GROUP(obj)) { ++ for (SPObject *child = obj->firstChild() ; child; child = child->getNext() ) { ++ add_ids_recursive(ids, child); ++ } } } } void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) { -- if (desktop == NULL) ++ if (desktop == NULL) { return; ++ } SPDocument *doc = desktop->doc(); -- Inkscape::XML::Document* xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document* xml_doc = doc->getReprDoc(); Inkscape::Selection *selection = sp_desktop_selection(desktop); // check if something is selected @@@ -407,7 -407,7 +409,7 @@@ for (unsigned int j = 0; j < old_ids.size(); 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"; ++ // std::cout << id << " old, its ori: " << orig->getId() << "; will relink:" << new_ids[i] << " to " << new_ids[j] << "\n"; gchar *newref = g_strdup_printf("#%s", new_ids[j]); SPObject *new_clone = doc->getObjectById(new_ids[i]); SP_OBJECT_REPR(new_clone)->setAttribute("xlink:href", newref); @@@ -415,23 -415,14 +417,23 @@@ g_free(newref); } } + } else if (SP_IS_OFFSET(old_clone)) { + for (guint j = 0; j < old_ids.size(); j++) { + gchar *source_href = SP_OFFSET(old_clone)->sourceHref; + if (source_href && source_href[0]=='#' && !strcmp(source_href+1, old_ids[j])) { + gchar *newref = g_strdup_printf("#%s", new_ids[j]); - doc->getObjectById(new_ids[i])->repr->setAttribute("xlink:href", newref); ++ doc->getObjectById(new_ids[i])->getRepr()->setAttribute("xlink:href", newref); + g_free(newref); + } + } } } } if ( !suppressDone ) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_DUPLICATE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_DUPLICATE, -- _("Duplicate")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_DUPLICATE, ++ _("Duplicate")); } selection->setReprList(newsel); @@@ -455,14 -446,14 +457,13 @@@ void sp_edit_clear_all(SPDesktop *dt items = g_slist_remove(items, items->data); } - sp_document_done(doc, SP_VERB_EDIT_CLEAR_ALL, - SPDocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL, -- _("Delete all")); ++ DocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL, ++ _("Delete all")); } --GSList * --get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, GSList const *exclude) ++GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, GSList const *exclude) { - for (SPObject *child = sp_object_first_child(from) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = SP_OBJECT(from)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM(child) && !desktop->isLayer(SP_ITEM(child)) && (!onlysensitive || !SP_ITEM(child)->isLocked()) && @@@ -632,11 -623,11 +633,12 @@@ void sp_selection_group_impl(GSList *p void sp_selection_group(SPDesktop *desktop) { -- if (desktop == NULL) ++ if (desktop == NULL) { return; ++ } SPDocument *doc = sp_desktop_document(desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::Selection *selection = sp_desktop_selection(desktop); @@@ -656,8 -647,8 +658,8 @@@ sp_selection_group_impl(p, group, xml_doc, doc); - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_GROUP, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_GROUP, -- _("Group")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_GROUP, ++ _("Group")); selection->set(group); Inkscape::GC::release(group); @@@ -717,8 -708,8 +719,8 @@@ void sp_selection_ungroup(SPDesktop *de g_slist_free(items); - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_UNGROUP, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_UNGROUP, -- _("Ungroup")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_UNGROUP, ++ _("Ungroup")); } /** Replace all groups in the list with their member objects, recursively; returns a new list, frees old */ @@@ -784,18 -775,18 +786,14 @@@ enclose_items(GSList const *items return r; } --SPObject * --prev_sibling(SPObject *child) ++// TODO determine if this is intentionally different from SPObject::getPrev() ++SPObject *prev_sibling(SPObject *child) { -- SPObject *parent = SP_OBJECT_PARENT(child); -- if (!SP_IS_GROUP(parent)) { -- return NULL; -- } - for ( SPObject *i = sp_object_first_child(parent) ; i; i = SP_OBJECT_NEXT(i) ) { - for ( SPObject *i = parent->first_child() ; i; i = SP_OBJECT_NEXT(i) ) { -- if (i->next == child) -- return i; ++ SPObject *prev = 0; ++ if ( child && SP_IS_GROUP(child->parent) ) { ++ prev = child->getPrev(); } -- return NULL; ++ return prev; } void @@@ -852,9 -843,11 +850,9 @@@ sp_selection_raise(SPDesktop *desktop g_slist_free(rev); } - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_RAISE, - //TRANSLATORS: "Raise" means "to raise an object" in the undo history - C_("Undo action", "Raise")); - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_RAISE, - //TRANSLATORS: only translate "string" in "context|string". - // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS - // "Raise" means "to raise an object" in the undo history - Q_("undo action|Raise")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_RAISE, ++ //TRANSLATORS: "Raise" means "to raise an object" in the undo history ++ C_("Undo action", "Raise")); } void sp_selection_raise_to_top(SPDesktop *desktop) @@@ -888,8 -881,8 +886,8 @@@ g_slist_free(rl); - sp_document_done(document, SP_VERB_SELECTION_TO_FRONT, - SPDocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, -- _("Raise to top")); ++ DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, ++ _("Raise to top")); } void @@@ -951,8 -944,8 +949,8 @@@ sp_selection_lower(SPDesktop *desktop g_slist_free(rev); } - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_LOWER, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_LOWER, -- _("Lower")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_LOWER, ++ _("Lower")); } void sp_selection_lower_to_bottom(SPDesktop *desktop) @@@ -988,7 -981,7 +986,7 @@@ pp = document->getObjectByRepr(sp_repr_parent(repr)); minpos = 0; g_assert(SP_IS_GROUP(pp)); - pc = sp_object_first_child(pp); - pc = pp->first_child(); ++ pc = pp->firstChild(); while (!SP_IS_ITEM(pc)) { minpos += 1; pc = pc->next; @@@ -998,22 -991,22 +996,24 @@@ g_slist_free(rl); - sp_document_done(document, SP_VERB_SELECTION_TO_BACK, - SPDocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK, -- _("Lower to bottom")); ++ DocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK, ++ _("Lower to bottom")); } void sp_undo(SPDesktop *desktop, SPDocument *) { - if (!sp_document_undo(sp_desktop_document(desktop))) - if (!SPDocumentUndo::undo(sp_desktop_document(desktop))) -- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to undo.")); ++ if (!DocumentUndo::undo(sp_desktop_document(desktop))) { ++ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to undo.")); ++ } } void sp_redo(SPDesktop *desktop, SPDocument *) { - if (!sp_document_redo(sp_desktop_document(desktop))) - if (!SPDocumentUndo::redo(sp_desktop_document(desktop))) -- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to redo.")); ++ if (!DocumentUndo::redo(sp_desktop_document(desktop))) { ++ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to redo.")); ++ } } void sp_selection_cut(SPDesktop *desktop) @@@ -1033,12 -1026,12 +1033,12 @@@ take_style_from_item(SPItem *item if (css == NULL) return NULL; - if ((SP_IS_GROUP(item) && SP_OBJECT(item)->children) || - (SP_IS_TEXT(item) && SP_OBJECT(item)->children && SP_OBJECT(item)->children->next == NULL)) { + if ((SP_IS_GROUP(item) && item->children) || + (SP_IS_TEXT(item) && item->children && item->children->next == NULL)) { // if this is a text with exactly one tspan child, merge the style of that tspan as well // If this is a group, merge the style of its topmost (last) child with style -- for (SPObject *last_element = item->lastChild(); last_element != NULL; last_element = SP_OBJECT_PREV(last_element)) { - if (SP_OBJECT_STYLE(last_element) != NULL) { ++ for (SPObject *last_element = item->lastChild(); last_element != NULL; last_element = last_element->getPrev()) { + if ( last_element->style ) { SPCSSAttr *temp = sp_css_attr_from_object(last_element, SP_STYLE_FLAG_IFSET); if (temp) { sp_repr_css_merge(css, temp); @@@ -1073,7 -1066,7 +1073,7 @@@ void sp_selection_paste(SPDesktop *desk { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); if (cm->paste(desktop, in_place)) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE, _("Paste")); - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE, _("Paste")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE, _("Paste")); } } @@@ -1081,7 -1074,7 +1081,7 @@@ void sp_selection_paste_style(SPDeskto { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); if (cm->pasteStyle(desktop)) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_STYLE, _("Paste style")); - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_STYLE, _("Paste style")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_STYLE, _("Paste style")); } } @@@ -1090,8 -1083,8 +1090,8 @@@ void sp_selection_paste_livepatheffect( { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); if (cm->pastePathEffect(desktop)) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_LIVEPATHEFFECT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_LIVEPATHEFFECT, -- _("Paste live path effect")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_LIVEPATHEFFECT, ++ _("Paste live path effect")); } } @@@ -1123,8 -1116,8 +1123,8 @@@ void sp_selection_remove_livepatheffect } - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT, -- _("Remove live path effect")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT, ++ _("Remove live path effect")); } void sp_selection_remove_filter(SPDesktop *desktop) @@@ -1144,8 -1137,8 +1144,8 @@@ sp_desktop_set_style(desktop, css); sp_repr_css_attr_unref(css); - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_FILTER, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_FILTER, -- _("Remove filter")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_REMOVE_FILTER, ++ _("Remove filter")); } @@@ -1153,8 -1146,8 +1153,8 @@@ void sp_selection_paste_size(SPDesktop { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); if (cm->pasteSize(desktop, false, apply_x, apply_y)) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_SIZE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_SIZE, -- _("Paste size")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_SIZE, ++ _("Paste size")); } } @@@ -1162,8 -1155,8 +1162,8 @@@ void sp_selection_paste_size_separately { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); if (cm->pasteSize(desktop, true, apply_x, apply_y)) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_SIZE_SEPARATELY, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_SIZE_SEPARATELY, -- _("Paste size separately")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_PASTE_SIZE_SEPARATELY, ++ _("Paste size separately")); } } @@@ -1183,7 -1176,7 +1183,7 @@@ void sp_selection_to_next_layer(SPDeskt SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); if (next) { GSList *temp_clip = NULL; -- sp_selection_copy_impl(items, &temp_clip, sp_document_repr_doc(dt->doc())); ++ sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); sp_selection_delete_impl(items, false, false); next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers GSList *copied; @@@ -1198,8 -1191,8 +1198,8 @@@ if (temp_clip) g_slist_free(temp_clip); if (next) dt->setCurrentLayer(next); if ( !suppressDone ) { - sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_MOVE_TO_NEXT, - SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_MOVE_TO_NEXT, -- _("Raise to next layer")); ++ DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_MOVE_TO_NEXT, ++ _("Raise to next layer")); } } else { no_more = true; @@@ -1228,7 -1221,7 +1228,7 @@@ void sp_selection_to_prev_layer(SPDeskt SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); if (next) { GSList *temp_clip = NULL; -- sp_selection_copy_impl(items, &temp_clip, sp_document_repr_doc(dt->doc())); // we're in the same doc, so no need to copy defs ++ sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs sp_selection_delete_impl(items, false, false); next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers GSList *copied; @@@ -1243,8 -1236,8 +1243,8 @@@ if (temp_clip) g_slist_free(temp_clip); if (next) dt->setCurrentLayer(next); if ( !suppressDone ) { - sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_MOVE_TO_PREV, - SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_MOVE_TO_PREV, -- _("Lower to previous layer")); ++ DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_MOVE_TO_PREV, ++ _("Lower to previous layer")); } } else { no_more = true; @@@ -1346,7 -1339,7 +1346,7 @@@ void sp_selection_apply_affine(Inkscape // we're moving both a clone and its original or any ancestor in clone chain? bool transform_clone_with_original = selection_contains_original(item, selection); // ...both a text-on-path and its path? - bool transform_textpath_with_path = (SP_IS_TEXT_TEXTPATH(item) && selection->includes( sp_textpath_get_path_item(SP_TEXTPATH(sp_object_first_child(item))) )); - bool transform_textpath_with_path = (SP_IS_TEXT_TEXTPATH(item) && selection->includes( sp_textpath_get_path_item(SP_TEXTPATH(SP_OBJECT(item)->first_child())) )); ++ bool transform_textpath_with_path = (SP_IS_TEXT_TEXTPATH(item) && selection->includes( sp_textpath_get_path_item(SP_TEXTPATH(item->firstChild())) )); // ...both a flowtext and its frame? bool transform_flowtext_with_frame = (SP_IS_FLOWTEXT(item) && selection->includes( SP_FLOWTEXT(item)->get_frame(NULL))); // (only the first frame is checked so far) // ...both an offset and its source? @@@ -1381,16 -1374,16 +1381,17 @@@ * Same for linked offset if we are also moving its source: do not move it. */ if (transform_textpath_with_path || transform_offset_with_source) { // Restore item->transform field from the repr, in case it was changed by seltrans. - sp_object_read_attr(item, "transform"); - SP_OBJECT(item)->readAttr( "transform"); ++ SP_OBJECT(item)->readAttr( "transform" ); } else if (transform_flowtext_with_frame) { // apply the inverse of the region's transform to the <use> so that the flow remains // the same (even though the output itself gets transformed) -- for (SPObject *region = item->firstChild() ; region ; region = SP_OBJECT_NEXT(region)) { -- if (!SP_IS_FLOWREGION(region) && !SP_IS_FLOWREGIONEXCLUDE(region)) -- continue; -- for (SPObject *use = region->firstChild() ; use ; use = SP_OBJECT_NEXT(use)) { -- if (!SP_IS_USE(use)) continue; - sp_item_write_transform(SP_USE(use), SP_OBJECT_REPR(use), item->transform.inverse(), NULL, compensate); - SP_USE(use)->doWriteTransform(SP_OBJECT_REPR(use), item->transform.inverse(), NULL, compensate); ++ for ( SPObject *region = item->firstChild() ; region ; region = region->getNext() ) { ++ if (SP_IS_FLOWREGION(region) || SP_IS_FLOWREGIONEXCLUDE(region)) { ++ for ( SPObject *use = region->firstChild() ; use ; use = use->getNext() ) { ++ if ( SP_IS_USE(use) ) { ++ SP_USE(use)->doWriteTransform(use->getRepr(), item->transform.inverse(), NULL, compensate); ++ } ++ } } } } else if (transform_clone_with_original) { @@@ -1399,10 -1392,10 +1400,10 @@@ // transform and its move compensation are both cancelled out. // restore item->transform field from the repr, in case it was changed by seltrans - sp_object_read_attr(item, "transform"); - SP_OBJECT(item)->readAttr( "transform"); ++ SP_OBJECT(item)->readAttr( "transform" ); // calculate the matrix we need to apply to the clone to cancel its induced transform from its original - Geom::Matrix parent2dt = sp_item_i2d_affine(SP_ITEM(SP_OBJECT_PARENT(item))); + Geom::Matrix parent2dt = SP_ITEM(SP_OBJECT_PARENT(item))->i2d_affine(); Geom::Matrix t = parent2dt * affine * parent2dt.inverse(); Geom::Matrix t_inv = t.inverse(); Geom::Matrix result = t_inv * item->transform * t; @@@ -1459,8 -1452,8 +1460,8 @@@ void sp_selection_remove_transform(SPDe l = l->next; } - sp_document_done(sp_desktop_document(desktop), SP_VERB_OBJECT_FLATTEN, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_OBJECT_FLATTEN, -- _("Remove transform")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_OBJECT_FLATTEN, ++ _("Remove transform")); } void @@@ -1561,9 -1554,9 +1562,9 @@@ void sp_selection_rotate_90(SPDesktop * sp_item_rotate_rel(item, rot_90); } - sp_document_done(sp_desktop_document(desktop), - SPDocumentUndo::done(sp_desktop_document(desktop), -- ccw ? SP_VERB_OBJECT_ROTATE_90_CCW : SP_VERB_OBJECT_ROTATE_90_CW, -- ccw ? _("Rotate 90° CCW") : _("Rotate 90° CW")); ++ DocumentUndo::done(sp_desktop_document(desktop), ++ ccw ? SP_VERB_OBJECT_ROTATE_90_CCW : SP_VERB_OBJECT_ROTATE_90_CW, ++ ccw ? _("Rotate 90° CCW") : _("Rotate 90° CW")); } void @@@ -1579,12 -1572,12 +1580,12 @@@ sp_selection_rotate(Inkscape::Selectio sp_selection_rotate_relative(selection, *center, angle_degrees); - sp_document_maybe_done(sp_desktop_document(selection->desktop()), - SPDocumentUndo::maybe_done(sp_desktop_document(selection->desktop()), -- ( ( angle_degrees > 0 ) -- ? "selector:rotate:ccw" -- : "selector:rotate:cw" ), -- SP_VERB_CONTEXT_SELECT, -- _("Rotate")); ++ DocumentUndo::maybeDone(sp_desktop_document(selection->desktop()), ++ ( ( angle_degrees > 0 ) ++ ? "selector:rotate:ccw" ++ : "selector:rotate:cw" ), ++ SP_VERB_CONTEXT_SELECT, ++ _("Rotate")); } // helper function: @@@ -1626,12 -1619,12 +1627,12 @@@ sp_selection_rotate_screen(Inkscape::Se sp_selection_rotate_relative(selection, *center, zangle); - sp_document_maybe_done(sp_desktop_document(selection->desktop()), - SPDocumentUndo::maybe_done(sp_desktop_document(selection->desktop()), -- ( (angle > 0) -- ? "selector:rotate:ccw" -- : "selector:rotate:cw" ), -- SP_VERB_CONTEXT_SELECT, -- _("Rotate by pixels")); ++ DocumentUndo::maybeDone(sp_desktop_document(selection->desktop()), ++ ( (angle > 0) ++ ? "selector:rotate:ccw" ++ : "selector:rotate:cw" ), ++ SP_VERB_CONTEXT_SELECT, ++ _("Rotate by pixels")); } void @@@ -1656,12 -1649,12 +1657,12 @@@ sp_selection_scale(Inkscape::Selection double const times = 1.0 + grow / max_len; sp_selection_scale_relative(selection, center, Geom::Scale(times, times)); - sp_document_maybe_done(sp_desktop_document(selection->desktop()), - SPDocumentUndo::maybe_done(sp_desktop_document(selection->desktop()), -- ( (grow > 0) -- ? "selector:scale:larger" -- : "selector:scale:smaller" ), -- SP_VERB_CONTEXT_SELECT, -- _("Scale")); ++ DocumentUndo::maybeDone(sp_desktop_document(selection->desktop()), ++ ( (grow > 0) ++ ? "selector:scale:larger" ++ : "selector:scale:smaller" ), ++ SP_VERB_CONTEXT_SELECT, ++ _("Scale")); } void @@@ -1685,8 -1678,8 +1686,8 @@@ sp_selection_scale_times(Inkscape::Sele Geom::Point const center(sel_bbox->midpoint()); sp_selection_scale_relative(selection, center, Geom::Scale(times, times)); - sp_document_done(sp_desktop_document(selection->desktop()), SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_CONTEXT_SELECT, -- _("Scale by whole factor")); ++ DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_CONTEXT_SELECT, ++ _("Scale by whole factor")); } void @@@ -1700,14 -1693,14 +1701,14 @@@ sp_selection_move(SPDesktop *desktop, g sp_selection_move_relative(selection, dx, dy); if (dx == 0) { - sp_document_maybe_done(sp_desktop_document(desktop), "selector:move:vertical", SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "selector:move:vertical", SP_VERB_CONTEXT_SELECT, -- _("Move vertically")); ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), "selector:move:vertical", SP_VERB_CONTEXT_SELECT, ++ _("Move vertically")); } else if (dy == 0) { - sp_document_maybe_done(sp_desktop_document(desktop), "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, -- _("Move horizontally")); ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, ++ _("Move horizontally")); } else { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SELECT, -- _("Move")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SELECT, ++ _("Move")); } } @@@ -1726,14 -1719,14 +1727,14 @@@ sp_selection_move_screen(SPDesktop *des sp_selection_move_relative(selection, zdx, zdy); if (dx == 0) { - sp_document_maybe_done(sp_desktop_document(desktop), "selector:move:vertical", SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "selector:move:vertical", SP_VERB_CONTEXT_SELECT, -- _("Move vertically by pixels")); ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), "selector:move:vertical", SP_VERB_CONTEXT_SELECT, ++ _("Move vertically by pixels")); } else if (dy == 0) { - sp_document_maybe_done(sp_desktop_document(desktop), "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, -- _("Move horizontally by pixels")); ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), "selector:move:horizontal", SP_VERB_CONTEXT_SELECT, ++ _("Move horizontally by pixels")); } else { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SELECT, -- _("Move")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SELECT, ++ _("Move")); } } @@@ -1750,15 -1743,15 +1751,15 @@@ SPItem *next_item_from_list(SPDesktop * struct Forward { typedef SPObject *Iterator; - static Iterator children(SPObject *o) { return sp_object_first_child(o); } - static Iterator children(SPObject *o) { return o->first_child(); } -- static Iterator siblings_after(SPObject *o) { return SP_OBJECT_NEXT(o); } ++ static Iterator children(SPObject *o) { return o->firstChild(); } ++ static Iterator siblings_after(SPObject *o) { return o->getNext(); } static void dispose(Iterator /*i*/) {} static SPObject *object(Iterator i) { return i; } -- static Iterator next(Iterator i) { return SP_OBJECT_NEXT(i); } ++ static Iterator next(Iterator i) { return i->getNext(); } }; - struct Reverse { + struct ListReverse { typedef GSList *Iterator; static Iterator children(SPObject *o) { @@@ -1778,10 -1771,10 +1779,14 @@@ private: static GSList *make_list(SPObject *object, SPObject *limit) { -- GSList *list=NULL; ++ GSList *list = NULL; while ( object != limit ) { ++ if (!object) { // TODO check if this happens in practice ++ g_warning("Unexpected list overrun"); ++ break; ++ } list = g_slist_prepend(list, object); -- object = SP_OBJECT_NEXT(object); ++ object = object->getNext(); } return list; } @@@ -2015,15 -2008,15 +2020,15 @@@ void scroll_to_show_item(SPDesktop *des } --void --sp_selection_clone(SPDesktop *desktop) ++void sp_selection_clone(SPDesktop *desktop) { -- if (desktop == NULL) ++ if (desktop == NULL) { return; ++ } Inkscape::Selection *selection = sp_desktop_selection(desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); // check if something is selected if (selection->isEmpty()) { @@@ -2060,8 -2053,10 +2065,8 @@@ Inkscape::GC::release(clone); } - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_CLONE, - C_("Action","Clone")); - // TRANSLATORS: only translate "string" in "context|string". - // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_CLONE, - Q_("action|Clone")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_CLONE, ++ C_("Action", "Clone")); selection->setReprList(newsel); @@@ -2110,8 -2105,8 +2115,8 @@@ sp_selection_relink(SPDesktop *desktop if (!relinked) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to relink</b> in the selection.")); } else { - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE, -- _("Relink clone")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE, ++ _("Relink clone")); } } @@@ -2182,8 -2172,8 +2187,8 @@@ sp_selection_unlink(SPDesktop *desktop desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to unlink</b> in the selection.")); } - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE, -- _("Unlink clone")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNLINK_CLONE, ++ _("Unlink clone")); } void @@@ -2210,7 -2200,7 +2215,7 @@@ sp_select_clone_original(SPDesktop *des } else if (SP_IS_OFFSET(item) && SP_OFFSET(item)->sourceHref) { original = sp_offset_get_source(SP_OFFSET(item)); } else if (SP_IS_TEXT_TEXTPATH(item)) { - original = sp_textpath_get_path_item(SP_TEXTPATH(sp_object_first_child(item))); - original = sp_textpath_get_path_item(SP_TEXTPATH(SP_OBJECT(item)->first_child())); ++ original = sp_textpath_get_path_item(SP_TEXTPATH(SP_OBJECT(item)->firstChild())); } else if (SP_IS_FLOWTEXT(item)) { original = SP_FLOWTEXT(item)->get_frame(NULL); // first frame only } else { // it's an object that we don't know what to do with @@@ -2261,11 -2251,11 +2266,12 @@@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) { -- if (desktop == NULL) ++ if (desktop == NULL) { return; ++ } SPDocument *doc = sp_desktop_document(desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::Selection *selection = sp_desktop_selection(desktop); @@@ -2275,7 -2265,7 +2281,7 @@@ return; } - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); Geom::OptRect r = selection->bounds(SPItem::RENDERING_BBOX); boost::optional<Geom::Point> c = selection->center(); if ( !r || !c ) { @@@ -2338,8 -2328,8 +2344,8 @@@ g_slist_free(items); - sp_document_done(doc, SP_VERB_EDIT_SELECTION_2_MARKER, - SPDocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_MARKER, -- _("Objects to marker")); ++ DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_MARKER, ++ _("Objects to marker")); } static void sp_selection_to_guides_recursive(SPItem *item, bool deleteitem, bool wholegroups) { @@@ -2348,10 -2338,10 +2354,10 @@@ sp_selection_to_guides_recursive(SP_ITEM(i->data), deleteitem, wholegroups); } } else { - sp_item_convert_item_to_guides(item); + item->convert_item_to_guides(); if (deleteitem) { - SP_OBJECT(item)->deleteObject(true); + item->deleteObject(true); } } } @@@ -2379,17 -2369,17 +2385,18 @@@ void sp_selection_to_guides(SPDesktop * sp_selection_to_guides_recursive(SP_ITEM(i->data), deleteitem, wholegroups); } - sp_document_done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides")); - SPDocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides")); ++ DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides")); } void sp_selection_tile(SPDesktop *desktop, bool apply) { -- if (desktop == NULL) ++ if (desktop == NULL) { return; ++ } SPDocument *doc = sp_desktop_document(desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::Selection *selection = sp_desktop_selection(desktop); @@@ -2399,7 -2389,7 +2406,7 @@@ return; } - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); Geom::OptRect r = selection->bounds(SPItem::RENDERING_BBOX); if ( !r ) { return; @@@ -2482,18 -2472,18 +2489,18 @@@ g_slist_free(items); - sp_document_done(doc, SP_VERB_EDIT_TILE, - SPDocumentUndo::done(doc, SP_VERB_EDIT_TILE, -- _("Objects to pattern")); ++ DocumentUndo::done(doc, SP_VERB_EDIT_TILE, ++ _("Objects to pattern")); } --void --sp_selection_untile(SPDesktop *desktop) ++void sp_selection_untile(SPDesktop *desktop) { -- if (desktop == NULL) ++ if (desktop == NULL) { return; ++ } SPDocument *doc = sp_desktop_document(desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::Selection *selection = sp_desktop_selection(desktop); @@@ -2530,7 -2520,7 +2537,7 @@@ Geom::Matrix pat_transform = to_2geom(pattern_patternTransform(SP_PATTERN(server))); pat_transform *= item->transform; - for (SPObject *child = sp_object_first_child(pattern) ; child != NULL; child = child->next ) { - for (SPObject *child = SP_OBJECT(pattern)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = pattern->firstChild() ; child != NULL; child = child->next ) { Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate(xml_doc); SPItem *i = SP_ITEM(desktop->currentLayer()->appendChildRepr(copy)); @@@ -2538,10 -2528,10 +2545,10 @@@ // use SPObject::setid when mental finishes it to steal ids of // this is needed to make sure the new item has curve (simply requestDisplayUpdate does not work) - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); Geom::Matrix transform( i->transform * pat_transform ); - sp_item_write_transform(i, SP_OBJECT_REPR(i), transform); + i->doWriteTransform(SP_OBJECT_REPR(i), transform); new_select = g_slist_prepend(new_select, i); } @@@ -2554,8 -2544,8 +2561,8 @@@ if (!did) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No pattern fills</b> in the selection.")); } else { - sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_UNTILE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNTILE, -- _("Pattern to objects")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_UNTILE, ++ _("Pattern to objects")); selection->setList(new_select); } } @@@ -2606,16 -2596,16 +2613,13 @@@ sp_selection_get_export_hints(Inkscape: } } --void --sp_document_get_export_hints(SPDocument *doc, char const **filename, float *xdpi, float *ydpi) ++void sp_document_get_export_hints(SPDocument *doc, char const **filename, float *xdpi, float *ydpi) { -- Inkscape::XML::Node * repr = sp_document_repr_root(doc); -- gchar const *dpi_string; ++ Inkscape::XML::Node * repr = doc->getReprRoot(); *filename = repr->attribute("inkscape:export-filename"); -- dpi_string = NULL; -- dpi_string = repr->attribute("inkscape:export-xdpi"); ++ gchar const *dpi_string = repr->attribute("inkscape:export-xdpi"); if (dpi_string != NULL) { *xdpi = atof(dpi_string); } @@@ -2627,14 -2617,14 +2631,14 @@@ } } --void --sp_selection_create_bitmap_copy(SPDesktop *desktop) ++void sp_selection_create_bitmap_copy(SPDesktop *desktop) { -- if (desktop == NULL) ++ if (desktop == NULL) { return; ++ } SPDocument *document = sp_desktop_document(desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::Selection *selection = sp_desktop_selection(desktop); @@@ -2650,7 -2640,7 +2654,7 @@@ // Get the bounding box of the selection NRRect bbox; - sp_document_ensure_up_to_date(document); - document->ensure_up_to_date(); ++ document->ensureUpToDate(); selection->bounds(&bbox); if (NR_RECT_DFLS_TEST_EMPTY(&bbox)) { desktop->clearWaitingCursor(); @@@ -2671,7 -2661,7 +2675,7 @@@ // Create the filename. gchar *const basename = g_strdup_printf("%s-%s-%u.png", -- document->name, ++ document->getName(), SP_OBJECT_REPR(items->data)->attribute("id"), current); // Imagemagick is known not to handle spaces in filenames, so we replace anything but letters, @@@ -2680,8 -2670,8 +2684,8 @@@ // Build the complete path by adding document base dir, if set, otherwise home dir gchar * directory = NULL; -- if (SP_DOCUMENT_URI(document)) { -- directory = g_dirname(SP_DOCUMENT_URI(document)); ++ if ( document->getURI() ) { ++ directory = g_dirname( document->getURI() ); } if (directory == NULL) { directory = homedir_path(NULL); @@@ -2817,8 -2807,8 +2821,8 @@@ gdk_pixbuf_unref(pb); // Complete undoable transaction - sp_document_done(document, SP_VERB_SELECTION_CREATE_BITMAP, - SPDocumentUndo::done(document, SP_VERB_SELECTION_CREATE_BITMAP, -- _("Create bitmap")); ++ DocumentUndo::done(document, SP_VERB_SELECTION_CREATE_BITMAP, ++ _("Create bitmap")); } desktop->clearWaitingCursor(); @@@ -2836,14 -2826,14 +2840,14 @@@ * If \a apply_clip_path parameter is true, clipPath is created, otherwise mask * */ --void --sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer) ++void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer) { -- if (desktop == NULL) ++ if (desktop == NULL) { return; ++ } SPDocument *doc = sp_desktop_document(desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::Selection *selection = sp_desktop_selection(desktop); @@@ -2865,7 -2855,7 +2869,7 @@@ } // /END FIXME - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); GSList *items = g_slist_copy((GSList *) selection->itemList()); @@@ -3033,18 -3023,18 +3037,20 @@@ selection->addList(items_to_select); g_slist_free(items_to_select); -- if (apply_clip_path) - sp_document_done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path")); - SPDocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path")); -- else - sp_document_done(doc, SP_VERB_OBJECT_SET_MASK, _("Set mask")); - SPDocumentUndo::done(doc, SP_VERB_OBJECT_SET_MASK, _("Set mask")); ++ if (apply_clip_path) { ++ DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path")); ++ } else { ++ DocumentUndo::done(doc, SP_VERB_OBJECT_SET_MASK, _("Set mask")); ++ } } void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { -- if (desktop == NULL) ++ if (desktop == NULL) { return; ++ } SPDocument *doc = sp_desktop_document(desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::Selection *selection = sp_desktop_selection(desktop); // check if something is selected @@@ -3056,7 -3046,7 +3062,7 @@@ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool remove_original = prefs->getBool("/options/maskobject/remove", true); bool ungroup_masked = prefs->getBool("/options/maskobject/ungrouping", true); - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); gchar const *attributeName = apply_clip_path ? "clip-path" : "mask"; std::map<SPObject*,SPItem*> referenced_objects; @@@ -3109,7 -3099,7 +3115,7 @@@ for ( std::map<SPObject*,SPItem*>::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) { SPObject *obj = (*it).first; // Group containing the clipped paths or masks GSList *items_to_move = NULL; - for (SPObject *child = sp_object_first_child(obj) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = obj->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) { // Collect all clipped paths and masks within a single group Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate(xml_doc); items_to_move = g_slist_prepend(items_to_move, copy); @@@ -3159,10 -3149,10 +3165,11 @@@ selection->addList(items_to_select); g_slist_free(items_to_select); -- if (apply_clip_path) - sp_document_done(doc, SP_VERB_OBJECT_UNSET_CLIPPATH, _("Release clipping path")); - SPDocumentUndo::done(doc, SP_VERB_OBJECT_UNSET_CLIPPATH, _("Release clipping path")); -- else - sp_document_done(doc, SP_VERB_OBJECT_UNSET_MASK, _("Release mask")); - SPDocumentUndo::done(doc, SP_VERB_OBJECT_UNSET_MASK, _("Release mask")); ++ if (apply_clip_path) { ++ DocumentUndo::done(doc, SP_VERB_OBJECT_UNSET_CLIPPATH, _("Release clipping path")); ++ } else { ++ DocumentUndo::done(doc, SP_VERB_OBJECT_UNSET_MASK, _("Release mask")); ++ } } /** @@@ -3199,8 -3189,8 +3206,8 @@@ voi verb_fit_canvas_to_selection(SPDesktop *const desktop) { if (fit_canvas_to_selection(desktop)) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_SELECTION, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_SELECTION, -- _("Fit Page to Selection")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_SELECTION, ++ _("Fit Page to Selection")); } } @@@ -3213,9 -3203,9 +3220,9 @@@ fit_canvas_to_drawing(SPDocument *doc, { g_return_val_if_fail(doc != NULL, false); - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); SPItem const *const root = SP_ITEM(doc->root); - Geom::OptRect const bbox(root->getBounds(sp_item_i2d_affine(root))); + Geom::OptRect const bbox(root->getBounds(root->i2d_affine())); if (bbox) { doc->fitToRect(*bbox, with_margins); return true; @@@ -3228,8 -3218,8 +3235,8 @@@ voi verb_fit_canvas_to_drawing(SPDesktop *desktop) { if (fit_canvas_to_drawing(sp_desktop_document(desktop))) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_DRAWING, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_DRAWING, -- _("Fit Page to Drawing")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_DRAWING, ++ _("Fit Page to Drawing")); } } @@@ -3249,8 -3239,8 +3256,8 @@@ void fit_canvas_to_selection_or_drawing ? fit_canvas_to_drawing(doc, true) : fit_canvas_to_selection(desktop, true) ); if (changed) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING, -- _("Fit Page to Selection or Drawing")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING, ++ _("Fit Page to Selection or Drawing")); } }; diff --cc src/selection-chemistry.h index 1f975975a,48d1a2d16..65d1ba296 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@@ -9,6 -9,6 +9,7 @@@ * Frank Felfe <innerspace@iname.com> * bulia byak <buliabyak@users.sf.net> * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2010 authors * Copyright (C) 2001-2002 Ximian, Inc. diff --cc src/selection-describer.cpp index c9d6871c3,bd8d8e12e..7bc6adf38 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@@ -4,6 -4,6 +4,7 @@@ * Authors: * MenTaLguY <mental@rydia.net> * bulia byak <buliabyak@users.sf.net> ++ * Abhishek Sharma * * Copyright (C) 2004-2006 Authors * diff --cc src/selection.cpp index a4508d9bb,acf6a8e6e..9cef87076 --- a/src/selection.cpp +++ b/src/selection.cpp @@@ -6,6 -6,6 +6,7 @@@ * MenTaLguY <mental@rydia.net> * bulia byak <buliabyak@users.sf.net> * Andrius R. <knutux@gmail.com> ++ * Abhishek Sharma * * Copyright (C) 2006 Andrius R. * Copyright (C) 2004-2005 MenTaLguY diff --cc src/seltrans.cpp index cdfcee742,627620a60..b0e19e60c --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@@ -6,6 -6,6 +6,7 @@@ * bulia byak <buliabyak@users.sf.net> * Carl Hetherington <inkscape@carlh.net> * Diederik van Lierop <mail@diedenrezi.nl> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 1999-2008 Authors @@@ -45,6 -45,6 +46,7 @@@ #include <2geom/angle.h> #include "display/snap-indicator.h" ++using Inkscape::DocumentUndo; static void sp_remove_handles(SPKnot *knot[], gint num); @@@ -505,17 -520,17 +507,17 @@@ void Inkscape::SelTrans::ungrab( _items_centers.clear(); if (_current_relative_affine.isTranslation()) { - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, -- _("Move")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, ++ _("Move")); } else if (_current_relative_affine.without_translation().isScale()) { - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, -- _("Scale")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, ++ _("Scale")); } else if (_current_relative_affine.without_translation().isRotation()) { - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, -- _("Rotate")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, ++ _("Rotate")); } else { - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, -- _("Skew")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, ++ _("Skew")); } } else { @@@ -526,8 -541,8 +528,8 @@@ SPItem *it = (SPItem*)SP_OBJECT(l->data); SP_OBJECT(it)->updateRepr(); } - sp_document_done (sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, -- _("Set center")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, ++ _("Set center")); } _items.clear(); @@@ -601,8 -616,8 +603,8 @@@ void Inkscape::SelTrans::stamp( Inkscape::GC::release(copy_repr); l = l->next; } - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, -- _("Stamp")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, ++ _("Stamp")); } if ( fixup && _stamp_cache ) { @@@ -790,8 -805,8 +792,8 @@@ void Inkscape::SelTrans::handleClick(SP _center_is_set = false; // center has changed _updateHandles(); } - sp_document_done (sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, -- _("Reset center")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, ++ _("Reset center")); } break; default: diff --cc src/sp-anchor.cpp index aabefdfdb,9a5e8b1c1..e57ac8a58 --- a/src/sp-anchor.cpp +++ b/src/sp-anchor.cpp @@@ -1,10 -1,10 +1,9 @@@ --#define __SP_ANCHOR_C__ -- /* * SVG <a> element implementation * * Author: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. @@@ -89,14 -89,14 +88,14 @@@ static void sp_anchor_build(SPObject *o ((SPObjectClass *) (parent_class))->build(object, document, repr); } - sp_object_read_attr(object, "xlink:type"); - sp_object_read_attr(object, "xlink:role"); - sp_object_read_attr(object, "xlink:arcrole"); - sp_object_read_attr(object, "xlink:title"); - sp_object_read_attr(object, "xlink:show"); - sp_object_read_attr(object, "xlink:actuate"); - sp_object_read_attr(object, "xlink:href"); - sp_object_read_attr(object, "target"); - object->readAttr( "xlink:type"); - object->readAttr( "xlink:role"); - object->readAttr( "xlink:arcrole"); - object->readAttr( "xlink:title"); - object->readAttr( "xlink:show"); - object->readAttr( "xlink:actuate"); - object->readAttr( "xlink:href"); - object->readAttr( "target"); ++ object->readAttr( "xlink:type" ); ++ object->readAttr( "xlink:role" ); ++ object->readAttr( "xlink:arcrole" ); ++ object->readAttr( "xlink:title" ); ++ object->readAttr( "xlink:show" ); ++ object->readAttr( "xlink:actuate" ); ++ object->readAttr( "xlink:href" ); ++ object->readAttr( "target" ); } static void sp_anchor_release(SPObject *object) @@@ -154,13 -154,15 +153,15 @@@ static Inkscape::XML::Node *sp_anchor_w repr->setAttribute("xlink:href", anchor->href); if (repr != SP_OBJECT_REPR(object)) { - COPY_ATTR(repr, object->repr, "xlink:type"); - COPY_ATTR(repr, object->repr, "xlink:role"); - COPY_ATTR(repr, object->repr, "xlink:arcrole"); - COPY_ATTR(repr, object->repr, "xlink:title"); - COPY_ATTR(repr, object->repr, "xlink:show"); - COPY_ATTR(repr, object->repr, "xlink:actuate"); - COPY_ATTR(repr, object->repr, "target"); - /* XML Tree being directly used while it shouldn't be in the - below COPY_ATTR lines*/ ++ // XML Tree being directly used while it shouldn't be in the ++ // below COPY_ATTR lines + COPY_ATTR(repr, object->getRepr(), "xlink:type"); + COPY_ATTR(repr, object->getRepr(), "xlink:role"); + COPY_ATTR(repr, object->getRepr(), "xlink:arcrole"); + COPY_ATTR(repr, object->getRepr(), "xlink:title"); + COPY_ATTR(repr, object->getRepr(), "xlink:show"); + COPY_ATTR(repr, object->getRepr(), "xlink:actuate"); + COPY_ATTR(repr, object->getRepr(), "target"); } if (((SPObjectClass *) (parent_class))->write) { diff --cc src/sp-animation.cpp index 132d0aa0f,85fa615de..f0796b7c6 --- a/src/sp-animation.cpp +++ b/src/sp-animation.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_ANIMATION_C__ -- /** \file * SVG <animate> implementation. * @@@ -8,6 -8,6 +6,7 @@@ /* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 2002 Lauris Kaplinski * @@@ -89,18 -89,18 +88,18 @@@ sp_animation_build(SPObject *object, SP if (((SPObjectClass *) animation_parent_class)->build) ((SPObjectClass *) animation_parent_class)->build(object, document, repr); - sp_object_read_attr(object, "xlink:href"); - sp_object_read_attr(object, "attributeName"); - sp_object_read_attr(object, "attributeType"); - sp_object_read_attr(object, "begin"); - sp_object_read_attr(object, "dur"); - sp_object_read_attr(object, "end"); - sp_object_read_attr(object, "min"); - sp_object_read_attr(object, "max"); - sp_object_read_attr(object, "restart"); - sp_object_read_attr(object, "repeatCount"); - sp_object_read_attr(object, "repeatDur"); - sp_object_read_attr(object, "fill"); - object->readAttr( "xlink:href"); - object->readAttr( "attributeName"); - object->readAttr( "attributeType"); - object->readAttr( "begin"); - object->readAttr( "dur"); - object->readAttr( "end"); - object->readAttr( "min"); - object->readAttr( "max"); - object->readAttr( "restart"); - object->readAttr( "repeatCount"); - object->readAttr( "repeatDur"); - object->readAttr( "fill"); ++ object->readAttr( "xlink:href" ); ++ object->readAttr( "attributeName" ); ++ object->readAttr( "attributeType" ); ++ object->readAttr( "begin" ); ++ object->readAttr( "dur" ); ++ object->readAttr( "end" ); ++ object->readAttr( "min" ); ++ object->readAttr( "max" ); ++ object->readAttr( "restart" ); ++ object->readAttr( "repeatCount" ); ++ object->readAttr( "repeatDur" ); ++ object->readAttr( "fill" ); } static void @@@ -176,15 -176,15 +175,15 @@@ sp_ianimation_build(SPObject *object, S if (((SPObjectClass *) ianimation_parent_class)->build) ((SPObjectClass *) ianimation_parent_class)->build(object, document, repr); - sp_object_read_attr(object, "calcMode"); - sp_object_read_attr(object, "values"); - sp_object_read_attr(object, "keyTimes"); - sp_object_read_attr(object, "keySplines"); - sp_object_read_attr(object, "from"); - sp_object_read_attr(object, "to"); - sp_object_read_attr(object, "by"); - sp_object_read_attr(object, "additive"); - sp_object_read_attr(object, "accumulate"); - object->readAttr( "calcMode"); - object->readAttr( "values"); - object->readAttr( "keyTimes"); - object->readAttr( "keySplines"); - object->readAttr( "from"); - object->readAttr( "to"); - object->readAttr( "by"); - object->readAttr( "additive"); - object->readAttr( "accumulate"); ++ object->readAttr( "calcMode" ); ++ object->readAttr( "values" ); ++ object->readAttr( "keyTimes" ); ++ object->readAttr( "keySplines" ); ++ object->readAttr( "from" ); ++ object->readAttr( "to" ); ++ object->readAttr( "by" ); ++ object->readAttr( "additive" ); ++ object->readAttr( "accumulate" ); } static void diff --cc src/sp-clippath.cpp index 856c10b1e,d074ef197..16368b9c6 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@@ -1,10 -1,10 +1,10 @@@ --#define __SP_CLIPPATH_C__ -- /* * SVG <clipPath> implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2001-2002 authors * Copyright (C) 2001 Ximian, Inc. @@@ -37,24 -37,25 +37,13 @@@ struct SPClipPathView NRRect bbox; }; - static void sp_clippath_class_init(SPClipPathClass *klass); -/*static void sp_clippath_class_init(SPClipPathClass *klass); --static void sp_clippath_init(SPClipPath *clippath); -- --static void sp_clippath_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); --static void sp_clippath_release(SPObject * object); --static void sp_clippath_set(SPObject *object, unsigned int key, gchar const *value); --static void sp_clippath_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); --static void sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags); --static void sp_clippath_modified(SPObject *object, guint flags); - static Inkscape::XML::Node *sp_clippath_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static Inkscape::XML::Node *sp_clippath_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);*/ -- SPClipPathView *sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, NRArenaItem *arenaitem); SPClipPathView *sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view); - static SPObjectGroupClass *parent_class; -//static SPObjectGroupClass *parent_class; + SPObjectGroupClass * SPClipPathClass::static_parent_class = 0; GType - sp_clippath_get_type(void) + SPClipPath::sp_clippath_get_type(void) { static GType type = 0; if (!type) { @@@ -65,32 -66,32 +54,30 @@@ NULL, NULL, sizeof(SPClipPath), 16, -- (GInstanceInitFunc) sp_clippath_init, -- NULL, /* value_table */ ++ (GInstanceInitFunc) SPClipPath::init, ++ NULL, /* value_table */ }; type = g_type_register_static(SP_TYPE_OBJECTGROUP, "SPClipPath", &info, (GTypeFlags)0); } return type; } - static void - sp_clippath_class_init(SPClipPathClass *klass) -void -SPClipPathClass::sp_clippath_class_init(SPClipPathClass *klass) ++void SPClipPathClass::sp_clippath_class_init(SPClipPathClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; - parent_class = (SPObjectGroupClass*)g_type_class_ref(SP_TYPE_OBJECTGROUP); + static_parent_class = (SPObjectGroupClass*)g_type_class_ref(SP_TYPE_OBJECTGROUP); - sp_object_class->build = sp_clippath_build; - sp_object_class->release = sp_clippath_release; - sp_object_class->set = sp_clippath_set; - sp_object_class->child_added = sp_clippath_child_added; - sp_object_class->update = sp_clippath_update; - sp_object_class->modified = sp_clippath_modified; - sp_object_class->write = sp_clippath_write; - sp_object_class->build = SPClipPath::sp_clippath_build; - sp_object_class->release = SPClipPath::sp_clippath_release; - sp_object_class->set = SPClipPath::sp_clippath_set; - sp_object_class->child_added = SPClipPath::sp_clippath_child_added; - sp_object_class->update = SPClipPath::sp_clippath_update; - sp_object_class->modified = SPClipPath::sp_clippath_modified; - sp_object_class->write = SPClipPath::sp_clippath_write; ++ sp_object_class->build = SPClipPath::build; ++ sp_object_class->release = SPClipPath::release; ++ sp_object_class->set = SPClipPath::set; ++ sp_object_class->child_added = SPClipPath::childAdded; ++ sp_object_class->update = SPClipPath::update; ++ sp_object_class->modified = SPClipPath::modified; ++ sp_object_class->write = SPClipPath::write; } - static void - sp_clippath_init(SPClipPath *cp) -void -SPClipPath::sp_clippath_init(SPClipPath *cp) ++void SPClipPath::init(SPClipPath *cp) { cp->clipPathUnits_set = FALSE; cp->clipPathUnits = SP_CONTENT_UNITS_USERSPACEONUSE; @@@ -98,24 -99,24 +85,22 @@@ cp->display = NULL; } - static void - sp_clippath_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -void -SPClipPath::sp_clippath_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) ++void SPClipPath::build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) parent_class)->build) - ((SPObjectClass *) parent_class)->build(object, document, repr); + if (((SPObjectClass *) SPClipPathClass::static_parent_class)->build) + ((SPObjectClass *) SPClipPathClass::static_parent_class)->build(object, document, repr); - sp_object_read_attr(object, "clipPathUnits"); - object->readAttr( "clipPathUnits"); ++ object->readAttr( "clipPathUnits" ); /* Register ourselves */ - sp_document_add_resource(document, "clipPath", object); - document->add_resource("clipPath", object); ++ document->addResource("clipPath", object); } - static void - sp_clippath_release(SPObject * object) -void -SPClipPath::sp_clippath_release(SPObject * object) ++void SPClipPath::release(SPObject * object) { if (SP_OBJECT_DOCUMENT(object)) { /* Unregister ourselves */ - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "clipPath", object); - SP_OBJECT_DOCUMENT(object)->remove_resource("clipPath", object); ++ SP_OBJECT_DOCUMENT(object)->removeResource("clipPath", object); } SPClipPath *cp = SP_CLIPPATH(object); @@@ -129,13 -130,13 +114,12 @@@ } } - static void - sp_clippath_set(SPObject *object, unsigned int key, gchar const *value) -void -SPClipPath::sp_clippath_set(SPObject *object, unsigned int key, gchar const *value) ++void SPClipPath::set(SPObject *object, unsigned int key, gchar const *value) { SPClipPath *cp = SP_CLIPPATH(object); switch (key) { -- case SP_ATTR_CLIPPATHUNITS: ++ case SP_ATTR_CLIPPATHUNITS: cp->clipPathUnits = SP_CONTENT_UNITS_USERSPACEONUSE; cp->clipPathUnits_set = FALSE; if (value) { @@@ -148,18 -149,18 +132,18 @@@ } object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; -- default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set(object, key, value); - if (((SPObjectClass *) SPClipPathClass::static_parent_class)->set) ++ default: ++ if (((SPObjectClass *) SPClipPathClass::static_parent_class)->set) { + ((SPObjectClass *) SPClipPathClass::static_parent_class)->set(object, key, value); ++ } break; } } - static void - sp_clippath_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) -void -SPClipPath::sp_clippath_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) ++void SPClipPath::childAdded(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { /* Invoke SPObjectGroup implementation */ - ((SPObjectClass *) (parent_class))->child_added(object, child, ref); + ((SPObjectClass *) (SPClipPathClass::static_parent_class))->child_added(object, child, ref); /* Show new object */ SPObject *ochild = SP_OBJECT_DOCUMENT(object)->getObjectByRepr(child); @@@ -177,8 -177,8 +160,7 @@@ } } - static void - sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags) -void -SPClipPath::sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags) ++void SPClipPath::update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@@ -188,7 -188,7 +170,7 @@@ SPObjectGroup *og = SP_OBJECTGROUP(object); GSList *l = NULL; - for (SPObject *child = sp_object_first_child(SP_OBJECT(og)); child != NULL; child = SP_OBJECT_NEXT(child)) { - for (SPObject *child = SP_OBJECT(og)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { ++ for ( SPObject *child = og->firstChild(); child; child = child->getNext()) { g_object_ref(G_OBJECT(child)); l = g_slist_prepend(l, child); } @@@ -215,8 -215,8 +197,7 @@@ } } - static void - sp_clippath_modified(SPObject *object, guint flags) -void -SPClipPath::sp_clippath_modified(SPObject *object, guint flags) ++void SPClipPath::modified(SPObject *object, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@@ -226,7 -226,7 +207,7 @@@ SPObjectGroup *og = SP_OBJECTGROUP(object); GSList *l = NULL; - for (SPObject *child = sp_object_first_child(SP_OBJECT(og)); child != NULL; child = SP_OBJECT_NEXT(child)) { - for (SPObject *child = SP_OBJECT(og)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { ++ for (SPObject *child = og->firstChild(); child; child = child->getNext()) { g_object_ref(G_OBJECT(child)); l = g_slist_prepend(l, child); } @@@ -241,33 -241,33 +222,30 @@@ } } - static Inkscape::XML::Node * - sp_clippath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) -Inkscape::XML::Node * -SPClipPath::sp_clippath_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) ++Inkscape::XML::Node *SPClipPath::write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:clipPath"); } - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); - if (((SPObjectClass *) (SPClipPathClass::static_parent_class))->write) ++ if (((SPObjectClass *) (SPClipPathClass::static_parent_class))->write) { + ((SPObjectClass *) (SPClipPathClass::static_parent_class))->write(object, xml_doc, repr, flags); ++ } return repr; } --NRArenaItem * - sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key) -SPClipPath::sp_clippath_show(NRArena *arena, unsigned int key) ++NRArenaItem *SPClipPath::show(NRArena *arena, unsigned int key) { - g_return_val_if_fail(cp != NULL, NULL); - g_return_val_if_fail(SP_IS_CLIPPATH(cp), NULL); - //g_return_val_if_fail(cp != NULL, NULL); - //g_return_val_if_fail(SP_IS_CLIPPATH(cp), NULL); g_return_val_if_fail(arena != NULL, NULL); g_return_val_if_fail(NR_IS_ARENA(arena), NULL); NRArenaItem *ai = NRArenaGroup::create(arena); - cp->display = sp_clippath_view_new_prepend(cp->display, key, ai); - this->display = sp_clippath_view_new_prepend(this->display, key, ai); ++ display = sp_clippath_view_new_prepend(display, key, ai); - for (SPObject *child = sp_object_first_child(SP_OBJECT(cp)) ; child != NULL; child = SP_OBJECT_NEXT(child)) { - for (SPObject *child = this->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child)) { ++ for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) { if (SP_IS_ITEM(child)) { - NRArenaItem *ac = sp_item_invoke_show(SP_ITEM(child), arena, key, SP_ITEM_REFERENCE_FLAGS); + NRArenaItem *ac = SP_ITEM(child)->invoke_show(arena, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { /* The order is not important in clippath */ nr_arena_item_add_child(ai, ac, NULL); @@@ -275,32 -275,32 +253,28 @@@ } } - if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - Geom::Matrix t(Geom::Scale(cp->display->bbox.x1 - cp->display->bbox.x0, cp->display->bbox.y1 - cp->display->bbox.y0)); - t[4] = cp->display->bbox.x0; - t[5] = cp->display->bbox.y0; - if (this->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { - Geom::Matrix t(Geom::Scale(this->display->bbox.x1 - this->display->bbox.x0, this->display->bbox.y1 - this->display->bbox.y0)); - t[4] = this->display->bbox.x0; - t[5] = this->display->bbox.y0; ++ if (clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { ++ Geom::Matrix t(Geom::Scale(display->bbox.x1 - display->bbox.x0, display->bbox.y1 - display->bbox.y0)); ++ t[4] = display->bbox.x0; ++ t[5] = display->bbox.y0; nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), &t); } return ai; } --void - sp_clippath_hide(SPClipPath *cp, unsigned int key) -SPClipPath::sp_clippath_hide(unsigned int key) ++void SPClipPath::hide(unsigned int key) { - g_return_if_fail(cp != NULL); - g_return_if_fail(SP_IS_CLIPPATH(cp)); - //g_return_if_fail(cp != NULL); - //g_return_if_fail(SP_IS_CLIPPATH(cp)); -- - for (SPObject *child = sp_object_first_child(SP_OBJECT(cp)) ; child != NULL; child = SP_OBJECT_NEXT(child)) { - for (SPObject *child = this->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child)) { ++ for ( SPObject *child = firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM(child)) { - sp_item_invoke_hide(SP_ITEM(child), key); + SP_ITEM(child)->invoke_hide(key); } } - for (SPClipPathView *v = cp->display; v != NULL; v = v->next) { - for (SPClipPathView *v = this->display; v != NULL; v = v->next) { ++ for (SPClipPathView *v = display; v != NULL; v = v->next) { if (v->key == key) { /* We simply unref and let item to manage this in handler */ - cp->display = sp_clippath_view_list_remove(cp->display, v); - this->display = sp_clippath_view_list_remove(this->display, v); ++ display = sp_clippath_view_list_remove(display, v); return; } } @@@ -308,10 -308,10 +282,9 @@@ g_assert_not_reached(); } --void - sp_clippath_set_bbox(SPClipPath *cp, unsigned int key, NRRect *bbox) -SPClipPath::sp_clippath_set_bbox(unsigned int key, NRRect *bbox) ++void SPClipPath::setBBox(unsigned int key, NRRect *bbox) { - for (SPClipPathView *v = cp->display; v != NULL; v = v->next) { - for (SPClipPathView *v = this->display; v != NULL; v = v->next) { ++ for (SPClipPathView *v = display; v != NULL; v = v->next) { if (v->key == key) { if (!NR_DF_TEST_CLOSE(v->bbox.x0, bbox->x0, NR_EPSILON) || !NR_DF_TEST_CLOSE(v->bbox.y0, bbox->y0, NR_EPSILON) || @@@ -324,24 -324,24 +297,26 @@@ } } --void - sp_clippath_get_bbox(SPClipPath *cp, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/) -SPClipPath::sp_clippath_get_bbox(NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/) ++void SPClipPath::getBBox(NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/) { -- SPObject *i; - for (i = sp_object_first_child(SP_OBJECT(cp)); i && !SP_IS_ITEM(i); i = SP_OBJECT_NEXT(i)){}; - for (i = this->first_child(); i && !SP_IS_ITEM(i); i = SP_OBJECT_NEXT(i)){}; -- if (!i) return; ++ SPObject *i = 0; ++ for (i = firstChild(); i && !SP_IS_ITEM(i); i = i->getNext()) { ++ } ++ if (!i) { ++ return; ++ } - sp_item_invoke_bbox_full(SP_ITEM(i), bbox, Geom::Matrix(SP_ITEM(i)->transform) * transform, SPItem::GEOMETRIC_BBOX, FALSE); + SP_ITEM(i)->invoke_bbox_full( bbox, Geom::Matrix(SP_ITEM(i)->transform) * transform, SPItem::GEOMETRIC_BBOX, FALSE); SPObject *i_start = i; while (i != NULL) { if (i != i_start) { NRRect i_box; - sp_item_invoke_bbox_full(SP_ITEM(i), &i_box, Geom::Matrix(SP_ITEM(i)->transform) * transform, SPItem::GEOMETRIC_BBOX, FALSE); + SP_ITEM(i)->invoke_bbox_full( &i_box, Geom::Matrix(SP_ITEM(i)->transform) * transform, SPItem::GEOMETRIC_BBOX, FALSE); nr_rect_d_union (bbox, bbox, &i_box); } -- i = SP_OBJECT_NEXT(i); -- for (; i && !SP_IS_ITEM(i); i = SP_OBJECT_NEXT(i)){}; ++ i = i->getNext(); ++ for (; i && !SP_IS_ITEM(i); i = i->getNext()){}; } } @@@ -380,12 -380,12 +355,11 @@@ sp_clippath_view_list_remove(SPClipPath } // Create a mask element (using passed elements), add it to <defs> --const gchar * - sp_clippath_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform) -SPClipPath::create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform) ++const gchar *SPClipPath::create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform) { Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document)); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:clipPath"); repr->setAttribute("clipPathUnits", "userSpaceOnUse"); diff --cc src/sp-clippath.h index 02395f3d2,239dca049..a622df1f6 --- a/src/sp-clippath.h +++ b/src/sp-clippath.h @@@ -1,11 -1,11 +1,13 @@@ --#ifndef __SP_CLIPPATH_H__ --#define __SP_CLIPPATH_H__ ++#ifndef SEEN_SP_CLIPPATH_H ++#define SEEN_SP_CLIPPATH_H /* * SVG <clipPath> implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma ++ * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2001-2002 authors * Copyright (C) 2001 Ximian, Inc. @@@ -13,11 -13,11 +15,11 @@@ * Released under GNU GPL, read the file 'COPYING' for more information */ - #define SP_TYPE_CLIPPATH (sp_clippath_get_type ()) -#define SP_TYPE_CLIPPATH (SPClipPath::sp_clippath_get_type ()) --#define SP_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CLIPPATH, SPClipPath)) --#define SP_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_CLIPPATH, SPClipPathClass)) --#define SP_IS_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_CLIPPATH)) --#define SP_IS_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_CLIPPATH)) ++#define SP_TYPE_CLIPPATH (SPClipPath::sp_clippath_get_type()) ++#define SP_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CLIPPATH, SPClipPath)) ++#define SP_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_CLIPPATH, SPClipPathClass)) ++#define SP_IS_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CLIPPATH)) ++#define SP_IS_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_CLIPPATH)) class SPClipPathView; @@@ -27,27 -27,54 +29,55 @@@ #include "uri-references.h" #include "xml/node.h" - struct SPClipPath : public SPObjectGroup { - class Reference; + class SPClipPath : public SPObjectGroup { - public: - class Reference; ++public: ++ class Reference; + - unsigned int clipPathUnits_set : 1; - unsigned int clipPathUnits : 1; ++ unsigned int clipPathUnits_set : 1; ++ unsigned int clipPathUnits : 1; - SPClipPathView *display; - }; - unsigned int clipPathUnits_set : 1; - unsigned int clipPathUnits : 1; ++ SPClipPathView *display; ++ static const gchar *create(GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform); ++ static GType sp_clippath_get_type(void); + - SPClipPathView *display; - static const gchar *create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform); - static GType sp_clippath_get_type (void); ++ NRArenaItem *show(NRArena *arena, unsigned int key); ++ void hide(unsigned int key); + - NRArenaItem *sp_clippath_show(NRArena *arena, unsigned int key); - void sp_clippath_hide(unsigned int key); ++ void setBBox(unsigned int key, NRRect *bbox); ++ void getBBox(NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); - struct SPClipPathClass { - SPObjectGroupClass parent_class; - void sp_clippath_set_bbox(unsigned int key, NRRect *bbox); - void sp_clippath_get_bbox(NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); - private: - static void sp_clippath_init(SPClipPath *clippath); ++private: ++ static void init(SPClipPath *clippath); + - static void sp_clippath_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); - static void sp_clippath_release(SPObject * object); - static void sp_clippath_set(SPObject *object, unsigned int key, gchar const *value); - static void sp_clippath_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); - static void sp_clippath_update(SPObject *object, SPCtx *ctx, guint flags); - static void sp_clippath_modified(SPObject *object, guint flags); - static Inkscape::XML::Node *sp_clippath_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); ++ static void build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); ++ static void release(SPObject * object); ++ static void set(SPObject *object, unsigned int key, gchar const *value); ++ static void childAdded(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); ++ static void update(SPObject *object, SPCtx *ctx, guint flags); ++ static void modified(SPObject *object, guint flags); ++ static Inkscape::XML::Node *write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); + - friend class SPClipPathClass; ++ friend class SPClipPathClass; }; - GType sp_clippath_get_type (void); + class SPClipPathClass { - public: - SPObjectGroupClass parent_class; - private: - static void sp_clippath_class_init(SPClipPathClass *klass); - static SPObjectGroupClass *static_parent_class; ++public: ++ SPObjectGroupClass parent_class; + - friend class SPClipPath; -}; ++private: ++ static void sp_clippath_class_init(SPClipPathClass *klass); ++ static SPObjectGroupClass *static_parent_class; + -//GType sp_clippath_get_type (void); ++ friend class SPClipPath; ++}; class SPClipPathReference : public Inkscape::URIReference { public: -- SPClipPathReference(SPObject *obj) : URIReference(obj) {} -- SPClipPath *getObject() const { -- return (SPClipPath *)URIReference::getObject(); -- } ++ SPClipPathReference(SPObject *obj) : URIReference(obj) {} ++ SPClipPath *getObject() const { ++ return (SPClipPath *)URIReference::getObject(); ++ } ++ protected: /** * If the owner element of this reference (the element with <... clippath="...">) @@@ -55,14 -82,16 +85,16 @@@ * \return false if obj is not a clippath or if obj is a parent of this * reference's owner element. True otherwise. */ -- virtual bool _acceptObject(SPObject *obj) const { -- if (!SP_IS_CLIPPATH(obj)) { -- return false; -- } -- SPObject * const owner = this->getOwner(); ++ virtual bool _acceptObject(SPObject *obj) const { ++ if (!SP_IS_CLIPPATH(obj)) { ++ return false; ++ } ++ SPObject * const owner = this->getOwner(); if (obj->isAncestorOf(owner)) { - Inkscape::XML::Node * const owner_repr = owner->repr; - Inkscape::XML::Node * const obj_repr = obj->repr; - //XML Tree being used directly here while it shouldn't be... ++ //XML Tree being used directly here while it shouldn't be... + Inkscape::XML::Node * const owner_repr = owner->getRepr(); - //XML Tree being used directly here while it shouldn't be... ++ //XML Tree being used directly here while it shouldn't be... + Inkscape::XML::Node * const obj_repr = obj->getRepr(); gchar const * owner_name = NULL; gchar const * owner_clippath = NULL; gchar const * obj_name = NULL; @@@ -82,15 -111,15 +114,18 @@@ return false; } return true; -- } ++ } }; - NRArenaItem *sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key); -/*NRArenaItem *sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key); --void sp_clippath_hide(SPClipPath *cp, unsigned int key); -- --void sp_clippath_set_bbox(SPClipPath *cp, unsigned int key, NRRect *bbox); - void sp_clippath_get_bbox(SPClipPath *cp, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); -void sp_clippath_get_bbox(SPClipPath *cp, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);*/ ++#endif // SEEN_SP_CLIPPATH_H - const gchar *sp_clippath_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform); -//const gchar *sp_clippath_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform); -- --#endif ++/* ++ Local Variables: ++ mode:c++ ++ c-file-style:"stroustrup" ++ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) ++ indent-tabs-mode:nil ++ fill-column:99 ++ End: ++*/ ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --cc src/sp-conn-end-pair.cpp index 7f019979a,21ecf6b43..0a5a6d7bd --- a/src/sp-conn-end-pair.cpp +++ b/src/sp-conn-end-pair.cpp @@@ -4,6 -4,6 +4,7 @@@ * Authors: * Peter Moulder <pmoulder@mail.csse.monash.edu.au> * Michael Wybrow <mjwybrow@users.sourceforge.net> ++ * Abhishek Sharma * * * Copyright (C) 2004-2005 Monash University * @@@ -79,12 -79,12 +80,12 @@@ SPConnEndPair::release( void sp_conn_end_pair_build(SPObject *object) { - sp_object_read_attr(object, "inkscape:connector-type"); - sp_object_read_attr(object, "inkscape:connection-start"); - sp_object_read_attr(object, "inkscape:connection-start-point"); - sp_object_read_attr(object, "inkscape:connection-end"); - sp_object_read_attr(object, "inkscape:connection-end-point"); - sp_object_read_attr(object, "inkscape:connector-curvature"); - object->readAttr( "inkscape:connector-type"); - object->readAttr( "inkscape:connection-start"); - object->readAttr( "inkscape:connection-start-point"); - object->readAttr( "inkscape:connection-end"); - object->readAttr( "inkscape:connection-end-point"); - object->readAttr( "inkscape:connector-curvature"); ++ object->readAttr( "inkscape:connector-type" ); ++ object->readAttr( "inkscape:connection-start" ); ++ object->readAttr( "inkscape:connection-start-point" ); ++ object->readAttr( "inkscape:connection-end" ); ++ object->readAttr( "inkscape:connection-end-point" ); ++ object->readAttr( "inkscape:connector-curvature" ); } diff --cc src/sp-defs.cpp index aa0cb0be7,b523322e1..2737b3f5c --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@@ -1,10 -1,10 +1,10 @@@ --#define __SP_DEFS_C__ -- /* * SVG <defs> implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2000-2002 authors * @@@ -20,32 -20,33 +20,24 @@@ #include "xml/repr.h" #include "document.h" - static void sp_defs_class_init(SPDefsClass *dc); -/*static void sp_defs_class_init(SPDefsClass *dc); --static void sp_defs_init(SPDefs *defs); -- --static void sp_defs_release(SPObject *object); --static void sp_defs_update(SPObject *object, SPCtx *ctx, guint flags); --static void sp_defs_modified(SPObject *object, guint flags); --static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -- - static SPObjectClass *parent_class; -static SPObjectClass *parent_class;*/ + SPObjectClass * SPDefsClass::static_parent_class = 0; - GType sp_defs_get_type(void) + GType SPDefs::sp_defs_get_type(void) { static GType defs_type = 0; if (!defs_type) { GTypeInfo defs_info = { sizeof(SPDefsClass), -- NULL, /* base_init */ -- NULL, /* base_finalize */ - (GClassInitFunc) sp_defs_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ ++ NULL, /* base_init */ ++ NULL, /* base_finalize */ + (GClassInitFunc) SPDefsClass::sp_defs_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ ++ NULL, /* class_finalize */ ++ NULL, /* class_data */ sizeof(SPDefs), -- 16, /* n_preallocs */ -- (GInstanceInitFunc) sp_defs_init, -- NULL, /* value_table */ ++ 16, /* n_preallocs */ ++ (GInstanceInitFunc) init, ++ NULL, /* value_table */ }; defs_type = g_type_register_static(SP_TYPE_OBJECT, "SPDefs", &defs_info, (GTypeFlags) 0); } @@@ -53,30 -54,30 +45,30 @@@ return defs_type; } - static void sp_defs_class_init(SPDefsClass *dc) + void SPDefsClass::sp_defs_class_init(SPDefsClass *dc) { - parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); + static_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); SPObjectClass *sp_object_class = (SPObjectClass *) dc; - sp_object_class->release = sp_defs_release; - sp_object_class->update = sp_defs_update; - sp_object_class->modified = sp_defs_modified; - sp_object_class->write = sp_defs_write; - sp_object_class->release = SPDefs::sp_defs_release; - sp_object_class->update = SPDefs::sp_defs_update; - sp_object_class->modified = SPDefs::sp_defs_modified; - sp_object_class->write = SPDefs::sp_defs_write; ++ sp_object_class->release = SPDefs::release; ++ sp_object_class->update = SPDefs::update; ++ sp_object_class->modified = SPDefs::modified; ++ sp_object_class->write = SPDefs::write; } - static void sp_defs_init(SPDefs */*defs*/) -void SPDefs::sp_defs_init(SPDefs */*defs*/) ++void SPDefs::init(SPDefs */*defs*/) { } - static void sp_defs_release(SPObject *object) -void SPDefs::sp_defs_release(SPObject *object) ++void SPDefs::release(SPObject *object) { - if (((SPObjectClass *) (parent_class))->release) { - ((SPObjectClass *) (parent_class))->release(object); + if (((SPObjectClass *) (SPDefsClass::static_parent_class))->release) { + ((SPObjectClass *) (SPDefsClass::static_parent_class))->release(object); } } - static void sp_defs_update(SPObject *object, SPCtx *ctx, guint flags) -void SPDefs::sp_defs_update(SPObject *object, SPCtx *ctx, guint flags) ++void SPDefs::update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@@ -95,7 -96,7 +87,7 @@@ } } - static void sp_defs_modified(SPObject *object, guint flags) -void SPDefs::sp_defs_modified(SPObject *object, guint flags) ++void SPDefs::modified(SPObject *object, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@@ -104,7 -105,7 +96,7 @@@ flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for ( SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = object->firstChild() ; child; child = child->getNext() ) { g_object_ref(G_OBJECT(child)); l = g_slist_prepend(l, child); } @@@ -117,11 -118,11 +109,11 @@@ if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(flags); } -- g_object_unref(G_OBJECT (child)); ++ g_object_unref( G_OBJECT(child) ); } } - static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) -Inkscape::XML::Node * SPDefs::sp_defs_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) ++Inkscape::XML::Node * SPDefs::write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if (flags & SP_OBJECT_WRITE_BUILD) { @@@ -130,9 -131,9 +122,11 @@@ } GSList *l = NULL; - for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for ( SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = object->firstChild() ; child; child = child->getNext() ) { Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); -- if (crepr) l = g_slist_prepend(l, crepr); ++ if (crepr) { ++ l = g_slist_prepend(l, crepr); ++ } } while (l) { @@@ -142,7 -143,7 +136,7 @@@ } } else { - for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for ( SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = object->firstChild() ; child; child = child->getNext() ) { child->updateRepr(flags); } } diff --cc src/sp-defs.h index 4b6f7a5b7,c88aef81e..83003f4ad --- a/src/sp-defs.h +++ b/src/sp-defs.h @@@ -6,6 -6,6 +6,7 @@@ * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 2000-2002 authors * @@@ -20,17 -20,35 +21,33 @@@ #define SP_IS_DEFS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_DEFS)) #define SP_IS_DEFS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_DEFS)) - struct SPDefs : public SPObject { + class SPDefs : public SPObject { - public: - static GType sp_defs_get_type(void); ++public: ++ static GType sp_defs_get_type(void); + - private: - static void sp_defs_init(SPDefs *defs); - static void sp_defs_release(SPObject *object); - static void sp_defs_update(SPObject *object, SPCtx *ctx, guint flags); - static void sp_defs_modified(SPObject *object, guint flags); - static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - - friend class SPDefsClass; ++private: ++ static void init(SPDefs *defs); ++ static void release(SPObject *object); ++ static void update(SPObject *object, SPCtx *ctx, guint flags); ++ static void modified(SPObject *object, guint flags); ++ static Inkscape::XML::Node *write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); ++ ++ friend class SPDefsClass; }; - struct SPDefsClass { + class SPDefsClass { - public: - SPObjectClass parent_class; ++public: + SPObjectClass parent_class; - }; - GType sp_defs_get_type(void); - private: - static void sp_defs_class_init(SPDefsClass *dc); - static SPObjectClass *static_parent_class; ++private: ++ static void sp_defs_class_init(SPDefsClass *dc); ++ static SPObjectClass *static_parent_class; + - friend class SPDefs; ++ friend class SPDefs; + }; -//GType sp_defs_get_type(void); - --#endif /* !SEEN_SP_DEFS_H */ ++#endif // !SEEN_SP_DEFS_H /* Local Variables: diff --cc src/sp-ellipse.cpp index d2472c914,7eb473d03..ef58e4d6e --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_ELLIPSE_C__ -- /* * SVG <ellipse> and related implementations * @@@ -7,6 -7,6 +5,7 @@@ * Lauris Kaplinski <lauris@kaplinski.com> * Mitsuru Oka * bulia byak <buliabyak@users.sf.net> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -144,18 -144,16 +143,18 @@@ sp_genericellipse_update(SPObject *obje SPGenericEllipse *ellipse = (SPGenericEllipse *) object; SPStyle const *style = object->style; Geom::OptRect viewbox = ((SPItemCtx const *) ctx)->vp; - double const dx = viewbox->width(); - double const dy = viewbox->height(); - double const dr = sqrt(dx*dx + dy*dy)/sqrt(2); - double const em = style->font_size.computed; - double const ex = em * 0.5; // fixme: get from pango or libnrtype - ellipse->cx.update(em, ex, dx); - ellipse->cy.update(em, ex, dy); - ellipse->rx.update(em, ex, dr); - ellipse->ry.update(em, ex, dr); - ((SPShape *) object)->setShape(); + if (viewbox) { + double const dx = viewbox->width(); + double const dy = viewbox->height(); + double const dr = sqrt(dx*dx + dy*dy)/sqrt(2); + double const em = style->font_size.computed; + double const ex = em * 0.5; // fixme: get from pango or libnrtype + ellipse->cx.update(em, ex, dx); + ellipse->cy.update(em, ex, dy); + ellipse->rx.update(em, ex, dr); + ellipse->ry.update(em, ex, dr); - sp_shape_set_shape((SPShape *) object); ++ static_cast<SPShape *>(object)->setShape(); + } } if (((SPObjectClass *) ge_parent_class)->update) @@@ -435,10 -433,10 +434,10 @@@ sp_ellipse_build(SPObject *object, SPDo if (((SPObjectClass *) ellipse_parent_class)->build) (* ((SPObjectClass *) ellipse_parent_class)->build) (object, document, repr); - sp_object_read_attr(object, "cx"); - sp_object_read_attr(object, "cy"); - sp_object_read_attr(object, "rx"); - sp_object_read_attr(object, "ry"); - object->readAttr( "cx"); - object->readAttr( "cy"); - object->readAttr( "rx"); - object->readAttr( "ry"); ++ object->readAttr( "cx" ); ++ object->readAttr( "cy" ); ++ object->readAttr( "rx" ); ++ object->readAttr( "ry" ); } static Inkscape::XML::Node * @@@ -583,9 -581,9 +582,9 @@@ sp_circle_build(SPObject *object, SPDoc if (((SPObjectClass *) circle_parent_class)->build) (* ((SPObjectClass *) circle_parent_class)->build)(object, document, repr); - sp_object_read_attr(object, "cx"); - sp_object_read_attr(object, "cy"); - sp_object_read_attr(object, "r"); - object->readAttr( "cx"); - object->readAttr( "cy"); - object->readAttr( "r"); ++ object->readAttr( "cx" ); ++ object->readAttr( "cy" ); ++ object->readAttr( "r" ); } static Inkscape::XML::Node * @@@ -708,14 -706,14 +707,14 @@@ sp_arc_build(SPObject *object, SPDocume if (((SPObjectClass *) arc_parent_class)->build) (* ((SPObjectClass *) arc_parent_class)->build) (object, document, repr); - sp_object_read_attr(object, "sodipodi:cx"); - sp_object_read_attr(object, "sodipodi:cy"); - sp_object_read_attr(object, "sodipodi:rx"); - sp_object_read_attr(object, "sodipodi:ry"); - object->readAttr( "sodipodi:cx"); - object->readAttr( "sodipodi:cy"); - object->readAttr( "sodipodi:rx"); - object->readAttr( "sodipodi:ry"); ++ object->readAttr( "sodipodi:cx" ); ++ object->readAttr( "sodipodi:cy" ); ++ object->readAttr( "sodipodi:rx" ); ++ object->readAttr( "sodipodi:ry" ); - sp_object_read_attr(object, "sodipodi:start"); - sp_object_read_attr(object, "sodipodi:end"); - sp_object_read_attr(object, "sodipodi:open"); - object->readAttr( "sodipodi:start"); - object->readAttr( "sodipodi:end"); - object->readAttr( "sodipodi:open"); ++ object->readAttr( "sodipodi:start" ); ++ object->readAttr( "sodipodi:end" ); ++ object->readAttr( "sodipodi:open" ); } /* diff --cc src/sp-filter-primitive.cpp index 265c72b14,4ce0e133d..30eda7159 --- a/src/sp-filter-primitive.cpp +++ b/src/sp-filter-primitive.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FILTER_PRIMITIVE_CPP__ -- /** \file * Superclass for all the filter primitives * @@@ -8,6 -8,6 +6,7 @@@ * Authors: * Kees Cook <kees@outflux.net> * Niko Kiirala <niko@kiirala.com> ++ * Abhishek Sharma * * Copyright (C) 2004-2007 Authors * @@@ -99,8 -99,8 +98,8 @@@ sp_filter_primitive_build(SPObject *obj ((SPObjectClass *) filter_primitive_parent_class)->build(object, document, repr); } - sp_object_read_attr(object, "in"); - sp_object_read_attr(object, "result"); - object->readAttr( "in"); - object->readAttr( "result"); ++ object->readAttr( "in" ); ++ object->readAttr( "result" ); } /** @@@ -164,8 -164,8 +163,8 @@@ sp_filter_primitive_update(SPObject *ob //SPFilterPrimitive *filter_primitive = SP_FILTER_PRIMITIVE(object); if (flags & SP_OBJECT_MODIFIED_FLAG) { - sp_object_read_attr(object, "in"); - sp_object_read_attr(object, "result"); - object->readAttr( "in"); - object->readAttr( "result"); ++ object->readAttr( "in" ); ++ object->readAttr( "result" ); } if (((SPObjectClass *) filter_primitive_parent_class)->update) { @@@ -259,7 -259,8 +258,8 @@@ int sp_filter_primitive_name_previous_o Glib::ustring name = sp_filter_get_new_result_name(parent); int slot = sp_filter_set_image_name(parent, name.c_str()); i_prim->image_out = slot; - i_prim->repr->setAttribute("result", name.c_str()); - //XML Tree is being directly used while it shouldn't be. ++ //XML Tree is being directly used while it shouldn't be. + i_prim->getRepr()->setAttribute("result", name.c_str()); return slot; } else { return i_prim->image_out; diff --cc src/sp-filter.cpp index a39cc6437,e65a7be05..cfd6253a3 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FILTER_CPP__ -- /** \file * SVG <filter> implementation. */ @@@ -7,6 -7,6 +5,8 @@@ * Authors: * Hugo Rodrigues <haa.rodrigues@gmail.com> * Niko Kiirala <niko@kiirala.com> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2006,2007 Authors * @@@ -136,17 -136,17 +136,17 @@@ sp_filter_build(SPObject *object, SPDoc } //Read values of key attributes from XML nodes into object. - sp_object_read_attr(object, "filterUnits"); - sp_object_read_attr(object, "primitiveUnits"); - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "width"); - sp_object_read_attr(object, "height"); - sp_object_read_attr(object, "filterRes"); - sp_object_read_attr(object, "xlink:href"); - object->readAttr( "filterUnits"); - object->readAttr( "primitiveUnits"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "width"); - object->readAttr( "height"); - object->readAttr( "filterRes"); - object->readAttr( "xlink:href"); ++ object->readAttr( "filterUnits" ); ++ object->readAttr( "primitiveUnits" ); ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "width" ); ++ object->readAttr( "height" ); ++ object->readAttr( "filterRes" ); ++ object->readAttr( "xlink:href" ); //is this necessary? - sp_document_add_resource(document, "filter", object); - document->add_resource("filter", object); ++ document->addResource("filter", object); } /** @@@ -159,7 -159,7 +159,7 @@@ sp_filter_release(SPObject *object if (SP_OBJECT_DOCUMENT(object)) { /* Unregister ourselves */ - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "filter", SP_OBJECT(object)); - SP_OBJECT_DOCUMENT(object)->remove_resource("filter", SP_OBJECT(object)); ++ SP_OBJECT_DOCUMENT(object)->removeResource("filter", SP_OBJECT(object)); } //TODO: release resources here @@@ -284,19 -284,19 +284,18 @@@ static Inkscape::XML::Node sp_filter_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { SPFilter *filter = SP_FILTER(object); -- SPObject *child; -- Inkscape::XML::Node *crepr; -- /* Original from sp-item-group.cpp */ ++ // Original from sp-item-group.cpp if (flags & SP_OBJECT_WRITE_BUILD) { -- GSList *l; if (!repr) { repr = doc->createElement("svg:filter"); } -- l = NULL; - for (child = sp_object_first_child(object); child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (child = object->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { -- crepr = child->updateRepr(doc, NULL, flags); -- if (crepr) l = g_slist_prepend (l, crepr); ++ GSList *l = NULL; ++ for ( SPObject *child = object->firstChild(); child; child = child->getNext() ) { ++ Inkscape::XML::Node *crepr = child->updateRepr(doc, NULL, flags); ++ if (crepr) { ++ l = g_slist_prepend (l, crepr); ++ } } while (l) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); @@@ -304,7 -304,7 +303,7 @@@ l = g_slist_remove (l, l->data); } } else { - for (child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = object->firstChild() ; child; child = child->getNext() ) { child->updateRepr(flags); } } diff --cc src/sp-flowdiv.cpp index 6d679701f,41df69609..4d07cffd7 --- a/src/sp-flowdiv.cpp +++ b/src/sp-flowdiv.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FLOWDIV_C__ -- /* */ @@@ -114,66 -114,66 +112,69 @@@ sp_flowdiv_release (SPObject *object if (((SPObjectClass *) flowdiv_parent_class)->release) ((SPObjectClass *) flowdiv_parent_class)->release (object); } --static void --sp_flowdiv_update (SPObject *object, SPCtx *ctx, unsigned int flags) --{ -- SPItemCtx *ictx=(SPItemCtx *) ctx; -- SPItemCtx cctx=*ictx; -- -- if (((SPObjectClass *) (flowdiv_parent_class))->update) -- ((SPObjectClass *) (flowdiv_parent_class))->update (object, ctx, flags); -- -- if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; -- flags &= SP_OBJECT_MODIFIED_CASCADE; -- GSList* l = NULL; - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- g_object_ref (G_OBJECT (child)); -- l = g_slist_prepend (l, child); -- } -- l = g_slist_reverse (l); -- while (l) { -- SPObject *child = SP_OBJECT (l->data); -- l = g_slist_remove (l, child); -- if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { -- if (SP_IS_ITEM (child)) { -- SPItem const &chi = *SP_ITEM(child); -- cctx.i2doc = chi.transform * ictx->i2doc; -- cctx.i2vp = chi.transform * ictx->i2vp; -- child->updateDisplay((SPCtx *)&cctx, flags); -- } else { -- child->updateDisplay(ctx, flags); -- } -- } -- g_object_unref (G_OBJECT (child)); -- } --} --static void --sp_flowdiv_modified (SPObject *object, guint flags) --{ -- SPObject *child; -- GSList *l; -- -- if (((SPObjectClass *) (flowdiv_parent_class))->modified) -- ((SPObjectClass *) (flowdiv_parent_class))->modified (object, flags); -- -- if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; -- flags &= SP_OBJECT_MODIFIED_CASCADE; -- -- l = NULL; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- g_object_ref (G_OBJECT (child)); -- l = g_slist_prepend (l, child); -- } -- l = g_slist_reverse (l); -- while (l) { -- child = SP_OBJECT (l->data); -- l = g_slist_remove (l, child); -- if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { -- child->emitModified(flags); -- } -- g_object_unref (G_OBJECT (child)); -- } ++static void sp_flowdiv_update(SPObject *object, SPCtx *ctx, unsigned int flags) ++{ ++ SPItemCtx *ictx = reinterpret_cast<SPItemCtx *>(ctx); ++ SPItemCtx cctx = *ictx; ++ ++ if (((SPObjectClass *) (flowdiv_parent_class))->update) { ++ ((SPObjectClass *) (flowdiv_parent_class))->update(object, ctx, flags); ++ } ++ ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } ++ flags &= SP_OBJECT_MODIFIED_CASCADE; ++ ++ GSList* l = NULL; ++ for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ g_object_ref( G_OBJECT(child) ); ++ l = g_slist_prepend(l, child); ++ } ++ l = g_slist_reverse(l); ++ while (l) { ++ SPObject *child = SP_OBJECT(l->data); ++ l = g_slist_remove(l, child); ++ if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { ++ if (SP_IS_ITEM(child)) { ++ SPItem const &chi = *SP_ITEM(child); ++ cctx.i2doc = chi.transform * ictx->i2doc; ++ cctx.i2vp = chi.transform * ictx->i2vp; ++ child->updateDisplay((SPCtx *)&cctx, flags); ++ } else { ++ child->updateDisplay(ctx, flags); ++ } ++ } ++ g_object_unref( G_OBJECT(child) ); ++ } ++} ++ ++static void sp_flowdiv_modified (SPObject *object, guint flags) ++{ ++ if (((SPObjectClass *) (flowdiv_parent_class))->modified) { ++ ((SPObjectClass *) (flowdiv_parent_class))->modified(object, flags); ++ } ++ ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } ++ flags &= SP_OBJECT_MODIFIED_CASCADE; ++ ++ GSList *l = NULL; ++ for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ g_object_ref( G_OBJECT(child) ); ++ l = g_slist_prepend(l, child); ++ } ++ l = g_slist_reverse (l); ++ while (l) { ++ SPObject *child = SP_OBJECT(l->data); ++ l = g_slist_remove(l, child); ++ if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { ++ child->emitModified(flags); ++ } ++ g_object_unref( G_OBJECT(child) ); ++ } } static void @@@ -185,53 -185,53 +186,55 @@@ sp_flowdiv_build (SPObject *object, SPD ((SPObjectClass *) flowdiv_parent_class)->build (object, doc, repr); } --static void --sp_flowdiv_set (SPObject *object, unsigned int key, const gchar *value) --{ -- if (((SPObjectClass *) flowdiv_parent_class)->set) -- (((SPObjectClass *) flowdiv_parent_class)->set) (object, key, value); --} -- --static Inkscape::XML::Node * --sp_flowdiv_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) --{ --// SPFlowdiv *group = SP_FLOWDIV (object); -- -- if ( flags&SP_OBJECT_WRITE_BUILD ) { -- if ( repr == NULL ) repr = xml_doc->createElement("svg:flowDiv"); -- GSList *l = NULL; - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- Inkscape::XML::Node* c_repr=NULL; -- if ( SP_IS_FLOWTSPAN (child) ) { -- c_repr = child->updateRepr(xml_doc, NULL, flags); -- } else if ( SP_IS_FLOWPARA(child) ) { -- c_repr = child->updateRepr(xml_doc, NULL, flags); -- } else if ( SP_IS_STRING(child) ) { -- c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); -- } -- if ( c_repr ) l = g_slist_prepend (l, c_repr); -- } -- while ( l ) { -- repr->addChild((Inkscape::XML::Node *) l->data, NULL); -- Inkscape::GC::release((Inkscape::XML::Node *) l->data); -- l = g_slist_remove (l, l->data); -- } -- } else { - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- if ( SP_IS_FLOWTSPAN (child) ) { -- child->updateRepr(flags); -- } else if ( SP_IS_FLOWPARA(child) ) { -- child->updateRepr(flags); -- } else if ( SP_IS_STRING(child) ) { -- SP_OBJECT_REPR (child)->setContent(SP_STRING(child)->string.c_str()); -- } -- } -- } -- -- if (((SPObjectClass *) (flowdiv_parent_class))->write) -- ((SPObjectClass *) (flowdiv_parent_class))->write (object, xml_doc, repr, flags); -- -- return repr; ++static void sp_flowdiv_set(SPObject *object, unsigned int key, const gchar *value) ++{ ++ if (((SPObjectClass *) flowdiv_parent_class)->set) { ++ (((SPObjectClass *) flowdiv_parent_class)->set)(object, key, value); ++ } ++} ++ ++static Inkscape::XML::Node *sp_flowdiv_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) ++{ ++ if ( flags & SP_OBJECT_WRITE_BUILD ) { ++ if ( repr == NULL ) { ++ repr = xml_doc->createElement("svg:flowDiv"); ++ } ++ GSList *l = NULL; ++ for (SPObject* child = object->firstChild() ; child ; child = child->getNext() ) { ++ Inkscape::XML::Node* c_repr = NULL; ++ if ( SP_IS_FLOWTSPAN (child) ) { ++ c_repr = child->updateRepr(xml_doc, NULL, flags); ++ } else if ( SP_IS_FLOWPARA(child) ) { ++ c_repr = child->updateRepr(xml_doc, NULL, flags); ++ } else if ( SP_IS_STRING(child) ) { ++ c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); ++ } ++ if ( c_repr ) { ++ l = g_slist_prepend (l, c_repr); ++ } ++ } ++ while ( l ) { ++ repr->addChild((Inkscape::XML::Node *) l->data, NULL); ++ Inkscape::GC::release((Inkscape::XML::Node *) l->data); ++ l = g_slist_remove(l, l->data); ++ } ++ } else { ++ for ( SPObject* child = object->firstChild() ; child ; child = child->getNext() ) { ++ if ( SP_IS_FLOWTSPAN (child) ) { ++ child->updateRepr(flags); ++ } else if ( SP_IS_FLOWPARA(child) ) { ++ child->updateRepr(flags); ++ } else if ( SP_IS_STRING(child) ) { ++ child->getRepr()->setContent(SP_STRING(child)->string.c_str()); ++ } ++ } ++ } ++ ++ if (((SPObjectClass *) (flowdiv_parent_class))->write) { ++ ((SPObjectClass *) (flowdiv_parent_class))->write(object, xml_doc, repr, flags); ++ } ++ ++ return repr; } @@@ -285,124 -285,124 +288,133 @@@ sp_flowtspan_init (SPFlowtspan */*group { } --static void --sp_flowtspan_release (SPObject *object) --{ -- if (((SPObjectClass *) flowtspan_parent_class)->release) -- ((SPObjectClass *) flowtspan_parent_class)->release (object); --} --static void --sp_flowtspan_update (SPObject *object, SPCtx *ctx, unsigned int flags) --{ --// SPFlowtspan *group=SP_FLOWTSPAN (object); -- SPItemCtx *ictx=(SPItemCtx *) ctx; -- SPItemCtx cctx=*ictx; -- -- if (((SPObjectClass *) (flowtspan_parent_class))->update) -- ((SPObjectClass *) (flowtspan_parent_class))->update (object, ctx, flags); -- -- if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; -- flags &= SP_OBJECT_MODIFIED_CASCADE; -- -- GSList* l = NULL; - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- g_object_ref (G_OBJECT (child)); -- l = g_slist_prepend (l, child); -- } -- l = g_slist_reverse (l); -- while (l) { -- SPObject *child = SP_OBJECT (l->data); -- l = g_slist_remove (l, child); -- if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { -- if (SP_IS_ITEM (child)) { -- SPItem const &chi = *SP_ITEM(child); -- cctx.i2doc = chi.transform * ictx->i2doc; -- cctx.i2vp = chi.transform * ictx->i2vp; -- child->updateDisplay((SPCtx *)&cctx, flags); -- } else { -- child->updateDisplay(ctx, flags); -- } -- } -- g_object_unref (G_OBJECT (child)); -- } --} --static void --sp_flowtspan_modified (SPObject *object, guint flags) --{ -- SPObject *child; -- GSList *l; -- -- if (((SPObjectClass *) (flowtspan_parent_class))->modified) -- ((SPObjectClass *) (flowtspan_parent_class))->modified (object, flags); -- -- if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; -- flags &= SP_OBJECT_MODIFIED_CASCADE; -- -- l = NULL; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- g_object_ref (G_OBJECT (child)); -- l = g_slist_prepend (l, child); -- } -- l = g_slist_reverse (l); -- while (l) { -- child = SP_OBJECT (l->data); -- l = g_slist_remove (l, child); -- if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { -- child->emitModified(flags); -- } -- g_object_unref (G_OBJECT (child)); -- } --} --static void --sp_flowtspan_build (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) --{ -- if (((SPObjectClass *) flowtspan_parent_class)->build) -- ((SPObjectClass *) flowtspan_parent_class)->build (object, doc, repr); --} --static void --sp_flowtspan_set (SPObject *object, unsigned int key, const gchar *value) --{ -- if (((SPObjectClass *) flowtspan_parent_class)->set) -- (((SPObjectClass *) flowtspan_parent_class)->set) (object, key, value); --} --static Inkscape::XML::Node * --sp_flowtspan_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) --{ -- if ( flags&SP_OBJECT_WRITE_BUILD ) { -- if ( repr == NULL ) repr = xml_doc->createElement("svg:flowSpan"); -- GSList *l = NULL; - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- Inkscape::XML::Node* c_repr=NULL; -- if ( SP_IS_FLOWTSPAN (child) ) { -- c_repr = child->updateRepr(xml_doc, NULL, flags); -- } else if ( SP_IS_FLOWPARA (child) ) { -- c_repr = child->updateRepr(xml_doc, NULL, flags); -- } else if ( SP_IS_STRING(child) ) { -- c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); -- } -- if ( c_repr ) l = g_slist_prepend (l, c_repr); -- } -- while ( l ) { -- repr->addChild((Inkscape::XML::Node *) l->data, NULL); -- Inkscape::GC::release((Inkscape::XML::Node *) l->data); -- l = g_slist_remove (l, l->data); -- } -- } else { - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- if ( SP_IS_FLOWTSPAN (child) ) { -- child->updateRepr(flags); -- } else if ( SP_IS_FLOWPARA (child) ) { -- child->updateRepr(flags); -- } else if ( SP_IS_STRING(child) ) { -- SP_OBJECT_REPR (child)->setContent(SP_STRING(child)->string.c_str()); -- } -- } -- } -- -- if (((SPObjectClass *) (flowtspan_parent_class))->write) -- ((SPObjectClass *) (flowtspan_parent_class))->write (object, xml_doc, repr, flags); -- -- return repr; ++static void sp_flowtspan_release(SPObject *object) ++{ ++ if (((SPObjectClass *) flowtspan_parent_class)->release) { ++ ((SPObjectClass *) flowtspan_parent_class)->release(object); ++ } ++} ++ ++static void sp_flowtspan_update(SPObject *object, SPCtx *ctx, unsigned int flags) ++{ ++ SPItemCtx *ictx = reinterpret_cast<SPItemCtx *>(ctx); ++ SPItemCtx cctx = *ictx; ++ ++ if (((SPObjectClass *) (flowtspan_parent_class))->update) { ++ ((SPObjectClass *) (flowtspan_parent_class))->update(object, ctx, flags); ++ } ++ ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } ++ flags &= SP_OBJECT_MODIFIED_CASCADE; ++ ++ GSList* l = NULL; ++ for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ g_object_ref( G_OBJECT(child) ); ++ l = g_slist_prepend(l, child); ++ } ++ l = g_slist_reverse (l); ++ while (l) { ++ SPObject *child = SP_OBJECT(l->data); ++ l = g_slist_remove(l, child); ++ if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { ++ if (SP_IS_ITEM(child)) { ++ SPItem const &chi = *SP_ITEM(child); ++ cctx.i2doc = chi.transform * ictx->i2doc; ++ cctx.i2vp = chi.transform * ictx->i2vp; ++ child->updateDisplay((SPCtx *)&cctx, flags); ++ } else { ++ child->updateDisplay(ctx, flags); ++ } ++ } ++ g_object_unref( G_OBJECT(child) ); ++ } ++} ++ ++static void sp_flowtspan_modified(SPObject *object, guint flags) ++{ ++ if (((SPObjectClass *) (flowtspan_parent_class))->modified) { ++ ((SPObjectClass *) (flowtspan_parent_class))->modified(object, flags); ++ } ++ ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } ++ flags &= SP_OBJECT_MODIFIED_CASCADE; ++ ++ GSList *l = NULL; ++ for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ g_object_ref( G_OBJECT(child) ); ++ l = g_slist_prepend(l, child); ++ } ++ l = g_slist_reverse (l); ++ while (l) { ++ SPObject *child = SP_OBJECT(l->data); ++ l = g_slist_remove(l, child); ++ if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { ++ child->emitModified(flags); ++ } ++ g_object_unref( G_OBJECT(child) ); ++ } ++} ++ ++static void sp_flowtspan_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) ++{ ++ if (((SPObjectClass *) flowtspan_parent_class)->build) { ++ ((SPObjectClass *) flowtspan_parent_class)->build(object, doc, repr); ++ } ++} ++ ++static void sp_flowtspan_set(SPObject *object, unsigned int key, const gchar *value) ++{ ++ if (((SPObjectClass *) flowtspan_parent_class)->set) { ++ (((SPObjectClass *) flowtspan_parent_class)->set)(object, key, value); ++ } ++} ++ ++static Inkscape::XML::Node *sp_flowtspan_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) ++{ ++ if ( flags&SP_OBJECT_WRITE_BUILD ) { ++ if ( repr == NULL ) { ++ repr = xml_doc->createElement("svg:flowSpan"); ++ } ++ GSList *l = NULL; ++ for ( SPObject* child = object->firstChild() ; child ; child = child->getNext() ) { ++ Inkscape::XML::Node* c_repr = NULL; ++ if ( SP_IS_FLOWTSPAN(child) ) { ++ c_repr = child->updateRepr(xml_doc, NULL, flags); ++ } else if ( SP_IS_FLOWPARA(child) ) { ++ c_repr = child->updateRepr(xml_doc, NULL, flags); ++ } else if ( SP_IS_STRING(child) ) { ++ c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); ++ } ++ if ( c_repr ) { ++ l = g_slist_prepend(l, c_repr); ++ } ++ } ++ while ( l ) { ++ repr->addChild((Inkscape::XML::Node *) l->data, NULL); ++ Inkscape::GC::release((Inkscape::XML::Node *) l->data); ++ l = g_slist_remove(l, l->data); ++ } ++ } else { ++ for ( SPObject* child = object->firstChild() ; child ; child = child->getNext() ) { ++ if ( SP_IS_FLOWTSPAN(child) ) { ++ child->updateRepr(flags); ++ } else if ( SP_IS_FLOWPARA(child) ) { ++ child->updateRepr(flags); ++ } else if ( SP_IS_STRING(child) ) { ++ SP_OBJECT_REPR(child)->setContent(SP_STRING(child)->string.c_str()); ++ } ++ } ++ } ++ ++ if (((SPObjectClass *) (flowtspan_parent_class))->write) { ++ ((SPObjectClass *) (flowtspan_parent_class))->write(object, xml_doc, repr, flags); ++ } ++ ++ return repr; } @@@ -463,119 -463,119 +475,124 @@@ sp_flowpara_release (SPObject *object ((SPObjectClass *) flowpara_parent_class)->release (object); } --static void --sp_flowpara_update (SPObject *object, SPCtx *ctx, unsigned int flags) --{ -- SPItemCtx *ictx=(SPItemCtx *) ctx; -- SPItemCtx cctx=*ictx; -- -- if (((SPObjectClass *) (flowpara_parent_class))->update) -- ((SPObjectClass *) (flowpara_parent_class))->update (object, ctx, flags); -- -- if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; -- flags &= SP_OBJECT_MODIFIED_CASCADE; -- -- GSList* l = NULL; - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- g_object_ref (G_OBJECT (child)); -- l = g_slist_prepend (l, child); -- } -- l = g_slist_reverse (l); -- while (l) { -- SPObject *child = SP_OBJECT (l->data); -- l = g_slist_remove (l, child); -- if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { -- if (SP_IS_ITEM (child)) { -- SPItem const &chi = *SP_ITEM(child); -- cctx.i2doc = chi.transform * ictx->i2doc; -- cctx.i2vp = chi.transform * ictx->i2vp; -- child->updateDisplay((SPCtx *)&cctx, flags); -- } else { -- child->updateDisplay(ctx, flags); -- } -- } -- g_object_unref (G_OBJECT (child)); -- } ++static void sp_flowpara_update(SPObject *object, SPCtx *ctx, unsigned int flags) ++{ ++ SPItemCtx *ictx = reinterpret_cast<SPItemCtx *>(ctx); ++ SPItemCtx cctx = *ictx; ++ ++ if (((SPObjectClass *) (flowpara_parent_class))->update) { ++ ((SPObjectClass *) (flowpara_parent_class))->update(object, ctx, flags); ++ } ++ ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } ++ flags &= SP_OBJECT_MODIFIED_CASCADE; ++ ++ GSList* l = NULL; ++ for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ g_object_ref( G_OBJECT(child) ); ++ l = g_slist_prepend(l, child); ++ } ++ l = g_slist_reverse (l); ++ while (l) { ++ SPObject *child = SP_OBJECT(l->data); ++ l = g_slist_remove(l, child); ++ if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { ++ if (SP_IS_ITEM(child)) { ++ SPItem const &chi = *SP_ITEM(child); ++ cctx.i2doc = chi.transform * ictx->i2doc; ++ cctx.i2vp = chi.transform * ictx->i2vp; ++ child->updateDisplay((SPCtx *)&cctx, flags); ++ } else { ++ child->updateDisplay(ctx, flags); ++ } ++ } ++ g_object_unref( G_OBJECT(child) ); ++ } ++} ++ ++static void sp_flowpara_modified(SPObject *object, guint flags) ++{ ++ if (((SPObjectClass *) (flowpara_parent_class))->modified) { ++ ((SPObjectClass *) (flowpara_parent_class))->modified(object, flags); ++ } ++ ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } ++ flags &= SP_OBJECT_MODIFIED_CASCADE; ++ ++ GSList *l = NULL; ++ for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ g_object_ref( G_OBJECT(child) ); ++ l = g_slist_prepend(l, child); ++ } ++ l = g_slist_reverse (l); ++ while (l) { ++ SPObject *child = SP_OBJECT(l->data); ++ l = g_slist_remove(l, child); ++ if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { ++ child->emitModified(flags); ++ } ++ g_object_unref( G_OBJECT(child) ); ++ } } --static void --sp_flowpara_modified (SPObject *object, guint flags) --{ -- SPObject *child; -- GSList *l; -- if (((SPObjectClass *) (flowpara_parent_class))->modified) -- ((SPObjectClass *) (flowpara_parent_class))->modified (object, flags); -- -- if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; -- flags &= SP_OBJECT_MODIFIED_CASCADE; -- -- l = NULL; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- g_object_ref (G_OBJECT (child)); -- l = g_slist_prepend (l, child); -- } -- l = g_slist_reverse (l); -- while (l) { -- child = SP_OBJECT (l->data); -- l = g_slist_remove (l, child); -- if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { -- child->emitModified(flags); -- } -- g_object_unref (G_OBJECT (child)); -- } --} static void sp_flowpara_build (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { if (((SPObjectClass *) flowpara_parent_class)->build) ((SPObjectClass *) flowpara_parent_class)->build (object, doc, repr); } ++ static void sp_flowpara_set (SPObject *object, unsigned int key, const gchar *value) { if (((SPObjectClass *) flowpara_parent_class)->set) (((SPObjectClass *) flowpara_parent_class)->set) (object, key, value); } --static Inkscape::XML::Node * --sp_flowpara_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) --{ -- // SPFlowpara *group = SP_FLOWPARA (object); -- -- if ( flags&SP_OBJECT_WRITE_BUILD ) { -- if ( repr == NULL ) repr = xml_doc->createElement("svg:flowPara"); -- GSList *l = NULL; - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- Inkscape::XML::Node* c_repr=NULL; -- if ( SP_IS_FLOWTSPAN (child) ) { -- c_repr = child->updateRepr(xml_doc, NULL, flags); -- } else if ( SP_IS_FLOWPARA (child) ) { -- c_repr = child->updateRepr(xml_doc, NULL, flags); -- } else if ( SP_IS_STRING(child) ) { -- c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); -- } -- if ( c_repr ) l = g_slist_prepend (l, c_repr); -- } -- while ( l ) { -- repr->addChild((Inkscape::XML::Node *) l->data, NULL); -- Inkscape::GC::release((Inkscape::XML::Node *) l->data); -- l = g_slist_remove (l, l->data); -- } -- } else { - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- if ( SP_IS_FLOWTSPAN (child) ) { -- child->updateRepr(flags); -- } else if ( SP_IS_FLOWPARA (child) ) { -- child->updateRepr(flags); -- } else if ( SP_IS_STRING(child) ) { -- SP_OBJECT_REPR (child)->setContent(SP_STRING(child)->string.c_str()); -- } -- } -- } -- -- if (((SPObjectClass *) (flowpara_parent_class))->write) -- ((SPObjectClass *) (flowpara_parent_class))->write (object, xml_doc, repr, flags); -- return repr; ++static Inkscape::XML::Node *sp_flowpara_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) ++{ ++ if ( flags&SP_OBJECT_WRITE_BUILD ) { ++ if ( repr == NULL ) repr = xml_doc->createElement("svg:flowPara"); ++ GSList *l = NULL; ++ for ( SPObject* child = object->firstChild() ; child ; child = child->getNext() ) { ++ Inkscape::XML::Node* c_repr = NULL; ++ if ( SP_IS_FLOWTSPAN(child) ) { ++ c_repr = child->updateRepr(xml_doc, NULL, flags); ++ } else if ( SP_IS_FLOWPARA(child) ) { ++ c_repr = child->updateRepr(xml_doc, NULL, flags); ++ } else if ( SP_IS_STRING(child) ) { ++ c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); ++ } ++ if ( c_repr ) { ++ l = g_slist_prepend(l, c_repr); ++ } ++ } ++ while ( l ) { ++ repr->addChild((Inkscape::XML::Node *) l->data, NULL); ++ Inkscape::GC::release((Inkscape::XML::Node *) l->data); ++ l = g_slist_remove(l, l->data); ++ } ++ } else { ++ for ( SPObject* child = object->firstChild() ; child ; child = child->getNext() ) { ++ if ( SP_IS_FLOWTSPAN(child) ) { ++ child->updateRepr(flags); ++ } else if ( SP_IS_FLOWPARA(child) ) { ++ child->updateRepr(flags); ++ } else if ( SP_IS_STRING(child) ) { ++ child->getRepr()->setContent(SP_STRING(child)->string.c_str()); ++ } ++ } ++ } ++ ++ if (((SPObjectClass *) (flowpara_parent_class))->write) { ++ ((SPObjectClass *) (flowpara_parent_class))->write(object, xml_doc, repr, flags); ++ } ++ ++ return repr; } /* @@@ -729,3 -729,3 +746,14 @@@ sp_flowregionbreak_write (SPObject *obj return repr; } ++ ++/* ++ Local Variables: ++ mode:c++ ++ c-file-style:"stroustrup" ++ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) ++ indent-tabs-mode:nil ++ fill-column:99 ++ End: ++*/ ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --cc src/sp-flowregion.cpp index 79007cac7,cff7a5db7..680589b55 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_FLOWREGION_C__ -- /* */ @@@ -143,105 -143,105 +141,101 @@@ sp_flowregion_remove_child (SPObject * } --static void --sp_flowregion_update (SPObject *object, SPCtx *ctx, unsigned int flags) ++static void sp_flowregion_update(SPObject *object, SPCtx *ctx, unsigned int flags) { -- SPFlowregion *group; -- SPObject *child; -- SPItemCtx *ictx, cctx; -- GSList *l; ++ SPFlowregion *group = SP_FLOWREGION(object); -- group = SP_FLOWREGION (object); -- ictx = (SPItemCtx *) ctx; -- cctx = *ictx; ++ SPItemCtx *ictx = reinterpret_cast<SPItemCtx *>(ctx); ++ SPItemCtx cctx = *ictx; -- if (((SPObjectClass *) (flowregion_parent_class))->update) -- ((SPObjectClass *) (flowregion_parent_class))->update (object, ctx, flags); ++ if (((SPObjectClass *) (flowregion_parent_class))->update) { ++ ((SPObjectClass *) (flowregion_parent_class))->update (object, ctx, flags); ++ } -- if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; -- flags &= SP_OBJECT_MODIFIED_CASCADE; ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } ++ flags &= SP_OBJECT_MODIFIED_CASCADE; -- l = NULL; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- g_object_ref (G_OBJECT (child)); -- l = g_slist_prepend (l, child); -- } -- l = g_slist_reverse (l); -- while (l) { -- child = SP_OBJECT (l->data); -- l = g_slist_remove (l, child); -- if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { -- if (SP_IS_ITEM (child)) { -- SPItem const &chi = *SP_ITEM(child); -- cctx.i2doc = chi.transform * ictx->i2doc; -- cctx.i2vp = chi.transform * ictx->i2vp; -- child->updateDisplay((SPCtx *)&cctx, flags); -- } else { -- child->updateDisplay(ctx, flags); -- } -- } -- g_object_unref (G_OBJECT (child)); -- } ++ GSList *l = NULL; ++ for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ g_object_ref( G_OBJECT(child) ); ++ l = g_slist_prepend(l, child); ++ } ++ l = g_slist_reverse(l); ++ while (l) { ++ SPObject *child = SP_OBJECT(l->data); ++ l = g_slist_remove(l, child); ++ if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { ++ if (SP_IS_ITEM (child)) { ++ SPItem const &chi = *SP_ITEM(child); ++ cctx.i2doc = chi.transform * ictx->i2doc; ++ cctx.i2vp = chi.transform * ictx->i2vp; ++ child->updateDisplay((SPCtx *)&cctx, flags); ++ } else { ++ child->updateDisplay(ctx, flags); ++ } ++ } ++ g_object_unref (G_OBJECT(child)); ++ } -- group->UpdateComputed(); ++ group->UpdateComputed(); } --void SPFlowregion::UpdateComputed(void) ++void SPFlowregion::UpdateComputed(void) { -- SPObject* object=SP_OBJECT(this); -- -- for (std::vector<Shape*>::iterator it = computed.begin() ; it != computed.end() ; it++) ++ for (std::vector<Shape*>::iterator it = computed.begin() ; it != computed.end() ; it++) { delete *it; ++ } computed.clear(); - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- Shape *shape = NULL; -- GetDest(child,&shape); ++ for (SPObject* child = firstChild() ; child ; child = child->getNext() ) { ++ Shape *shape = 0; ++ GetDest(child, &shape); computed.push_back(shape); -- } ++ } } --static void --sp_flowregion_modified (SPObject *object, guint flags) ++static void sp_flowregion_modified(SPObject *object, guint flags) { -- SPFlowregion *group; -- SPObject *child; -- GSList *l; -- -- group = SP_FLOWREGION (object); ++ SP_FLOWREGION(object); // ensure it is the proper type. -- if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; -- flags &= SP_OBJECT_MODIFIED_CASCADE; ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } ++ flags &= SP_OBJECT_MODIFIED_CASCADE; -- l = NULL; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- g_object_ref (G_OBJECT (child)); -- l = g_slist_prepend (l, child); -- } -- l = g_slist_reverse (l); -- while (l) { -- child = SP_OBJECT (l->data); -- l = g_slist_remove (l, child); -- if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { -- child->emitModified(flags); -- } -- g_object_unref (G_OBJECT (child)); -- } ++ GSList *l = NULL; ++ for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ g_object_ref( G_OBJECT(child) ); ++ l = g_slist_prepend(l, child); ++ } ++ l = g_slist_reverse(l); ++ while (l) { ++ SPObject *child = SP_OBJECT(l->data); ++ l = g_slist_remove(l, child); ++ if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { ++ child->emitModified(flags); ++ } ++ g_object_unref( G_OBJECT(child) ); ++ } } --static Inkscape::XML::Node * --sp_flowregion_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) ++static Inkscape::XML::Node *sp_flowregion_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if (flags & SP_OBJECT_WRITE_BUILD) { -- if ( repr == NULL ) { ++ if ( repr == NULL ) { repr = xml_doc->createElement("svg:flowRegion"); -- } ++ } GSList *l = NULL; - for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for ( SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { -- if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; -- Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); -- if (crepr) l = g_slist_prepend(l, crepr); ++ for ( SPObject *child = object->firstChild() ; child; child = child->getNext() ) { ++ if ( !SP_IS_TITLE(child) && !SP_IS_DESC(child) ) { ++ Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); ++ if (crepr) { ++ l = g_slist_prepend(l, crepr); ++ } ++ } } while (l) { @@@ -251,16 -251,16 +245,18 @@@ } } else { - for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for ( SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { -- if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; -- child->updateRepr(flags); ++ for ( SPObject *child = object->firstChild() ; child; child = child->getNext() ) { ++ if ( !SP_IS_TITLE(child) && !SP_IS_DESC(child) ) { ++ child->updateRepr(flags); ++ } } } -- if (((SPObjectClass *) (flowregion_parent_class))->write) -- ((SPObjectClass *) (flowregion_parent_class))->write (object, xml_doc, repr, flags); ++ if (((SPObjectClass *) (flowregion_parent_class))->write) { ++ ((SPObjectClass *) (flowregion_parent_class))->write (object, xml_doc, repr, flags); ++ } -- return repr; ++ return repr; } @@@ -361,102 -361,102 +357,97 @@@ sp_flowregionexclude_remove_child (SPOb } --static void --sp_flowregionexclude_update (SPObject *object, SPCtx *ctx, unsigned int flags) ++static void sp_flowregionexclude_update(SPObject *object, SPCtx *ctx, unsigned int flags) { -- SPFlowregionExclude *group; -- SPObject *child; -- SPItemCtx *ictx, cctx; -- GSList *l; ++ SPFlowregionExclude *group = SP_FLOWREGIONEXCLUDE (object); -- group = SP_FLOWREGIONEXCLUDE (object); -- ictx = (SPItemCtx *) ctx; -- cctx = *ictx; ++ SPItemCtx *ictx = reinterpret_cast<SPItemCtx *>(ctx); ++ SPItemCtx cctx = *ictx; -- if (((SPObjectClass *) (flowregionexclude_parent_class))->update) -- ((SPObjectClass *) (flowregionexclude_parent_class))->update (object, ctx, flags); ++ if (((SPObjectClass *) (flowregionexclude_parent_class))->update) { ++ ((SPObjectClass *) (flowregionexclude_parent_class))->update (object, ctx, flags); ++ } -- if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; -- flags &= SP_OBJECT_MODIFIED_CASCADE; ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } ++ flags &= SP_OBJECT_MODIFIED_CASCADE; -- l = NULL; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- g_object_ref (G_OBJECT (child)); -- l = g_slist_prepend (l, child); -- } -- l = g_slist_reverse (l); -- while (l) { -- child = SP_OBJECT (l->data); -- l = g_slist_remove (l, child); -- if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { -- if (SP_IS_ITEM (child)) { -- SPItem const &chi = *SP_ITEM(child); -- cctx.i2doc = chi.transform * ictx->i2doc; -- cctx.i2vp = chi.transform * ictx->i2vp; -- child->updateDisplay((SPCtx *)&cctx, flags); -- } else { -- child->updateDisplay(ctx, flags); -- } -- } -- g_object_unref (G_OBJECT (child)); -- } ++ GSList *l = NULL; ++ for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ g_object_ref( G_OBJECT(child) ); ++ l = g_slist_prepend(l, child); ++ } ++ l = g_slist_reverse (l); ++ while (l) { ++ SPObject *child = SP_OBJECT(l->data); ++ l = g_slist_remove(l, child); ++ if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { ++ if (SP_IS_ITEM (child)) { ++ SPItem const &chi = *SP_ITEM(child); ++ cctx.i2doc = chi.transform * ictx->i2doc; ++ cctx.i2vp = chi.transform * ictx->i2vp; ++ child->updateDisplay((SPCtx *)&cctx, flags); ++ } else { ++ child->updateDisplay(ctx, flags); ++ } ++ } ++ g_object_unref( G_OBJECT(child) ); ++ } -- group->UpdateComputed(); ++ group->UpdateComputed(); } --void SPFlowregionExclude::UpdateComputed(void) --{ -- SPObject* object=SP_OBJECT(this); ++void SPFlowregionExclude::UpdateComputed(void) ++{ if (computed) { delete computed; computed = NULL; } - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- GetDest(child,&computed); -- } ++ for ( SPObject* child = firstChild() ; child ; child = child->getNext() ) { ++ GetDest(child, &computed); ++ } } --static void --sp_flowregionexclude_modified (SPObject *object, guint flags) ++static void sp_flowregionexclude_modified(SPObject *object, guint flags) { -- SPFlowregionExclude *group; -- SPObject *child; -- GSList *l; -- -- group = SP_FLOWREGIONEXCLUDE (object); ++ SP_FLOWREGIONEXCLUDE(object); // Ensure it is the proper type -- if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; -- flags &= SP_OBJECT_MODIFIED_CASCADE; ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } ++ flags &= SP_OBJECT_MODIFIED_CASCADE; -- l = NULL; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- g_object_ref (G_OBJECT (child)); -- l = g_slist_prepend (l, child); -- } -- l = g_slist_reverse (l); -- while (l) { -- child = SP_OBJECT (l->data); -- l = g_slist_remove (l, child); -- if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { -- child->emitModified(flags); -- } -- g_object_unref (G_OBJECT (child)); -- } ++ GSList *l = NULL; ++ for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ g_object_ref( G_OBJECT(child) ); ++ l = g_slist_prepend(l, child); ++ } ++ l = g_slist_reverse (l); ++ while (l) { ++ SPObject *child = SP_OBJECT(l->data); ++ l = g_slist_remove(l, child); ++ if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { ++ child->emitModified(flags); ++ } ++ g_object_unref( G_OBJECT(child) ); ++ } } --static Inkscape::XML::Node * --sp_flowregionexclude_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) ++static Inkscape::XML::Node *sp_flowregionexclude_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if (flags & SP_OBJECT_WRITE_BUILD) { if ( repr == NULL ) { repr = xml_doc->createElement("svg:flowRegionExclude"); -- } ++ } GSList *l = NULL; - for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for ( SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = object->firstChild() ; child; child = child->getNext() ) { Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); -- if (crepr) l = g_slist_prepend(l, crepr); ++ if (crepr) { ++ l = g_slist_prepend(l, crepr); ++ } } while (l) { @@@ -466,15 -466,15 +457,16 @@@ } } else { - for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for ( SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = object->firstChild() ; child; child = child->getNext() ) { child->updateRepr(flags); } } -- if (((SPObjectClass *) (flowregionexclude_parent_class))->write) -- ((SPObjectClass *) (flowregionexclude_parent_class))->write (object, xml_doc, repr, flags); ++ if (((SPObjectClass *) (flowregionexclude_parent_class))->write) { ++ ((SPObjectClass *) (flowregionexclude_parent_class))->write (object, xml_doc, repr, flags); ++ } -- return repr; ++ return repr; } @@@ -548,3 -548,3 +540,13 @@@ static void GetDest(SPObject* c } } ++/* ++ Local Variables: ++ mode:c++ ++ c-file-style:"stroustrup" ++ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) ++ indent-tabs-mode:nil ++ fill-column:99 ++ End: ++*/ ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --cc src/sp-flowtext.cpp index b01146d60,4c3cc8a6c..3af12064f --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@@ -139,21 -139,21 +139,21 @@@ sp_flowtext_remove_child(SPObject *obje object->requestModified(SP_OBJECT_MODIFIED_FLAG); } --static void --sp_flowtext_update(SPObject *object, SPCtx *ctx, unsigned flags) ++static void sp_flowtext_update(SPObject *object, SPCtx *ctx, unsigned flags) { SPFlowtext *group = SP_FLOWTEXT(object); SPItemCtx *ictx = (SPItemCtx *) ctx; SPItemCtx cctx = *ictx; -- if (((SPObjectClass *) (parent_class))->update) ++ if (((SPObjectClass *) (parent_class))->update) { ((SPObjectClass *) (parent_class))->update(object, ctx, flags); ++ } if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { g_object_ref(G_OBJECT(child)); l = g_slist_prepend(l, child); } @@@ -186,8 -186,8 +186,7 @@@ } } --static void --sp_flowtext_modified(SPObject *object, guint flags) ++static void sp_flowtext_modified(SPObject *object, guint flags) { SPObject *ft = SP_FLOWTEXT (object); SPObject *region = NULL; @@@ -207,17 -207,17 +206,17 @@@ } } - for (SPObject *o = sp_object_first_child(SP_OBJECT(ft)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { - for (SPObject *o = SP_OBJECT(ft)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { ++ for ( SPObject *o = ft->firstChild() ; o ; o = o->getNext() ) { if (SP_IS_FLOWREGION(o)) { region = o; break; } } -- if (!region) return; -- -- if (flags || (region->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { -- region->emitModified(flags); // pass down to the region only ++ if (region) { ++ if (flags || (region->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { ++ region->emitModified(flags); // pass down to the region only ++ } } } @@@ -230,7 -230,7 +229,7 @@@ sp_flowtext_build(SPObject *object, SPD (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); } - sp_object_read_attr(object, "inkscape:layoutOptions"); // must happen after css has been read - object->readAttr( "inkscape:layoutOptions"); // must happen after css has been read ++ object->readAttr( "inkscape:layoutOptions" ); // must happen after css has been read } static void @@@ -241,7 -241,8 +240,8 @@@ sp_flowtext_set(SPObject *object, unsig switch (key) { case SP_ATTR_LAYOUT_OPTIONS: { // deprecated attribute, read for backward compatibility only - SPCSSAttr *opts = sp_repr_css_attr((SP_OBJECT(group))->repr, "inkscape:layoutOptions"); - //XML Tree being directly used while it shouldn't be. ++ //XML Tree being directly used while it shouldn't be. + SPCSSAttr *opts = sp_repr_css_attr((SP_OBJECT(group))->getRepr(), "inkscape:layoutOptions"); { gchar const *val = sp_repr_css_property(opts, "justification", NULL); if (val != NULL && !object->style->text_align.set) { @@@ -291,18 -292,18 +291,21 @@@ } } --static Inkscape::XML::Node * --sp_flowtext_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) ++static Inkscape::XML::Node *sp_flowtext_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if ( flags & SP_OBJECT_WRITE_BUILD ) { -- if ( repr == NULL ) repr = xml_doc->createElement("svg:flowRoot"); ++ if ( repr == NULL ) { ++ repr = xml_doc->createElement("svg:flowRoot"); ++ } GSList *l = NULL; - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { Inkscape::XML::Node *c_repr = NULL; if ( SP_IS_FLOWDIV(child) || SP_IS_FLOWPARA(child) || SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child)) { c_repr = child->updateRepr(xml_doc, NULL, flags); } -- if ( c_repr ) l = g_slist_prepend(l, c_repr); ++ if ( c_repr ) { ++ l = g_slist_prepend(l, c_repr); ++ } } while ( l ) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); @@@ -310,15 -311,15 +313,16 @@@ l = g_slist_remove(l, l->data); } } else { - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { if ( SP_IS_FLOWDIV(child) || SP_IS_FLOWPARA(child) || SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child) ) { child->updateRepr(flags); } } } -- if (((SPObjectClass *) (parent_class))->write) ++ if (((SPObjectClass *) (parent_class))->write) { ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); ++ } return repr; } @@@ -456,7 -457,7 +460,7 @@@ void SPFlowtext::_buildLayoutInput(SPOb *pending_line_break_object = NULL; } - for (SPObject *child = sp_object_first_child(root) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = root->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = root->firstChild() ; child ; child = child->getNext() ) { if (SP_IS_STRING(child)) { if (*pending_line_break_object) { if (SP_IS_FLOWREGIONBREAK(*pending_line_break_object)) @@@ -466,23 -467,24 +470,27 @@@ } *pending_line_break_object = NULL; } -- if (with_indent) ++ if (with_indent) { layout.appendText(SP_STRING(child)->string, root->style, child, &pi); -- else ++ } else { layout.appendText(SP_STRING(child)->string, root->style, child); ++ } } else if (SP_IS_FLOWREGION(child)) { std::vector<Shape*> const &computed = SP_FLOWREGION(child)->computed; for (std::vector<Shape*>::const_iterator it = computed.begin() ; it != computed.end() ; it++) { shapes->push_back(Shape()); -- if (exclusion_shape->hasEdges()) ++ if (exclusion_shape->hasEdges()) { shapes->back().Booleen(*it, const_cast<Shape*>(exclusion_shape), bool_op_diff); -- else ++ } else { shapes->back().Copy(*it); ++ } layout.appendWrapShape(&shapes->back()); } } - else if (!SP_IS_FLOWREGIONEXCLUDE(child) && !sp_repr_is_meta_element(child->repr)) - //XML Tree is being directly used while it shouldn't be. - else if (!SP_IS_FLOWREGIONEXCLUDE(child) && !sp_repr_is_meta_element(child->getRepr())) ++ //XML Tree is being directly used while it shouldn't be. ++ else if (!SP_IS_FLOWREGIONEXCLUDE(child) && !sp_repr_is_meta_element(child->getRepr())) { _buildLayoutInput(child, exclusion_shape, shapes, pending_line_break_object); ++ } } if (SP_IS_FLOWDIV(root) || SP_IS_FLOWPARA(root) || SP_IS_FLOWREGIONBREAK(root) || SP_IS_FLOWLINE(root)) { @@@ -497,17 -499,17 +505,18 @@@ Shape* SPFlowtext::_buildExclusionShape Shape *shape = new Shape; Shape *shape_temp = new Shape; -- for (SPObject *child = children ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = children ; child ; child = child->getNext() ) { // RH: is it right that this shouldn't be recursive? if ( SP_IS_FLOWREGIONEXCLUDE(child) ) { SPFlowregionExclude *c_child = SP_FLOWREGIONEXCLUDE(child); -- if (c_child->computed == NULL || !c_child->computed->hasEdges()) -- continue; -- if (shape->hasEdges()) { -- shape_temp->Booleen(shape, c_child->computed, bool_op_union); -- std::swap(shape, shape_temp); -- } else -- shape->Copy(c_child->computed); ++ if ( c_child->computed && c_child->computed->hasEdges() ) { ++ if (shape->hasEdges()) { ++ shape_temp->Booleen(shape, c_child->computed, bool_op_union); ++ std::swap(shape, shape_temp); ++ } else { ++ shape->Copy(c_child->computed); ++ } ++ } } } delete shape_temp; @@@ -547,7 -549,7 +556,7 @@@ SPFlowtext::getAsText( SPItem *item = SP_ITEM(this); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(this)); ++ Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(this)->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:text"); repr->setAttribute("xml:space", "preserve"); repr->setAttribute("style", SP_OBJECT_REPR(this)->attribute("style")); @@@ -650,40 -652,40 +659,36 @@@ SPItem *SPFlowtext::get_frame(SPItem *after) { -- SPObject *ft = SP_OBJECT (this); -- SPObject *region = NULL; ++ SPItem *frame = 0; - for (SPObject *o = sp_object_first_child(SP_OBJECT(ft)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { - for (SPObject *o = SP_OBJECT(ft)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { ++ SPObject *region = 0; ++ for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { if (SP_IS_FLOWREGION(o)) { region = o; break; } } -- if (!region) return NULL; -- -- bool past = false; -- SPItem *frame = NULL; ++ if (region) { ++ bool past = false; - for (SPObject *o = sp_object_first_child(SP_OBJECT(region)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { - for (SPObject *o = SP_OBJECT(region)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { -- if (SP_IS_ITEM(o)) { -- if (after == NULL || past) { -- frame = SP_ITEM(o); -- } else { -- if (SP_ITEM(o) == after) { -- past = true; ++ for (SPObject *o = region->firstChild() ; o ; o = o->getNext() ) { ++ if (SP_IS_ITEM(o)) { ++ if ( (after == NULL) || past ) { ++ frame = SP_ITEM(o); ++ } else { ++ if (SP_ITEM(o) == after) { ++ past = true; ++ } } } } -- } -- if (!frame) return NULL; -- -- if (SP_IS_USE (frame)) { -- return sp_use_get_original(SP_USE(frame)); -- } else { -- return frame; ++ if ( frame && SP_IS_USE(frame) ) { ++ frame = sp_use_get_original(SP_USE(frame)); ++ } } ++ return frame; } bool SPFlowtext::has_internal_frame() @@@ -698,7 -700,7 +703,7 @@@ SPItem *create_flowtext_with_internal_f { SPDocument *doc = sp_desktop_document (desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *root_repr = xml_doc->createElement("svg:flowRoot"); root_repr->setAttribute("xml:space", "preserve"); // we preserve spaces in the text objects we create SPItem *ft_item = SP_ITEM(desktop->currentLayer()->appendChildRepr(root_repr)); diff --cc src/sp-font-face.cpp index 1912676d4,a5894f83a..93e2eeac8 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@@ -3,7 -3,7 +3,6 @@@ #endif #ifdef ENABLE_SVG_FONTS --#define __SP_FONTFACE_C__ /* * SVG <font-face> element implementation @@@ -14,6 -14,6 +13,7 @@@ * * Author: * Felipe C. da S. Sanches <juca@members.fsf.org> ++ * Abhishek Sharma * * Copyright (C) 2008, Felipe C. da S. Sanches * @@@ -403,39 -403,39 +403,39 @@@ static void sp_fontface_build(SPObject ((SPObjectClass *) (parent_class))->build(object, document, repr); } - sp_object_read_attr(object, "font-family"); - sp_object_read_attr(object, "font-style"); - sp_object_read_attr(object, "font-variant"); - sp_object_read_attr(object, "font-weight"); - sp_object_read_attr(object, "font-stretch"); - sp_object_read_attr(object, "font-size"); - sp_object_read_attr(object, "unicode-range"); - sp_object_read_attr(object, "units-per-em"); - sp_object_read_attr(object, "panose-1"); - sp_object_read_attr(object, "stem-v"); - sp_object_read_attr(object, "stem-h"); - sp_object_read_attr(object, "slope"); - sp_object_read_attr(object, "cap-height"); - sp_object_read_attr(object, "x-height"); - sp_object_read_attr(object, "accent-height"); - sp_object_read_attr(object, "ascent"); - sp_object_read_attr(object, "descent"); - sp_object_read_attr(object, "widths"); - sp_object_read_attr(object, "bbox"); - sp_object_read_attr(object, "ideographic"); - sp_object_read_attr(object, "alphabetic"); - sp_object_read_attr(object, "mathematical"); - sp_object_read_attr(object, "ranging"); - sp_object_read_attr(object, "v-ideogaphic"); - sp_object_read_attr(object, "v-alphabetic"); - sp_object_read_attr(object, "v-mathematical"); - sp_object_read_attr(object, "v-hanging"); - sp_object_read_attr(object, "underline-position"); - sp_object_read_attr(object, "underline-thickness"); - sp_object_read_attr(object, "strikethrough-position"); - sp_object_read_attr(object, "strikethrough-thickness"); - sp_object_read_attr(object, "overline-position"); - sp_object_read_attr(object, "overline-thickness"); - object->readAttr( "font-family"); - object->readAttr( "font-style"); - object->readAttr( "font-variant"); - object->readAttr( "font-weight"); - object->readAttr( "font-stretch"); - object->readAttr( "font-size"); - object->readAttr( "unicode-range"); - object->readAttr( "units-per-em"); - object->readAttr( "panose-1"); - object->readAttr( "stem-v"); - object->readAttr( "stem-h"); - object->readAttr( "slope"); - object->readAttr( "cap-height"); - object->readAttr( "x-height"); - object->readAttr( "accent-height"); - object->readAttr( "ascent"); - object->readAttr( "descent"); - object->readAttr( "widths"); - object->readAttr( "bbox"); - object->readAttr( "ideographic"); - object->readAttr( "alphabetic"); - object->readAttr( "mathematical"); - object->readAttr( "ranging"); - object->readAttr( "v-ideogaphic"); - object->readAttr( "v-alphabetic"); - object->readAttr( "v-mathematical"); - object->readAttr( "v-hanging"); - object->readAttr( "underline-position"); - object->readAttr( "underline-thickness"); - object->readAttr( "strikethrough-position"); - object->readAttr( "strikethrough-thickness"); - object->readAttr( "overline-position"); - object->readAttr( "overline-thickness"); ++ object->readAttr( "font-family" ); ++ object->readAttr( "font-style" ); ++ object->readAttr( "font-variant" ); ++ object->readAttr( "font-weight" ); ++ object->readAttr( "font-stretch" ); ++ object->readAttr( "font-size" ); ++ object->readAttr( "unicode-range" ); ++ object->readAttr( "units-per-em" ); ++ object->readAttr( "panose-1" ); ++ object->readAttr( "stem-v" ); ++ object->readAttr( "stem-h" ); ++ object->readAttr( "slope" ); ++ object->readAttr( "cap-height" ); ++ object->readAttr( "x-height" ); ++ object->readAttr( "accent-height" ); ++ object->readAttr( "ascent" ); ++ object->readAttr( "descent" ); ++ object->readAttr( "widths" ); ++ object->readAttr( "bbox" ); ++ object->readAttr( "ideographic" ); ++ object->readAttr( "alphabetic" ); ++ object->readAttr( "mathematical" ); ++ object->readAttr( "ranging" ); ++ object->readAttr( "v-ideogaphic" ); ++ object->readAttr( "v-alphabetic" ); ++ object->readAttr( "v-mathematical" ); ++ object->readAttr( "v-hanging" ); ++ object->readAttr( "underline-position" ); ++ object->readAttr( "underline-thickness" ); ++ object->readAttr( "strikethrough-position" ); ++ object->readAttr( "strikethrough-thickness" ); ++ object->readAttr( "overline-position" ); ++ object->readAttr( "overline-thickness" ); } static void sp_fontface_children_modified(SPFontFace */*sp_fontface*/) @@@ -780,39 -780,39 +780,39 @@@ static voi sp_fontface_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG)) { - sp_object_read_attr(object, "font-family"); - sp_object_read_attr(object, "font-style"); - sp_object_read_attr(object, "font-variant"); - sp_object_read_attr(object, "font-weight"); - sp_object_read_attr(object, "font-stretch"); - sp_object_read_attr(object, "font-size"); - sp_object_read_attr(object, "unicode-range"); - sp_object_read_attr(object, "units-per-em"); - sp_object_read_attr(object, "panose-1"); - sp_object_read_attr(object, "stemv"); - sp_object_read_attr(object, "stemh"); - sp_object_read_attr(object, "slope"); - sp_object_read_attr(object, "cap-height"); - sp_object_read_attr(object, "x-height"); - sp_object_read_attr(object, "accent-height"); - sp_object_read_attr(object, "ascent"); - sp_object_read_attr(object, "descent"); - sp_object_read_attr(object, "widths"); - sp_object_read_attr(object, "bbox"); - sp_object_read_attr(object, "ideographic"); - sp_object_read_attr(object, "alphabetic"); - sp_object_read_attr(object, "mathematical"); - sp_object_read_attr(object, "hanging"); - sp_object_read_attr(object, "v-ideographic"); - sp_object_read_attr(object, "v-alphabetic"); - sp_object_read_attr(object, "v-mathematical"); - sp_object_read_attr(object, "v-hanging"); - sp_object_read_attr(object, "underline-position"); - sp_object_read_attr(object, "underline-thickness"); - sp_object_read_attr(object, "strikethrough-position"); - sp_object_read_attr(object, "strikethrough-thickness"); - sp_object_read_attr(object, "overline-position"); - sp_object_read_attr(object, "overline-thickness"); - object->readAttr( "font-family"); - object->readAttr( "font-style"); - object->readAttr( "font-variant"); - object->readAttr( "font-weight"); - object->readAttr( "font-stretch"); - object->readAttr( "font-size"); - object->readAttr( "unicode-range"); - object->readAttr( "units-per-em"); - object->readAttr( "panose-1"); - object->readAttr( "stemv"); - object->readAttr( "stemh"); - object->readAttr( "slope"); - object->readAttr( "cap-height"); - object->readAttr( "x-height"); - object->readAttr( "accent-height"); - object->readAttr( "ascent"); - object->readAttr( "descent"); - object->readAttr( "widths"); - object->readAttr( "bbox"); - object->readAttr( "ideographic"); - object->readAttr( "alphabetic"); - object->readAttr( "mathematical"); - object->readAttr( "hanging"); - object->readAttr( "v-ideographic"); - object->readAttr( "v-alphabetic"); - object->readAttr( "v-mathematical"); - object->readAttr( "v-hanging"); - object->readAttr( "underline-position"); - object->readAttr( "underline-thickness"); - object->readAttr( "strikethrough-position"); - object->readAttr( "strikethrough-thickness"); - object->readAttr( "overline-position"); - object->readAttr( "overline-thickness"); ++ object->readAttr( "font-family" ); ++ object->readAttr( "font-style" ); ++ object->readAttr( "font-variant" ); ++ object->readAttr( "font-weight" ); ++ object->readAttr( "font-stretch" ); ++ object->readAttr( "font-size" ); ++ object->readAttr( "unicode-range" ); ++ object->readAttr( "units-per-em" ); ++ object->readAttr( "panose-1" ); ++ object->readAttr( "stemv" ); ++ object->readAttr( "stemh" ); ++ object->readAttr( "slope" ); ++ object->readAttr( "cap-height" ); ++ object->readAttr( "x-height" ); ++ object->readAttr( "accent-height" ); ++ object->readAttr( "ascent" ); ++ object->readAttr( "descent" ); ++ object->readAttr( "widths" ); ++ object->readAttr( "bbox" ); ++ object->readAttr( "ideographic" ); ++ object->readAttr( "alphabetic" ); ++ object->readAttr( "mathematical" ); ++ object->readAttr( "hanging" ); ++ object->readAttr( "v-ideographic" ); ++ object->readAttr( "v-alphabetic" ); ++ object->readAttr( "v-mathematical" ); ++ object->readAttr( "v-hanging" ); ++ object->readAttr( "underline-position" ); ++ object->readAttr( "underline-thickness" ); ++ object->readAttr( "strikethrough-position" ); ++ object->readAttr( "strikethrough-thickness" ); ++ object->readAttr( "overline-position" ); ++ object->readAttr( "overline-thickness" ); } if (((SPObjectClass *) parent_class)->update) { @@@ -866,39 -866,41 +866,41 @@@ static Inkscape::XML::Node *sp_fontface sp_repr_set_svg_double(repr, "overline-thickness", face->overline_thickness); if (repr != SP_OBJECT_REPR(object)) { - COPY_ATTR(repr, object->repr, "font-family"); - COPY_ATTR(repr, object->repr, "font-style"); - COPY_ATTR(repr, object->repr, "font-variant"); - COPY_ATTR(repr, object->repr, "font-weight"); - COPY_ATTR(repr, object->repr, "font-stretch"); - COPY_ATTR(repr, object->repr, "font-size"); - COPY_ATTR(repr, object->repr, "unicode-range"); - COPY_ATTR(repr, object->repr, "units-per-em"); - COPY_ATTR(repr, object->repr, "panose-1"); - COPY_ATTR(repr, object->repr, "stemv"); - COPY_ATTR(repr, object->repr, "stemh"); - COPY_ATTR(repr, object->repr, "slope"); - COPY_ATTR(repr, object->repr, "cap-height"); - COPY_ATTR(repr, object->repr, "x-height"); - COPY_ATTR(repr, object->repr, "accent-height"); - COPY_ATTR(repr, object->repr, "ascent"); - COPY_ATTR(repr, object->repr, "descent"); - COPY_ATTR(repr, object->repr, "widths"); - COPY_ATTR(repr, object->repr, "bbox"); - COPY_ATTR(repr, object->repr, "ideographic"); - COPY_ATTR(repr, object->repr, "alphabetic"); - COPY_ATTR(repr, object->repr, "mathematical"); - COPY_ATTR(repr, object->repr, "hanging"); - COPY_ATTR(repr, object->repr, "v-ideographic"); - COPY_ATTR(repr, object->repr, "v-alphabetic"); - COPY_ATTR(repr, object->repr, "v-mathematical"); - COPY_ATTR(repr, object->repr, "v-hanging"); - COPY_ATTR(repr, object->repr, "underline-position"); - COPY_ATTR(repr, object->repr, "underline-thickness"); - COPY_ATTR(repr, object->repr, "strikethrough-position"); - COPY_ATTR(repr, object->repr, "strikethrough-thickness"); - COPY_ATTR(repr, object->repr, "overline-position"); - COPY_ATTR(repr, object->repr, "overline-thickness"); - /*/ In all COPY_ATTR given below the XML tree is - being used directly while it shouldn't be.*/ ++ // In all COPY_ATTR given below the XML tree is ++ // being used directly while it shouldn't be. + COPY_ATTR(repr, object->getRepr(), "font-family"); + COPY_ATTR(repr, object->getRepr(), "font-style"); + COPY_ATTR(repr, object->getRepr(), "font-variant"); + COPY_ATTR(repr, object->getRepr(), "font-weight"); + COPY_ATTR(repr, object->getRepr(), "font-stretch"); + COPY_ATTR(repr, object->getRepr(), "font-size"); + COPY_ATTR(repr, object->getRepr(), "unicode-range"); + COPY_ATTR(repr, object->getRepr(), "units-per-em"); + COPY_ATTR(repr, object->getRepr(), "panose-1"); + COPY_ATTR(repr, object->getRepr(), "stemv"); + COPY_ATTR(repr, object->getRepr(), "stemh"); + COPY_ATTR(repr, object->getRepr(), "slope"); + COPY_ATTR(repr, object->getRepr(), "cap-height"); + COPY_ATTR(repr, object->getRepr(), "x-height"); + COPY_ATTR(repr, object->getRepr(), "accent-height"); + COPY_ATTR(repr, object->getRepr(), "ascent"); + COPY_ATTR(repr, object->getRepr(), "descent"); + COPY_ATTR(repr, object->getRepr(), "widths"); + COPY_ATTR(repr, object->getRepr(), "bbox"); + COPY_ATTR(repr, object->getRepr(), "ideographic"); + COPY_ATTR(repr, object->getRepr(), "alphabetic"); + COPY_ATTR(repr, object->getRepr(), "mathematical"); + COPY_ATTR(repr, object->getRepr(), "hanging"); + COPY_ATTR(repr, object->getRepr(), "v-ideographic"); + COPY_ATTR(repr, object->getRepr(), "v-alphabetic"); + COPY_ATTR(repr, object->getRepr(), "v-mathematical"); + COPY_ATTR(repr, object->getRepr(), "v-hanging"); + COPY_ATTR(repr, object->getRepr(), "underline-position"); + COPY_ATTR(repr, object->getRepr(), "underline-thickness"); + COPY_ATTR(repr, object->getRepr(), "strikethrough-position"); + COPY_ATTR(repr, object->getRepr(), "strikethrough-thickness"); + COPY_ATTR(repr, object->getRepr(), "overline-position"); + COPY_ATTR(repr, object->getRepr(), "overline-thickness"); } if (((SPObjectClass *) (parent_class))->write) { diff --cc src/sp-font.cpp index b2003cf08,a1a2c425f..64f7bd481 --- a/src/sp-font.cpp +++ b/src/sp-font.cpp @@@ -9,6 -9,6 +9,7 @@@ * * Author: * Felipe C. da S. Sanches <juca@members.fsf.org> ++ * Abhishek Sharma * * Copyright (C) 2008, Felipe C. da S. Sanches * @@@ -101,14 -101,14 +102,14 @@@ static void sp_font_build(SPObject *obj ((SPObjectClass *) (parent_class))->build(object, document, repr); } - sp_object_read_attr(object, "horiz-origin-x"); - sp_object_read_attr(object, "horiz-origin-y"); - sp_object_read_attr(object, "horiz-adv-x"); - sp_object_read_attr(object, "vert-origin-x"); - sp_object_read_attr(object, "vert-origin-y"); - sp_object_read_attr(object, "vert-adv-y"); - object->readAttr( "horiz-origin-x"); - object->readAttr( "horiz-origin-y"); - object->readAttr( "horiz-adv-x"); - object->readAttr( "vert-origin-x"); - object->readAttr( "vert-origin-y"); - object->readAttr( "vert-adv-y"); ++ object->readAttr( "horiz-origin-x" ); ++ object->readAttr( "horiz-origin-y" ); ++ object->readAttr( "horiz-adv-x" ); ++ object->readAttr( "vert-origin-x" ); ++ object->readAttr( "vert-origin-y" ); ++ object->readAttr( "vert-adv-y" ); - sp_document_add_resource(document, "font", object); - document->add_resource("font", object); ++ document->addResource("font", object); } @@@ -150,7 -150,7 +151,7 @@@ sp_font_remove_child(SPObject *object, static void sp_font_release(SPObject *object) { //SPFont *font = SP_FONT(object); - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "font", object); - SP_OBJECT_DOCUMENT(object)->remove_resource("font", object); ++ SP_OBJECT_DOCUMENT(object)->removeResource("font", object); if (((SPObjectClass *) parent_class)->release) { ((SPObjectClass *) parent_class)->release(object); @@@ -232,12 -232,12 +233,12 @@@ static voi sp_font_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG)) { - sp_object_read_attr(object, "horiz-origin-x"); - sp_object_read_attr(object, "horiz-origin-y"); - sp_object_read_attr(object, "horiz-adv-x"); - sp_object_read_attr(object, "vert-origin-x"); - sp_object_read_attr(object, "vert-origin-y"); - sp_object_read_attr(object, "vert-adv-y"); - object->readAttr( "horiz-origin-x"); - object->readAttr( "horiz-origin-y"); - object->readAttr( "horiz-adv-x"); - object->readAttr( "vert-origin-x"); - object->readAttr( "vert-origin-y"); - object->readAttr( "vert-adv-y"); ++ object->readAttr( "horiz-origin-x" ); ++ object->readAttr( "horiz-origin-y" ); ++ object->readAttr( "horiz-adv-x" ); ++ object->readAttr( "vert-origin-x" ); ++ object->readAttr( "vert-origin-y" ); ++ object->readAttr( "vert-adv-y" ); } if (((SPObjectClass *) parent_class)->update) { @@@ -263,12 -263,14 +264,14 @@@ static Inkscape::XML::Node *sp_font_wri sp_repr_set_svg_double(repr, "vert-adv-y", font->vert_adv_y); if (repr != SP_OBJECT_REPR(object)) { - COPY_ATTR(repr, object->repr, "horiz-origin-x"); - COPY_ATTR(repr, object->repr, "horiz-origin-y"); - COPY_ATTR(repr, object->repr, "horiz-adv-x"); - COPY_ATTR(repr, object->repr, "vert-origin-x"); - COPY_ATTR(repr, object->repr, "vert-origin-y"); - COPY_ATTR(repr, object->repr, "vert-adv-y"); - /*All the below COPY_ATTR funtions are directly using - the XML Tree while they shouldn't*/ ++ // All the below COPY_ATTR funtions are directly using ++ // the XML Tree while they shouldn't + COPY_ATTR(repr, object->getRepr(), "horiz-origin-x"); + COPY_ATTR(repr, object->getRepr(), "horiz-origin-y"); + COPY_ATTR(repr, object->getRepr(), "horiz-adv-x"); + COPY_ATTR(repr, object->getRepr(), "vert-origin-x"); + COPY_ATTR(repr, object->getRepr(), "vert-origin-y"); + COPY_ATTR(repr, object->getRepr(), "vert-adv-y"); } if (((SPObjectClass *) (parent_class))->write) { diff --cc src/sp-gaussian-blur.cpp index 6bb1f64e7,7182e5ce9..1c28fb76f --- a/src/sp-gaussian-blur.cpp +++ b/src/sp-gaussian-blur.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_GAUSSIANBLUR_CPP__ -- /** \file * SVG <gaussianBlur> implementation. * @@@ -8,6 -8,6 +6,7 @@@ * Authors: * Hugo Rodrigues <haa.rodrigues@gmail.com> * Niko Kiirala <niko@kiirala.com> ++ * Abhishek Sharma * * Copyright (C) 2006,2007 Authors * @@@ -100,7 -100,7 +99,7 @@@ sp_gaussianBlur_build(SPObject *object ((SPObjectClass *) gaussianBlur_parent_class)->build(object, document, repr); } - sp_object_read_attr(object, "stdDeviation"); - object->readAttr( "stdDeviation"); ++ object->readAttr( "stdDeviation" ); } @@@ -143,7 -143,7 +142,7 @@@ static voi sp_gaussianBlur_update(SPObject *object, SPCtx *ctx, guint flags) { if (flags & SP_OBJECT_MODIFIED_FLAG) { - sp_object_read_attr(object, "stdDeviation"); - object->readAttr( "stdDeviation"); ++ object->readAttr( "stdDeviation" ); } if (((SPObjectClass *) gaussianBlur_parent_class)->update) { diff --cc src/sp-glyph-kerning.cpp index d62fbb2c2,2efdedf7a..7a9f9b2ff --- a/src/sp-glyph-kerning.cpp +++ b/src/sp-glyph-kerning.cpp @@@ -11,6 -11,6 +11,7 @@@ * * Author: * Felipe C. da S. Sanches <juca@members.fsf.org> ++ * Abhishek Sharma * * Copyright (C) 2008, Felipe C. da S. Sanches * @@@ -42,15 -42,15 +43,15 @@@ GType sp_glyph_kerning_h_get_type(void if (!type) { GTypeInfo info = { sizeof(SPGlyphKerningClass), -- NULL, /* base_init */ -- NULL, /* base_finalize */ ++ NULL, /* base_init */ ++ NULL, /* base_finalize */ (GClassInitFunc) sp_glyph_kerning_class_init, -- NULL, /* class_finalize */ -- NULL, /* class_data */ ++ NULL, /* class_finalize */ ++ NULL, /* class_data */ sizeof(SPHkern), -- 16, /* n_preallocs */ ++ 16, /* n_preallocs */ (GInstanceInitFunc) sp_glyph_kerning_init, -- NULL, /* value_table */ ++ NULL, /* value_table */ }; type = g_type_register_static(SP_TYPE_OBJECT, "SPHkern", &info, (GTypeFlags) 0); } @@@ -65,15 -65,15 +66,15 @@@ GType sp_glyph_kerning_v_get_type(void if (!type) { GTypeInfo info = { sizeof(SPGlyphKerningClass), -- NULL, /* base_init */ -- NULL, /* base_finalize */ ++ NULL, /* base_init */ ++ NULL, /* base_finalize */ (GClassInitFunc) sp_glyph_kerning_class_init, -- NULL, /* class_finalize */ -- NULL, /* class_data */ ++ NULL, /* class_finalize */ ++ NULL, /* class_data */ sizeof(SPVkern), -- 16, /* n_preallocs */ ++ 16, /* n_preallocs */ (GInstanceInitFunc) sp_glyph_kerning_init, -- NULL, /* value_table */ ++ NULL, /* value_table */ }; type = g_type_register_static(SP_TYPE_OBJECT, "SPVkern", &info, (GTypeFlags) 0); } @@@ -110,11 -110,11 +111,11 @@@ static void sp_glyph_kerning_build(SPOb ((SPObjectClass *) (parent_class))->build(object, document, repr); } - sp_object_read_attr(object, "u1"); - sp_object_read_attr(object, "g1"); - sp_object_read_attr(object, "u2"); - sp_object_read_attr(object, "g2"); - sp_object_read_attr(object, "k"); - object->readAttr( "u1"); - object->readAttr( "g1"); - object->readAttr( "u2"); - object->readAttr( "g2"); - object->readAttr( "k"); ++ object->readAttr( "u1" ); ++ object->readAttr( "g1" ); ++ object->readAttr( "u2" ); ++ object->readAttr( "g2" ); ++ object->readAttr( "k" ); } static void sp_glyph_kerning_release(SPObject *object) @@@ -216,10 -216,10 +217,10 @@@ sp_glyph_kerning_update(SPObject *objec if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ - sp_object_read_attr(object, "u1"); - sp_object_read_attr(object, "u2"); - sp_object_read_attr(object, "g2"); - sp_object_read_attr(object, "k"); - object->readAttr( "u1"); - object->readAttr( "u2"); - object->readAttr( "g2"); - object->readAttr( "k"); ++ object->readAttr( "u1" ); ++ object->readAttr( "u2" ); ++ object->readAttr( "g2" ); ++ object->readAttr( "k" ); } if (((SPObjectClass *) parent_class)->update) { @@@ -250,11 -250,13 +251,13 @@@ static Inkscape::XML::Node *sp_glyph_ke sp_repr_set_svg_double(repr, "vert-adv-y", glyph->vert_adv_y); */ if (repr != SP_OBJECT_REPR(object)) { - COPY_ATTR(repr, object->repr, "u1"); - COPY_ATTR(repr, object->repr, "g1"); - COPY_ATTR(repr, object->repr, "u2"); - COPY_ATTR(repr, object->repr, "g2"); - COPY_ATTR(repr, object->repr, "k"); - /* All the COPY_ATTR functions below use - XML Tree directly, while they shouldn't.*/ ++ // All the COPY_ATTR functions below use ++ // XML Tree directly, while they shouldn't. + COPY_ATTR(repr, object->getRepr(), "u1"); + COPY_ATTR(repr, object->getRepr(), "g1"); + COPY_ATTR(repr, object->getRepr(), "u2"); + COPY_ATTR(repr, object->getRepr(), "g2"); + COPY_ATTR(repr, object->getRepr(), "k"); } if (((SPObjectClass *) (parent_class))->write) { diff --cc src/sp-glyph.cpp index 0b3b85d3f,a2a5c7fcd..6f7238133 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@@ -10,6 -10,6 +10,7 @@@ * * Author: * Felipe C. da S. Sanches <juca@members.fsf.org> ++ * Abhishek Sharma * * Copyright (C) 2008, Felipe C. da S. Sanches * @@@ -39,15 -39,15 +40,15 @@@ GType sp_glyph_get_type(void if (!type) { GTypeInfo info = { sizeof(SPGlyphClass), -- NULL, /* base_init */ -- NULL, /* base_finalize */ ++ NULL, /* base_init */ ++ NULL, /* base_finalize */ (GClassInitFunc) sp_glyph_class_init, -- NULL, /* class_finalize */ -- NULL, /* class_data */ ++ NULL, /* class_finalize */ ++ NULL, /* class_data */ sizeof(SPGlyph), -- 16, /* n_preallocs */ ++ 16, /* n_preallocs */ (GInstanceInitFunc) sp_glyph_init, -- NULL, /* value_table */ ++ NULL, /* value_table */ }; type = g_type_register_static(SP_TYPE_OBJECT, "SPGlyph", &info, (GTypeFlags) 0); } @@@ -90,16 -90,16 +91,16 @@@ static void sp_glyph_build(SPObject *ob ((SPObjectClass *) (parent_class))->build(object, document, repr); } - sp_object_read_attr(object, "unicode"); - sp_object_read_attr(object, "glyph-name"); - sp_object_read_attr(object, "d"); - sp_object_read_attr(object, "orientation"); - sp_object_read_attr(object, "arabic-form"); - sp_object_read_attr(object, "lang"); - sp_object_read_attr(object, "horiz-adv-x"); - sp_object_read_attr(object, "vert-origin-x"); - sp_object_read_attr(object, "vert-origin-y"); - sp_object_read_attr(object, "vert-adv-y"); - object->readAttr( "unicode"); - object->readAttr( "glyph-name"); - object->readAttr( "d"); - object->readAttr( "orientation"); - object->readAttr( "arabic-form"); - object->readAttr( "lang"); - object->readAttr( "horiz-adv-x"); - object->readAttr( "vert-origin-x"); - object->readAttr( "vert-origin-y"); - object->readAttr( "vert-adv-y"); ++ object->readAttr( "unicode" ); ++ object->readAttr( "glyph-name" ); ++ object->readAttr( "d" ); ++ object->readAttr( "orientation" ); ++ object->readAttr( "arabic-form" ); ++ object->readAttr( "lang" ); ++ object->readAttr( "horiz-adv-x" ); ++ object->readAttr( "vert-origin-x" ); ++ object->readAttr( "vert-origin-y" ); ++ object->readAttr( "vert-adv-y" ); } static void sp_glyph_release(SPObject *object) @@@ -250,16 -250,16 +251,16 @@@ sp_glyph_update(SPObject *object, SPCt if (flags & SP_OBJECT_MODIFIED_FLAG) { /* do something to trigger redisplay, updates? */ - sp_object_read_attr(object, "unicode"); - sp_object_read_attr(object, "glyph-name"); - sp_object_read_attr(object, "d"); - sp_object_read_attr(object, "orientation"); - sp_object_read_attr(object, "arabic-form"); - sp_object_read_attr(object, "lang"); - sp_object_read_attr(object, "horiz-adv-x"); - sp_object_read_attr(object, "vert-origin-x"); - sp_object_read_attr(object, "vert-origin-y"); - sp_object_read_attr(object, "vert-adv-y"); - object->readAttr( "unicode"); - object->readAttr( "glyph-name"); - object->readAttr( "d"); - object->readAttr( "orientation"); - object->readAttr( "arabic-form"); - object->readAttr( "lang"); - object->readAttr( "horiz-adv-x"); - object->readAttr( "vert-origin-x"); - object->readAttr( "vert-origin-y"); - object->readAttr( "vert-adv-y"); ++ object->readAttr( "unicode" ); ++ object->readAttr( "glyph-name" ); ++ object->readAttr( "d" ); ++ object->readAttr( "orientation" ); ++ object->readAttr( "arabic-form" ); ++ object->readAttr( "lang" ); ++ object->readAttr( "horiz-adv-x" ); ++ object->readAttr( "vert-origin-x" ); ++ object->readAttr( "vert-origin-y" ); ++ object->readAttr( "vert-adv-y" ); } if (((SPObjectClass *) parent_class)->update) { @@@ -290,16 -290,18 +291,18 @@@ static Inkscape::XML::Node *sp_glyph_wr sp_repr_set_svg_double(repr, "vert-adv-y", glyph->vert_adv_y); */ if (repr != SP_OBJECT_REPR(object)) { - COPY_ATTR(repr, object->repr, "unicode"); - COPY_ATTR(repr, object->repr, "glyph-name"); - COPY_ATTR(repr, object->repr, "d"); - COPY_ATTR(repr, object->repr, "orientation"); - COPY_ATTR(repr, object->repr, "arabic-form"); - COPY_ATTR(repr, object->repr, "lang"); - COPY_ATTR(repr, object->repr, "horiz-adv-x"); - COPY_ATTR(repr, object->repr, "vert-origin-x"); - COPY_ATTR(repr, object->repr, "vert-origin-y"); - COPY_ATTR(repr, object->repr, "vert-adv-y"); - /* All the COPY_ATTR functions below use - XML Tree directly while they shouldn't. */ ++ // All the COPY_ATTR functions below use ++ // XML Tree directly while they shouldn't. + COPY_ATTR(repr, object->getRepr(), "unicode"); + COPY_ATTR(repr, object->getRepr(), "glyph-name"); + COPY_ATTR(repr, object->getRepr(), "d"); + COPY_ATTR(repr, object->getRepr(), "orientation"); + COPY_ATTR(repr, object->getRepr(), "arabic-form"); + COPY_ATTR(repr, object->getRepr(), "lang"); + COPY_ATTR(repr, object->getRepr(), "horiz-adv-x"); + COPY_ATTR(repr, object->getRepr(), "vert-origin-x"); + COPY_ATTR(repr, object->getRepr(), "vert-origin-y"); + COPY_ATTR(repr, object->getRepr(), "vert-adv-y"); } if (((SPObjectClass *) (parent_class))->write) { diff --cc src/sp-gradient-test.h index a664218e0,62c0ac8c2..2a061595e --- a/src/sp-gradient-test.h +++ b/src/sp-gradient-test.h @@@ -1,4 -1,4 +1,3 @@@ -- #ifndef SEEN_SP_GRADIENT_TEST_H #define SEEN_SP_GRADIENT_TEST_H diff --cc src/sp-gradient.cpp index cd57f40b5,56ddd09d9..1b8f9a111 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@@ -6,6 -6,6 +6,8 @@@ * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> * Jasper van de Gronde <th.v.d.gronde@hccnet.nl> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -142,10 -141,10 +144,10 @@@ static void sp_stop_build(SPObject *obj if (((SPObjectClass *) stop_parent_class)->build) (* ((SPObjectClass *) stop_parent_class)->build)(object, document, repr); - sp_object_read_attr(object, "offset"); - sp_object_read_attr(object, "stop-color"); - sp_object_read_attr(object, "stop-opacity"); - sp_object_read_attr(object, "style"); - object->readAttr( "offset"); - object->readAttr( "stop-color"); - object->readAttr( "stop-opacity"); - object->readAttr( "style"); ++ object->readAttr( "offset" ); ++ object->readAttr( "stop-color" ); ++ object->readAttr( "stop-opacity" ); ++ object->readAttr( "style" ); } /** @@@ -286,17 -288,6 +288,17 @@@ SPGradientSpread SPGradient::getSpread( return spread; } +void SPGradient::setSwatch( bool swatch ) +{ + if ( swatch != isSwatch() ) { + this->swatch = swatch; // to make isSolid() work, this happens first + gchar const* paintVal = swatch ? (isSolid() ? "solid" : "gradient") : 0; - sp_object_setAttribute( this, "osb:paint", paintVal, 0 ); ++ setAttribute( "osb:paint", paintVal, 0 ); + + requestModified( SP_OBJECT_MODIFIED_FLAG ); + } +} + /** * Return stop's color as 32bit value. */ @@@ -408,30 -422,24 +410,30 @@@ void SPGradientImpl::build(SPObject *ob { SPGradient *gradient = SP_GRADIENT(object); - if (((SPObjectClass *) gradient_parent_class)->build) + // Work-around in case a swatch had been marked for immediate collection: + if ( repr->attribute("osb:paint") && repr->attribute("inkscape:collect") ) { + repr->setAttribute("inkscape:collect", 0); + } + + if (((SPObjectClass *) gradient_parent_class)->build) { (* ((SPObjectClass *) gradient_parent_class)->build)(object, document, repr); + } - for ( SPObject *ochild = sp_object_first_child(object); ochild; ochild = ochild->next ) { - SPObject *ochild; - for ( ochild = object->first_child() ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { ++ for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) { if (SP_IS_STOP(ochild)) { gradient->has_stops = TRUE; break; } } - sp_object_read_attr(object, "gradientUnits"); - sp_object_read_attr(object, "gradientTransform"); - sp_object_read_attr(object, "spreadMethod"); - sp_object_read_attr(object, "xlink:href"); - sp_object_read_attr(object, "osb:paint"); - object->readAttr( "gradientUnits"); - object->readAttr( "gradientTransform"); - object->readAttr( "spreadMethod"); - object->readAttr( "xlink:href"); ++ object->readAttr( "gradientUnits" ); ++ object->readAttr( "gradientTransform" ); ++ object->readAttr( "spreadMethod" ); ++ object->readAttr( "xlink:href" ); ++ object->readAttr( "osb:paint" ); -- /* Register ourselves */ - sp_document_add_resource(document, "gradient", object); - document->add_resource("gradient", object); ++ // Register ourselves ++ document->addResource("gradient", object); } /** @@@ -442,12 -450,12 +444,12 @@@ void SPGradientImpl::release(SPObject * SPGradient *gradient = (SPGradient *) object; #ifdef SP_GRADIENT_VERBOSE -- g_print("Releasing gradient %s\n", SP_OBJECT_ID(object)); ++ g_print("Releasing gradient %s\n", object->getId()); #endif if (SP_OBJECT_DOCUMENT(object)) { /* Unregister ourselves */ - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "gradient", SP_OBJECT(object)); - SP_OBJECT_DOCUMENT(object)->remove_resource("gradient", SP_OBJECT(object)); ++ SP_OBJECT_DOCUMENT(object)->removeResource("gradient", SP_OBJECT(object)); } if (gradient->ref) { @@@ -529,31 -537,9 +531,31 @@@ void SPGradientImpl::setGradientAttr(SP gr->ref->detach(); } break; + case SP_ATTR_OSB_SWATCH: + { + bool newVal = (value != 0); + bool modified = false; + if (newVal != gr->swatch) { + gr->swatch = newVal; + modified = true; + } + if (newVal) { + // Might need to flip solid/gradient + Glib::ustring paintVal = ( gr->hasStops() && (gr->getStopCount() == 0) ) ? "solid" : "gradient"; + if ( paintVal != value ) { - sp_object_setAttribute( gr, "osb:paint", paintVal.c_str(), 0 ); ++ gr->setAttribute( "osb:paint", paintVal.c_str(), 0 ); + modified = true; + } + } + if (modified) { + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + } + } + break; default: - if (((SPObjectClass *) gradient_parent_class)->set) + if (((SPObjectClass *) gradient_parent_class)->set) { ((SPObjectClass *) gradient_parent_class)->set(object, key, value); + } break; } } @@@ -596,19 -582,12 +598,19 @@@ void SPGradientImpl::childAdded(SPObjec gr->invalidateVector(); - if (((SPObjectClass *) gradient_parent_class)->child_added) + if (((SPObjectClass *) gradient_parent_class)->child_added) { (* ((SPObjectClass *) gradient_parent_class)->child_added)(object, child, ref); + } - SPObject *ochild = sp_object_get_child_by_repr(object, child); + SPObject *ochild = object->get_child_by_repr(child); if ( ochild && SP_IS_STOP(ochild) ) { gr->has_stops = TRUE; + if ( gr->getStopCount() > 0 ) { - gchar const * attr = gr->repr->attribute("osb:paint"); ++ gchar const * attr = gr->getAttribute("osb:paint"); + if ( attr && strcmp(attr, "gradient") ) { - sp_object_setAttribute( gr, "osb:paint", "gradient", 0 ); ++ gr->setAttribute( "osb:paint", "gradient", 0 ); + } + } } /// \todo Fixme: should we schedule "modified" here? @@@ -629,21 -608,14 +631,20 @@@ void SPGradientImpl::removeChild(SPObje } gr->has_stops = FALSE; -- SPObject *ochild; - for ( ochild = sp_object_first_child(object) ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { - for ( ochild = object->first_child() ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { ++ for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) { if (SP_IS_STOP(ochild)) { gr->has_stops = TRUE; break; } } + if ( gr->getStopCount() == 0 ) { - gchar const * attr = gr->repr->attribute("osb:paint"); ++ gchar const * attr = gr->getAttribute("osb:paint"); + if ( attr && strcmp(attr, "solid") ) { - sp_object_setAttribute( gr, "osb:paint", "solid", 0 ); ++ gr->setAttribute( "osb:paint", "solid", 0 ); + } + } + /* Fixme: should we schedule "modified" here? */ object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@@ -668,7 -640,7 +669,7 @@@ void SPGradientImpl::modified(SPObject // FIXME: climb up the ladder of hrefs GSList *l = NULL; - for (SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = object->firstChild() ; child; child = child->getNext() ) { g_object_ref(G_OBJECT(child)); l = g_slist_prepend(l, child); } @@@ -686,7 -658,7 +687,7 @@@ SPStop* SPGradient::getFirstStop() { SPStop* first = 0; - for (SPObject *ochild = sp_object_first_child(this); ochild && !first; ochild = SP_OBJECT_NEXT(ochild)) { - for (SPObject *ochild = this->first_child(); ochild && !first; ochild = SP_OBJECT_NEXT(ochild)) { ++ for (SPObject *ochild = firstChild(); ochild && !first; ochild = ochild->getNext()) { if (SP_IS_STOP(ochild)) { first = SP_STOP(ochild); } @@@ -718,11 -689,10 +719,11 @@@ Inkscape::XML::Node *SPGradientImpl::wr if (flags & SP_OBJECT_WRITE_BUILD) { GSList *l = NULL; - for (SPObject *child = sp_object_first_child(object); child; child = SP_OBJECT_NEXT(child)) { - for (SPObject *child = object->first_child(); child; child = SP_OBJECT_NEXT(child)) { - Inkscape::XML::Node *crepr; - crepr = child->updateRepr(xml_doc, NULL, flags); - if (crepr) l = g_slist_prepend(l, crepr); ++ for (SPObject *child = object->firstChild(); child; child = child->getNext()) { + Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + if (crepr) { + l = g_slist_prepend(l, crepr); + } } while (l) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); @@@ -961,7 -921,7 +962,7 @@@ sp_gradient_repr_write_vector(SPGradien g_return_if_fail(gr != NULL); g_return_if_fail(SP_IS_GRADIENT(gr)); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(gr)); ++ Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(gr)->getReprDoc(); Inkscape::XML::Node *repr = SP_OBJECT_REPR(gr); /* We have to be careful, as vector may be our own, so construct repr list at first */ @@@ -1023,9 -985,9 +1024,7 @@@ bool SPGradient::invalidateVector( void SPGradient::rebuildVector() { gint len = 0; - for ( SPObject *child = sp_object_first_child(SP_OBJECT(this)) ; - for ( SPObject *child = SP_OBJECT(this)->first_child() ; -- child != NULL ; -- child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) { if (SP_IS_STOP(child)) { len ++; } @@@ -1047,9 -1009,9 +1046,7 @@@ } } - for (SPObject *child = sp_object_first_child(SP_OBJECT(this)) ; - for (SPObject *child = SP_OBJECT(this)->first_child() ; -- child != NULL; -- child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = firstChild(); child; child = child->getNext() ) { if (SP_IS_STOP(child)) { SPStop *stop = SP_STOP(child); @@@ -1530,10 -1492,10 +1527,10 @@@ static void sp_lineargradient_build(SPO if (((SPObjectClass *) lg_parent_class)->build) (* ((SPObjectClass *) lg_parent_class)->build)(object, document, repr); - sp_object_read_attr(object, "x1"); - sp_object_read_attr(object, "y1"); - sp_object_read_attr(object, "x2"); - sp_object_read_attr(object, "y2"); - object->readAttr( "x1"); - object->readAttr( "y1"); - object->readAttr( "x2"); - object->readAttr( "y2"); ++ object->readAttr( "x1" ); ++ object->readAttr( "y1" ); ++ object->readAttr( "x2" ); ++ object->readAttr( "y2" ); } /** @@@ -1807,11 -1769,11 +1804,11 @@@ sp_radialgradient_build(SPObject *objec if (((SPObjectClass *) rg_parent_class)->build) (* ((SPObjectClass *) rg_parent_class)->build)(object, document, repr); - sp_object_read_attr(object, "cx"); - sp_object_read_attr(object, "cy"); - sp_object_read_attr(object, "r"); - sp_object_read_attr(object, "fx"); - sp_object_read_attr(object, "fy"); - object->readAttr( "cx"); - object->readAttr( "cy"); - object->readAttr( "r"); - object->readAttr( "fx"); - object->readAttr( "fy"); ++ object->readAttr( "cx" ); ++ object->readAttr( "cy" ); ++ object->readAttr( "r" ); ++ object->readAttr( "fx" ); ++ object->readAttr( "fy" ); } /** diff --cc src/sp-guide-attachment.h index e42b2ed32,5e3688b88..e5c63d04e --- a/src/sp-guide-attachment.h +++ b/src/sp-guide-attachment.h @@@ -1,7 -1,8 +1,8 @@@ --#ifndef __SP_GUIDE_ATTACHMENT_H__ --#define __SP_GUIDE_ATTACHMENT_H__ ++#ifndef SEEN_SP_GUIDE_ATTACHMENT_H ++#define SEEN_SP_GUIDE_ATTACHMENT_H #include <forward.h> + #include "sp-item.h" class SPGuideAttachment { public: @@@ -28,8 -29,8 +29,7 @@@ public } }; -- --#endif /* !__SP_GUIDE_ATTACHMENT_H__ */ ++#endif // SEEN_SP_GUIDE_ATTACHMENT_H /* Local Variables: diff --cc src/sp-guide.cpp index f5edf7d97,21b350486..f92d79116 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_GUIDE_C__ -- /* * Inkscape guideline implementation * @@@ -7,6 -7,6 +5,8 @@@ * Lauris Kaplinski <lauris@kaplinski.com> * Peter Moulder <pmoulder@mail.csse.monash.edu.au> * Johan Engelen ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2000-2002 authors * Copyright (C) 2004 Monash University @@@ -41,6 -41,6 +41,7 @@@ #include <2geom/angle.h> #include "document.h" ++using Inkscape::DocumentUndo; using std::vector; enum { @@@ -73,7 -73,7 +74,7 @@@ GType sp_guide_get_type(void sizeof(SPGuide), 16, (GInstanceInitFunc) sp_guide_init, -- NULL, /* value_table */ ++ NULL, /* value_table */ }; guide_type = g_type_register_static(SP_TYPE_OBJECT, "SPGuide", &guide_info, (GTypeFlags) 0); } @@@ -158,8 -158,8 +159,8 @@@ static void sp_guide_build(SPObject *ob (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); } - sp_object_read_attr(object, "orientation"); - sp_object_read_attr(object, "position"); - object->readAttr( "orientation"); - object->readAttr( "position"); ++ object->readAttr( "orientation" ); ++ object->readAttr( "position" ); } static void sp_guide_release(SPObject *object) @@@ -241,10 -241,10 +242,10 @@@ static void sp_guide_set(SPObject *obje } } --SPGuide * - sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2) { -SPGuide::createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2) { -- SPDocument *doc=sp_desktop_document(desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++SPGuide *SPGuide::createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2) ++{ ++ SPDocument *doc = sp_desktop_document(desktop); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide"); @@@ -253,7 -253,8 +254,7 @@@ sp_repr_set_point(repr, "position", pt1); sp_repr_set_point(repr, "orientation", n); - SP_OBJECT_REPR(desktop->namedview)->appendChild(repr); - //SP_OBJECT_REPR(desktop->namedview)->appendChild(repr); + desktop->namedview->appendChild(repr); Inkscape::GC::release(repr); SPGuide *guide= SP_GUIDE(doc->getObjectByRepr(repr)); @@@ -263,7 -264,7 +264,7 @@@ void sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list<std::pair<Geom::Point, Geom::Point> > &pts) { for (std::list<std::pair<Geom::Point, Geom::Point> >::iterator i = pts.begin(); i != pts.end(); ++i) { - sp_guide_create(dt, (*i).first, (*i).second); - SPGuide::createSPGuide(dt, (*i).first, (*i).second); ++ SPGuide::createSPGuide(dt, (*i).first, (*i).second); } } @@@ -284,30 -285,30 +285,28 @@@ sp_guide_create_guides_around_page(SPDe sp_guide_pt_pairs_to_guides(dt, pts); - sp_document_done (doc, SP_VERB_NONE, _("Guides Around Page")); - SPDocumentUndo::done (doc, SP_VERB_NONE, _("Guides Around Page")); ++ DocumentUndo::done(doc, SP_VERB_NONE, _("Guides Around Page")); } - void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler) + void SPGuide::showSPGuide(SPCanvasGroup *group, GCallback handler) { - SPCanvasItem *item = sp_guideline_new(group, guide->point_on_line, guide->normal_to_line); - sp_guideline_set_color(SP_GUIDELINE(item), guide->color); - SPCanvasItem *item = sp_guideline_new(group, this->point_on_line, this->normal_to_line); - sp_guideline_set_color(SP_GUIDELINE(item), this->color); ++ SPCanvasItem *item = sp_guideline_new(group, point_on_line, normal_to_line); ++ sp_guideline_set_color(SP_GUIDELINE(item), color); - g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), guide); + g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), this); - guide->views = g_slist_prepend(guide->views, item); - this->views = g_slist_prepend(this->views, item); ++ views = g_slist_prepend(views, item); } - void sp_guide_hide(SPGuide *guide, SPCanvas *canvas) + void SPGuide::hideSPGuide(SPCanvas *canvas) { - g_assert(guide != NULL); - g_assert(SP_IS_GUIDE(guide)); - //g_assert(guide != NULL); - //g_assert(SP_IS_GUIDE(guide)); g_assert(canvas != NULL); g_assert(SP_IS_CANVAS(canvas)); - for (GSList *l = guide->views; l != NULL; l = l->next) { - for (GSList *l = this->views; l != NULL; l = l->next) { ++ for (GSList *l = views; l != NULL; l = l->next) { if (canvas == SP_CANVAS_ITEM(l->data)->canvas) { sp_guideline_delete(SP_GUIDELINE(l->data)); - guide->views = g_slist_remove(guide->views, l->data); - this->views = g_slist_remove(this->views, l->data); ++ views = g_slist_remove(views, l->data); return; } } @@@ -315,14 -316,14 +314,12 @@@ g_assert_not_reached(); } - void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive) + void SPGuide::sensitize(SPCanvas *canvas, gboolean sensitive) { - g_assert(guide != NULL); - g_assert(SP_IS_GUIDE(guide)); - //g_assert(guide != NULL); - //g_assert(SP_IS_GUIDE(guide)); g_assert(canvas != NULL); g_assert(SP_IS_CANVAS(canvas)); - for (GSList *l = guide->views; l != NULL; l = l->next) { - for (GSList *l = this->views; l != NULL; l = l->next) { ++ for (GSList *l = views; l != NULL; l = l->next) { if (canvas == SP_CANVAS_ITEM(l->data)->canvas) { sp_guideline_set_sensitive(SP_GUIDELINE(l->data), sensitive); return; @@@ -332,14 -333,14 +329,14 @@@ g_assert_not_reached(); } - Geom::Point sp_guide_position_from_pt(SPGuide const *guide, Geom::Point const &pt) + Geom::Point SPGuide::getPositionFrom(Geom::Point const &pt) const { - return -(pt - guide->point_on_line); - return -(pt - this->point_on_line); ++ return -(pt - point_on_line); } - double sp_guide_distance_from_pt(SPGuide const *guide, Geom::Point const &pt) + double SPGuide::getDistanceFrom(Geom::Point const &pt) const { - return Geom::dot(pt - guide->point_on_line, guide->normal_to_line); - return Geom::dot(pt - this->point_on_line, this->normal_to_line); ++ return Geom::dot(pt - point_on_line, normal_to_line); } /** @@@ -358,7 -359,8 +355,8 @@@ void sp_guide_moveto(SPGuide const &gui /* Calling sp_repr_set_point must precede calling sp_item_notify_moveto in the commit case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */ if (commit) { - sp_repr_set_point(SP_OBJECT(&guide)->repr, "position", point_on_line); - //XML Tree being used here directly while it shouldn't be. ++ //XML Tree being used here directly while it shouldn't be. + sp_repr_set_point(SP_OBJECT(&guide)->getRepr(), "position", point_on_line); } /* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan) @@@ -388,7 -390,8 +386,8 @@@ void sp_guide_set_normal(SPGuide const /* Calling sp_repr_set_svg_point must precede calling sp_item_notify_moveto in the commit case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */ if (commit) { - sp_repr_set_point(SP_OBJECT(&guide)->repr, "orientation", normal_to_line); - //XML Tree being used directly while it shouldn't be ++ //XML Tree being used directly while it shouldn't be + sp_repr_set_point(SP_OBJECT(&guide)->getRepr(), "orientation", normal_to_line); } /* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan) @@@ -457,8 -460,9 +456,9 @@@ void sp_guide_remove(SPGuide *guide remove_last(att.item->constraints, SPGuideConstraint(guide, att.snappoint_ix)); } guide->attached_items.clear(); - - //XML Tree being used directly while it shouldn't be. + - sp_repr_unparent(SP_OBJECT(guide)->repr); ++ //XML Tree being used directly while it shouldn't be. + sp_repr_unparent(SP_OBJECT(guide)->getRepr()); } /* diff --cc src/sp-guide.h index 91c181a70,b5914e890..4fc4032db --- a/src/sp-guide.h +++ b/src/sp-guide.h @@@ -1,5 -1,5 +1,5 @@@ --#ifndef SP_GUIDE_H --#define SP_GUIDE_H ++#ifndef SEEN_SP_GUIDE_H ++#define SEEN_SP_GUIDE_H /* * SPGuide @@@ -8,6 -8,6 +8,8 @@@ * * Copyright (C) Lauris Kaplinski 2000 * Copyright (C) Johan Engelen 2007 ++ * Abhishek Sharma ++ * Jon A. Cruz <jon@joncruz.org> * */ @@@ -25,7 -25,8 +27,8 @@@ #define SP_IS_GUIDE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GUIDE)) /* Represents the constraint on p that dot(g.direction, p) == g.position. */ - struct SPGuide : public SPObject { + class SPGuide : public SPObject { - public: ++public: Geom::Point normal_to_line; Geom::Point point_on_line; @@@ -34,27 -35,34 +37,27 @@@ GSList *views; std::vector<SPGuideAttachment> attached_items; -- inline bool is_horizontal() const { return (normal_to_line[Geom::X] == 0.); }; -- inline bool is_vertical() const { return (normal_to_line[Geom::Y] == 0.); }; ++ inline bool isHorizontal() const { return (normal_to_line[Geom::X] == 0.); }; ++ inline bool isVertical() const { return (normal_to_line[Geom::Y] == 0.); }; inline double angle() const { return std::atan2( - normal_to_line[Geom::X], normal_to_line[Geom::Y] ); }; - static SPGuide *createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2); - void showSPGuide(SPCanvasGroup *group, GCallback handler); - void hideSPGuide(SPCanvas *canvas); - void sensitize(SPCanvas *canvas, gboolean sensitive); - Geom::Point getPositionFrom(Geom::Point const &pt) const; - double getDistanceFrom(Geom::Point const &pt) const; ++ static SPGuide *createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2); ++ void showSPGuide(SPCanvasGroup *group, GCallback handler); ++ void hideSPGuide(SPCanvas *canvas); ++ void sensitize(SPCanvas *canvas, gboolean sensitive); ++ Geom::Point getPositionFrom(Geom::Point const &pt) const; ++ double getDistanceFrom(Geom::Point const &pt) const; }; - struct SPGuideClass { + class SPGuideClass { - public: ++public: SPObjectClass parent_class; }; GType sp_guide_get_type(); - SPGuide *sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2); -//SPGuide *sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2); void sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list<std::pair<Geom::Point, Geom::Point> > &pts); void sp_guide_create_guides_around_page(SPDesktop *dt); - void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler); - void sp_guide_hide(SPGuide *guide, SPCanvas *canvas); - void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive); -//void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler); -//void sp_guide_hide(SPGuide *guide, SPCanvas *canvas); -//void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive); -- - Geom::Point sp_guide_position_from_pt(SPGuide const *guide, Geom::Point const &pt); - double sp_guide_distance_from_pt(SPGuide const *guide, Geom::Point const &pt); -//Geom::Point sp_guide_position_from_pt(SPGuide const *guide, Geom::Point const &pt); -//double sp_guide_distance_from_pt(SPGuide const *guide, Geom::Point const &pt); void sp_guide_moveto(SPGuide const &guide, Geom::Point const point_on_line, bool const commit); void sp_guide_set_normal(SPGuide const &guide, Geom::Point const normal_to_line, bool const commit); void sp_guide_remove(SPGuide *guide); @@@ -62,7 -70,7 +65,7 @@@ char *sp_guide_description(SPGuide const *guide, const bool verbose = true); --#endif /* !SP_GUIDE_H */ ++#endif // SEEN_SP_GUIDE_H /* Local Variables: diff --cc src/sp-image.cpp index 68bafdeab,ae7ac6fa3..ad9e79de2 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@@ -4,6 -4,6 +4,7 @@@ * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Edward Flick (EAF) ++ * Abhishek Sharma * * Copyright (C) 1999-2005 Authors * Copyright (C) 2000-2001 Ximian, Inc. @@@ -637,16 -637,16 +638,16 @@@ sp_image_build (SPObject *object, SPDoc ((SPObjectClass *) parent_class)->build (object, document, repr); } - sp_object_read_attr (object, "xlink:href"); - sp_object_read_attr (object, "x"); - sp_object_read_attr (object, "y"); - sp_object_read_attr (object, "width"); - sp_object_read_attr (object, "height"); - sp_object_read_attr (object, "preserveAspectRatio"); - sp_object_read_attr (object, "color-profile"); - object->readAttr( "xlink:href"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "width"); - object->readAttr( "height"); - object->readAttr( "preserveAspectRatio"); - object->readAttr( "color-profile"); ++ object->readAttr( "xlink:href" ); ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "width" ); ++ object->readAttr( "height" ); ++ object->readAttr( "preserveAspectRatio" ); ++ object->readAttr( "color-profile" ); /* Register */ - sp_document_add_resource (document, "image", object); - document->add_resource ("image", object); ++ document->addResource("image", object); } static void @@@ -656,7 -656,7 +657,7 @@@ sp_image_release (SPObject *object if (SP_OBJECT_DOCUMENT (object)) { /* Unregister ourselves */ - sp_document_remove_resource (SP_OBJECT_DOCUMENT (object), "image", SP_OBJECT (object)); - SP_OBJECT_DOCUMENT (object)->remove_resource ("image", SP_OBJECT (object)); ++ SP_OBJECT_DOCUMENT(object)->removeResource("image", SP_OBJECT(object)); } if (image->href) { @@@ -838,9 -838,13 +839,13 @@@ sp_image_update (SPObject *object, SPCt pixbuf = sp_image_repr_read_image ( image->lastMod, image->pixPath, - object->repr->attribute("xlink:href"), - object->repr->attribute("sodipodi:absref"), - doc->base); + - //XML Tree being used directly while it shouldn't be. ++ //XML Tree being used directly while it shouldn't be. + object->getRepr()->attribute("xlink:href"), - - //XML Tree being used directly while it shouldn't be. ++ ++ //XML Tree being used directly while it shouldn't be. + object->getRepr()->attribute("sodipodi:absref"), - doc->base); ++ doc->getBase()); if (pixbuf) { pixbuf = sp_image_pixbuf_force_rgba (pixbuf); // BLIP @@@ -1056,7 -1060,9 +1061,9 @@@ sp_image_write (SPObject *object, Inksc if (image->height._set) { sp_repr_set_svg_double(repr, "height", image->height.computed); } - repr->setAttribute("preserveAspectRatio", object->repr->attribute("preserveAspectRatio")); + - //XML Tree being used directly here while it shouldn't be... ++ //XML Tree being used directly here while it shouldn't be... + repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio")); #if ENABLE_LCMS if (image->color_profile) { repr->setAttribute("color-profile", image->color_profile); diff --cc src/sp-item-group.cpp index 588427752,56b9dbc21..30d085584 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_GROUP_C__ -- /* * SVG <g> implementation * @@@ -7,6 -7,6 +5,8 @@@ * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2006 authors * Copyright (C) 2000-2001 Ximian, Inc. @@@ -50,6 -50,6 +50,8 @@@ #include "sp-desc.h" #include "sp-switch.h" ++using Inkscape::DocumentUndo; ++ static void sp_group_class_init (SPGroupClass *klass); static void sp_group_init (SPGroup *group); static void sp_group_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); @@@ -145,7 -145,7 +147,7 @@@ sp_group_init (SPGroup *group static void sp_group_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - sp_object_read_attr(object, "inkscape:groupmode"); - object->readAttr( "inkscape:groupmode"); ++ object->readAttr( "inkscape:groupmode" ); if (((SPObjectClass *)parent_class)->build) { ((SPObjectClass *)parent_class)->build(object, document, repr); @@@ -154,7 -154,7 +156,7 @@@ static void sp_group_release(SPObject *object) { if ( SP_GROUP(object)->_layer_mode == SPGroup::LAYER ) { - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "layer", object); - SP_OBJECT_DOCUMENT(object)->remove_resource("layer", object); ++ SP_OBJECT_DOCUMENT(object)->removeResource("layer", object); } if (((SPObjectClass *)parent_class)->release) { ((SPObjectClass *)parent_class)->release(object); @@@ -219,28 -219,28 +221,27 @@@ sp_group_modified (SPObject *object, gu SP_GROUP(object)->group->onModified(flags); } --static Inkscape::XML::Node * --sp_group_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) ++static Inkscape::XML::Node * sp_group_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { -- SPGroup *group; -- SPObject *child; -- Inkscape::XML::Node *crepr; -- -- group = SP_GROUP (object); ++ SPGroup *group = SP_GROUP(object); if (flags & SP_OBJECT_WRITE_BUILD) { GSList *l; if (!repr) { -- if (SP_IS_SWITCH(object)) ++ if (SP_IS_SWITCH(object)) { repr = xml_doc->createElement("svg:switch"); -- else ++ } else { repr = xml_doc->createElement("svg:g"); ++ } } l = NULL; - for (child = sp_object_first_child(object); child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (child = object->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { -- if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; -- crepr = child->updateRepr(xml_doc, NULL, flags); -- if (crepr) l = g_slist_prepend (l, crepr); ++ for (SPObject *child = object->firstChild(); child; child = child->getNext() ) { ++ if ( !SP_IS_TITLE(child) && !SP_IS_DESC(child) ) { ++ Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); ++ if (crepr) { ++ l = g_slist_prepend (l, crepr); ++ } ++ } } while (l) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); @@@ -248,9 -248,9 +249,10 @@@ l = g_slist_remove (l, l->data); } } else { - for (child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { -- if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; -- child->updateRepr(flags); ++ for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ if ( !SP_IS_TITLE(child) && !SP_IS_DESC(child) ) { ++ child->updateRepr(flags); ++ } } } @@@ -268,8 -268,8 +270,9 @@@ repr->setAttribute("inkscape:groupmode", value); } -- if (((SPObjectClass *) (parent_class))->write) ++ if (((SPObjectClass *) (parent_class))->write) { ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); ++ } return repr; } @@@ -324,14 -324,14 +327,12 @@@ sp_group_hide (SPItem *item, unsigned i SP_GROUP(item)->group->hide(key); } --static void sp_group_snappoints (SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) ++static void sp_group_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { - for (SPObject const *o = sp_object_first_child(SP_OBJECT(item)); - for (SPObject const *o = SP_OBJECT(item)->first_child(); -- o != NULL; -- o = SP_OBJECT_NEXT(o)) ++ for ( SPObject const *o = item->firstChild(); o; o = o->getNext() ) { if (SP_IS_ITEM(o)) { - sp_item_snappoints(SP_ITEM(o), p, snapprefs); + SP_ITEM(o)->getSnappoints(p, snapprefs); } } } @@@ -344,7 -344,7 +345,7 @@@ sp_item_group_ungroup (SPGroup *group, g_return_if_fail (SP_IS_GROUP (group)); SPDocument *doc = SP_OBJECT_DOCUMENT (group); -- SPObject *root = SP_DOCUMENT_ROOT (doc); ++ SPObject *root = doc->getRoot(); SPObject *defs = SP_OBJECT (SP_ROOT (root)->defs); SPItem *gitem = SP_ITEM (group); @@@ -368,7 -368,7 +369,7 @@@ /* Step 1 - generate lists of children objects */ GSList *items = NULL; GSList *objects = NULL; - for (SPObject *child = sp_object_first_child(SP_OBJECT(group)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = SP_OBJECT(group)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = group->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM (child)) { @@@ -496,38 -496,38 +497,36 @@@ items = g_slist_remove (items, items->data); } -- if (do_done) - sp_document_done (doc, SP_VERB_NONE, _("Ungroup")); - SPDocumentUndo::done (doc, SP_VERB_NONE, _("Ungroup")); ++ if (do_done) { ++ DocumentUndo::done(doc, SP_VERB_NONE, _("Ungroup")); ++ } } /* * some API for list aspect of SPGroup */ --GSList * --sp_item_group_item_list (SPGroup * group) ++GSList *sp_item_group_item_list(SPGroup * group) { -- g_return_val_if_fail (group != NULL, NULL); -- g_return_val_if_fail (SP_IS_GROUP (group), NULL); ++ g_return_val_if_fail(group != NULL, NULL); ++ g_return_val_if_fail(SP_IS_GROUP(group), NULL); GSList *s = NULL; - for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { - for (SPObject *o = SP_OBJECT(group)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { -- if (SP_IS_ITEM (o)) { -- s = g_slist_prepend (s, o); ++ for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { ++ if ( SP_IS_ITEM(o) ) { ++ s = g_slist_prepend(s, o); } } return g_slist_reverse (s); } --SPObject * --sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const gchar *name) ++SPObject *sp_item_group_get_child_by_name(SPGroup *group, SPObject *ref, const gchar *name) { -- SPObject *child; - child = (ref) ? SP_OBJECT_NEXT(ref) : sp_object_first_child(SP_OBJECT(group)); - child = (ref) ? SP_OBJECT_NEXT(ref) : SP_OBJECT(group)->first_child(); -- while ( child && strcmp (SP_OBJECT_REPR(child)->name(), name) ) { -- child = SP_OBJECT_NEXT(child); ++ SPObject *child = (ref) ? ref->getNext() : group->firstChild(); ++ while ( child && strcmp(child->getRepr()->name(), name) ) { ++ child = child->getNext(); } return child; } @@@ -535,9 -535,9 +534,9 @@@ void SPGroup::setLayerMode(LayerMode mode) { if ( _layer_mode != mode ) { if ( mode == LAYER ) { - sp_document_add_resource(SP_OBJECT_DOCUMENT(this), "layer", this); - SP_OBJECT_DOCUMENT(this)->add_resource("layer", this); ++ SP_OBJECT_DOCUMENT(this)->addResource("layer", this); } else if ( _layer_mode == LAYER ) { - sp_document_remove_resource(SP_OBJECT_DOCUMENT(this), "layer", this); - SP_OBJECT_DOCUMENT(this)->remove_resource("layer", this); ++ SP_OBJECT_DOCUMENT(this)->removeResource("layer", this); } _layer_mode = mode; _updateLayerMode(); @@@ -575,12 -575,12 +574,10 @@@ void SPGroup::_updateLayerMode(unsigne void SPGroup::translateChildItems(Geom::Translate const &tr) { -- if (this->hasChildren()) -- { -- SPObject *o = NULL; - for (o = sp_object_first_child(SP_OBJECT(this)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { - for (o = SP_OBJECT(this)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { -- if (SP_IS_ITEM (o)) { -- sp_item_move_rel(static_cast<SPItem *>(o), tr); ++ if ( hasChildren() ) { ++ for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { ++ if ( SP_IS_ITEM(o) ) { ++ sp_item_move_rel(reinterpret_cast<SPItem *>(o), tr); } } } @@@ -730,7 -730,7 +727,7 @@@ void CGroup::onPrint(SPPrintContext *ct gint CGroup::getItemCount() { gint len = 0; - for (SPObject *o = sp_object_first_child(SP_OBJECT(_group)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { - for (SPObject *o = SP_OBJECT(_group)->first_child() ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { ++ for (SPObject *o = _group->firstChild() ; o ; o = o->getNext() ) { if (SP_IS_ITEM(o)) { len++; } diff --cc src/sp-item-transform.cpp index e401f437c,275d6b046..81780220c --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_ITEM_TRANSFORM_C__ -- /* * Transforming single items * @@@ -8,6 -8,6 +6,7 @@@ * Frank Felfe <innerspace@iname.com> * bulia byak <buliabyak@gmail.com> * Johan Engelen <goejendaagh@zonnet.nl> ++ * Abhishek Sharma * * Copyright (C) 1999-2008 authors * diff --cc src/sp-item.cpp index d213ce2d7,fc605516d..755ee0bf4 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@@ -6,6 -6,6 +6,8 @@@ * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> ++ * Abhishek Sharma ++ * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2001-2006 authors * Copyright (C) 2001 Ximian, Inc. @@@ -46,6 -46,6 +48,7 @@@ #include "sp-text.h" #include "sp-item-rm-unsatisfied-cns.h" #include "sp-pattern.h" ++#include "sp-paint-server.h" #include "sp-switch.h" #include "sp-guide-constraint.h" #include "gradient-chemistry.h" @@@ -80,25 -80,27 +83,7 @@@ #define noSP_ITEM_DEBUG_IDLE - static void sp_item_class_init(SPItemClass *klass); - static void sp_item_init(SPItem *item); -//static void sp_item_class_init(SPItemClass *klass); -//static void sp_item_init(SPItem *item); -- - static void sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); - static void sp_item_release(SPObject *object); - static void sp_item_set(SPObject *object, unsigned key, gchar const *value); - static void sp_item_update(SPObject *object, SPCtx *ctx, guint flags); - static Inkscape::XML::Node *sp_item_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -//static void sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); -//static void sp_item_release(SPObject *object); -//static void sp_item_set(SPObject *object, unsigned key, gchar const *value); -//static void sp_item_update(SPObject *object, SPCtx *ctx, guint flags); -//static Inkscape::XML::Node *sp_item_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -- - static gchar *sp_item_private_description(SPItem *item); - static void sp_item_private_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); -//static gchar *sp_item_private_description(SPItem *item); -//static void sp_item_private_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); -- - static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem); - static SPItemView *sp_item_view_list_remove(SPItemView *list, SPItemView *view); -//static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem); -//static SPItemView *sp_item_view_list_remove(SPItemView *list, SPItemView *view); -- - static SPObjectClass *parent_class; -//static SPObjectClass *parent_class; -- - static void clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); - static void mask_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); -//static void clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); -//static void mask_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); - + SPObjectClass * SPItemClass::static_parent_class=0; /** * Registers SPItem class and returns its type number. @@@ -146,40 -148,40 +131,39 @@@ SPItemClass::sp_item_class_init(SPItemC /** * Callback for SPItem object initialization. */ - static void - sp_item_init(SPItem *item) -void -SPItem::sp_item_init(SPItem *item) ++void SPItem::sp_item_init(SPItem *item) { item->init(); } void SPItem::init() { -- this->sensitive = TRUE; ++ sensitive = TRUE; -- this->transform_center_x = 0; -- this->transform_center_y = 0; ++ transform_center_x = 0; ++ transform_center_y = 0; -- this->_is_evaluated = true; -- this->_evaluated_status = StatusUnknown; ++ _is_evaluated = true; ++ _evaluated_status = StatusUnknown; -- this->transform = Geom::identity(); ++ transform = Geom::identity(); -- this->display = NULL; ++ display = NULL; -- this->clip_ref = new SPClipPathReference(this); -- sigc::signal<void, SPObject *, SPObject *> cs1=this->clip_ref->changedSignal(); -- sigc::slot2<void,SPObject*, SPObject *> sl1=sigc::bind(sigc::ptr_fun(clip_ref_changed), this); ++ clip_ref = new SPClipPathReference(this); ++ sigc::signal<void, SPObject *, SPObject *> cs1 = clip_ref->changedSignal(); ++ sigc::slot2<void,SPObject*, SPObject *> sl1 = sigc::bind(sigc::ptr_fun(clip_ref_changed), this); _clip_ref_connection = cs1.connect(sl1); -- this->mask_ref = new SPMaskReference(this); -- sigc::signal<void, SPObject *, SPObject *> cs2=this->mask_ref->changedSignal(); ++ mask_ref = new SPMaskReference(this); ++ sigc::signal<void, SPObject *, SPObject *> cs2 = mask_ref->changedSignal(); sigc::slot2<void,SPObject*, SPObject *> sl2=sigc::bind(sigc::ptr_fun(mask_ref_changed), this); _mask_ref_connection = cs2.connect(sl2); -- this->avoidRef = new SPAvoidRef(this); ++ avoidRef = new SPAvoidRef(this); -- new (&this->constraints) std::vector<SPGuideConstraint>(); ++ new (&constraints) std::vector<SPGuideConstraint>(); -- new (&this->_transformed_signal) sigc::signal<void, Geom::Matrix const *, SPItem *>(); ++ new (&_transformed_signal) sigc::signal<void, Geom::Matrix const *, SPItem *>(); } bool SPItem::isVisibleAndUnlocked() const { @@@ -200,8 -201,8 +184,8 @@@ bool SPItem::isLocked() const } void SPItem::setLocked(bool locked) { - this->repr->setAttribute("sodipodi:insensitive", - ( locked ? "1" : NULL )); - SP_OBJECT_REPR(this)->setAttribute("sodipodi:insensitive", - ( locked ? "1" : NULL )); ++ setAttribute("sodipodi:insensitive", ++ ( locked ? "1" : NULL )); updateRepr(); } @@@ -251,7 -252,7 +235,6 @@@ void SPItem::resetEvaluated() requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); } } if ( StatusSet == _evaluated_status ) { - SPObject const *const parent = this->parent; - SPObject const *const parent = SP_OBJECT_PARENT(this); if (SP_IS_SWITCH(parent)) { SP_SWITCH(parent)->resetChildEvaluated(); } @@@ -270,34 -271,34 +253,31 @@@ bool SPItem::isEvaluated() const * Returns something suitable for the `Hide' checkbox in the Object Properties dialog box. * Corresponds to setExplicitlyHidden. */ --bool --SPItem::isExplicitlyHidden() const ++bool SPItem::isExplicitlyHidden() const { -- return (this->style->display.set -- && this->style->display.value == SP_CSS_DISPLAY_NONE); ++ return (style->display.set ++ && style->display.value == SP_CSS_DISPLAY_NONE); } /** * Sets the display CSS property to `hidden' if \a val is true, * otherwise makes it unset */ --void --SPItem::setExplicitlyHidden(bool const val) { -- this->style->display.set = val; -- this->style->display.value = ( val ? SP_CSS_DISPLAY_NONE : SP_CSS_DISPLAY_INLINE ); -- this->style->display.computed = this->style->display.value; -- this->updateRepr(); ++void SPItem::setExplicitlyHidden(bool const val) { ++ style->display.set = val; ++ style->display.value = ( val ? SP_CSS_DISPLAY_NONE : SP_CSS_DISPLAY_INLINE ); ++ style->display.computed = style->display.value; ++ updateRepr(); } /** * Sets the transform_center_x and transform_center_y properties to retain the rotation centre */ --void --SPItem::setCenter(Geom::Point object_centre) { ++void SPItem::setCenter(Geom::Point object_centre) { // for getBounds() to work - sp_document_ensure_up_to_date( this->document ); - SP_OBJECT_DOCUMENT(this)->ensure_up_to_date(); ++ document->ensureUpToDate(); - Geom::OptRect bbox = getBounds(sp_item_i2d_affine(this)); + Geom::OptRect bbox = getBounds(i2d_affine()); if (bbox) { transform_center_x = object_centre[Geom::X] - bbox->midpoint()[Geom::X]; if (fabs(transform_center_x) < 1e-5) // rounding error @@@ -320,13 -321,13 +300,13 @@@ bool SPItem::isCenterSet() Geom::Point SPItem::getCenter() const { // for getBounds() to work - sp_document_ensure_up_to_date( this->document ); - SP_OBJECT_DOCUMENT(this)->ensure_up_to_date(); ++ document->ensureUpToDate(); - Geom::OptRect bbox = getBounds(sp_item_i2d_affine(this)); + Geom::OptRect bbox = getBounds(i2d_affine()); if (bbox) { -- return to_2geom(bbox->midpoint()) + Geom::Point (this->transform_center_x, this->transform_center_y); ++ return to_2geom(bbox->midpoint()) + Geom::Point (transform_center_x, transform_center_y); } else { -- return Geom::Point (0, 0); // something's wrong! ++ return Geom::Point(0, 0); // something's wrong! } } @@@ -343,22 -344,22 +323,20 @@@ void SPItem::raiseToTop() using Inkscape::Algorithms::find_last_if; SPObject *topmost=find_last_if<SPObject::SiblingIterator>( - this->next, NULL, &is_item - SP_OBJECT_NEXT(this), NULL, &is_item ++ next, NULL, &is_item ); if (topmost) { - Inkscape::XML::Node *repr = this->repr; - sp_repr_parent(repr)->changeOrder( repr, topmost->repr ); - Inkscape::XML::Node *repr=SP_OBJECT_REPR(this); - sp_repr_parent(repr)->changeOrder(repr, SP_OBJECT_REPR(topmost)); ++ getRepr()->parent()->changeOrder( getRepr(), topmost->getRepr() ); } } void SPItem::raiseOne() { SPObject *next_higher=std::find_if<SPObject::SiblingIterator>( - this->next, NULL, &is_item - SP_OBJECT_NEXT(this), NULL, &is_item ++ next, NULL, &is_item ); if (next_higher) { - Inkscape::XML::Node *repr = this->repr; - Inkscape::XML::Node *ref = next_higher->repr; - Inkscape::XML::Node *repr=SP_OBJECT_REPR(this); - Inkscape::XML::Node *ref=SP_OBJECT_REPR(next_higher); -- sp_repr_parent(repr)->changeOrder(repr, ref); ++ Inkscape::XML::Node *ref = next_higher->getRepr(); ++ getRepr()->parent()->changeOrder(getRepr(), ref); } } @@@ -368,16 -369,16 +346,15 @@@ void SPItem::lowerOne() MutableList<SPObject &> next_lower=std::find_if( reverse_list<SPObject::SiblingIterator>( - this->parent->firstChild(), this - SP_OBJECT_PARENT(this)->firstChild(), this ++ parent->firstChild(), this ), MutableList<SPObject &>(), &is_item ); if (next_lower) { ++next_lower; - Inkscape::XML::Node *repr = this->repr; - Inkscape::XML::Node *ref = ( next_lower ? next_lower->repr : NULL ); - Inkscape::XML::Node *repr=SP_OBJECT_REPR(this); - Inkscape::XML::Node *ref=( next_lower ? SP_OBJECT_REPR(&*next_lower) : NULL ); -- sp_repr_parent(repr)->changeOrder(repr, ref); ++ Inkscape::XML::Node *ref = ( next_lower ? next_lower->getRepr() : NULL ); ++ getRepr()->parent()->changeOrder(getRepr(), ref); } } @@@ -388,40 -389,40 +365,37 @@@ void SPItem::lowerToBottom() MutableList<SPObject &> bottom=find_last_if( reverse_list<SPObject::SiblingIterator>( - this->parent->firstChild(), this - SP_OBJECT_PARENT(this)->firstChild(), this ++ parent->firstChild(), this ), MutableList<SPObject &>(), &is_item ); if (bottom) { ++bottom; - Inkscape::XML::Node *repr = this->repr; - Inkscape::XML::Node *ref = ( bottom ? bottom->repr : NULL ); - Inkscape::XML::Node *repr=SP_OBJECT_REPR(this); - Inkscape::XML::Node *ref=( bottom ? SP_OBJECT_REPR(&*bottom) : NULL ); -- sp_repr_parent(repr)->changeOrder(repr, ref); ++ Inkscape::XML::Node *ref = ( bottom ? bottom->getRepr() : NULL ); ++ getRepr()->parent()->changeOrder(getRepr(), ref); } } - static void - sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -void -SPItem::sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) ++void SPItem::sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - sp_object_read_attr(object, "style"); - sp_object_read_attr(object, "transform"); - sp_object_read_attr(object, "clip-path"); - sp_object_read_attr(object, "mask"); - sp_object_read_attr(object, "sodipodi:insensitive"); - sp_object_read_attr(object, "sodipodi:nonprintable"); - sp_object_read_attr(object, "inkscape:transform-center-x"); - sp_object_read_attr(object, "inkscape:transform-center-y"); - sp_object_read_attr(object, "inkscape:connector-avoid"); - sp_object_read_attr(object, "inkscape:connection-points"); - object->readAttr( "style"); - object->readAttr( "transform"); - object->readAttr( "clip-path"); - object->readAttr( "mask"); - object->readAttr( "sodipodi:insensitive"); - object->readAttr( "sodipodi:nonprintable"); - object->readAttr( "inkscape:transform-center-x"); - object->readAttr( "inkscape:transform-center-y"); - object->readAttr( "inkscape:connector-avoid"); - object->readAttr( "inkscape:connection-points"); ++ object->readAttr( "style" ); ++ object->readAttr( "transform" ); ++ object->readAttr( "clip-path" ); ++ object->readAttr( "mask" ); ++ object->readAttr( "sodipodi:insensitive" ); ++ object->readAttr( "sodipodi:nonprintable" ); ++ object->readAttr( "inkscape:transform-center-x" ); ++ object->readAttr( "inkscape:transform-center-y" ); ++ object->readAttr( "inkscape:connector-avoid" ); ++ object->readAttr( "inkscape:connection-points" ); - if (((SPObjectClass *) (parent_class))->build) { - (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); + if (((SPObjectClass *) (SPItemClass::static_parent_class))->build) { + (* ((SPObjectClass *) (SPItemClass::static_parent_class))->build)(object, document, repr); } } - static void - sp_item_release(SPObject *object) -void -SPItem::sp_item_release(SPObject *object) ++void SPItem::sp_item_release(SPObject *object) { SPItem *item = (SPItem *) object; @@@ -429,7 -430,7 +403,7 @@@ item->_mask_ref_connection.disconnect(); // Note: do this here before the clip_ref is deleted, since calling -- // sp_document_ensure_up_to_date for triggered routing may reference ++ // ensureUpToDate() for triggered routing may reference // the deleted clip_ref. if (item->avoidRef) { delete item->avoidRef; @@@ -460,8 -461,8 +434,7 @@@ item->_transformed_signal.~signal(); } - static void - sp_item_set(SPObject *object, unsigned key, gchar const *value) -void -SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value) ++void SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value) { SPItem *item = (SPItem *) object; @@@ -555,37 -556,37 +528,35 @@@ } } - static void - clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) -void -SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) ++void SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) { if (old_clip) { SPItemView *v; /* Hide clippath */ for (v = item->display; v != NULL; v = v->next) { - sp_clippath_hide(SP_CLIPPATH(old_clip), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); - SP_CLIPPATH(old_clip)->sp_clippath_hide(NR_ARENA_ITEM_GET_KEY(v->arenaitem)); ++ SP_CLIPPATH(old_clip)->hide(NR_ARENA_ITEM_GET_KEY(v->arenaitem)); nr_arena_item_set_clip(v->arenaitem, NULL); } } if (SP_IS_CLIPPATH(clip)) { NRRect bbox; - sp_item_invoke_bbox(item, &bbox, Geom::identity(), TRUE); + item->invoke_bbox( &bbox, Geom::identity(), TRUE); for (SPItemView *v = item->display; v != NULL; v = v->next) { if (!v->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY(v->arenaitem, sp_item_display_key_new(3)); + NR_ARENA_ITEM_SET_KEY(v->arenaitem, SPItem::display_key_new(3)); } - NRArenaItem *ai = sp_clippath_show(SP_CLIPPATH(clip), - NRArenaItem *ai = SP_CLIPPATH(clip)->sp_clippath_show( ++ NRArenaItem *ai = SP_CLIPPATH(clip)->show( NR_ARENA_ITEM_ARENA(v->arenaitem), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); nr_arena_item_set_clip(v->arenaitem, ai); nr_arena_item_unref(ai); - sp_clippath_set_bbox(SP_CLIPPATH(clip), NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); - SP_CLIPPATH(clip)->sp_clippath_set_bbox(NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); - SP_OBJECT(clip)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); ++ SP_CLIPPATH(clip)->setBBox(NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); + clip->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } } - static void - mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) -void -SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) ++void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) { if (old_mask) { /* Hide mask */ @@@ -612,13 -613,13 +583,13 @@@ } } - static void - sp_item_update(SPObject *object, SPCtx *ctx, guint flags) -void -SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) ++void SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) { SPItem *item = SP_ITEM(object); - if (((SPObjectClass *) (parent_class))->update) - (* ((SPObjectClass *) (parent_class))->update)(object, ctx, flags); - if (((SPObjectClass *) (SPItemClass::static_parent_class))->update) ++ if (((SPObjectClass *) (SPItemClass::static_parent_class))->update) { + (* ((SPObjectClass *) (SPItemClass::static_parent_class))->update)(object, ctx, flags); ++ } if (flags & (SP_OBJECT_CHILD_MODIFIED_FLAG | SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG)) { if (flags & SP_OBJECT_MODIFIED_FLAG) { @@@ -632,10 -633,10 +603,10 @@@ if ( clip_path || mask ) { NRRect bbox; - sp_item_invoke_bbox(item, &bbox, Geom::identity(), TRUE); + item->invoke_bbox( &bbox, Geom::identity(), TRUE); if (clip_path) { for (SPItemView *v = item->display; v != NULL; v = v->next) { - sp_clippath_set_bbox(clip_path, NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); - clip_path->sp_clippath_set_bbox(NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); ++ clip_path->setBBox(NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); } } if (mask) { @@@ -670,8 -671,8 +641,7 @@@ item->avoidRef->handleSettingChange(); } - static Inkscape::XML::Node * - sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) -Inkscape::XML::Node * -SPItem::sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) ++Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPObject *child; SPItem *item = SP_ITEM(object); @@@ -682,7 -683,7 +652,7 @@@ Inkscape::XML::Node *crepr; GSList *l; l = NULL; - for (child = sp_object_first_child(object); child != NULL; child = child->next ) { - for (child = object->first_child(); child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for (child = object->firstChild(); child != NULL; child = child->next ) { if (!SP_IS_TITLE(child) && !SP_IS_DESC(child)) continue; crepr = child->updateRepr(xml_doc, NULL, flags); if (crepr) l = g_slist_prepend (l, crepr); @@@ -693,7 -694,7 +663,7 @@@ l = g_slist_remove (l, l->data); } } else { - for (child = sp_object_first_child(object) ; child != NULL; child = child->next ) { - for (child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for (child = object->firstChild() ; child != NULL; child = child->next ) { if (!SP_IS_TITLE(child) && !SP_IS_DESC(child)) continue; child->updateRepr(flags); } @@@ -742,21 -743,21 +712,19 @@@ Geom::OptRect SPItem::getBounds(Geom::M unsigned int /*dkey*/) const { Geom::OptRect r; - sp_item_invoke_bbox_full(this, r, transform, type, TRUE); - SP_ITEM(this)->invoke_bbox_full( r, transform, type, TRUE); ++ invoke_bbox_full( r, transform, type, TRUE); return r; } --void - sp_item_invoke_bbox(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) -SPItem::invoke_bbox( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) ++void SPItem::invoke_bbox( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) { - sp_item_invoke_bbox_full(item, bbox, transform, type, clear); + invoke_bbox_full( bbox, transform, type, clear); } // DEPRECATED to phase out the use of NRRect in favor of Geom::OptRect --void - sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) -SPItem::invoke_bbox( NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) ++void SPItem::invoke_bbox( NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) { - sp_item_invoke_bbox_full(item, bbox, transform, type, clear); + invoke_bbox_full( bbox, transform, type, clear); } /** Calls \a item's subclass' bounding box method; clips it by the bbox of clippath, if any; and @@@ -766,12 -767,12 +734,8 @@@ * \retval bbox Note that there is no guarantee that bbox will contain a rectangle when the * function returns. If this item does not have a boundingbox, this might well be empty. */ --void - sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) -SPItem::invoke_bbox_full( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) ++void SPItem::invoke_bbox_full( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) const { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); - //g_assert(this != NULL); - //g_assert(SP_IS_ITEM(this)); -- if (clear) { bbox = Geom::OptRect(); } @@@ -789,8 -790,8 +753,8 @@@ // unless this is geometric bbox, extend by filter area and crop the bbox by clip path, if any if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX) { - if ( item->style && item->style->filter.href ) { - SPObject *filter = item->style->getFilter(); - if (SP_OBJECT_STYLE(this) && SP_OBJECT_STYLE(this)->filter.href) { - SPObject *filter = SP_OBJECT_STYLE(this)->getFilter(); ++ if ( style && style->filter.href) { ++ SPObject *filter = style->getFilter(); if (filter && SP_IS_FILTER(filter)) { // default filer area per the SVG spec: double x = -0.1; @@@ -843,9 -844,9 +807,9 @@@ temp_bbox.y1 += dy1; } } - if (item->clip_ref->getObject()) { - if (this->clip_ref->getObject()) { ++ if (clip_ref->getObject()) { NRRect b; - sp_clippath_get_bbox(SP_CLIPPATH(item->clip_ref->getObject()), &b, transform, flags); - SP_CLIPPATH(this->clip_ref->getObject())->sp_clippath_get_bbox(&b, transform, flags); ++ SP_CLIPPATH(clip_ref->getObject())->getBBox(&b, transform, flags); nr_rect_d_intersect (&temp_bbox, &temp_bbox, &b); } } @@@ -874,11 -875,11 +838,8 @@@ * unions the resulting bbox with \a bbox. If \a clear is true, empties \a bbox first. Passes the * transform and the flags to the actual bbox methods. Note that many of subclasses (e.g. groups, * clones), in turn, call this function in their bbox methods. */ --void - sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) -SPItem::invoke_bbox_full( NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) ++void SPItem::invoke_bbox_full( NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); - //g_assert(this != NULL); - //g_assert(SP_IS_ITEM(this)); g_assert(bbox != NULL); if (clear) { @@@ -896,9 -897,9 +857,9 @@@ } // unless this is geometric bbox, crop the bbox by clip path, if any - if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX && item->clip_ref->getObject()) { - if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX && this->clip_ref->getObject()) { ++ if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX && clip_ref->getObject()) { NRRect b; - sp_clippath_get_bbox(SP_CLIPPATH(item->clip_ref->getObject()), &b, transform, flags); - SP_CLIPPATH(this->clip_ref->getObject())->sp_clippath_get_bbox(&b, transform, flags); ++ SP_CLIPPATH(clip_ref->getObject())->getBBox(&b, transform, flags); nr_rect_d_intersect (&this_bbox, &this_bbox, &b); } @@@ -908,19 -909,19 +869,15 @@@ } } - unsigned sp_item_pos_in_parent(SPItem *item) + unsigned SPItem::pos_in_parent() { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); - //g_assert(this != NULL); - //g_assert(SP_IS_ITEM(this)); -- - SPObject *parent = item->parent; - SPObject *parent = SP_OBJECT_PARENT(this); g_assert(parent != NULL); g_assert(SP_IS_OBJECT(parent)); - SPObject *object = item; - SPObject *object = SP_OBJECT(this); ++ SPObject *object = this; - unsigned pos = 0; - for ( SPObject *iter = sp_object_first_child(parent) ; iter ; iter = iter->next) { + unsigned pos=0; - for ( SPObject *iter = parent->first_child() ; iter ; iter = SP_OBJECT_NEXT(iter)) { ++ for ( SPObject *iter = parent->firstChild() ; iter ; iter = iter->next) { if ( iter == object ) { return pos; } @@@ -933,20 -934,20 +890,17 @@@ return 0; } --void - sp_item_bbox_desktop(SPItem *item, NRRect *bbox, SPItem::BBoxType type) -SPItem::getBboxDesktop(NRRect *bbox, SPItem::BBoxType type) ++void SPItem::getBboxDesktop(NRRect *bbox, SPItem::BBoxType type) { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); - //g_assert(item != NULL); - //g_assert(SP_IS_ITEM(item)); g_assert(bbox != NULL); - sp_item_invoke_bbox(item, bbox, sp_item_i2d_affine(item), TRUE, type); + invoke_bbox( bbox, i2d_affine(), TRUE, type); } - Geom::OptRect sp_item_bbox_desktop(SPItem *item, SPItem::BBoxType type) + Geom::OptRect SPItem::getBboxDesktop(SPItem::BBoxType type) { Geom::OptRect rect = Geom::OptRect(); - sp_item_invoke_bbox(item, rect, sp_item_i2d_affine(item), TRUE, type); + invoke_bbox( rect, i2d_affine(), TRUE, type); return rect; } @@@ -971,22 -972,15 +925,12 @@@ void SPItem::sp_item_private_snappoints } - void sp_item_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) + void SPItem::getSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const { - if (item == NULL) { - g_warning("sp_item_snappoints: cannot snap because no item is being provided"); - return; - } - - if (!SP_IS_ITEM(item)) { - g_warning("sp_item_snappoints: cannot snap because this is not a SP_ITEM"); - return; - } - //g_assert (this != NULL); - //g_assert (SP_IS_ITEM(this)); -- // Get the snappoints of the item - SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(item); + SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(this); if (item_class.snappoints) { - item_class.snappoints(item, p, snapprefs); + item_class.snappoints(this, p, snapprefs); } // Get the snappoints at the item's center @@@ -997,8 -991,8 +941,8 @@@ // Get the snappoints of clipping paths and mask, if any std::list<SPObject const *> clips_and_masks; - clips_and_masks.push_back(item->clip_ref->getObject()); - clips_and_masks.push_back(item->mask_ref->getObject()); - clips_and_masks.push_back(SP_OBJECT(clip_ref->getObject())); - clips_and_masks.push_back(SP_OBJECT(mask_ref->getObject())); ++ clips_and_masks.push_back(clip_ref->getObject()); ++ clips_and_masks.push_back(mask_ref->getObject()); SPDesktop *desktop = inkscape_active_desktop(); for (std::list<SPObject const *>::const_iterator o = clips_and_masks.begin(); o != clips_and_masks.end(); o++) { @@@ -1022,26 -1016,26 +966,24 @@@ } } --void - sp_item_invoke_print(SPItem *item, SPPrintContext *ctx) -SPItem::invoke_print(SPPrintContext *ctx) ++void SPItem::invoke_print(SPPrintContext *ctx) { - if (!item->isHidden()) { - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->print) { - if (!item->transform.isIdentity() - || item->style->opacity.value != SP_SCALE24_MAX) - if (!this->isHidden()) { - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->print) { - if (!this->transform.isIdentity() - || SP_OBJECT_STYLE(this)->opacity.value != SP_SCALE24_MAX) ++ if ( !isHidden() ) { ++ if ( reinterpret_cast<SPItemClass *>(G_OBJECT_GET_CLASS(this))->print ) { ++ if (!transform.isIdentity() ++ || style->opacity.value != SP_SCALE24_MAX) { - sp_print_bind(ctx, item->transform, SP_SCALE24_TO_FLOAT(item->style->opacity.value)); - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->print(item, ctx); - sp_print_bind(ctx, this->transform, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(this)->opacity.value)); - ((SPItemClass *) G_OBJECT_GET_CLASS(this))->print(this, ctx); ++ sp_print_bind(ctx, transform, SP_SCALE24_TO_FLOAT(style->opacity.value)); ++ reinterpret_cast<SPItemClass *>(G_OBJECT_GET_CLASS(this))->print(this, ctx); sp_print_release(ctx); } else { - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->print(item, ctx); - ((SPItemClass *) G_OBJECT_GET_CLASS(this))->print(this, ctx); ++ reinterpret_cast<SPItemClass *>(G_OBJECT_GET_CLASS(this))->print(this, ctx); } } } } - static gchar * - sp_item_private_description(SPItem */*item*/) -gchar * -SPItem::sp_item_private_description(SPItem */*item*/) ++gchar *SPItem::sp_item_private_description(SPItem */*item*/) { return g_strdup(_("Object")); } @@@ -1051,15 -1045,15 +993,11 @@@ * * Must be freed by caller. */ --gchar * - sp_item_description(SPItem *item) -SPItem::description() ++gchar *SPItem::description() { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); - //g_assert(this != NULL); - //g_assert(SP_IS_ITEM(this)); -- - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->description) { - gchar *s = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->description(item); - if (s && item->clip_ref->getObject()) { + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->description) { + gchar *s = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->description(this); + if (s && clip_ref->getObject()) { gchar *snew = g_strdup_printf (_("%s; <i>clipped</i>"), s); g_free (s); s = snew; @@@ -1069,9 -1063,9 +1007,9 @@@ g_free (s); s = snew; } - if ( item->style && item->style->filter.href && item->style->filter.href->getObject() ) { - const gchar *label = item->style->filter.href->getObject()->label(); - if (SP_OBJECT_STYLE(this) && SP_OBJECT_STYLE(this)->filter.href && SP_OBJECT_STYLE(this)->filter.href->getObject()) { - const gchar *label = SP_OBJECT_STYLE(this)->filter.href->getObject()->label(); -- gchar *snew; ++ if ( style && style->filter.href && style->filter.href->getObject() ) { ++ const gchar *label = style->filter.href->getObject()->label(); ++ gchar *snew = 0; if (label) { snew = g_strdup_printf (_("%s; <i>filtered (%s)</i>"), s, _(label)); } else { @@@ -1093,8 -1087,8 +1031,7 @@@ * \return First allocated key; hence if the returned key is n * you can use n, n + 1, ..., n + (numkeys - 1) */ --unsigned - sp_item_display_key_new(unsigned numkeys) -SPItem::display_key_new(unsigned numkeys) ++unsigned SPItem::display_key_new(unsigned numkeys) { static unsigned dkey = 0; @@@ -1103,11 -1097,11 +1040,8 @@@ return dkey - numkeys; } --NRArenaItem * - sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags) -SPItem::invoke_show(NRArena *arena, unsigned key, unsigned flags) ++NRArenaItem *SPItem::invoke_show(NRArena *arena, unsigned key, unsigned flags) { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); - //g_assert(this != NULL); - //g_assert(SP_IS_ITEM(this)); g_assert(arena != NULL); g_assert(NR_IS_ARENA(arena)); @@@ -1117,37 -1111,37 +1051,37 @@@ } if (ai != NULL) { - item->display = sp_item_view_new_prepend(item->display, item, flags, key, ai); - nr_arena_item_set_transform(ai, item->transform); - nr_arena_item_set_opacity(ai, SP_SCALE24_TO_FLOAT(item->style->opacity.value)); - nr_arena_item_set_visible(ai, !item->isHidden()); - nr_arena_item_set_sensitive(ai, item->sensitive); - if (item->clip_ref->getObject()) { - SPClipPath *cp = item->clip_ref->getObject(); - - if (!item->display->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3)); + display = sp_item_view_new_prepend(display, this, flags, key, ai); + nr_arena_item_set_transform(ai, transform); - nr_arena_item_set_opacity(ai, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(this)->opacity.value)); ++ nr_arena_item_set_opacity(ai, SP_SCALE24_TO_FLOAT(style->opacity.value)); + nr_arena_item_set_visible(ai, !isHidden()); + nr_arena_item_set_sensitive(ai, sensitive); + if (clip_ref->getObject()) { + SPClipPath *cp = clip_ref->getObject(); + + if (!display->arenaitem->key) { + NR_ARENA_ITEM_SET_KEY(display->arenaitem, display_key_new(3)); } - int clip_key = NR_ARENA_ITEM_GET_KEY(item->display->arenaitem); + int clip_key = NR_ARENA_ITEM_GET_KEY(display->arenaitem); // Show and set clip - NRArenaItem *ac = sp_clippath_show(cp, arena, clip_key); - NRArenaItem *ac = cp->sp_clippath_show(arena, clip_key); ++ NRArenaItem *ac = cp->show(arena, clip_key); nr_arena_item_set_clip(ai, ac); nr_arena_item_unref(ac); // Update bbox, in case the clip uses bbox units NRRect bbox; - sp_item_invoke_bbox(item, &bbox, Geom::identity(), TRUE); - sp_clippath_set_bbox(SP_CLIPPATH(cp), clip_key, &bbox); + invoke_bbox( &bbox, Geom::identity(), TRUE); - SP_CLIPPATH(cp)->sp_clippath_set_bbox(clip_key, &bbox); - SP_OBJECT(cp)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); ++ SP_CLIPPATH(cp)->setBBox(clip_key, &bbox); + cp->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } - if (item->mask_ref->getObject()) { - SPMask *mask = item->mask_ref->getObject(); + if (mask_ref->getObject()) { + SPMask *mask = mask_ref->getObject(); - if (!item->display->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3)); + if (!display->arenaitem->key) { + NR_ARENA_ITEM_SET_KEY(display->arenaitem, display_key_new(3)); } - int mask_key = NR_ARENA_ITEM_GET_KEY(item->display->arenaitem); + int mask_key = NR_ARENA_ITEM_GET_KEY(display->arenaitem); // Show and set mask NRArenaItem *ac = sp_mask_show(mask, arena, mask_key); @@@ -1156,27 -1150,27 +1090,23 @@@ // Update bbox, in case the mask uses bbox units NRRect bbox; - sp_item_invoke_bbox(item, &bbox, Geom::identity(), TRUE); + invoke_bbox( &bbox, Geom::identity(), TRUE); sp_mask_set_bbox(SP_MASK(mask), mask_key, &bbox); - SP_OBJECT(mask)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } - NR_ARENA_ITEM_SET_DATA(ai, item); + NR_ARENA_ITEM_SET_DATA(ai, this); Geom::OptRect item_bbox; - sp_item_invoke_bbox(item, item_bbox, Geom::identity(), TRUE, SPItem::GEOMETRIC_BBOX); + invoke_bbox( item_bbox, Geom::identity(), TRUE, SPItem::GEOMETRIC_BBOX); nr_arena_item_set_item_bbox(ai, item_bbox); } return ai; } --void - sp_item_invoke_hide(SPItem *item, unsigned key) -SPItem::invoke_hide(unsigned key) ++void SPItem::invoke_hide(unsigned key) { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); - //g_assert(this != NULL); - //g_assert(SP_IS_ITEM(this)); -- - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->hide) { - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->hide(item, key); + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->hide) { + ((SPItemClass *) G_OBJECT_GET_CLASS(this))->hide(this, key); } SPItemView *ref = NULL; @@@ -1184,12 -1178,12 +1114,12 @@@ while (v != NULL) { SPItemView *next = v->next; if (v->key == key) { - if (item->clip_ref->getObject()) { - sp_clippath_hide(item->clip_ref->getObject(), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); + if (clip_ref->getObject()) { - (clip_ref->getObject())->sp_clippath_hide(NR_ARENA_ITEM_GET_KEY(v->arenaitem)); ++ (clip_ref->getObject())->hide(NR_ARENA_ITEM_GET_KEY(v->arenaitem)); nr_arena_item_set_clip(v->arenaitem, NULL); } - if (item->mask_ref->getObject()) { - sp_mask_hide(item->mask_ref->getObject(), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); + if (mask_ref->getObject()) { + sp_mask_hide(mask_ref->getObject(), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); nr_arena_item_set_mask(v->arenaitem, NULL); } if (!ref) { @@@ -1209,35 -1203,37 +1139,30 @@@ // Adjusters --void - sp_item_adjust_pattern (SPItem *item, Geom::Matrix const &postmul, bool set) -SPItem::adjust_pattern (Geom::Matrix const &postmul, bool set) ++void SPItem::adjust_pattern (Geom::Matrix const &postmul, bool set) { - SPStyle *style = item->style; - SPStyle *style = SP_OBJECT_STYLE (this); -- - if ( style && style->fill.isPaintserver() ) { - SPPaintServer *server = item->style->getFillPaintServer(); + if (style && (style->fill.isPaintserver())) { - SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (this); - if (SP_IS_PATTERN (server)) { - SPPattern *pattern = sp_pattern_clone_if_necessary (this, SP_PATTERN (server), "fill"); - sp_pattern_transform_multiply (pattern, postmul, set); ++ SPObject *server = style->getFillPaintServer(); + if ( SP_IS_PATTERN(server) ) { - SPPattern *pattern = sp_pattern_clone_if_necessary(item, SP_PATTERN(server), "fill"); ++ SPPattern *pattern = sp_pattern_clone_if_necessary(this, SP_PATTERN(server), "fill"); + sp_pattern_transform_multiply(pattern, postmul, set); } } - if ( style && style->stroke.isPaintserver() ) { - SPPaintServer *server = item->style->getStrokePaintServer(); + if (style && (style->stroke.isPaintserver())) { - SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (this); - if (SP_IS_PATTERN (server)) { - SPPattern *pattern = sp_pattern_clone_if_necessary (this, SP_PATTERN (server), "stroke"); - sp_pattern_transform_multiply (pattern, postmul, set); ++ SPObject *server = style->getStrokePaintServer(); + if ( SP_IS_PATTERN(server) ) { - SPPattern *pattern = sp_pattern_clone_if_necessary(item, SP_PATTERN(server), "stroke"); ++ SPPattern *pattern = sp_pattern_clone_if_necessary(this, SP_PATTERN(server), "stroke"); + sp_pattern_transform_multiply(pattern, postmul, set); } } - } - void sp_item_adjust_gradient( SPItem *item, Geom::Matrix const &postmul, bool set ) -void -SPItem::adjust_gradient (Geom::Matrix const &postmul, bool set) ++void SPItem::adjust_gradient( Geom::Matrix const &postmul, bool set ) { - SPStyle *style = item->style; - SPStyle *style = SP_OBJECT_STYLE (this); -- - if (style && (style->fill.isPaintserver())) { - SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(this); - if (SP_IS_GRADIENT (server)) { + if ( style && style->fill.isPaintserver() ) { - SPPaintServer *server = item->style->getFillPaintServer(); ++ SPPaintServer *server = style->getFillPaintServer(); + if ( SP_IS_GRADIENT(server) ) { /** * \note Bbox units for a gradient are generally a bad idea because @@@ -1248,26 -1244,28 +1173,24 @@@ * \todo FIXME: convert back to bbox units after transforming with * the item, so as to preserve the original units. */ - SPGradient *gradient = sp_gradient_convert_to_userspace( SP_GRADIENT(server), item, "fill" ); - SPGradient *gradient = sp_gradient_convert_to_userspace (SP_GRADIENT (server), this, "fill"); ++ SPGradient *gradient = sp_gradient_convert_to_userspace( SP_GRADIENT(server), this, "fill" ); - sp_gradient_transform_multiply (gradient, postmul, set); + sp_gradient_transform_multiply( gradient, postmul, set ); } } - if (style && (style->stroke.isPaintserver())) { - SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER(this); - if (SP_IS_GRADIENT (server)) { - SPGradient *gradient = sp_gradient_convert_to_userspace (SP_GRADIENT (server), this, "stroke"); - sp_gradient_transform_multiply (gradient, postmul, set); + if ( style && style->stroke.isPaintserver() ) { - SPPaintServer *server = item->style->getStrokePaintServer(); ++ SPPaintServer *server = style->getStrokePaintServer(); + if ( SP_IS_GRADIENT(server) ) { - SPGradient *gradient = sp_gradient_convert_to_userspace( SP_GRADIENT(server), item, "stroke" ); ++ SPGradient *gradient = sp_gradient_convert_to_userspace( SP_GRADIENT(server), this, "stroke"); + sp_gradient_transform_multiply( gradient, postmul, set ); } } } - void sp_item_adjust_stroke( SPItem *item, gdouble ex ) -void -SPItem::adjust_stroke (gdouble ex) ++void SPItem::adjust_stroke( gdouble ex ) { - SPStyle *style = item->style; - SPStyle *style = SP_OBJECT_STYLE (this); - - if (style && !style->stroke.isNone() && !NR_DF_TEST_CLOSE (ex, 1.0, NR_EPSILON)) { -- + if ( style && !style->stroke.isNone() && !NR_DF_TEST_CLOSE(ex, 1.0, NR_EPSILON) ) { style->stroke_width.computed *= ex; style->stroke_width.set = TRUE; @@@ -1278,18 -1277,18 +1201,17 @@@ style->stroke_dash.offset *= ex; } - item->updateRepr(); - SP_OBJECT(this)->updateRepr(); ++ updateRepr(); } } /** * Find out the inverse of previous transform of an item (from its repr) */ --Geom::Matrix --sp_item_transform_repr (SPItem *item) ++Geom::Matrix sp_item_transform_repr (SPItem *item) { Geom::Matrix t_old(Geom::identity()); - gchar const *t_attr = item->repr->attribute("transform"); - gchar const *t_attr = SP_OBJECT_REPR(item)->attribute("transform"); ++ gchar const *t_attr = item->getRepr()->attribute("transform"); if (t_attr) { Geom::Matrix t; if (sp_svg_transform_read(t_attr, &t)) { @@@ -1304,18 -1303,18 +1226,17 @@@ /** * Recursively scale stroke width in \a item and its children by \a expansion. */ --void - sp_item_adjust_stroke_width_recursive(SPItem *item, double expansion) -SPItem::adjust_stroke_width_recursive(double expansion) ++void SPItem::adjust_stroke_width_recursive(double expansion) { - sp_item_adjust_stroke (item, expansion); + adjust_stroke (expansion); // A clone's child is the ghost of its original - we must not touch it, skip recursion - if (item && SP_IS_USE(item)) - if (this && SP_IS_USE(this)) -- return; -- - for (SPObject *o = item->children; o != NULL; o = o->next) { - for (SPObject *o = SP_OBJECT(this)->children; o != NULL; o = o->next) { -- if (SP_IS_ITEM(o)) - sp_item_adjust_stroke_width_recursive(SP_ITEM(o), expansion); - SP_ITEM(o)->adjust_stroke_width_recursive(expansion); ++ if ( !SP_IS_USE(this) ) { ++ for ( SPObject *o = children; o; o = o->getNext() ) { ++ if (SP_IS_ITEM(o)) { ++ SP_ITEM(o)->adjust_stroke_width_recursive(expansion); ++ } ++ } } } @@@ -1338,8 -1337,8 +1259,7 @@@ sp_item_adjust_rects_recursive(SPItem * /** * Recursively compensate pattern or gradient transform. */ --void - sp_item_adjust_paint_recursive (SPItem *item, Geom::Matrix advertized_transform, Geom::Matrix t_ancestors, bool is_pattern) -SPItem::adjust_paint_recursive (Geom::Matrix advertized_transform, Geom::Matrix t_ancestors, bool is_pattern) ++void SPItem::adjust_paint_recursive (Geom::Matrix advertized_transform, Geom::Matrix t_ancestors, bool is_pattern) { // _Before_ full pattern/gradient transform: t_paint * t_item * t_ancestors // _After_ full pattern/gradient transform: t_paint_new * t_item * t_ancestors * advertised_transform @@@ -1350,8 -1349,8 +1270,8 @@@ // Within text, we do not fork gradients, and so must not recurse to avoid double compensation; // also we do not recurse into clones, because a clone's child is the ghost of its original - // we must not touch it - if (!(item && (SP_IS_TEXT(item) || SP_IS_USE(item)))) { - for (SPObject *o = item->children; o != NULL; o = o->next) { + if (!(this && (SP_IS_TEXT(this) || SP_IS_USE(this)))) { - for (SPObject *o = SP_OBJECT(this)->children; o != NULL; o = o->next) { ++ for (SPObject *o = children; o != NULL; o = o->next) { if (SP_IS_ITEM(o)) { // At the level of the transformed item, t_ancestors is identity; // below it, it is the accmmulated chain of transforms from this level to the top level @@@ -1365,31 -1364,31 +1285,29 @@@ // and paintservers on leaves inheriting their values from ancestors could adjust themselves properly // before ancestors themselves are adjusted, probably differently (bug 1286535) -- if (is_pattern) - sp_item_adjust_pattern (item, paint_delta); - adjust_pattern (paint_delta); -- else - sp_item_adjust_gradient (item, paint_delta); - adjust_gradient (paint_delta); -- ++ if (is_pattern) { ++ adjust_pattern(paint_delta); ++ } else { ++ adjust_gradient(paint_delta); ++ } } --void - sp_item_adjust_livepatheffect (SPItem *item, Geom::Matrix const &postmul, bool set) -SPItem::adjust_livepatheffect (Geom::Matrix const &postmul, bool set) ++void SPItem::adjust_livepatheffect (Geom::Matrix const &postmul, bool set) { - if ( !SP_IS_LPE_ITEM(item) ) - if ( !SP_IS_LPE_ITEM(this) ) -- return; -- - SPLPEItem *lpeitem = SP_LPE_ITEM (item); - SPLPEItem *lpeitem = SP_LPE_ITEM (this); -- if ( sp_lpe_item_has_path_effect(lpeitem) ) { -- sp_lpe_item_fork_path_effects_if_necessary(lpeitem); -- -- // now that all LPEs are forked_if_necessary, we can apply the transform -- PathEffectList effect_list = sp_lpe_item_get_effect_list(lpeitem); -- for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); it++) -- { -- LivePathEffectObject *lpeobj = (*it)->lpeobject; -- if (lpeobj && lpeobj->get_lpe()) { -- Inkscape::LivePathEffect::Effect * effect = lpeobj->get_lpe(); -- effect->transform_multiply(postmul, set); ++ if ( SP_IS_LPE_ITEM(this) ) { ++ SPLPEItem *lpeitem = SP_LPE_ITEM (this); ++ if ( sp_lpe_item_has_path_effect(lpeitem) ) { ++ sp_lpe_item_fork_path_effects_if_necessary(lpeitem); ++ ++ // now that all LPEs are forked_if_necessary, we can apply the transform ++ PathEffectList effect_list = sp_lpe_item_get_effect_list(lpeitem); ++ for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); it++) ++ { ++ LivePathEffectObject *lpeobj = (*it)->lpeobject; ++ if (lpeobj && lpeobj->get_lpe()) { ++ Inkscape::LivePathEffect::Effect * effect = lpeobj->get_lpe(); ++ effect->transform_multiply(postmul, set); ++ } } } } @@@ -1403,11 -1402,11 +1321,8 @@@ * stored optimized. Send _transformed_signal. Invoke _write method so that * the repr is updated with the new transform. */ --void - sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv, bool compensate) -SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv, bool compensate) ++void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv, bool compensate) { - g_return_if_fail(item != NULL); - g_return_if_fail(SP_IS_ITEM(item)); - //g_return_if_fail(this != NULL); - //g_return_if_fail(SP_IS_ITEM(this)); g_return_if_fail(repr != NULL); // calculate the relative transform, if not given by the adv attribute @@@ -1451,36 -1450,36 +1366,32 @@@ gint preserve = prefs->getBool("/options/preservetransform/value", 0); Geom::Matrix transform_attr (transform); if ( // run the object's set_transform (i.e. embed transform) only if: - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform && // it does have a set_transform method + ((SPItemClass *) G_OBJECT_GET_CLASS(this))->set_transform && // it does have a set_transform method !preserve && // user did not chose to preserve all transforms - !item->clip_ref->getObject() && // the object does not have a clippath - !item->mask_ref->getObject() && // the object does not have a mask - !(!transform.isTranslation() && item->style && item->style->getFilter()) + !clip_ref->getObject() && // the object does not have a clippath + !mask_ref->getObject() && // the object does not have a mask - !(!transform.isTranslation() && SP_OBJECT_STYLE(this) && SP_OBJECT_STYLE(this)->getFilter()) ++ !(!transform.isTranslation() && style && style->getFilter()) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) ) { - transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform(item, transform); + transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->set_transform(this, transform); } - sp_item_set_item_transform(item, transform_attr); + set_item_transform(transform_attr); // Note: updateRepr comes before emitting the transformed signal since // it causes clone SPUse's copy of the original object to brought up to // date with the original. Otherwise, sp_use_bbox returns incorrect // values if called in code handling the transformed signal. - item->updateRepr(); - SP_OBJECT(this)->updateRepr(); ++ updateRepr(); // send the relative transform with a _transformed_signal - item->_transformed_signal.emit(&advertized_transform, item); + _transformed_signal.emit(&advertized_transform, this); } --gint - sp_item_event(SPItem *item, SPEvent *event) -SPItem::emitEvent(SPEvent &event) ++gint SPItem::emitEvent(SPEvent &event) { - g_return_val_if_fail(item != NULL, FALSE); - g_return_val_if_fail(SP_IS_ITEM(item), FALSE); - g_return_val_if_fail(event != NULL, FALSE); - //g_return_val_if_fail(this != NULL, FALSE); - //g_return_val_if_fail(SP_IS_ITEM(this), FALSE); - //g_return_val_if_fail((&event) != NULL, FALSE); -- - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->event) - return ((SPItemClass *) G_OBJECT_GET_CLASS(item))->event(item, event); - if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->event) ++ if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->event) { + return ((SPItemClass *) G_OBJECT_GET_CLASS(this))->event(this, &event); ++ } return FALSE; } @@@ -1489,35 -1488,35 +1400,26 @@@ * Sets item private transform (not propagated to repr), without compensating stroke widths, * gradients, patterns as sp_item_write_transform does. */ --void - sp_item_set_item_transform(SPItem *item, Geom::Matrix const &transform) -SPItem::set_item_transform(Geom::Matrix const &transform_matrix) ++void SPItem::set_item_transform(Geom::Matrix const &transform_matrix) { - g_return_if_fail(item != NULL); - g_return_if_fail(SP_IS_ITEM(item)); - g_return_if_fail(this != NULL); - g_return_if_fail(SP_IS_ITEM(this)); -- - if (!matrix_equalp(transform, item->transform, NR_EPSILON)) { - item->transform = transform; + if (!matrix_equalp(transform_matrix, transform, NR_EPSILON)) { + transform = transform_matrix; /* The SP_OBJECT_USER_MODIFIED_FLAG_B is used to mark the fact that it's only a transformation. It's apparently not used anywhere else. */ - item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_USER_MODIFIED_FLAG_B); - sp_item_rm_unsatisfied_cns(*item); + requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_USER_MODIFIED_FLAG_B); + sp_item_rm_unsatisfied_cns(*this); } } --void - sp_item_convert_item_to_guides(SPItem *item) { - g_return_if_fail(item != NULL); - g_return_if_fail(SP_IS_ITEM(item)); -SPItem::convert_item_to_guides() { - g_return_if_fail(this != NULL); - g_return_if_fail(SP_IS_ITEM(this)); - - /* Use derived method if present ... */ ++void SPItem::convert_item_to_guides() { ++ // Use derived method if present ... + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->convert_to_guides) { + (*((SPItemClass *) G_OBJECT_GET_CLASS(this))->convert_to_guides)(this); - return; - } - - /* .. otherwise simply place the guides around the item's bounding box */ ++ } else { ++ // .. otherwise simply place the guides around the item's bounding box - /* Use derived method if present ... */ - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->convert_to_guides) { - (*((SPItemClass *) G_OBJECT_GET_CLASS(item))->convert_to_guides)(item); - return; - convert_to_guides(); ++ convert_to_guides(); + } - - /* .. otherwise simply place the guides around the item's bounding box */ - - sp_item_convert_to_guides(item); } @@@ -1565,27 -1564,27 +1467,21 @@@ Geom::Matrix SPItem::i2doc_affine() con /** * Returns the transformation from item to desktop coords */ - Geom::Matrix sp_item_i2d_affine(SPItem const *item) + Geom::Matrix SPItem::i2d_affine() const { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); - //g_assert(item != NULL); - //g_assert(SP_IS_ITEM(item)); -- - Geom::Matrix const ret( sp_item_i2doc_affine(item) + Geom::Matrix const ret( i2doc_affine() * Geom::Scale(1, -1) - * Geom::Translate(0, sp_document_height(item->document)) ); - * Geom::Translate(0, SP_OBJECT_DOCUMENT(this)->getHeight()) ); ++ * Geom::Translate(0, document->getHeight()) ); return ret; } - void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &i2dt) + void SPItem::set_i2d_affine(Geom::Matrix const &i2dt) { - g_return_if_fail( item != NULL ); - g_return_if_fail( SP_IS_ITEM(item) ); - //g_return_if_fail( item != NULL ); - //g_return_if_fail( SP_IS_ITEM(item) ); -- Geom::Matrix dt2p; /* desktop to item parent transform */ - if (item->parent) { - dt2p = sp_item_i2d_affine(static_cast<SPItem *>(item->parent)).inverse(); - if (SP_OBJECT_PARENT(this)) { - dt2p = static_cast<SPItem *>(SP_OBJECT_PARENT(this))->i2d_affine().inverse(); ++ if (parent) { ++ dt2p = static_cast<SPItem *>(parent)->i2d_affine().inverse(); } else { - dt2p = ( Geom::Translate(0, -sp_document_height(item->document)) - dt2p = ( Geom::Translate(0, -SP_OBJECT_DOCUMENT(this)->getHeight()) ++ dt2p = ( Geom::Translate(0, -document->getHeight()) * Geom::Scale(1, -1) ); } @@@ -1597,26 -1596,26 +1493,22 @@@ /** * should rather be named "sp_item_d2i_affine" to match "sp_item_i2d_affine" (or vice versa) */ --Geom::Matrix - sp_item_dt2i_affine(SPItem const *item) -SPItem::dt2i_affine() const ++Geom::Matrix SPItem::dt2i_affine() const { /* fixme: Implement the right way (Lauris) */ - return sp_item_i2d_affine(item).inverse(); + return i2d_affine().inverse(); } /* Item views */ - static SPItemView * - sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem) -SPItemView * -SPItem::sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem) ++SPItemView *SPItem::sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem) { -- SPItemView *new_view; -- g_assert(item != NULL); g_assert(SP_IS_ITEM(item)); g_assert(arenaitem != NULL); g_assert(NR_IS_ARENA_ITEM(arenaitem)); -- new_view = g_new(SPItemView, 1); ++ SPItemView *new_view = g_new(SPItemView, 1); new_view->next = list; new_view->flags = flags; @@@ -1626,8 -1625,8 +1518,7 @@@ return new_view; } - static SPItemView * - sp_item_view_list_remove(SPItemView *list, SPItemView *view) -SPItemView * -SPItem::sp_item_view_list_remove(SPItemView *list, SPItemView *view) ++SPItemView *SPItem::sp_item_view_list_remove(SPItemView *list, SPItemView *view) { if (view == list) { list = list->next; @@@ -1648,10 -1647,10 +1539,9 @@@ * Return the arenaitem corresponding to the given item in the display * with the given key */ --NRArenaItem * - sp_item_get_arenaitem(SPItem *item, unsigned key) -SPItem::get_arenaitem(unsigned key) ++NRArenaItem *SPItem::get_arenaitem(unsigned key) { - for ( SPItemView *iv = item->display ; iv ; iv = iv->next ) { + for ( SPItemView *iv = display ; iv ; iv = iv->next ) { if ( iv->key == key ) { return iv->arenaitem; } @@@ -1660,29 -1659,28 +1550,27 @@@ return NULL; } --int --sp_item_repr_compare_position(SPItem *first, SPItem *second) ++int sp_item_repr_compare_position(SPItem *first, SPItem *second) { - return sp_repr_compare_position(first->repr, - second->repr); - return sp_repr_compare_position(SP_OBJECT_REPR(first), - SP_OBJECT_REPR(second)); ++ return sp_repr_compare_position(first->getRepr(), ++ second->getRepr()); } --SPItem * --sp_item_first_item_child (SPObject *obj) ++SPItem *sp_item_first_item_child(SPObject *obj) { - for ( SPObject *iter = sp_object_first_child(obj) ; iter ; iter = iter->next) { - for ( SPObject *iter = obj->first_child() ; iter ; iter = SP_OBJECT_NEXT(iter)) { - if (SP_IS_ITEM (iter)) - return SP_ITEM (iter); ++ SPItem *child = 0; ++ for ( SPObject *iter = obj->firstChild() ; iter ; iter = iter->next ) { + if ( SP_IS_ITEM(iter) ) { - return SP_ITEM (iter); ++ child = SP_ITEM(iter); ++ break; + } } -- return NULL; ++ return child; } --void - sp_item_convert_to_guides(SPItem *item) { -SPItem::convert_to_guides() { ++void SPItem::convert_to_guides() { SPDesktop *dt = inkscape_active_desktop(); -- SPNamedView *nv = sp_desktop_namedview(dt); -- (void)nv; ++ sp_desktop_namedview(dt); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getInt("/tools/bounding_box", 0); diff --cc src/sp-item.h index 7387a63cf,d2c24baf0..4ba3dc7a4 --- a/src/sp-item.h +++ b/src/sp-item.h @@@ -1,5 -1,5 +1,5 @@@ --#ifndef __SP_ITEM_H__ --#define __SP_ITEM_H__ ++#ifndef SEEN_SP_ITEM_H ++#define SEEN_SP_ITEM_H /** \file * Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx, SPItemClass, SPEvent. @@@ -10,6 -10,6 +10,7 @@@ * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> ++ * Abhishek Sharma * * Copyright (C) 1999-2006 authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -53,13 -53,17 +54,15 @@@ enum * Also, this probably goes to SPObject base class. * */ - struct SPEvent { -//struct SPEvent { + class SPEvent { - public: ++public: unsigned int type; gpointer data; }; /// SPItemView - struct SPItemView { -//struct SPItemView { + class SPItemView { - public: ++public: SPItemView *next; unsigned int flags; unsigned int key; @@@ -79,7 -83,9 +82,8 @@@ #define SP_ITEM_REFERENCE_FLAGS (1 << 1) /// Contains transformations to document/viewport and the viewport size. - struct SPItemCtx { -//struct SPItemCtx { + class SPItemCtx { - public: ++public: SPCtx ctx; /** Item to document transformation */ Geom::Matrix i2doc; @@@ -89,8 -95,20 +93,19 @@@ Geom::Matrix i2vp; }; + class SPItem; + class SPItemClass; + + #define SP_TYPE_ITEM (SPItem::getType ()) + #define SP_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ITEM, SPItem)) + #define SP_ITEM_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_ITEM, SPItemClass)) + #define SP_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ITEM)) + + /** Abstract base class for all visible shapes. */ - struct SPItem : public SPObject { -//struct SPItem : public SPObject { + class SPItem : public SPObject { - public: - static GType getType (); ++public: ++ static GType getType(); enum BBoxType { // legacy behavior: includes crude stroke, markers; excludes long miters, blur margin; is known to be wrong for caps APPROXIMATE_BBOX, @@@ -160,7 -178,36 +175,37 @@@ sigc::connection connectTransformed(sigc::slot<void, Geom::Matrix const *, SPItem *> slot) { return _transformed_signal.connect(slot); } - void invoke_bbox( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); - void invoke_bbox( NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); - void invoke_bbox_full( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear); - void invoke_bbox_full( NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) __attribute__ ((deprecated)); - - unsigned pos_in_parent(); - gchar *description(); - void invoke_print(SPPrintContext *ctx); - static unsigned int display_key_new(unsigned int numkeys); - NRArenaItem *invoke_show(NRArena *arena, unsigned int key, unsigned int flags); - void invoke_hide(unsigned int key); - void getSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs=0) const; - void adjust_pattern(/* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); - void adjust_gradient(/* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); - void adjust_stroke(gdouble ex); - void adjust_stroke_width_recursive(gdouble ex); - void adjust_paint_recursive(Geom::Matrix advertized_transform, Geom::Matrix t_ancestors, bool is_pattern); - void adjust_livepatheffect(Geom::Matrix const &postmul, bool set = false); - void doWriteTransform(Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv = NULL, bool compensate = true); - void set_item_transform(Geom::Matrix const &transform_matrix); - void convert_item_to_guides(); - gint emitEvent (SPEvent &event); - NRArenaItem *get_arenaitem(unsigned int key); - void getBboxDesktop(NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); - Geom::OptRect getBboxDesktop(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); - Geom::Matrix i2doc_affine() const; - Geom::Matrix i2d_affine() const; - void set_i2d_affine(Geom::Matrix const &transform); - Geom::Matrix dt2i_affine() const; - void convert_to_guides(); ++ void invoke_bbox( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); ++ void invoke_bbox( NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); ++ void invoke_bbox_full( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) const; ++ void invoke_bbox_full( NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) __attribute__ ((deprecated)); ++ ++ unsigned pos_in_parent(); ++ gchar *description(); ++ void invoke_print(SPPrintContext *ctx); ++ static unsigned int display_key_new(unsigned int numkeys); ++ NRArenaItem *invoke_show(NRArena *arena, unsigned int key, unsigned int flags); ++ void invoke_hide(unsigned int key); ++ void getSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs=0) const; ++ void adjust_pattern(/* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); ++ void adjust_gradient(/* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); ++ void adjust_stroke(gdouble ex); ++ void adjust_stroke_width_recursive(gdouble ex); ++ void adjust_paint_recursive(Geom::Matrix advertized_transform, Geom::Matrix t_ancestors, bool is_pattern); ++ void adjust_livepatheffect(Geom::Matrix const &postmul, bool set = false); ++ void doWriteTransform(Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv = NULL, bool compensate = true); ++ void set_item_transform(Geom::Matrix const &transform_matrix); ++ void convert_item_to_guides(); ++ gint emitEvent (SPEvent &event); ++ NRArenaItem *get_arenaitem(unsigned int key); ++ void getBboxDesktop(NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); ++ Geom::OptRect getBboxDesktop(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); ++ Geom::Matrix i2doc_affine() const; ++ Geom::Matrix i2d_affine() const; ++ void set_i2d_affine(Geom::Matrix const &transform); ++ Geom::Matrix dt2i_affine() const; ++ void convert_to_guides(); + private: enum EvaluatedStatus { @@@ -169,10 -216,30 +214,29 @@@ mutable bool _is_evaluated; mutable EvaluatedStatus _evaluated_status; + - static void sp_item_init(SPItem *item); ++ static void sp_item_init(SPItem *item); ++ ++ static void sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); ++ static void sp_item_release(SPObject *object); ++ static void sp_item_set(SPObject *object, unsigned key, gchar const *value); ++ static void sp_item_update(SPObject *object, SPCtx *ctx, guint flags); ++ static Inkscape::XML::Node *sp_item_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); + - static void sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); - static void sp_item_release(SPObject *object); - static void sp_item_set(SPObject *object, unsigned key, gchar const *value); - static void sp_item_update(SPObject *object, SPCtx *ctx, guint flags); - static Inkscape::XML::Node *sp_item_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); ++ static gchar *sp_item_private_description(SPItem *item); ++ static void sp_item_private_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); + - static gchar *sp_item_private_description(SPItem *item); - static void sp_item_private_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); ++ static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem); ++ static SPItemView *sp_item_view_list_remove(SPItemView *list, SPItemView *view); ++ static void clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); ++ static void mask_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); + - static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem); - static SPItemView *sp_item_view_list_remove(SPItemView *list, SPItemView *view); - static void clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); - static void mask_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); - - friend class SPItemClass; ++ friend class SPItemClass; }; /// The SPItem vtable. - struct SPItemClass { -//struct SPItemClass { + class SPItemClass { - public: ++public: SPObjectClass parent_class; /** BBox union in given coordinate system */ @@@ -201,58 -268,64 +265,19 @@@ /** Emit event, if applicable */ gint (* event) (SPItem *item, SPEvent *event); - }; - - /* Flag testing macros */ - - #define SP_ITEM_STOP_PAINT(i) (SP_ITEM (i)->stop_paint) - - /* Methods */ - - void sp_item_invoke_bbox(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); - void sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); - void sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear); - void sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) __attribute__ ((deprecated)); - unsigned sp_item_pos_in_parent(SPItem *item); + private: + static SPObjectClass *static_parent_class; + static void sp_item_class_init(SPItemClass *klass); - gchar *sp_item_description(SPItem * item); - void sp_item_invoke_print(SPItem *item, SPPrintContext *ctx); - - /** Shows/Hides item on given arena display list */ - unsigned int sp_item_display_key_new(unsigned int numkeys); - NRArenaItem *sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); - void sp_item_invoke_hide(SPItem *item, unsigned int key); - - void sp_item_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); - - void sp_item_adjust_pattern(SPItem *item, /* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); - void sp_item_adjust_gradient(SPItem *item, /* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); - void sp_item_adjust_stroke(SPItem *item, gdouble ex); - void sp_item_adjust_stroke_width_recursive(SPItem *item, gdouble ex); - void sp_item_adjust_paint_recursive(SPItem *item, Geom::Matrix advertized_transform, Geom::Matrix t_ancestors, bool is_pattern); - void sp_item_adjust_livepatheffect(SPItem *item, Geom::Matrix const &postmul, bool set = false); - - void sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv = NULL, bool compensate = true); - - void sp_item_set_item_transform(SPItem *item, Geom::Matrix const &transform); - - void sp_item_convert_item_to_guides(SPItem *item); - - gint sp_item_event (SPItem *item, SPEvent *event); - - /* Utility */ - - NRArenaItem *sp_item_get_arenaitem(SPItem *item, unsigned int key); + friend class SPItem; + }; - void sp_item_bbox_desktop(SPItem *item, NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); - Geom::OptRect sp_item_bbox_desktop(SPItem *item, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); -/* Flag testing macros */ - -#define SP_ITEM_STOP_PAINT(i) (SP_ITEM (i)->stop_paint) - -/* Methods */ - -//void sp_item_invoke_bbox(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); -//void sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); -//void sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear); -//void sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) __attribute__ ((deprecated)); - -//unsigned sp_item_pos_in_parent(SPItem *item); - -//gchar *sp_item_description(SPItem * item); -//void sp_item_invoke_print(SPItem *item, SPPrintContext *ctx); - -/** Shows/Hides item on given arena display list */ -//unsigned int sp_item_display_key_new(unsigned int numkeys); -//NRArenaItem *sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); -//void sp_item_invoke_hide(SPItem *item, unsigned int key); - -//void sp_item_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); - -//void sp_item_adjust_pattern(SPItem *item, /* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); -//void sp_item_adjust_gradient(SPItem *item, /* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); -//void sp_item_adjust_stroke(SPItem *item, gdouble ex); -//void sp_item_adjust_stroke_width_recursive(SPItem *item, gdouble ex); -//void sp_item_adjust_paint_recursive(SPItem *item, Geom::Matrix advertized_transform, Geom::Matrix t_ancestors, bool is_pattern); -//void sp_item_adjust_livepatheffect(SPItem *item, Geom::Matrix const &postmul, bool set = false); - -//void sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv = NULL, bool compensate = true); - -//void sp_item_set_item_transform(SPItem *item, Geom::Matrix const &transform); - -//void sp_item_convert_item_to_guides(SPItem *item); - -//gint sp_item_event (SPItem *item, SPEvent *event); - -/* Utility */ - -//NRArenaItem *sp_item_get_arenaitem(SPItem *item, unsigned int key); - -//void sp_item_bbox_desktop(SPItem *item, NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); -//Geom::OptRect sp_item_bbox_desktop(SPItem *item, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); ++// Utility Geom::Matrix i2anc_affine(SPObject const *item, SPObject const *ancestor); Geom::Matrix i2i_affine(SPObject const *src, SPObject const *dest); - Geom::Matrix sp_item_i2doc_affine(SPItem const *item); -//Geom::Matrix sp_item_i2doc_affine(SPItem const *item); -- /* fixme: - these are evil, but OK */ /* Fill *TRANSFORM with the item-to-desktop transform. See doc/coordinates.txt @@@ -261,15 -334,15 +286,10 @@@ * * \return TRANSFORM. */ - Geom::Matrix sp_item_i2d_affine(SPItem const *item); - void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &transform); - Geom::Matrix sp_item_dt2i_affine(SPItem const *item); -//Geom::Matrix sp_item_i2d_affine(SPItem const *item); -//void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &transform); -//Geom::Matrix sp_item_dt2i_affine(SPItem const *item); int sp_item_repr_compare_position(SPItem *first, SPItem *second); SPItem *sp_item_first_item_child (SPObject *obj); - void sp_item_convert_to_guides(SPItem *item); -//void sp_item_convert_to_guides(SPItem *item); -- --#endif ++#endif // SEEN_SP_ITEM_H /* Local Variables: diff --cc src/sp-line.cpp index d0ce32397,b71616c5b..b8c5a19b7 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@@ -1,10 -1,10 +1,10 @@@ --#define __SP_LINE_C__ -- /* * SVG <line> implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma ++ * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 1999-2002 Lauris Kaplinski * @@@ -25,224 -25,226 +25,213 @@@ #include "document.h" #include "inkscape.h" - static void sp_line_class_init (SPLineClass *klass); - static void sp_line_init (SPLine *line); -//static void sp_line_class_init (SPLineClass *klass); -//static void sp_line_init (SPLine *line); -- - static void sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); - static void sp_line_set (SPObject *object, unsigned int key, const gchar *value); - static Inkscape::XML::Node *sp_line_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -//static void sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); -//static void sp_line_set (SPObject *object, unsigned int key, const gchar *value); -//static Inkscape::XML::Node *sp_line_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -- - static gchar *sp_line_description (SPItem * item); - static Geom::Matrix sp_line_set_transform(SPItem *item, Geom::Matrix const &xform); -//static gchar *sp_line_description (SPItem * item); -//static Geom::Matrix sp_line_set_transform(SPItem *item, Geom::Matrix const &xform); -- - static void sp_line_update (SPObject *object, SPCtx *ctx, guint flags); - static void sp_line_set_shape (SPShape *shape); - static void sp_line_convert_to_guides(SPItem *item); -//static void sp_line_update (SPObject *object, SPCtx *ctx, guint flags); -//static void sp_line_set_shape (SPShape *shape); -//static void sp_line_convert_to_guides(SPItem *item); ++SPShapeClass * SPLineClass::static_parent_class = 0; - static SPShapeClass *parent_class; -//static SPShapeClass *static_parent_class; -SPShapeClass * SPLineClass::static_parent_class=0; -- --GType - sp_line_get_type (void) -SPLine::sp_line_get_type (void) ++GType SPLine::sp_line_get_type(void) { -- static GType line_type = 0; -- -- if (!line_type) { -- GTypeInfo line_info = { -- sizeof (SPLineClass), -- NULL, /* base_init */ -- NULL, /* base_finalize */ - (GClassInitFunc) sp_line_class_init, - (GClassInitFunc) SPLineClass::sp_line_class_init, -- NULL, /* klass_finalize */ -- NULL, /* klass_data */ -- sizeof (SPLine), -- 16, /* n_preallocs */ -- (GInstanceInitFunc) sp_line_init, -- NULL, /* value_table */ -- }; -- line_type = g_type_register_static (SP_TYPE_SHAPE, "SPLine", &line_info, (GTypeFlags)0); -- } -- return line_type; ++ static GType line_type = 0; ++ ++ if (!line_type) { ++ GTypeInfo line_info = { ++ sizeof(SPLineClass), ++ NULL, /* base_init */ ++ NULL, /* base_finalize */ ++ (GClassInitFunc) SPLineClass::sp_line_class_init, ++ NULL, /* klass_finalize */ ++ NULL, /* klass_data */ ++ sizeof(SPLine), ++ 16, /* n_preallocs */ ++ (GInstanceInitFunc) init, ++ NULL, /* value_table */ ++ }; ++ line_type = g_type_register_static(SP_TYPE_SHAPE, "SPLine", &line_info,(GTypeFlags)0); ++ } ++ return line_type; } - static void - sp_line_class_init (SPLineClass *klass) - -void -SPLineClass::sp_line_class_init (SPLineClass *klass) ++void SPLineClass::sp_line_class_init(SPLineClass *klass) { - parent_class = (SPShapeClass *) g_type_class_ref (SP_TYPE_SHAPE); - SPLineClass::static_parent_class = (SPShapeClass *) g_type_class_ref (SP_TYPE_SHAPE); ++ SPLineClass::static_parent_class = (SPShapeClass *) g_type_class_ref(SP_TYPE_SHAPE); -- SPObjectClass *sp_object_class = (SPObjectClass *) klass; - sp_object_class->build = sp_line_build; - sp_object_class->set = sp_line_set; - sp_object_class->write = sp_line_write; - sp_object_class->build = SPLine::sp_line_build; - sp_object_class->set = SPLine::sp_line_set; - sp_object_class->write = SPLine::sp_line_write; ++ SPObjectClass *sp_object_class = (SPObjectClass *) klass; ++ sp_object_class->build = SPLine::build; ++ sp_object_class->set = SPLine::set; ++ sp_object_class->write = SPLine::write; -- SPItemClass *item_class = (SPItemClass *) klass; - item_class->description = sp_line_description; - item_class->set_transform = sp_line_set_transform; - item_class->convert_to_guides = sp_line_convert_to_guides; - item_class->description = SPLine::sp_line_description; - item_class->set_transform = SPLine::sp_line_set_transform; - item_class->convert_to_guides = SPLine::sp_line_convert_to_guides; ++ SPItemClass *item_class = (SPItemClass *) klass; ++ item_class->description = SPLine::getDescription; ++ item_class->set_transform = SPLine::setTransform; ++ item_class->convert_to_guides = SPLine::convertToGuides; - sp_object_class->update = sp_line_update; - sp_object_class->update = SPLine::sp_line_update; ++ sp_object_class->update = SPLine::update; -- SPShapeClass *shape_class = (SPShapeClass *) klass; - shape_class->set_shape = sp_line_set_shape; - shape_class->set_shape = SPLine::sp_line_set_shape; ++ SPShapeClass *shape_class = (SPShapeClass *) klass; ++ shape_class->set_shape = SPLine::setShape; } - static void - sp_line_init (SPLine * line) -void -SPLine::sp_line_init (SPLine * line) ++void SPLine::init(SPLine * line) { -- line->x1.unset(); -- line->y1.unset(); -- line->x2.unset(); -- line->y2.unset(); ++ line->x1.unset(); ++ line->y1.unset(); ++ line->x2.unset(); ++ line->y2.unset(); } - static void - sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) -void -SPLine::sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) ++void SPLine::build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build (object, document, repr); - if (((SPObjectClass *) SPLineClass::static_parent_class)->build) { - ((SPObjectClass *) SPLineClass::static_parent_class)->build (object, document, repr); -- } -- - sp_object_read_attr (object, "x1"); - sp_object_read_attr (object, "y1"); - sp_object_read_attr (object, "x2"); - sp_object_read_attr (object, "y2"); - object->readAttr( "x1"); - object->readAttr( "y1"); - object->readAttr( "x2"); - object->readAttr( "y2"); ++ if (((SPObjectClass *) SPLineClass::static_parent_class)->build) { ++ ((SPObjectClass *) SPLineClass::static_parent_class)->build(object, document, repr); ++ } ++ ++ object->readAttr( "x1" ); ++ object->readAttr( "y1" ); ++ object->readAttr( "x2" ); ++ object->readAttr( "y2" ); } - static void - sp_line_set (SPObject *object, unsigned int key, const gchar *value) -void -SPLine::sp_line_set (SPObject *object, unsigned int key, const gchar *value) ++void SPLine::set(SPObject *object, unsigned int key, const gchar *value) { -- SPLine * line = SP_LINE (object); -- -- /* fixme: we should really collect updates */ -- -- switch (key) { -- case SP_ATTR_X1: -- line->x1.readOrUnset(value); -- object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -- break; -- case SP_ATTR_Y1: -- line->y1.readOrUnset(value); -- object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -- break; -- case SP_ATTR_X2: -- line->x2.readOrUnset(value); -- object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -- break; -- case SP_ATTR_Y2: -- line->y2.readOrUnset(value); -- object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -- break; -- default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); - if (((SPObjectClass *) SPLineClass::static_parent_class)->set) - ((SPObjectClass *) SPLineClass::static_parent_class)->set (object, key, value); -- break; -- } ++ SPLine * line = SP_LINE(object); ++ ++ /* fixme: we should really collect updates */ ++ ++ switch (key) { ++ case SP_ATTR_X1: ++ line->x1.readOrUnset(value); ++ object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); ++ break; ++ case SP_ATTR_Y1: ++ line->y1.readOrUnset(value); ++ object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); ++ break; ++ case SP_ATTR_X2: ++ line->x2.readOrUnset(value); ++ object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); ++ break; ++ case SP_ATTR_Y2: ++ line->y2.readOrUnset(value); ++ object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); ++ break; ++ default: ++ if (((SPObjectClass *) SPLineClass::static_parent_class)->set) { ++ ((SPObjectClass *) SPLineClass::static_parent_class)->set(object, key, value); ++ } ++ break; ++ } } - static void - sp_line_update (SPObject *object, SPCtx *ctx, guint flags) -void -SPLine::sp_line_update (SPObject *object, SPCtx *ctx, guint flags) ++void SPLine::update(SPObject *object, SPCtx *ctx, guint flags) { -- if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { -- SPLine *line = SP_LINE (object); ++ if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { ++ SPLine *line = SP_LINE(object); -- SPStyle const *style = object->style; ++ SPStyle const *style = object->style; SPItemCtx const *ictx = (SPItemCtx const *) ctx; double const w = (ictx->vp.x1 - ictx->vp.x0); double const h = (ictx->vp.y1 - ictx->vp.y0); -- double const em = style->font_size.computed; -- double const ex = em * 0.5; // fixme: get from pango or libnrtype. -- line->x1.update(em, ex, w); -- line->x2.update(em, ex, w); -- line->y1.update(em, ex, h); -- line->y2.update(em, ex, h); -- - sp_shape_set_shape ((SPShape *) object); - ((SPShape *) object)->setShape (); -- } -- - if (((SPObjectClass *) parent_class)->update) - ((SPObjectClass *) parent_class)->update (object, ctx, flags); - if (((SPObjectClass *) SPLineClass::static_parent_class)->update) - ((SPObjectClass *) SPLineClass::static_parent_class)->update (object, ctx, flags); ++ double const em = style->font_size.computed; ++ double const ex = em * 0.5; // fixme: get from pango or libnrtype. ++ line->x1.update(em, ex, w); ++ line->x2.update(em, ex, w); ++ line->y1.update(em, ex, h); ++ line->y2.update(em, ex, h); ++ ++ ((SPShape *) object)->setShape(); ++ } ++ ++ if (((SPObjectClass *) SPLineClass::static_parent_class)->update) { ++ ((SPObjectClass *) SPLineClass::static_parent_class)->update(object, ctx, flags); ++ } } - static Inkscape::XML::Node * - sp_line_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) -Inkscape::XML::Node * -SPLine::sp_line_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) ++Inkscape::XML::Node * SPLine::write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { -- SPLine *line = SP_LINE (object); ++ SPLine *line = SP_LINE(object); -- if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { -- repr = xml_doc->createElement("svg:line"); -- } ++ if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { ++ repr = xml_doc->createElement("svg:line"); ++ } -- if (repr != SP_OBJECT_REPR (object)) { -- repr->mergeFrom(SP_OBJECT_REPR (object), "id"); -- } ++ if (repr != object->getRepr()) { ++ repr->mergeFrom(object->getRepr(), "id"); ++ } -- sp_repr_set_svg_double(repr, "x1", line->x1.computed); -- sp_repr_set_svg_double(repr, "y1", line->y1.computed); -- sp_repr_set_svg_double(repr, "x2", line->x2.computed); -- sp_repr_set_svg_double(repr, "y2", line->y2.computed); ++ sp_repr_set_svg_double(repr, "x1", line->x1.computed); ++ sp_repr_set_svg_double(repr, "y1", line->y1.computed); ++ sp_repr_set_svg_double(repr, "x2", line->x2.computed); ++ sp_repr_set_svg_double(repr, "y2", line->y2.computed); - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); - if (((SPObjectClass *) (SPLineClass::static_parent_class))->write) - ((SPObjectClass *) (SPLineClass::static_parent_class))->write (object, xml_doc, repr, flags); ++ if (((SPObjectClass *) (SPLineClass::static_parent_class))->write) { ++ ((SPObjectClass *) (SPLineClass::static_parent_class))->write(object, xml_doc, repr, flags); ++ } -- return repr; ++ return repr; } - static gchar * - sp_line_description(SPItem */*item*/) -gchar * -SPLine::sp_line_description(SPItem */*item*/) ++gchar * SPLine::getDescription(SPItem */*item*/) { return g_strdup(_("<b>Line</b>")); } - static void - sp_line_convert_to_guides(SPItem *item) -void -SPLine::sp_line_convert_to_guides(SPItem *item) ++void SPLine::convertToGuides(SPItem *item) { -- SPLine *line = SP_LINE(item); -- Geom::Point points[2]; ++ SPLine *line = SP_LINE(item); ++ Geom::Point points[2]; - Geom::Matrix const i2d (sp_item_i2d_affine(item)); - Geom::Matrix const i2d (item->i2d_affine()); ++ Geom::Matrix const i2d(item->i2d_affine()); -- points[0] = Geom::Point(line->x1.computed, line->y1.computed)*i2d; -- points[1] = Geom::Point(line->x2.computed, line->y2.computed)*i2d; ++ points[0] = Geom::Point(line->x1.computed, line->y1.computed)*i2d; ++ points[1] = Geom::Point(line->x2.computed, line->y2.computed)*i2d; - sp_guide_create(inkscape_active_desktop(), points[0], points[1]); - SPGuide::createSPGuide(inkscape_active_desktop(), points[0], points[1]); ++ SPGuide::createSPGuide(inkscape_active_desktop(), points[0], points[1]); } - static Geom::Matrix - sp_line_set_transform (SPItem *item, Geom::Matrix const &xform) -Geom::Matrix -SPLine::sp_line_set_transform (SPItem *item, Geom::Matrix const &xform) ++Geom::Matrix SPLine::setTransform(SPItem *item, Geom::Matrix const &xform) { -- SPLine *line = SP_LINE (item); -- Geom::Point points[2]; ++ SPLine *line = SP_LINE(item); ++ Geom::Point points[2]; -- points[0] = Geom::Point(line->x1.computed, line->y1.computed); -- points[1] = Geom::Point(line->x2.computed, line->y2.computed); ++ points[0] = Geom::Point(line->x1.computed, line->y1.computed); ++ points[1] = Geom::Point(line->x2.computed, line->y2.computed); -- points[0] *= xform; -- points[1] *= xform; ++ points[0] *= xform; ++ points[1] *= xform; -- line->x1.computed = points[0][Geom::X]; -- line->y1.computed = points[0][Geom::Y]; -- line->x2.computed = points[1][Geom::X]; -- line->y2.computed = points[1][Geom::Y]; ++ line->x1.computed = points[0][Geom::X]; ++ line->y1.computed = points[0][Geom::Y]; ++ line->x2.computed = points[1][Geom::X]; ++ line->y2.computed = points[1][Geom::Y]; - sp_item_adjust_stroke(item, xform.descrim()); - item->adjust_stroke(xform.descrim()); ++ item->adjust_stroke(xform.descrim()); -- SP_OBJECT (item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); ++ SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); -- return Geom::identity(); ++ return Geom::identity(); } - static void - sp_line_set_shape (SPShape *shape) -void -SPLine::sp_line_set_shape (SPShape *shape) ++void SPLine::setShape(SPShape *shape) { -- SPLine *line = SP_LINE (shape); ++ SPLine *line = SP_LINE(shape); -- SPCurve *c = new SPCurve (); ++ SPCurve *c = new SPCurve(); -- c->moveto(line->x1.computed, line->y1.computed); -- c->lineto(line->x2.computed, line->y2.computed); ++ c->moveto(line->x1.computed, line->y1.computed); ++ c->lineto(line->x2.computed, line->y2.computed); - sp_shape_set_curve_insync (shape, c, TRUE); // *_insync does not call update, avoiding infinite recursion when set_shape is called by update - shape->setCurveInsync (c, TRUE); // *_insync does not call update, avoiding infinite recursion when set_shape is called by update ++ shape->setCurveInsync(c, TRUE); // *_insync does not call update, avoiding infinite recursion when set_shape is called by update -- c->unref(); ++ c->unref(); } ++ ++/* ++ Local Variables: ++ mode:c++ ++ c-file-style:"stroustrup" ++ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) ++ indent-tabs-mode:nil ++ fill-column:99 ++ End: ++*/ ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --cc src/sp-line.h index cc6802b7f,114b0ea7c..8bcb81645 --- a/src/sp-line.h +++ b/src/sp-line.h @@@ -1,11 -1,11 +1,13 @@@ --#ifndef __SP_LINE_H__ --#define __SP_LINE_H__ ++#ifndef SEEN_SP_LINE_H ++#define SEEN_SP_LINE_H /* * SVG <line> implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma ++ * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 1999-2002 Lauris Kaplinski * @@@ -17,28 -17,53 +19,60 @@@ - #define SP_TYPE_LINE (sp_line_get_type ()) -#define SP_TYPE_LINE (SPLine::sp_line_get_type ()) --#define SP_LINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_LINE, SPLine)) --#define SP_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_LINE, SPLineClass)) --#define SP_IS_LINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_LINE)) --#define SP_IS_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_LINE)) ++#define SP_TYPE_LINE (SPLine::sp_line_get_type()) ++#define SP_LINE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_LINE, SPLine)) ++#define SP_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_LINE, SPLineClass)) ++#define SP_IS_LINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_LINE)) ++#define SP_IS_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_LINE)) class SPLine; class SPLineClass; - struct SPLine : public SPShape { - SVGLength x1; - SVGLength y1; - SVGLength x2; - SVGLength y2; - }; -//static void sp_line_class_init (SPLineClass *klass); - + class SPLine : public SPShape { - public: - SVGLength x1; - SVGLength y1; - SVGLength x2; - SVGLength y2; - static GType sp_line_get_type (void); - private: - static void sp_line_init (SPLine *line); - - static void sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); - static void sp_line_set (SPObject *object, unsigned int key, const gchar *value); - static Inkscape::XML::Node *sp_line_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - - static gchar *sp_line_description (SPItem * item); - static Geom::Matrix sp_line_set_transform(SPItem *item, Geom::Matrix const &xform); - - static void sp_line_update (SPObject *object, SPCtx *ctx, guint flags); - static void sp_line_set_shape (SPShape *shape); - static void sp_line_convert_to_guides(SPItem *item); - - friend class SPLineClass; ++public: ++ SVGLength x1; ++ SVGLength y1; ++ SVGLength x2; ++ SVGLength y2; ++ static GType sp_line_get_type(void); ++ ++private: ++ static void init(SPLine *line); ++ ++ static void build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); ++ static void set(SPObject *object, unsigned int key, const gchar *value); ++ static Inkscape::XML::Node *write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); ++ ++ static gchar *getDescription(SPItem * item); ++ static Geom::Matrix setTransform(SPItem *item, Geom::Matrix const &xform); + - struct SPLineClass { - SPShapeClass parent_class; ++ static void update(SPObject *object, SPCtx *ctx, guint flags); ++ static void setShape(SPShape *shape); ++ static void convertToGuides(SPItem *item); ++ ++ friend class SPLineClass; }; - GType sp_line_get_type (void); + class SPLineClass { - public: - SPShapeClass parent_class; - private: - static SPShapeClass *static_parent_class; - static void sp_line_class_init (SPLineClass *klass); ++public: ++ SPShapeClass parent_class; + ++private: ++ static SPShapeClass *static_parent_class; ++ static void sp_line_class_init(SPLineClass *klass); + - friend class SPLine; ++ friend class SPLine; + }; -//GType sp_line_get_type (void); - - --#endif ++#endif // SEEN_SP_LINE_H ++/* ++ Local Variables: ++ mode:c++ ++ c-file-style:"stroustrup" ++ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) ++ indent-tabs-mode:nil ++ fill-column:99 ++ End: ++*/ ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --cc src/sp-lpe-item.cpp index 43eb3c52e,655c4b27e..afd36d2dd --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_LPE_ITEM_CPP__ -- /** \file * Base class for live path effect items */ @@@ -7,6 -7,6 +5,7 @@@ * Authors: * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> * Bastien Bouclet <bgkweb@gmail.com> ++ * Abhishek Sharma * * Copyright (C) 2008 authors * @@@ -137,7 -137,7 +136,7 @@@ sp_lpe_item_finalize(GObject *object static void sp_lpe_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - sp_object_read_attr(object, "inkscape:path-effect"); - object->readAttr( "inkscape:path-effect"); ++ object->readAttr( "inkscape:path-effect" ); if (((SPObjectClass *) parent_class)->build) { ((SPObjectClass *) parent_class)->build(object, document, repr); diff --cc src/sp-mask.cpp index 15be0348f,26ddfa009..dde91b062 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@@ -1,10 -1,10 +1,10 @@@ --#define __SP_MASK_C__ -- /* * SVG <mask> implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2003 authors * @@@ -104,11 -104,11 +104,11 @@@ sp_mask_build (SPObject *object, SPDocu ((SPObjectClass *) parent_class)->build (object, document, repr); } - sp_object_read_attr (object, "maskUnits"); - sp_object_read_attr (object, "maskContentUnits"); - object->readAttr( "maskUnits"); - object->readAttr( "maskContentUnits"); ++ object->readAttr( "maskUnits" ); ++ object->readAttr( "maskContentUnits" ); /* Register ourselves */ - sp_document_add_resource (document, "mask", object); - document->add_resource ("mask", object); ++ document->addResource("mask", object); } static void @@@ -116,7 -116,7 +116,7 @@@ sp_mask_release (SPObject * object { if (SP_OBJECT_DOCUMENT (object)) { /* Unregister ourselves */ - sp_document_remove_resource (SP_OBJECT_DOCUMENT (object), "mask", object); - SP_OBJECT_DOCUMENT (object)->remove_resource ("mask", object); ++ SP_OBJECT_DOCUMENT(object)->removeResource("mask", object); } SPMask *cp = SP_MASK (object); @@@ -191,68 -190,68 +190,66 @@@ sp_mask_child_added (SPObject *object, } } --static void --sp_mask_update (SPObject *object, SPCtx *ctx, guint flags) ++static void sp_mask_update(SPObject *object, SPCtx *ctx, guint flags) { -- if (flags & SP_OBJECT_MODIFIED_FLAG) { -- flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; -- } ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } -- flags &= SP_OBJECT_MODIFIED_CASCADE; ++ flags &= SP_OBJECT_MODIFIED_CASCADE; -- SPObjectGroup *og = SP_OBJECTGROUP (object); -- GSList *l = NULL; - for (SPObject *child = sp_object_first_child(SP_OBJECT(og)); child != NULL; child = SP_OBJECT_NEXT(child)) { - for (SPObject *child = SP_OBJECT(og)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { -- g_object_ref (G_OBJECT (child)); -- l = g_slist_prepend (l, child); -- } -- l = g_slist_reverse (l); -- while (l) { -- SPObject *child = SP_OBJECT (l->data); -- l = g_slist_remove (l, child); -- if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { -- child->updateDisplay(ctx, flags); -- } -- g_object_unref (G_OBJECT (child)); -- } ++ SPObjectGroup *og = SP_OBJECTGROUP(object); ++ GSList *l = NULL; ++ for (SPObject *child = og->firstChild(); child; child = child->getNext()) { ++ g_object_ref(G_OBJECT (child)); ++ l = g_slist_prepend (l, child); ++ } ++ l = g_slist_reverse (l); ++ while (l) { ++ SPObject *child = SP_OBJECT(l->data); ++ l = g_slist_remove(l, child); ++ if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { ++ child->updateDisplay(ctx, flags); ++ } ++ g_object_unref(G_OBJECT(child)); ++ } -- SPMask *mask = SP_MASK (object); -- for (SPMaskView *v = mask->display; v != NULL; v = v->next) { -- if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { ++ SPMask *mask = SP_MASK(object); ++ for (SPMaskView *v = mask->display; v != NULL; v = v->next) { ++ if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) { Geom::Matrix t(Geom::Scale(v->bbox.x1 - v->bbox.x0, v->bbox.y1 - v->bbox.y0)); -- t[4] = v->bbox.x0; -- t[5] = v->bbox.y0; -- nr_arena_group_set_child_transform (NR_ARENA_GROUP (v->arenaitem), &t); -- } else { -- nr_arena_group_set_child_transform (NR_ARENA_GROUP (v->arenaitem), NULL); -- } -- } ++ t[4] = v->bbox.x0; ++ t[5] = v->bbox.y0; ++ nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), &t); ++ } else { ++ nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), NULL); ++ } ++ } } --static void --sp_mask_modified (SPObject *object, guint flags) ++static void sp_mask_modified(SPObject *object, guint flags) { -- if (flags & SP_OBJECT_MODIFIED_FLAG) { -- flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; -- } ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } -- flags &= SP_OBJECT_MODIFIED_CASCADE; ++ flags &= SP_OBJECT_MODIFIED_CASCADE; -- SPObjectGroup *og = SP_OBJECTGROUP (object); -- GSList *l = NULL; - for (SPObject *child = sp_object_first_child(SP_OBJECT(og)); child != NULL; child = SP_OBJECT_NEXT(child)) { - for (SPObject *child = SP_OBJECT(og)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { -- g_object_ref (G_OBJECT (child)); -- l = g_slist_prepend (l, child); -- } -- l = g_slist_reverse (l); -- while (l) { -- SPObject *child = SP_OBJECT (l->data); -- l = g_slist_remove (l, child); -- if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { -- child->emitModified(flags); -- } -- g_object_unref (G_OBJECT (child)); -- } ++ SPObjectGroup *og = SP_OBJECTGROUP(object); ++ GSList *l = NULL; ++ for (SPObject *child = og->firstChild(); child; child = child->getNext()) { ++ g_object_ref(G_OBJECT(child)); ++ l = g_slist_prepend(l, child); ++ } ++ l = g_slist_reverse(l); ++ while (l) { ++ SPObject *child = SP_OBJECT(l->data); ++ l = g_slist_remove(l, child); ++ if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { ++ child->emitModified(flags); ++ } ++ g_object_unref(G_OBJECT(child)); ++ } } static Inkscape::XML::Node * @@@ -274,7 -273,7 +271,7 @@@ sp_mask_create (GSList *reprs, SPDocume { Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document)); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:mask"); repr->setAttribute("maskUnits", "userSpaceOnUse"); @@@ -300,8 -299,8 +297,7 @@@ return mask_id; } --NRArenaItem * --sp_mask_show (SPMask *mask, NRArena *arena, unsigned int key) ++NRArenaItem *sp_mask_show(SPMask *mask, NRArena *arena, unsigned int key) { g_return_val_if_fail (mask != NULL, NULL); g_return_val_if_fail (SP_IS_MASK (mask), NULL); @@@ -311,9 -310,9 +307,9 @@@ NRArenaItem *ai = NRArenaGroup::create(arena); mask->display = sp_mask_view_new_prepend (mask->display, key, ai); - for (SPObject *child = sp_object_first_child(SP_OBJECT(mask)) ; child != NULL; child = SP_OBJECT_NEXT(child)) { - for (SPObject *child = SP_OBJECT(mask)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child)) { ++ for ( SPObject *child = mask->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM (child)) { - NRArenaItem *ac = sp_item_invoke_show (SP_ITEM (child), arena, key, SP_ITEM_REFERENCE_FLAGS); + NRArenaItem *ac = SP_ITEM (child)->invoke_show (arena, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { /* The order is not important in mask */ nr_arena_item_add_child (ai, ac, NULL); @@@ -331,15 -330,15 +327,14 @@@ return ai; } --void --sp_mask_hide (SPMask *cp, unsigned int key) ++void sp_mask_hide(SPMask *cp, unsigned int key) { g_return_if_fail (cp != NULL); g_return_if_fail (SP_IS_MASK (cp)); - for (SPObject *child = sp_object_first_child(SP_OBJECT(cp)); child != NULL; child = SP_OBJECT_NEXT(child)) { - for (SPObject *child = SP_OBJECT(cp)->first_child(); child != NULL; child = SP_OBJECT_NEXT(child)) { ++ for ( SPObject *child = cp->firstChild(); child; child = child->getNext()) { if (SP_IS_ITEM (child)) { - sp_item_invoke_hide (SP_ITEM (child), key); + SP_ITEM(child)->invoke_hide (key); } } diff --cc src/sp-mask.h index 0b995f0ce,ae3b76210..d8b6b33ea --- a/src/sp-mask.h +++ b/src/sp-mask.h @@@ -1,11 -1,11 +1,12 @@@ --#ifndef __SP_MASK_H__ --#define __SP_MASK_H__ ++#ifndef SEEN_SP_MASK_H ++#define SEEN_SP_MASK_H /* * SVG <mask> implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 2003 authors * @@@ -63,8 -63,10 +64,10 @@@ protected } SPObject * const owner = this->getOwner(); if (obj->isAncestorOf(owner)) { - Inkscape::XML::Node * const owner_repr = owner->repr; - Inkscape::XML::Node * const obj_repr = obj->repr; - //XML Tree being used directly here while it shouldn't be... - Inkscape::XML::Node * const owner_repr = owner->getRepr(); - //XML Tree being used directly here while it shouldn't be... - Inkscape::XML::Node * const obj_repr = obj->getRepr(); ++ //XML Tree being used directly here while it shouldn't be... ++ Inkscape::XML::Node * const owner_repr = owner->getRepr(); ++ //XML Tree being used directly here while it shouldn't be... ++ Inkscape::XML::Node * const obj_repr = obj->getRepr(); gchar const * owner_name = NULL; gchar const * owner_mask = NULL; gchar const * obj_name = NULL; @@@ -94,4 -96,4 +97,4 @@@ void sp_mask_set_bbox (SPMask *mask, un const gchar *sp_mask_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTransform); --#endif ++#endif // SEEN_SP_MASK_H diff --cc src/sp-missing-glyph.cpp index 7d5c42763,9833a6995..9604fe0ca --- a/src/sp-missing-glyph.cpp +++ b/src/sp-missing-glyph.cpp @@@ -3,13 -3,13 +3,13 @@@ #endif #ifdef ENABLE_SVG_FONTS --#define __SP_MISSING_GLYPH_C__ /* * SVG <missing-glyph> element implementation * * Author: * Felipe C. da S. Sanches <juca@members.fsf.org> ++ * Abhishek Sharma * * Copyright (C) 2008, Felipe C. da S. Sanches * @@@ -82,11 -82,11 +82,11 @@@ static void sp_missing_glyph_build(SPOb ((SPObjectClass *) (parent_class))->build(object, document, repr); } - sp_object_read_attr(object, "d"); - sp_object_read_attr(object, "horiz-adv-x"); - sp_object_read_attr(object, "vert-origin-x"); - sp_object_read_attr(object, "vert-origin-y"); - sp_object_read_attr(object, "vert-adv-y"); - object->readAttr( "d"); - object->readAttr( "horiz-adv-x"); - object->readAttr( "vert-origin-x"); - object->readAttr( "vert-origin-y"); - object->readAttr( "vert-adv-y"); ++ object->readAttr( "d" ); ++ object->readAttr( "horiz-adv-x" ); ++ object->readAttr( "vert-origin-x" ); ++ object->readAttr( "vert-origin-y" ); ++ object->readAttr( "vert-adv-y" ); } static void sp_missing_glyph_release(SPObject *object) @@@ -176,11 -176,14 +176,14 @@@ static Inkscape::XML::Node *sp_missing_ sp_repr_set_svg_double(repr, "vert-adv-y", glyph->vert_adv_y); */ if (repr != SP_OBJECT_REPR(object)) { - COPY_ATTR(repr, object->repr, "d"); - COPY_ATTR(repr, object->repr, "horiz-adv-x"); - COPY_ATTR(repr, object->repr, "vert-origin-x"); - COPY_ATTR(repr, object->repr, "vert-origin-y"); - COPY_ATTR(repr, object->repr, "vert-adv-y"); + - /* All the COPY_ATTR functions below use - XML Tree directly while they shouldn't.*/ ++ // All the COPY_ATTR functions below use ++ // XML Tree directly while they shouldn't. + COPY_ATTR(repr, object->getRepr(), "d"); + COPY_ATTR(repr, object->getRepr(), "horiz-adv-x"); + COPY_ATTR(repr, object->getRepr(), "vert-origin-x"); + COPY_ATTR(repr, object->getRepr(), "vert-origin-y"); + COPY_ATTR(repr, object->getRepr(), "vert-adv-y"); } if (((SPObjectClass *) (parent_class))->write) { diff --cc src/sp-namedview.cpp index be2bcd478,61685b321..59ef4762d --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@@ -1,11 -1,11 +1,11 @@@ --#define __SP_NAMEDVIEW_C__ -- /* * <sodipodi:namedview> implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> * Copyright (C) 1999-2008 Authors @@@ -35,6 -35,6 +35,8 @@@ #include "desktop.h" #include "conn-avoid-ref.h" // for defaultConnSpacing. ++using Inkscape::DocumentUndo; ++ #define DEFAULTGRIDCOLOR 0x3f3fff25 #define DEFAULTGRIDEMPCOLOR 0x3f3fff60 #define DEFAULTGRIDEMPSPACING 5 @@@ -176,7 -176,7 +178,7 @@@ static void sp_namedview_generate_old_g // generate new xy grid with the correct settings // first create the child xml node, then hook it to repr. This order is important, to not set off listeners to repr before the new node is complete. -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *newnode = xml_doc->createElement("inkscape:grid"); newnode->setAttribute("id", "GridFromPre046Settings"); newnode->setAttribute("type", Inkscape::CanvasGrid::getSVGName(Inkscape::GRID_RECTANGULAR)); @@@ -217,57 -217,56 +219,57 @@@ static void sp_namedview_build(SPObjec (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); } - sp_object_read_attr(object, "inkscape:document-units"); - sp_object_read_attr(object, "units"); - sp_object_read_attr(object, "viewonly"); - sp_object_read_attr(object, "showguides"); - sp_object_read_attr(object, "showgrid"); - sp_object_read_attr(object, "gridtolerance"); - sp_object_read_attr(object, "guidetolerance"); - sp_object_read_attr(object, "objecttolerance"); - sp_object_read_attr(object, "guidecolor"); - sp_object_read_attr(object, "guideopacity"); - sp_object_read_attr(object, "guidehicolor"); - sp_object_read_attr(object, "guidehiopacity"); - sp_object_read_attr(object, "showborder"); - sp_object_read_attr(object, "inkscape:showpageshadow"); - sp_object_read_attr(object, "borderlayer"); - sp_object_read_attr(object, "bordercolor"); - sp_object_read_attr(object, "borderopacity"); - sp_object_read_attr(object, "pagecolor"); - sp_object_read_attr(object, "inkscape:pageopacity"); - sp_object_read_attr(object, "inkscape:pageshadow"); - sp_object_read_attr(object, "inkscape:zoom"); - sp_object_read_attr(object, "inkscape:cx"); - sp_object_read_attr(object, "inkscape:cy"); - sp_object_read_attr(object, "inkscape:window-width"); - sp_object_read_attr(object, "inkscape:window-height"); - sp_object_read_attr(object, "inkscape:window-x"); - sp_object_read_attr(object, "inkscape:window-y"); - sp_object_read_attr(object, "inkscape:window-maximized"); - sp_object_read_attr(object, "inkscape:snap-global"); - sp_object_read_attr(object, "inkscape:snap-bbox"); - sp_object_read_attr(object, "inkscape:snap-nodes"); - sp_object_read_attr(object, "inkscape:snap-from-guide"); - sp_object_read_attr(object, "inkscape:snap-center"); - sp_object_read_attr(object, "inkscape:snap-smooth-nodes"); - sp_object_read_attr(object, "inkscape:snap-midpoints"); - sp_object_read_attr(object, "inkscape:snap-object-midpoints"); - sp_object_read_attr(object, "inkscape:snap-bbox-edge-midpoints"); - sp_object_read_attr(object, "inkscape:snap-bbox-midpoints"); - sp_object_read_attr(object, "inkscape:snap-to-guides"); - sp_object_read_attr(object, "inkscape:snap-grids"); - sp_object_read_attr(object, "inkscape:snap-intersection-paths"); - sp_object_read_attr(object, "inkscape:object-paths"); - sp_object_read_attr(object, "inkscape:object-nodes"); - sp_object_read_attr(object, "inkscape:bbox-paths"); - sp_object_read_attr(object, "inkscape:bbox-nodes"); - sp_object_read_attr(object, "inkscape:snap-page"); - sp_object_read_attr(object, "inkscape:current-layer"); - sp_object_read_attr(object, "inkscape:connector-spacing"); - object->readAttr( "inkscape:document-units"); - object->readAttr( "viewonly"); - object->readAttr( "showguides"); - object->readAttr( "showgrid"); - object->readAttr( "gridtolerance"); - object->readAttr( "guidetolerance"); - object->readAttr( "objecttolerance"); - object->readAttr( "guidecolor"); - object->readAttr( "guideopacity"); - object->readAttr( "guidehicolor"); - object->readAttr( "guidehiopacity"); - object->readAttr( "showborder"); - object->readAttr( "inkscape:showpageshadow"); - object->readAttr( "borderlayer"); - object->readAttr( "bordercolor"); - object->readAttr( "borderopacity"); - object->readAttr( "pagecolor"); - object->readAttr( "inkscape:pageopacity"); - object->readAttr( "inkscape:pageshadow"); - object->readAttr( "inkscape:zoom"); - object->readAttr( "inkscape:cx"); - object->readAttr( "inkscape:cy"); - object->readAttr( "inkscape:window-width"); - object->readAttr( "inkscape:window-height"); - object->readAttr( "inkscape:window-x"); - object->readAttr( "inkscape:window-y"); - object->readAttr( "inkscape:window-maximized"); - object->readAttr( "inkscape:snap-global"); - object->readAttr( "inkscape:snap-bbox"); - object->readAttr( "inkscape:snap-nodes"); - object->readAttr( "inkscape:snap-from-guide"); - object->readAttr( "inkscape:snap-center"); - object->readAttr( "inkscape:snap-smooth-nodes"); - object->readAttr( "inkscape:snap-midpoints"); - object->readAttr( "inkscape:snap-object-midpoints"); - object->readAttr( "inkscape:snap-bbox-edge-midpoints"); - object->readAttr( "inkscape:snap-bbox-midpoints"); - object->readAttr( "inkscape:snap-to-guides"); - object->readAttr( "inkscape:snap-grids"); - object->readAttr( "inkscape:snap-intersection-paths"); - object->readAttr( "inkscape:object-paths"); - object->readAttr( "inkscape:object-nodes"); - object->readAttr( "inkscape:bbox-paths"); - object->readAttr( "inkscape:bbox-nodes"); - object->readAttr( "inkscape:snap-page"); - object->readAttr( "inkscape:current-layer"); - object->readAttr( "inkscape:connector-spacing"); ++ object->readAttr( "inkscape:document-units" ); ++ object->readAttr( "units" ); ++ object->readAttr( "viewonly" ); ++ object->readAttr( "showguides" ); ++ object->readAttr( "showgrid" ); ++ object->readAttr( "gridtolerance" ); ++ object->readAttr( "guidetolerance" ); ++ object->readAttr( "objecttolerance" ); ++ object->readAttr( "guidecolor" ); ++ object->readAttr( "guideopacity" ); ++ object->readAttr( "guidehicolor" ); ++ object->readAttr( "guidehiopacity" ); ++ object->readAttr( "showborder" ); ++ object->readAttr( "inkscape:showpageshadow" ); ++ object->readAttr( "borderlayer" ); ++ object->readAttr( "bordercolor" ); ++ object->readAttr( "borderopacity" ); ++ object->readAttr( "pagecolor" ); ++ object->readAttr( "inkscape:pageopacity" ); ++ object->readAttr( "inkscape:pageshadow" ); ++ object->readAttr( "inkscape:zoom" ); ++ object->readAttr( "inkscape:cx" ); ++ object->readAttr( "inkscape:cy" ); ++ object->readAttr( "inkscape:window-width" ); ++ object->readAttr( "inkscape:window-height" ); ++ object->readAttr( "inkscape:window-x" ); ++ object->readAttr( "inkscape:window-y" ); ++ object->readAttr( "inkscape:window-maximized" ); ++ object->readAttr( "inkscape:snap-global" ); ++ object->readAttr( "inkscape:snap-bbox" ); ++ object->readAttr( "inkscape:snap-nodes" ); ++ object->readAttr( "inkscape:snap-from-guide" ); ++ object->readAttr( "inkscape:snap-center" ); ++ object->readAttr( "inkscape:snap-smooth-nodes" ); ++ object->readAttr( "inkscape:snap-midpoints" ); ++ object->readAttr( "inkscape:snap-object-midpoints" ); ++ object->readAttr( "inkscape:snap-bbox-edge-midpoints" ); ++ object->readAttr( "inkscape:snap-bbox-midpoints" ); ++ object->readAttr( "inkscape:snap-to-guides" ); ++ object->readAttr( "inkscape:snap-grids" ); ++ object->readAttr( "inkscape:snap-intersection-paths" ); ++ object->readAttr( "inkscape:object-paths" ); ++ object->readAttr( "inkscape:object-nodes" ); ++ object->readAttr( "inkscape:bbox-paths" ); ++ object->readAttr( "inkscape:bbox-nodes" ); ++ object->readAttr( "inkscape:snap-page" ); ++ object->readAttr( "inkscape:current-layer" ); ++ object->readAttr( "inkscape:connector-spacing" ); /* Construct guideline list */ - for (SPObject *o = sp_object_first_child(SP_OBJECT(og)) ; o != NULL; o = SP_OBJECT_NEXT(o) ) { - for (SPObject *o = SP_OBJECT(og)->first_child() ; o != NULL; o = SP_OBJECT_NEXT(o) ) { ++ for (SPObject *o = SP_OBJECT(og)->firstChild() ; o; o = o->getNext() ) { if (SP_IS_GUIDE(o)) { SPGuide * g = SP_GUIDE(o); nv->guides = g_slist_prepend(nv->guides, g); @@@ -331,17 -330,17 +333,17 @@@ static void sp_namedview_set(SPObject * object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_GRIDTOLERANCE: -- nv->snap_manager.snapprefs.setGridTolerance(value ? g_ascii_strtod(value, NULL) : 10000); -- object->requestModified(SP_OBJECT_MODIFIED_FLAG); -- break; ++ nv->snap_manager.snapprefs.setGridTolerance(value ? g_ascii_strtod(value, NULL) : 10000); ++ object->requestModified(SP_OBJECT_MODIFIED_FLAG); ++ break; case SP_ATTR_GUIDETOLERANCE: -- nv->snap_manager.snapprefs.setGuideTolerance(value ? g_ascii_strtod(value, NULL) : 20); -- object->requestModified(SP_OBJECT_MODIFIED_FLAG); -- break; ++ nv->snap_manager.snapprefs.setGuideTolerance(value ? g_ascii_strtod(value, NULL) : 20); ++ object->requestModified(SP_OBJECT_MODIFIED_FLAG); ++ break; case SP_ATTR_OBJECTTOLERANCE: -- nv->snap_manager.snapprefs.setObjectTolerance(value ? g_ascii_strtod(value, NULL) : 20); -- object->requestModified(SP_OBJECT_MODIFIED_FLAG); -- break; ++ nv->snap_manager.snapprefs.setObjectTolerance(value ? g_ascii_strtod(value, NULL) : 20); ++ object->requestModified(SP_OBJECT_MODIFIED_FLAG); ++ break; case SP_ATTR_GUIDECOLOR: nv->guidecolor = (nv->guidecolor & 0xff) | (DEFAULTGUIDECOLOR & 0xffffff00); if (value) { @@@ -448,10 -447,10 +450,10 @@@ object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_WINDOW_MAXIMIZED: -- nv->window_maximized = value ? atoi(value) : 0; -- object->requestModified(SP_OBJECT_MODIFIED_FLAG); -- break; -- case SP_ATTR_INKSCAPE_SNAP_GLOBAL: ++ nv->window_maximized = value ? atoi(value) : 0; ++ object->requestModified(SP_OBJECT_MODIFIED_FLAG); ++ break; ++ case SP_ATTR_INKSCAPE_SNAP_GLOBAL: nv->snap_manager.snapprefs.setSnapEnabledGlobally(value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; @@@ -468,14 -467,14 +470,14 @@@ object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_GRIDS: -- nv->snap_manager.snapprefs.setSnapToGrids(value ? sp_str_to_bool(value) : TRUE); -- object->requestModified(SP_OBJECT_MODIFIED_FLAG); -- break; ++ nv->snap_manager.snapprefs.setSnapToGrids(value ? sp_str_to_bool(value) : TRUE); ++ object->requestModified(SP_OBJECT_MODIFIED_FLAG); ++ break; case SP_ATTR_INKSCAPE_SNAP_TO_GUIDES: -- nv->snap_manager.snapprefs.setSnapToGuides(value ? sp_str_to_bool(value) : TRUE); -- object->requestModified(SP_OBJECT_MODIFIED_FLAG); -- break; -- case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES: ++ nv->snap_manager.snapprefs.setSnapToGuides(value ? sp_str_to_bool(value) : TRUE); ++ object->requestModified(SP_OBJECT_MODIFIED_FLAG); ++ break; ++ case SP_ATTR_INKSCAPE_SNAP_SMOOTH_NODES: nv->snap_manager.snapprefs.setSnapSmoothNodes(value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; @@@ -484,18 -483,18 +486,18 @@@ object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS: -- nv->snap_manager.snapprefs.setSnapObjectMidpoints(value ? sp_str_to_bool(value) : FALSE); -- object->requestModified(SP_OBJECT_MODIFIED_FLAG); -- break; ++ nv->snap_manager.snapprefs.setSnapObjectMidpoints(value ? sp_str_to_bool(value) : FALSE); ++ object->requestModified(SP_OBJECT_MODIFIED_FLAG); ++ break; case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS: -- nv->snap_manager.snapprefs.setSnapBBoxEdgeMidpoints(value ? sp_str_to_bool(value) : FALSE); -- object->requestModified(SP_OBJECT_MODIFIED_FLAG); -- break; -- case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS: -- nv->snap_manager.snapprefs.setSnapBBoxMidpoints(value ? sp_str_to_bool(value) : FALSE); -- object->requestModified(SP_OBJECT_MODIFIED_FLAG); -- break; -- case SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE: ++ nv->snap_manager.snapprefs.setSnapBBoxEdgeMidpoints(value ? sp_str_to_bool(value) : FALSE); ++ object->requestModified(SP_OBJECT_MODIFIED_FLAG); ++ break; ++ case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS: ++ nv->snap_manager.snapprefs.setSnapBBoxMidpoints(value ? sp_str_to_bool(value) : FALSE); ++ object->requestModified(SP_OBJECT_MODIFIED_FLAG); ++ break; ++ case SP_ATTR_INKSCAPE_SNAP_FROM_GUIDE: nv->snap_manager.snapprefs.setSnapModeGuide(value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; @@@ -752,6 -726,12 +753,12 @@@ void SPNamedView::show(SPDesktop *deskt #define MIN_ONSCREEN_DISTANCE 50 + void SPNamedView::writeNewGrid(SPDocument *document,int gridtype) + { - g_assert(this->getRepr() != NULL); - Inkscape::CanvasGrid::writeNewGridToRepr(this->getRepr(),document,static_cast<Inkscape::GridType>(gridtype)); ++ g_assert(this->getRepr() != NULL); ++ Inkscape::CanvasGrid::writeNewGridToRepr(this->getRepr(),document,static_cast<Inkscape::GridType>(gridtype)); + } + /* * Restores window geometry from the document settings or defaults in prefs */ @@@ -763,25 -743,25 +770,25 @@@ void sp_namedview_window_from_document( // restore window size and position stored with the document if (geometry_from_file) { -- if (nv->window_maximized) { -- Gtk::Window *win = desktop->getToplevel(); -- if (win){ -- win->maximize(); -- } -- } else { -- gint w = MIN(gdk_screen_width(), nv->window_width); -- gint h = MIN(gdk_screen_height(), nv->window_height); -- // prevent the window from moving off the screen to the right or to the bottom -- gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, nv->window_x); -- gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, nv->window_y); -- // prevent the window from moving off the screen to the left or to the top -- x = MAX(MIN_ONSCREEN_DISTANCE - nv->window_width, x); -- y = MAX(MIN_ONSCREEN_DISTANCE - nv->window_height, y); -- if (w>0 && h>0) { -- desktop->setWindowSize(w, h); -- desktop->setWindowPosition(Geom::Point(x, y)); -- } -- } ++ if (nv->window_maximized) { ++ Gtk::Window *win = desktop->getToplevel(); ++ if (win){ ++ win->maximize(); ++ } ++ } else { ++ gint w = MIN(gdk_screen_width(), nv->window_width); ++ gint h = MIN(gdk_screen_height(), nv->window_height); ++ // prevent the window from moving off the screen to the right or to the bottom ++ gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, nv->window_x); ++ gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, nv->window_y); ++ // prevent the window from moving off the screen to the left or to the top ++ x = MAX(MIN_ONSCREEN_DISTANCE - nv->window_width, x); ++ y = MAX(MIN_ONSCREEN_DISTANCE - nv->window_height, y); ++ if (w>0 && h>0) { ++ desktop->setWindowSize(w, h); ++ desktop->setWindowPosition(Geom::Point(x, y)); ++ } ++ } } // restore zoom and view @@@ -800,6 -780,17 +807,17 @@@ } } + bool SPNamedView::getSnapGlobal() const + { - return this->snap_manager.snapprefs.getSnapEnabledGlobally(); ++ return this->snap_manager.snapprefs.getSnapEnabledGlobally(); + } + + void SPNamedView::setSnapGlobal(bool v) + { - g_assert(this->getRepr() != NULL); - sp_repr_set_boolean(this->getRepr(), "inkscape:snap-global", v); ++ g_assert(this->getRepr() != NULL); ++ sp_repr_set_boolean(this->getRepr(), "inkscape:snap-global", v); + } + void sp_namedview_update_layers_from_document (SPDesktop *desktop) { SPObject *layer = NULL; @@@ -814,8 -805,8 +832,7 @@@ } // if that didn't work out, look for the topmost layer if (!layer) { - SPObject *iter = sp_object_first_child(SP_DOCUMENT_ROOT(document)); - SPObject *iter = SP_DOCUMENT_ROOT(document)->first_child(); -- for ( ; iter ; iter = SP_OBJECT_NEXT(iter) ) { ++ for ( SPObject *iter = document->getRoot()->firstChild(); iter ; iter = iter->getNext() ) { if (desktop->isLayer(iter)) { layer = iter; } @@@ -837,15 -828,15 +854,15 @@@ void sp_namedview_document_from_window( Geom::Rect const r = desktop->get_display_area(); // saving window geometry is not undoable - bool saved = sp_document_get_undo_sensitive(sp_desktop_document(desktop)); - sp_document_set_undo_sensitive(sp_desktop_document(desktop), false); - bool saved = SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop)); - SPDocumentUndo::set_undo_sensitive(sp_desktop_document(desktop), false); ++ bool saved = DocumentUndo::getUndoSensitive(sp_desktop_document(desktop)); ++ DocumentUndo::setUndoSensitive(sp_desktop_document(desktop), false); sp_repr_set_svg_double(view, "inkscape:zoom", desktop->current_zoom()); sp_repr_set_svg_double(view, "inkscape:cx", r.midpoint()[Geom::X]); sp_repr_set_svg_double(view, "inkscape:cy", r.midpoint()[Geom::Y]); if (save_geometry_in_file) { -- gint w, h, x, y; ++ gint w, h, x, y; desktop->getWindowGeometry(x, y, w, h); sp_repr_set_int(view, "inkscape:window-width", w); sp_repr_set_int(view, "inkscape:window-height", h); @@@ -857,7 -848,7 +874,7 @@@ view->setAttribute("inkscape:current-layer", desktop->currentLayer()->getId()); // restore undoability - sp_document_set_undo_sensitive(sp_desktop_document(desktop), saved); - SPDocumentUndo::set_undo_sensitive(sp_desktop_document(desktop), saved); ++ DocumentUndo::setUndoSensitive(sp_desktop_document(desktop), saved); } void SPNamedView::hide(SPDesktop const *desktop) @@@ -887,21 -878,21 +904,21 @@@ void SPNamedView::activateGuides(gpoint static void sp_namedview_setup_guides(SPNamedView *nv) { for (GSList *l = nv->guides; l != NULL; l = l->next) { -- sp_namedview_show_single_guide(SP_GUIDE(l->data), nv->showguides); ++ sp_namedview_show_single_guide(SP_GUIDE(l->data), nv->showguides); } } static void sp_namedview_show_single_guide(SPGuide* guide, bool show) { -- for (GSList *v = guide->views; v != NULL; v = v->next) { -- if (show) { -- sp_canvas_item_show(SP_CANVAS_ITEM(v->data)); -- sp_canvas_item_show(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin)); -- } else { -- sp_canvas_item_hide(SP_CANVAS_ITEM(v->data)); -- sp_canvas_item_hide(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin)); -- } -- } ++ for (GSList *v = guide->views; v != NULL; v = v->next) { ++ if (show) { ++ sp_canvas_item_show(SP_CANVAS_ITEM(v->data)); ++ sp_canvas_item_show(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin)); ++ } else { ++ sp_canvas_item_hide(SP_CANVAS_ITEM(v->data)); ++ sp_canvas_item_hide(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin)); ++ } ++ } } void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr) @@@ -914,10 -905,10 +931,10 @@@ v = !v; } - bool saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive(doc, false); - bool saved = SPDocumentUndo::get_undo_sensitive(doc); - SPDocumentUndo::set_undo_sensitive(doc, false); ++ bool saved = DocumentUndo::getUndoSensitive(doc); ++ DocumentUndo::setUndoSensitive(doc, false); sp_repr_set_boolean(repr, "showguides", v); - sp_document_set_undo_sensitive(doc, saved); - SPDocumentUndo::set_undo_sensitive(doc, saved); ++ DocumentUndo::setUndoSensitive(doc, saved); doc->setModifiedSinceSave(); } @@@ -929,10 -920,10 +946,10 @@@ void sp_namedview_show_grids(SPNamedVie SPDocument *doc = SP_OBJECT_DOCUMENT (namedview); Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); - bool saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive(doc, false); - bool saved = SPDocumentUndo::get_undo_sensitive(doc); - SPDocumentUndo::set_undo_sensitive(doc, false); ++ bool saved = DocumentUndo::getUndoSensitive(doc); ++ DocumentUndo::setUndoSensitive(doc, false); sp_repr_set_boolean(repr, "showgrid", namedview->grids_visible); - sp_document_set_undo_sensitive(doc, saved); - SPDocumentUndo::set_undo_sensitive(doc, saved); ++ DocumentUndo::setUndoSensitive(doc, saved); /* we don't want the document to get dirty on startup; that's when we call this function with dirty_document = false */ @@@ -1010,6 -1001,48 +1027,47 @@@ SPNamedView *sp_document_namedview(SPDo return (SPNamedView *) nv; } + void SPNamedView::setGuides(bool v) + { - g_assert(this->getRepr() != NULL); - sp_repr_set_boolean(this->getRepr(), "showguides", v); - sp_repr_set_boolean(this->getRepr(), "inkscape:guide-bbox", v); - ++ g_assert(this->getRepr() != NULL); ++ sp_repr_set_boolean(this->getRepr(), "showguides", v); ++ sp_repr_set_boolean(this->getRepr(), "inkscape:guide-bbox", v); + } + + /** + * Gets page fitting margin information from the namedview node in the XML. + * \param nv_repr reference to this document's namedview + * \param key the same key used by the RegisteredScalarUnit in + * ui/widget/page-sizer.cpp + * \param margin_units units for the margin + * \param return_units units to return the result in + * \param width width in px (for percentage margins) + * \param height height in px (for percentage margins) + * \param use_width true if the this key is left or right margins, false + * otherwise. Used for percentage margins. + * \return the margin size in px, else 0.0 if anything is invalid. + */ + double SPNamedView::getMarginLength(gchar const * const key, + SPUnit const * const margin_units, + SPUnit const * const return_units, + double const width, + double const height, + bool const use_width) + { + double value; - if(!this->storeAsDouble(key,&value)) { ++ if(!this->storeAsDouble(key,&value)) { + return 0.0; + } + if (margin_units == &sp_unit_get_by_id (SP_UNIT_PERCENT)) { + return (use_width)? width * value : height * value; + } + if (!sp_convert_distance (&value, margin_units, return_units)) { + return 0.0; + } + return value; + } + + /** * Returns namedview's default metric. */ diff --cc src/sp-namedview.h index 7a54b2dc5,337a67deb..86b16a557 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@@ -6,6 -6,6 +6,7 @@@ * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> * Copyright (C) Lauris Kaplinski 2000-2002 @@@ -81,6 -82,14 +84,14 @@@ struct SPNamedView : public SPObjectGro void translateGuides(Geom::Translate const &translation); void scrollAllDesktops(double dx, double dy, bool is_scrolling); - void writeNewGrid(SPDocument *document,int gridtype); - bool getSnapGlobal() const; - void setSnapGlobal(bool v); - void setGuides(bool v); - - private: - double getMarginLength(gchar const * const key,SPUnit const * const margin_units,SPUnit const * const return_units,double const width,double const height,bool const use_width); - friend class SPDocument; ++ void writeNewGrid(SPDocument *document,int gridtype); ++ bool getSnapGlobal() const; ++ void setSnapGlobal(bool v); ++ void setGuides(bool v); ++ ++private: ++ double getMarginLength(gchar const * const key,SPUnit const * const margin_units,SPUnit const * const return_units,double const width,double const height,bool const use_width); ++ friend class SPDocument; }; struct SPNamedViewClass { diff --cc src/sp-object-group.cpp index 1d5c04339,d0e5c01a7..001d7898f --- a/src/sp-object-group.cpp +++ b/src/sp-object-group.cpp @@@ -1,10 -1,10 +1,10 @@@ --#define __SP_OBJECTGROUP_C__ -- /* * Abstract base class for non-item groups * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2003 Authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -16,120 -16,122 +16,113 @@@ #include "xml/repr.h" #include "document.h" - static void sp_objectgroup_class_init (SPObjectGroupClass *klass); -/*static void sp_objectgroup_class_init (SPObjectGroupClass *klass); --static void sp_objectgroup_init (SPObjectGroup *objectgroup); -- --static void sp_objectgroup_child_added (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * ref); --static void sp_objectgroup_remove_child (SPObject * object, Inkscape::XML::Node * child); --static void sp_objectgroup_order_changed (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * old_ref, Inkscape::XML::Node * new_ref); - static Inkscape::XML::Node *sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static Inkscape::XML::Node *sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);*/ -- - static SPObjectClass *parent_class; -//static SPObjectClass *parent_class; - + SPObjectClass * SPObjectGroupClass::static_parent_class = 0; --GType - sp_objectgroup_get_type (void) -SPObjectGroup::sp_objectgroup_get_type (void) ++GType SPObjectGroup::sp_objectgroup_get_type(void) { -- static GType objectgroup_type = 0; -- if (!objectgroup_type) { -- GTypeInfo objectgroup_info = { -- sizeof (SPObjectGroupClass), -- NULL, /* base_init */ -- NULL, /* base_finalize */ - (GClassInitFunc) sp_objectgroup_class_init, - (GClassInitFunc) SPObjectGroupClass::sp_objectgroup_class_init, -- NULL, /* class_finalize */ -- NULL, /* class_data */ -- sizeof (SPObjectGroup), -- 16, /* n_preallocs */ -- (GInstanceInitFunc) sp_objectgroup_init, -- NULL, /* value_table */ -- }; -- objectgroup_type = g_type_register_static (SP_TYPE_OBJECT, "SPObjectGroup", &objectgroup_info, (GTypeFlags)0); -- } -- return objectgroup_type; ++ static GType objectgroup_type = 0; ++ if (!objectgroup_type) { ++ GTypeInfo objectgroup_info = { ++ sizeof(SPObjectGroupClass), ++ NULL, /* base_init */ ++ NULL, /* base_finalize */ ++ (GClassInitFunc) SPObjectGroupClass::sp_objectgroup_class_init, ++ NULL, /* class_finalize */ ++ NULL, /* class_data */ ++ sizeof(SPObjectGroup), ++ 16, /* n_preallocs */ ++ (GInstanceInitFunc) init, ++ NULL, /* value_table */ ++ }; ++ objectgroup_type = g_type_register_static(SP_TYPE_OBJECT, "SPObjectGroup", &objectgroup_info, (GTypeFlags)0); ++ } ++ return objectgroup_type; } - static void - sp_objectgroup_class_init (SPObjectGroupClass *klass) -void -SPObjectGroupClass::sp_objectgroup_class_init (SPObjectGroupClass *klass) ++void SPObjectGroupClass::sp_objectgroup_class_init(SPObjectGroupClass *klass) { -- GObjectClass * object_class; -- SPObjectClass * sp_object_class; - - object_class = (GObjectClass *) klass; - sp_object_class = (SPObjectClass *) klass; ++ GObjectClass * object_class = (GObjectClass *) klass; ++ SPObjectClass * sp_object_class = (SPObjectClass *) klass; - object_class = (GObjectClass *) klass; - sp_object_class = (SPObjectClass *) klass; - static_parent_class = (SPObjectClass *)g_type_class_ref (SP_TYPE_OBJECT); ++ static_parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT); - parent_class = (SPObjectClass *)g_type_class_ref (SP_TYPE_OBJECT); - - sp_object_class->child_added = sp_objectgroup_child_added; - sp_object_class->remove_child = sp_objectgroup_remove_child; - sp_object_class->order_changed = sp_objectgroup_order_changed; - sp_object_class->write = sp_objectgroup_write; - sp_object_class->child_added = SPObjectGroup::sp_objectgroup_child_added; - sp_object_class->remove_child = SPObjectGroup::sp_objectgroup_remove_child; - sp_object_class->order_changed = SPObjectGroup::sp_objectgroup_order_changed; - sp_object_class->write = SPObjectGroup::sp_objectgroup_write; ++ sp_object_class->child_added = SPObjectGroup::childAdded; ++ sp_object_class->remove_child = SPObjectGroup::removeChild; ++ sp_object_class->order_changed = SPObjectGroup::orderChanged; ++ sp_object_class->write = SPObjectGroup::write; } - static void - sp_objectgroup_init (SPObjectGroup */*objectgroup*/) -void -SPObjectGroup::sp_objectgroup_init (SPObjectGroup */*objectgroup*/) ++void SPObjectGroup::init(SPObjectGroup * /*objectgroup*/) { } - static void - sp_objectgroup_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) -void -SPObjectGroup::sp_objectgroup_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) ++void SPObjectGroup::childAdded(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - if (((SPObjectClass *) (parent_class))->child_added) - (* ((SPObjectClass *) (parent_class))->child_added) (object, child, ref); - if (((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->child_added) - (* ((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->child_added) (object, child, ref); ++ if (((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->child_added) { ++ (* ((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->child_added)(object, child, ref); ++ } -- object->requestModified(SP_OBJECT_MODIFIED_FLAG); ++ object->requestModified(SP_OBJECT_MODIFIED_FLAG); } - static void - sp_objectgroup_remove_child (SPObject *object, Inkscape::XML::Node *child) -void -SPObjectGroup::sp_objectgroup_remove_child (SPObject *object, Inkscape::XML::Node *child) ++void SPObjectGroup::removeChild(SPObject *object, Inkscape::XML::Node *child) { - if (((SPObjectClass *) (parent_class))->remove_child) - (* ((SPObjectClass *) (parent_class))->remove_child) (object, child); - if (((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->remove_child) - (* ((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->remove_child) (object, child); ++ if (((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->remove_child) { ++ (* ((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->remove_child)(object, child); ++ } -- object->requestModified(SP_OBJECT_MODIFIED_FLAG); ++ object->requestModified(SP_OBJECT_MODIFIED_FLAG); } - static void - sp_objectgroup_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) -void -SPObjectGroup::sp_objectgroup_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) ++void SPObjectGroup::orderChanged(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) { - if (((SPObjectClass *) (parent_class))->order_changed) - (* ((SPObjectClass *) (parent_class))->order_changed) (object, child, old_ref, new_ref); - if (((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->order_changed) - (* ((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->order_changed) (object, child, old_ref, new_ref); ++ if (((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->order_changed) { ++ (* ((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->order_changed)(object, child, old_ref, new_ref); ++ } -- object->requestModified(SP_OBJECT_MODIFIED_FLAG); ++ object->requestModified(SP_OBJECT_MODIFIED_FLAG); } - static Inkscape::XML::Node * - sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) -Inkscape::XML::Node * -SPObjectGroup::sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) ++Inkscape::XML::Node *SPObjectGroup::write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { -- SPObjectGroup *group; -- SPObject *child; -- Inkscape::XML::Node *crepr; -- -- group = SP_OBJECTGROUP (object); -- -- if (flags & SP_OBJECT_WRITE_BUILD) { -- GSList *l; -- if (!repr) { -- repr = xml_doc->createElement("svg:g"); -- } -- l = NULL; - for ( child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for ( child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- crepr = child->updateRepr(xml_doc, NULL, flags); -- if (crepr) l = g_slist_prepend (l, crepr); -- } -- while (l) { -- repr->addChild((Inkscape::XML::Node *) l->data, NULL); -- Inkscape::GC::release((Inkscape::XML::Node *) l->data); -- l = g_slist_remove (l, l->data); -- } -- } else { - for ( child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for ( child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- child->updateRepr(flags); -- } -- } -- - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); - if (((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->write) - ((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->write (object, xml_doc, repr, flags); -- -- return repr; ++ SP_OBJECTGROUP(object); // Ensure we have the right type of SPObject ++ ++ if (flags & SP_OBJECT_WRITE_BUILD) { ++ if (!repr) { ++ repr = xml_doc->createElement("svg:g"); ++ } ++ GSList *l = 0; ++ for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); ++ if (crepr) { ++ l = g_slist_prepend(l, crepr); ++ } ++ } ++ while (l) { ++ repr->addChild((Inkscape::XML::Node *) l->data, NULL); ++ Inkscape::GC::release((Inkscape::XML::Node *) l->data); ++ l = g_slist_remove(l, l->data); ++ } ++ } else { ++ for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ child->updateRepr(flags); ++ } ++ } ++ ++ if (((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->write) { ++ ((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->write(object, xml_doc, repr, flags); ++ } ++ ++ return repr; } ++/* ++ Local Variables: ++ mode:c++ ++ c-file-style:"stroustrup" ++ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) ++ indent-tabs-mode:nil ++ fill-column:99 ++ End: ++*/ ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --cc src/sp-object-group.h index 5d67df6fe,7d35cfc17..a666a316a --- a/src/sp-object-group.h +++ b/src/sp-object-group.h @@@ -1,11 -1,11 +1,12 @@@ --#ifndef __SP_OBJECTGROUP_H__ --#define __SP_OBJECTGROUP_H__ ++#ifndef SEEN_SP_OBJECTGROUP_H ++#define SEEN_SP_OBJECTGROUP_H /* * Abstract base class for non-item groups * * Author: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 1999-2003 Authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -21,13 -21,32 +22,40 @@@ #define SP_IS_OBJECTGROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_OBJECTGROUP)) #define SP_IS_OBJECTGROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_OBJECTGROUP)) - struct SPObjectGroup : public SPObject { - }; + class SPObjectGroup : public SPObject { - public: - static GType sp_objectgroup_get_type (void); ++public: ++ static GType sp_objectgroup_get_type(void); + - private: - static void sp_objectgroup_init (SPObjectGroup *objectgroup); ++private: ++ static void init(SPObjectGroup *objectgroup); - struct SPObjectGroupClass { - SPObjectClass parent_class; - static void sp_objectgroup_child_added (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * ref); - static void sp_objectgroup_remove_child (SPObject * object, Inkscape::XML::Node * child); - static void sp_objectgroup_order_changed (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * old_ref, Inkscape::XML::Node * new_ref); - static Inkscape::XML::Node *sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); ++ static void childAdded(SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * ref); ++ static void removeChild(SPObject * object, Inkscape::XML::Node * child); ++ static void orderChanged(SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * old_ref, Inkscape::XML::Node * new_ref); ++ static Inkscape::XML::Node *write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); + - friend class SPObjectGroupClass; ++ friend class SPObjectGroupClass; }; - GType sp_objectgroup_get_type (void); + class SPObjectGroupClass { - public: - SPObjectClass parent_class; ++public: ++ SPObjectClass parent_class; + - private: - static void sp_objectgroup_class_init (SPObjectGroupClass *klass); - static SPObjectClass *static_parent_class; ++private: ++ static void sp_objectgroup_class_init(SPObjectGroupClass *klass); ++ static SPObjectClass *static_parent_class; - #endif - friend class SPObjectGroup; ++ friend class SPObjectGroup; + }; + -//GType sp_objectgroup_get_type (void); - -#endif ++#endif // SEEN_SP_OBJECTGROUP_H ++/* ++ Local Variables: ++ mode:c++ ++ c-file-style:"stroustrup" ++ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) ++ indent-tabs-mode:nil ++ fill-column:99 ++ End: ++*/ ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --cc src/sp-object-repr.cpp index 17f2706ad,207d08277..475a57521 --- a/src/sp-object-repr.cpp +++ b/src/sp-object-repr.cpp @@@ -1,10 -1,10 +1,9 @@@ --#define __SP_OBJECT_REPR_C__ -- /* * Object type dictionary and build frontend * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 1999-2003 Lauris Kaplinski * diff --cc src/sp-object-repr.h index 4e85acf53,d1501fe3e..02ad3ea93 --- a/src/sp-object-repr.h +++ b/src/sp-object-repr.h @@@ -1,5 -1,5 +1,5 @@@ --#ifndef __SP_OBJECT_REPR_H__ --#define __SP_OBJECT_REPR_H__ ++#ifndef SEEN_SP_OBJECT_REPR_H ++#define SEEN_SP_OBJECT_REPR_H /* * Object type dictionary and build frontend @@@ -27,7 -27,7 +27,7 @@@ GType sp_repr_type_lookup (Inkscape::XM void sp_object_type_register(gchar const *name, GType type); --#endif ++#endif // SEEN_SP_OBJECT_REPR_H /* Local Variables: diff --cc src/sp-object.cpp index 7fe099699,88d24bffd..17def7f15 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@@ -1,4 -1,4 +1,3 @@@ --#define __SP_OBJECT_C__ /** \file * SPObject implementation. * @@@ -6,6 -6,6 +5,8 @@@ * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> * Stephen Silver <sasilver@users.sourceforge.net> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2008 authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -76,41 -75,41 +77,14 @@@ using std::strstr # define debug(f, a...) /**/ #endif - static void sp_object_class_init(SPObjectClass *klass); -/*static void sp_object_class_init(SPObjectClass *klass); --static void sp_object_init(SPObject *object); --static void sp_object_finalize(GObject *object); -- --static void sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); --static void sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child); --static void sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref); -- --static void sp_object_release(SPObject *object); --static void sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); -- --static void sp_object_private_set(SPObject *object, unsigned int key, gchar const *value); --static Inkscape::XML::Node *sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -- - /* Real handlers of repr signals */ -* Real handlers of repr signals */ -- - static void sp_object_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data); -/*static void sp_object_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data); -- --static void sp_object_repr_content_changed(Inkscape::XML::Node *repr, gchar const *oldcontent, gchar const *newcontent, gpointer data); -- --static void sp_object_repr_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data); --static void sp_object_repr_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void *data); -- --static void sp_object_repr_order_changed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data); -- - static gchar *sp_object_get_unique_id(SPObject *object, gchar const *defid); -static gchar *sp_object_get_unique_id(SPObject *object, gchar const *defid);*/ -- guint update_in_progress = 0; // guard against update-during-update Inkscape::XML::NodeEventVector object_event_vector = { - sp_object_repr_child_added, - sp_object_repr_child_removed, - sp_object_repr_attr_changed, - sp_object_repr_content_changed, - sp_object_repr_order_changed - SPObject::sp_object_repr_child_added, ++ SPObject::sp_object_repr_child_added, + SPObject::sp_object_repr_child_removed, + SPObject::sp_object_repr_attr_changed, + SPObject::sp_object_repr_content_changed, + SPObject::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 @@@ -144,13 -143,15 +118,12 @@@ public }; - static GObjectClass *parent_class; -//static GObjectClass *parent_class; - + GObjectClass * SPObjectClass::static_parent_class = 0; /** * Registers the SPObject class with Gdk and returns its type number. */ --GType - sp_object_get_type(void) -SPObject::sp_object_get_type() ++GType SPObject::sp_object_get_type() { static GType type = 0; if (!type) { @@@ -172,34 -173,34 +145,32 @@@ /** * Initializes the SPObject vtable. */ - static void - sp_object_class_init(SPObjectClass *klass) -void -SPObjectClass::sp_object_class_init(SPObjectClass *klass) ++void SPObjectClass::sp_object_class_init(SPObjectClass *klass) { GObjectClass *object_class; object_class = (GObjectClass *) klass; - parent_class = (GObjectClass *) g_type_class_ref(G_TYPE_OBJECT); - static_parent_class = (GObjectClass *) g_type_class_ref(G_TYPE_OBJECT); ++ static_parent_class = (GObjectClass *) g_type_class_ref(G_TYPE_OBJECT); - object_class->finalize = sp_object_finalize; + object_class->finalize = SPObject::sp_object_finalize; - klass->child_added = sp_object_child_added; - klass->remove_child = sp_object_remove_child; - klass->order_changed = sp_object_order_changed; + klass->child_added = SPObject::sp_object_child_added; + klass->remove_child = SPObject::sp_object_remove_child; + klass->order_changed = SPObject::sp_object_order_changed; - klass->release = sp_object_release; + klass->release = SPObject::sp_object_release; - klass->build = sp_object_build; + klass->build = SPObject::sp_object_build; - klass->set = sp_object_private_set; - klass->write = sp_object_private_write; + klass->set = SPObject::sp_object_private_set; + klass->write = SPObject::sp_object_private_write; } /** * Callback to initialize the SPObject object. */ - static void - sp_object_init(SPObject *object) -void -SPObject::sp_object_init(SPObject *object) ++void SPObject::sp_object_init(SPObject *object) { debug("id=%x, typename=%s",object, g_type_name_from_instance((GTypeInstance*)object)); @@@ -208,7 -209,10 +179,10 @@@ object->document = NULL; object->children = object->_last_child = NULL; object->parent = object->next = NULL; - object->repr = NULL; + - //used XML Tree here. - Inkscape::XML::Node *repr = object->getRepr(); - repr = NULL; ++ //used XML Tree here. ++ Inkscape::XML::Node *repr = object->getRepr(); ++ repr = NULL; SPObjectImpl::setIdNull(object); object->_collection_policy = SPObject::COLLECT_WITH_PARENT; @@@ -232,8 -236,8 +206,7 @@@ /** * Callback to destroy all members and connections of object and itself. */ - static void - sp_object_finalize(GObject *object) -void -SPObject::sp_object_finalize(GObject *object) ++void SPObject::sp_object_finalize(GObject *object) { SPObject *spobject = (SPObject *)object; @@@ -295,6 -299,15 +268,15 @@@ gchar const* SPObject::getId() const return id; } + Inkscape::XML::Node * SPObject::getRepr() { - return repr; ++ return repr; + } + + Inkscape::XML::Node const* SPObject::getRepr() const{ - return repr; ++ return repr; + } + + /** * Increase reference count of object, with possible debugging. * @@@ -302,8 -315,8 +284,7 @@@ * \return object, NULL is error. * \pre object points to real object */ --SPObject * --sp_object_ref(SPObject *object, SPObject *owner) ++SPObject *sp_object_ref(SPObject *object, SPObject *owner) { g_return_val_if_fail(object != NULL, NULL); g_return_val_if_fail(SP_IS_OBJECT(object), NULL); @@@ -322,8 -335,8 +303,7 @@@ * \return always NULL * \pre object points to real object */ --SPObject * --sp_object_unref(SPObject *object, SPObject *owner) ++SPObject *sp_object_unref(SPObject *object, SPObject *owner) { g_return_val_if_fail(object != NULL, NULL); g_return_val_if_fail(SP_IS_OBJECT(object), NULL); @@@ -344,8 -357,8 +324,7 @@@ * \return object, NULL is error * \pre object points to real object */ --SPObject * --sp_object_href(SPObject *object, gpointer /*owner*/) ++SPObject *sp_object_href(SPObject *object, gpointer /*owner*/) { g_return_val_if_fail(object != NULL, NULL); g_return_val_if_fail(SP_IS_OBJECT(object), NULL); @@@ -365,8 -378,8 +344,7 @@@ * \return always NULL * \pre object points to real object and hrefcount>0 */ --SPObject * --sp_object_hunref(SPObject *object, gpointer /*owner*/) ++SPObject *sp_object_hunref(SPObject *object, gpointer /*owner*/) { g_return_val_if_fail(object != NULL, NULL); g_return_val_if_fail(SP_IS_OBJECT(object), NULL); @@@ -381,10 -394,10 +359,9 @@@ /** * Adds increment to _total_hrefcount of object and its parents. */ --void --SPObject::_updateTotalHRefCount(int increment) { ++void SPObject::_updateTotalHRefCount(int increment) { SPObject *topmost_collectable = NULL; -- for ( SPObject *iter = this ; iter ; iter = SP_OBJECT_PARENT(iter) ) { ++ for ( SPObject *iter = this ; iter ; iter = iter->parent ) { iter->_total_hrefcount += increment; if ( iter->_total_hrefcount < iter->hrefcount ) { g_critical("HRefs overcounted"); @@@ -403,15 -416,15 +380,14 @@@ /** * True if object is non-NULL and this is some in/direct parent of object. */ --bool --SPObject::isAncestorOf(SPObject const *object) const { ++bool SPObject::isAncestorOf(SPObject const *object) const { g_return_val_if_fail(object != NULL, false); -- object = SP_OBJECT_PARENT(object); ++ object = object->parent; while (object) { if ( object == this ) { return true; } -- object = SP_OBJECT_PARENT(object); ++ object = object->parent; } return false; } @@@ -427,8 -440,8 +403,7 @@@ bool same_objects(SPObject const &a, SP /** * Returns youngest object being parent to this and object. */ --SPObject const * --SPObject::nearestCommonAncestor(SPObject const *object) const { ++SPObject const *SPObject::nearestCommonAncestor(SPObject const *object) const { g_return_val_if_fail(object != NULL, NULL); using Inkscape::Algorithms::longest_common_suffix; @@@ -436,11 -449,11 +411,15 @@@ } SPObject const *AncestorSon(SPObject const *obj, SPObject const *ancestor) { -- if (obj == NULL || ancestor == NULL) -- return NULL; -- if (SP_OBJECT_PARENT(obj) == ancestor) -- return obj; -- return AncestorSon(SP_OBJECT_PARENT(obj), ancestor); ++ SPObject const *result = 0; ++ if ( obj && ancestor ) { ++ if (obj->parent == ancestor) { ++ result = obj; ++ } else { ++ result = AncestorSon(obj->parent, ancestor); ++ } ++ } ++ return result; } /** @@@ -452,26 -465,26 +431,29 @@@ * 1 first object's position is greater than the second * -1 first object's position is less than the second \endverbatim */ --int --sp_object_compare_position(SPObject const *first, SPObject const *second) ++int sp_object_compare_position(SPObject const *first, SPObject const *second) { -- if (first == second) return 0; -- -- SPObject const *ancestor = first->nearestCommonAncestor(second); -- if (ancestor == NULL) return 0; // cannot compare, no common ancestor! -- -- // we have an object and its ancestor (should not happen when sorting selection) -- if (ancestor == first) -- return 1; -- if (ancestor == second) -- return -1; -- -- SPObject const *to_first = AncestorSon(first, ancestor); -- SPObject const *to_second = AncestorSon(second, ancestor); ++ int result = 0; ++ if (first != second) { ++ SPObject const *ancestor = first->nearestCommonAncestor(second); ++ // Need a common ancestor to be able to compare ++ if ( ancestor ) { ++ // we have an object and its ancestor (should not happen when sorting selection) ++ if (ancestor == first) { ++ result = 1; ++ } else if (ancestor == second) { ++ result = -1; ++ } else { ++ SPObject const *to_first = AncestorSon(first, ancestor); ++ SPObject const *to_second = AncestorSon(second, ancestor); -- g_assert(SP_OBJECT_PARENT(to_second) == SP_OBJECT_PARENT(to_first)); ++ g_assert(to_second->parent == to_first->parent); -- return sp_repr_compare_position(SP_OBJECT_REPR(to_first), SP_OBJECT_REPR(to_second)); ++ result = sp_repr_compare_position(to_first->getRepr(), to_second->getRepr()); ++ } ++ } ++ } ++ return result; } @@@ -479,26 -492,38 +461,34 @@@ * Append repr as child of this object. * \pre this is not a cloned object */ --SPObject * --SPObject::appendChildRepr(Inkscape::XML::Node *repr) { -- if (!SP_OBJECT_IS_CLONED(this)) { -- SP_OBJECT_REPR(this)->appendChild(repr); -- return SP_OBJECT_DOCUMENT(this)->getObjectByRepr(repr); ++SPObject *SPObject::appendChildRepr(Inkscape::XML::Node *repr) { ++ if ( !cloned ) { ++ getRepr()->appendChild(repr); ++ return document->getObjectByRepr(repr); } else { g_critical("Attempt to append repr as child of cloned object"); return NULL; } } - /** - * Retrieves the children as a GSList object, optionally ref'ing the children - * in the process, if add_ref is specified. - */ + void SPObject::setCSS(SPCSSAttr *css, gchar const *attr) + { - g_assert(this->getRepr() != NULL); - sp_repr_css_set(this->getRepr(), css, attr); ++ g_assert(this->getRepr() != NULL); ++ sp_repr_css_set(this->getRepr(), css, attr); + } + + void SPObject::changeCSS(SPCSSAttr *css, gchar const *attr) + { - g_assert(this->getRepr() != NULL); - sp_repr_css_change(this->getRepr(), css, attr); ++ g_assert(this->getRepr() != NULL); ++ sp_repr_css_change(this->getRepr(), css, attr); + } + -/** - * Retrieves the children as a GSList object, optionally ref'ing the children - * in the process, if add_ref is specified. - */ GSList *SPObject::childList(bool add_ref, Action) { GSList *l = NULL; - for (SPObject *child = sp_object_first_child(this) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = this->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { -- if (add_ref) ++ for ( SPObject *child = firstChild() ; child; child = child->getNext() ) { ++ if (add_ref) { g_object_ref (G_OBJECT (child)); ++ } l = g_slist_prepend (l, child); } @@@ -509,23 -534,23 +499,20 @@@ /** Gets the label property for the object or a default if no label * is defined. */ --gchar const * --SPObject::label() const { ++gchar const *SPObject::label() const { return _label; } /** Returns a default label property for the object. */ --gchar const * --SPObject::defaultLabel() const { ++gchar const *SPObject::defaultLabel() const { if (_label) { return _label; } else { if (!_default_label) { -- gchar const *id=SP_OBJECT_ID(this); -- if (id) { -- _default_label = g_strdup_printf("#%s", id); ++ if (getId()) { ++ _default_label = g_strdup_printf("#%s", getId()); } else { -- _default_label = g_strdup_printf("<%s>", SP_OBJECT_REPR(this)->name()); ++ _default_label = g_strdup_printf("<%s>", getRepr()->name()); } } return _default_label; @@@ -533,9 -558,9 +520,8 @@@ } /** Sets the label property for the object */ --void --SPObject::setLabel(gchar const *label) { -- SP_OBJECT_REPR(this)->setAttribute("inkscape:label", label, false); ++void SPObject::setLabel(gchar const *label) { ++ getRepr()->setAttribute("inkscape:label", label, false); } @@@ -544,35 -570,30 +530,33 @@@ void SPObject::requestOrphanCollection( g_return_if_fail(document != NULL); // do not remove style or script elements (Bug #276244) - if (SP_IS_STYLE_ELEM(this)) - return; - if (SP_IS_SCRIPT(this)) - return; - - document->queueForOrphanCollection(this); + if (SP_IS_STYLE_ELEM(this)) { + // leave it + } else if (SP_IS_SCRIPT(this)) { + // leave it + } else if (SP_IS_PAINT_SERVER(this) && static_cast<SPPaintServer*>(this)->isSwatch() ) { + // leave it + } else if (IS_COLORPROFILE(this)) { + // leave it + } else { + document->queueForOrphanCollection(this); - /** \todo - * This is a temporary hack added to make fill&stroke rebuild its - * gradient list when the defs are vacuumed. gradient-vector.cpp - * listens to the modified signal on defs, and now we give it that - * signal. Mental says that this should be made automatic by - * merging SPObjectGroup with SPObject; SPObjectGroup would issue - * this signal automatically. Or maybe just derive SPDefs from - * SPObjectGroup? - */ + /** \todo + * This is a temporary hack added to make fill&stroke rebuild its + * gradient list when the defs are vacuumed. gradient-vector.cpp + * listens to the modified signal on defs, and now we give it that + * signal. Mental says that this should be made automatic by + * merging SPObjectGroup with SPObject; SPObjectGroup would issue + * this signal automatically. Or maybe just derive SPDefs from + * SPObjectGroup? + */ - this->requestModified(SP_OBJECT_CHILD_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_CHILD_MODIFIED_FLAG); + } } --/** Sends the delete signal to all children of this object recursively */ --void --SPObject::_sendDeleteSignalRecursive() { - for (SPObject *child = sp_object_first_child(this); child; child = SP_OBJECT_NEXT(child)) { - for (SPObject *child = this->first_child(); child; child = SP_OBJECT_NEXT(child)) { ++void SPObject::_sendDeleteSignalRecursive() { ++ for (SPObject *child = firstChild(); child; child = child->getNext()) { child->_delete_signal.emit(child); child->_sendDeleteSignalRecursive(); } @@@ -585,8 -606,8 +569,7 @@@ * signal. If the \a propagate_descendants parameter is true, it * recursively sends the delete signal to children. */ --void --SPObject::deleteObject(bool propagate, bool propagate_descendants) ++void SPObject::deleteObject(bool propagate, bool propagate_descendants) { sp_object_ref(this, NULL); if (propagate) { @@@ -596,7 -617,7 +579,7 @@@ this->_sendDeleteSignalRecursive(); } -- Inkscape::XML::Node *repr=SP_OBJECT_REPR(this); ++ Inkscape::XML::Node *repr = getRepr(); if (repr && sp_repr_parent(repr)) { sp_repr_unparent(repr); } @@@ -611,11 -632,11 +594,10 @@@ * Put object into object tree, under parent, and behind prev; * also update object's XML space. */ --void - sp_object_attach(SPObject *parent, SPObject *object, SPObject *prev) -SPObject::attach(SPObject *object, SPObject *prev) ++void SPObject::attach(SPObject *object, SPObject *prev) { - g_return_if_fail(parent != NULL); - g_return_if_fail(SP_IS_OBJECT(parent)); + //g_return_if_fail(parent != NULL); + //g_return_if_fail(SP_IS_OBJECT(parent)); g_return_if_fail(object != NULL); g_return_if_fail(SP_IS_OBJECT(object)); g_return_if_fail(!prev || SP_IS_OBJECT(prev)); @@@ -645,19 -666,19 +627,18 @@@ /** * In list of object's siblings, move object behind prev. */ --void - sp_object_reorder(SPObject *object, SPObject *prev) { - g_return_if_fail(object != NULL); - g_return_if_fail(SP_IS_OBJECT(object)); - g_return_if_fail(object->parent != NULL); - g_return_if_fail(object != prev); -SPObject::reorder(SPObject *prev) { ++void SPObject::reorder(SPObject *prev) { + //g_return_if_fail(object != NULL); + //g_return_if_fail(SP_IS_OBJECT(object)); + g_return_if_fail(this->parent != NULL); + g_return_if_fail(this != prev); g_return_if_fail(!prev || SP_IS_OBJECT(prev)); - g_return_if_fail(!prev || prev->parent == object->parent); + g_return_if_fail(!prev || prev->parent == this->parent); - SPObject *const parent=object->parent; + SPObject *const parent=this->parent; SPObject *old_prev=NULL; - for ( SPObject *child = parent->children ; child && child != object ; + for ( SPObject *child = parent->children ; child && child != this ; child = child->next ) { old_prev = child; @@@ -688,13 -709,13 +669,12 @@@ /** * Remove object from parent's children, release and unref it. */ --void - sp_object_detach(SPObject *parent, SPObject *object) { - g_return_if_fail(parent != NULL); - g_return_if_fail(SP_IS_OBJECT(parent)); -SPObject::detach(SPObject *object) { ++void SPObject::detach(SPObject *object) { + //g_return_if_fail(parent != NULL); + //g_return_if_fail(SP_IS_OBJECT(parent)); g_return_if_fail(object != NULL); g_return_if_fail(SP_IS_OBJECT(object)); - g_return_if_fail(object->parent == parent); + g_return_if_fail(object->parent == this); object->releaseReferences(); @@@ -709,10 -730,10 +689,10 @@@ if (prev) { prev->next = next; } else { - parent->children = next; + this->children = next; } if (!next) { - parent->_last_child = prev; - this->_last_child = prev; ++ this->_last_child = prev; } object->next = NULL; @@@ -725,41 -746,41 +705,40 @@@ /** * Return object's child whose node pointer equals repr. */ --SPObject * - sp_object_get_child_by_repr(SPObject *object, Inkscape::XML::Node *repr) -SPObject::get_child_by_repr(Inkscape::XML::Node *repr) ++SPObject *SPObject::get_child_by_repr(Inkscape::XML::Node *repr) { - g_return_val_if_fail(object != NULL, NULL); - g_return_val_if_fail(SP_IS_OBJECT(object), NULL); - //g_return_val_if_fail(object != NULL, NULL); - //g_return_val_if_fail(SP_IS_OBJECT(object), NULL); g_return_val_if_fail(repr != NULL, NULL); ++ SPObject *result = 0; - if (object->_last_child && SP_OBJECT_REPR(object->_last_child) == repr) - return object->_last_child; // optimization for common scenario - for ( SPObject *child = object->children ; child ; child = child->next ) { - if (this->_last_child && SP_OBJECT_REPR(this->_last_child) == repr) - return this->_last_child; // optimization for common scenario - for ( SPObject *child = this->children ; child ; child = child->next ) { -- if ( SP_OBJECT_REPR(child) == repr ) { -- return child; ++ if ( _last_child && (_last_child->getRepr() == repr) ) { ++ result = _last_child; // optimization for common scenario ++ } else { ++ for ( SPObject *child = children ; child ; child = child->next ) { ++ if ( child->getRepr() == repr ) { ++ result = child; ++ break; ++ } } } -- -- return NULL; ++ return result; } /** * Callback for child_added event. * Invoked whenever the given mutation event happens in the XML tree. */ - static void - sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) -void -SPObject::sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) ++void SPObject::sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { GType type = sp_repr_type_lookup(child); if (!type) { return; } SPObject *ochild = SP_OBJECT(g_object_new(type, 0)); - SPObject *prev = ref ? sp_object_get_child_by_repr(object, ref) : NULL; - sp_object_attach(object, ochild, prev); + SPObject *prev = ref ? object->get_child_by_repr(ref) : NULL; + object->attach(ochild, prev); sp_object_unref(ochild, NULL); - sp_object_invoke_build(ochild, object->document, child, SP_OBJECT_IS_CLONED(object)); - ochild->invoke_build(object->document, child, SP_OBJECT_IS_CLONED(object)); ++ ochild->invoke_build(object->document, child, object->cloned); } /** @@@ -789,14 -810,14 +768,14 @@@ void SPObject::sp_object_release(SPObje * tree, BEFORE removal from the XML tree happens, so grouping * objects can safely release the child data. */ - static void - sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child) -void -SPObject::sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child) ++void SPObject::sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child) { debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); - SPObject *ochild = sp_object_get_child_by_repr(object, child); + SPObject *ochild = object->get_child_by_repr(child); g_return_if_fail (ochild != NULL || !strcmp("comment", child->name())); // comments have no objects -- if (ochild) - sp_object_detach(object, ochild); ++ if (ochild) { + object->detach(ochild); ++ } } /** @@@ -826,8 -847,8 +805,7 @@@ void SPObject::sp_object_order_changed( * SPDocument does after the creation of the XML tree). * \see sp_object_release() */ - static void - sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -void -SPObject::sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) ++void SPObject::sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { /* Nothing specific here */ debug("id=%x, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); @@@ -842,9 -863,9 +820,9 @@@ continue; } SPObject *child = SP_OBJECT(g_object_new(type, 0)); - sp_object_attach(object, child, object->lastChild()); + object->attach(child, object->lastChild()); sp_object_unref(child, NULL); - sp_object_invoke_build(child, document, rchild, SP_OBJECT_IS_CLONED(object)); - child->invoke_build(document, rchild, SP_OBJECT_IS_CLONED(object)); ++ child->invoke_build(document, rchild, object->cloned); } } @@@ -863,25 -884,25 +841,26 @@@ void SPObject::invoke_build(SPDocument /* Bookkeeping */ - object->document = document; - object->repr = repr; - if (!cloned) + this->document = document; + this->repr = repr; - if (!cloned) ++ if (!cloned) { Inkscape::GC::anchor(repr); - object->cloned = cloned; ++ } + this->cloned = cloned; - if (!SP_OBJECT_IS_CLONED(object)) { - object->document->bindObjectToRepr(object->repr, object); - if (!SP_OBJECT_IS_CLONED(this)) { ++ if ( !cloned ) { + this->document->bindObjectToRepr(this->repr, this); - if (Inkscape::XML::id_permitted(object->repr)) { + if (Inkscape::XML::id_permitted(this->repr)) { /* If we are not cloned, and not seeking, force unique id */ - gchar const *id = object->repr->attribute("id"); + gchar const *id = this->repr->attribute("id"); if (!document->isSeeking()) { { - gchar *realid = sp_object_get_unique_id(object, id); + gchar *realid = sp_object_get_unique_id(this, id); g_assert(realid != NULL); - object->document->bindObjectToId(realid, object); - SPObjectImpl::setId(object, realid); + this->document->bindObjectToId(realid, this); + SPObjectImpl::setId(this, realid); g_free(realid); } @@@ -908,7 -929,31 +887,31 @@@ } /* Signalling (should be connected AFTER processing derived methods */ - sp_repr_add_listener(repr, &object_event_vector, object); + sp_repr_add_listener(repr, &object_event_vector, this); + } + + long long int SPObject::getIntAttribute(char const *key, long long int def) + { - return sp_repr_get_int_attribute(getRepr(),key,def); ++ return sp_repr_get_int_attribute(getRepr(),key,def); + } + + unsigned SPObject::getPosition(){ - g_assert(this->repr); ++ g_assert(this->repr); + - return repr->position(); ++ return repr->position(); + } + + void SPObject::appendChild(Inkscape::XML::Node *child) { - g_assert(this->repr); ++ g_assert(this->repr); + - repr->appendChild(child); ++ repr->appendChild(child); + } + + void SPObject::addChild(Inkscape::XML::Node *child, Inkscape::XML::Node * prev) + { - g_assert(this->repr); ++ g_assert(this->repr); + - repr->addChild(child,prev); ++ repr->addChild(child,prev); } void SPObject::releaseReferences() { @@@ -926,7 -971,7 +929,7 @@@ /* all hrefs should be released by the "release" handlers */ g_assert(this->hrefcount == 0); -- if (!SP_OBJECT_IS_CLONED(this)) { ++ if (!cloned) { if (this->id) { this->document->bindObjectToId(this->id, NULL); } @@@ -952,33 -997,33 +955,33 @@@ } --SPObject *SPObject::getNext() --{ -- return next; --} -- SPObject *SPObject::getPrev() { - return sp_object_prev(this); - return this->prev(); ++ SPObject *prev = 0; ++ for ( SPObject *obj = parent->firstChild(); obj && !prev; obj = obj->getNext() ) { ++ if (obj->getNext() == this) { ++ prev = obj; ++ } ++ } ++ return prev; } /** * Callback for child_added node event. */ - static void - sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data) -void -SPObject::sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data) ++void SPObject::sp_object_repr_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data) { SPObject *object = SP_OBJECT(data); -- if (((SPObjectClass *) G_OBJECT_GET_CLASS(object))->child_added) ++ if (((SPObjectClass *) G_OBJECT_GET_CLASS(object))->child_added) { (*((SPObjectClass *)G_OBJECT_GET_CLASS(object))->child_added)(object, child, ref); ++ } } /** * Callback for remove_child node event. */ - static void - sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node */*ref*/, gpointer data) -void -SPObject::sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node */*ref*/, gpointer data) ++void SPObject::sp_object_repr_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node */*ref*/, gpointer data) { SPObject *object = SP_OBJECT(data); @@@ -992,8 -1037,8 +995,7 @@@ * * \todo fixme: */ - static void - sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data) -void -SPObject::sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data) ++void SPObject::sp_object_repr_order_changed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data) { SPObject *object = SP_OBJECT(data); @@@ -1005,14 -1050,16 +1007,15 @@@ /** * Callback for set event. */ - static void - sp_object_private_set(SPObject *object, unsigned int key, gchar const *value) -void -SPObject::sp_object_private_set(SPObject *object, unsigned int key, gchar const *value) ++void SPObject::sp_object_private_set(SPObject *object, unsigned int key, gchar const *value) { g_assert(key != SP_ATTR_INVALID); switch (key) { case SP_ATTR_ID: - if ( !SP_OBJECT_IS_CLONED(object) && object->repr->type() == Inkscape::XML::ELEMENT_NODE ) { + - //XML Tree being used here. - if ( !SP_OBJECT_IS_CLONED(object) && object->getRepr()->type() == Inkscape::XML::ELEMENT_NODE ) { ++ //XML Tree being used here. ++ if ( !object->cloned && object->getRepr()->type() == Inkscape::XML::ELEMENT_NODE ) { SPDocument *document=object->document; SPObject *conflict=NULL; @@@ -1027,7 -1074,7 +1030,7 @@@ sp_object_ref(conflict, NULL); // give the conflicting object a new ID gchar *new_conflict_id = sp_object_get_unique_id(conflict, NULL); -- SP_OBJECT_REPR(conflict)->setAttribute("id", new_conflict_id); ++ conflict->getRepr()->setAttribute("id", new_conflict_id); g_free(new_conflict_id); sp_object_unref(conflict, NULL); } else { @@@ -1092,28 -1139,29 +1095,27 @@@ /** * Call virtual set() function of object. */ --void - sp_object_set(SPObject *object, unsigned int key, gchar const *value) -SPObject::setKeyValue(unsigned int key, gchar const *value) ++void SPObject::setKeyValue(unsigned int key, gchar const *value) { - g_assert(object != NULL); - g_assert(SP_IS_OBJECT(object)); + //g_assert(object != NULL); + //g_assert(SP_IS_OBJECT(object)); - if (((SPObjectClass *) G_OBJECT_GET_CLASS(object))->set) { - ((SPObjectClass *) G_OBJECT_GET_CLASS(object))->set(object, key, value); + if (((SPObjectClass *) G_OBJECT_GET_CLASS(this))->set) { + ((SPObjectClass *) G_OBJECT_GET_CLASS(this))->set(this, key, value); } } /** * Read value of key attribute from XML node into object. */ --void - sp_object_read_attr(SPObject *object, gchar const *key) -SPObject::readAttr(gchar const *key) ++void SPObject::readAttr(gchar const *key) { - g_assert(object != NULL); - g_assert(SP_IS_OBJECT(object)); + //g_assert(object != NULL); + //g_assert(SP_IS_OBJECT(object)); g_assert(key != NULL); - g_assert(object->repr != NULL); - //XML Tree being used here. ++ //XML Tree being used here. + g_assert(this->getRepr() != NULL); unsigned int keyid = sp_attribute_lookup(key); if (keyid != SP_ATTR_INVALID) { @@@ -1127,8 -1175,8 +1129,7 @@@ /** * Callback for attr_changed node event. */ - static void - sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *key, gchar const */*oldval*/, gchar const */*newval*/, bool is_interactive, gpointer data) -void -SPObject::sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *key, gchar const */*oldval*/, gchar const */*newval*/, bool is_interactive, gpointer data) ++void SPObject::sp_object_repr_attr_changed(Inkscape::XML::Node */*repr*/, gchar const *key, gchar const */*oldval*/, gchar const */*newval*/, bool is_interactive, gpointer data) { SPObject *object = SP_OBJECT(data); @@@ -1144,13 -1192,13 +1145,13 @@@ /** * Callback for content_changed node event. */ - static void - sp_object_repr_content_changed(Inkscape::XML::Node */*repr*/, gchar const */*oldcontent*/, gchar const */*newcontent*/, gpointer data) -void -SPObject::sp_object_repr_content_changed(Inkscape::XML::Node */*repr*/, gchar const */*oldcontent*/, gchar const */*newcontent*/, gpointer data) ++void SPObject::sp_object_repr_content_changed(Inkscape::XML::Node */*repr*/, gchar const */*oldcontent*/, gchar const */*newcontent*/, gpointer data) { SPObject *object = SP_OBJECT(data); -- if (((SPObjectClass *) G_OBJECT_GET_CLASS(object))->read_content) ++ if (((SPObjectClass *) G_OBJECT_GET_CLASS(object))->read_content) { (*((SPObjectClass *) G_OBJECT_GET_CLASS(object))->read_content)(object); ++ } } /** @@@ -1172,11 -1220,11 +1173,10 @@@ sp_xml_get_space_string(unsigned int sp /** * Callback for write event. */ - static Inkscape::XML::Node * - sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) -Inkscape::XML::Node * -SPObject::sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) ++Inkscape::XML::Node * SPObject::sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { if (!repr && (flags & SP_OBJECT_WRITE_BUILD)) { -- repr = SP_OBJECT_REPR(object)->duplicate(doc); ++ repr = object->getRepr()->duplicate(doc); if (!( flags & SP_OBJECT_WRITE_EXT )) { repr->setAttribute("inkscape:collect", NULL); } @@@ -1197,7 -1245,7 +1197,7 @@@ repr->setAttribute("inkscape:collect", NULL); } -- SPStyle const *const obj_style = SP_OBJECT_STYLE(object); ++ SPStyle const *const obj_style = object->style; if (obj_style) { gchar *s = sp_style_write_string(obj_style, SP_STYLE_FLAG_IFSET); repr->setAttribute("style", ( *s ? s : NULL )); @@@ -1236,10 -1284,10 +1236,9 @@@ /** * Update this object's XML node with flags value. */ --Inkscape::XML::Node * --SPObject::updateRepr(unsigned int flags) { -- if (!SP_OBJECT_IS_CLONED(this)) { -- Inkscape::XML::Node *repr=SP_OBJECT_REPR(this); ++Inkscape::XML::Node * SPObject::updateRepr(unsigned int flags) { ++ if ( !cloned ) { ++ Inkscape::XML::Node *repr = getRepr(); if (repr) { return updateRepr(repr->document(), repr, flags); } else { @@@ -1256,28 -1304,28 +1255,27 @@@ * reprs in another document (e.g. a temporary document used when * saving as "Plain SVG" */ --Inkscape::XML::Node * --SPObject::updateRepr(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags) { ++Inkscape::XML::Node * SPObject::updateRepr(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags) { g_assert(doc != NULL); -- if (SP_OBJECT_IS_CLONED(this)) { ++ if (cloned) { /* cloned objects have no repr */ return NULL; } if (((SPObjectClass *) G_OBJECT_GET_CLASS(this))->write) { if (!(flags & SP_OBJECT_WRITE_BUILD) && !repr) { -- repr = SP_OBJECT_REPR(this); ++ repr = getRepr(); } return ((SPObjectClass *) G_OBJECT_GET_CLASS(this))->write(this, doc, repr, flags); } else { g_warning("Class %s does not implement ::write", G_OBJECT_TYPE_NAME(this)); if (!repr) { if (flags & SP_OBJECT_WRITE_BUILD) { -- repr = SP_OBJECT_REPR(this)->duplicate(doc); ++ repr = getRepr()->duplicate(doc); } /// \todo FIXME: else probably error (Lauris) */ } else { -- repr->mergeFrom(SP_OBJECT_REPR(this), "id"); ++ repr->mergeFrom(getRepr(), "id"); } return repr; } @@@ -1290,8 -1338,8 +1288,7 @@@ * recursively add CHILD_MODIFIED flag to * parent and ancestors (as far up as necessary). */ --void --SPObject::requestDisplayUpdate(unsigned int flags) ++void SPObject::requestDisplayUpdate(unsigned int flags) { g_return_if_fail( this->document != NULL ); @@@ -1313,11 -1361,11 +1310,10 @@@ * don't need to set CHILD_MODIFIED on our ancestors because it's already been done. */ if (already_propagated) { -- SPObject *parent = SP_OBJECT_PARENT(this); if (parent) { parent->requestDisplayUpdate(SP_OBJECT_CHILD_MODIFIED_FLAG); } else { - sp_document_request_modified(SP_OBJECT_DOCUMENT(this)); - SP_OBJECT_DOCUMENT(this)->request_modified(); ++ document->requestModified(); } } } @@@ -1325,15 -1373,15 +1321,14 @@@ /** * Update views */ --void --SPObject::updateDisplay(SPCtx *ctx, unsigned int flags) ++void SPObject::updateDisplay(SPCtx *ctx, unsigned int flags) { g_return_if_fail(!(flags & ~SP_OBJECT_MODIFIED_CASCADE)); update_in_progress ++; #ifdef SP_OBJECT_DEBUG_CASCADE -- g_print("Update %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *) this), SP_OBJECT_ID(this), flags, this->uflags, this->mflags); ++ g_print("Update %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *) this), getId(), flags, this->uflags, this->mflags); #endif /* Get this flags */ @@@ -1357,8 -1405,8 +1352,9 @@@ try { -- if (((SPObjectClass *) G_OBJECT_GET_CLASS(this))->update) ++ if (((SPObjectClass *) G_OBJECT_GET_CLASS(this))->update) { ((SPObjectClass *) G_OBJECT_GET_CLASS(this))->update(this, ctx, flags); ++ } } catch(...) { @@@ -1378,8 -1426,8 +1374,7 @@@ * request display update, which trickles down and relies on the * flags set during this pass... */ --void --SPObject::requestModified(unsigned int flags) ++void SPObject::requestModified(unsigned int flags) { g_return_if_fail( this->document != NULL ); @@@ -1397,11 -1445,11 +1392,10 @@@ * don't need to set CHILD_MODIFIED on our ancestors because it's already been done. */ if (already_propagated) { -- SPObject *parent=SP_OBJECT_PARENT(this); if (parent) { parent->requestModified(SP_OBJECT_CHILD_MODIFIED_FLAG); } else { - sp_document_request_modified(SP_OBJECT_DOCUMENT(this)); - SP_OBJECT_DOCUMENT(this)->request_modified(); ++ document->requestModified(); } } } @@@ -1412,14 -1460,14 +1406,13 @@@ * later delivery here. Once emitModified() is called, those flags don't * need to be stored any longer. */ --void --SPObject::emitModified(unsigned int flags) ++void SPObject::emitModified(unsigned int flags) { /* only the MODIFIED_CASCADE flag is legal here */ g_return_if_fail(!(flags & ~SP_OBJECT_MODIFIED_CASCADE)); #ifdef SP_OBJECT_DEBUG_CASCADE -- g_print("Modified %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *) this), SP_OBJECT_ID(this), flags, this->uflags, this->mflags); ++ g_print("Modified %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *) this), getId(), flags, this->uflags, this->mflags); #endif flags |= this->mflags; @@@ -1437,54 -1485,67 +1430,62 @@@ g_object_unref(G_OBJECT(this)); } --gchar const * - sp_object_tagName_get(SPObject const *object, SPException *ex) -SPObject::getTagName(SPException *ex) const ++gchar const *SPObject::getTagName(SPException *ex) const { - g_assert(repr != NULL); ++ g_assert(repr != NULL); /* If exception is not clear, return */ if (!SP_EXCEPTION_IS_OK(ex)) { return NULL; } /// \todo fixme: Exception if object is NULL? */ - return object->repr->name(); - //XML Tree being used here. ++ //XML Tree being used here. + return getRepr()->name(); } --gchar const * - sp_object_getAttribute(SPObject const *object, gchar const *key, SPException *ex) -SPObject::getAttribute(gchar const *key, SPException *ex) const ++gchar const *SPObject::getAttribute(gchar const *key, SPException *ex) const { - g_assert(this->repr != NULL); ++ g_assert(this->repr != NULL); /* If exception is not clear, return */ if (!SP_EXCEPTION_IS_OK(ex)) { return NULL; } /// \todo fixme: Exception if object is NULL? */ - return (gchar const *) object->repr->attribute(key); - //XML Tree being used here. ++ //XML Tree being used here. + return (gchar const *) getRepr()->attribute(key); } --void - sp_object_setAttribute(SPObject *object, gchar const *key, gchar const *value, SPException *ex) -SPObject::setAttribute(gchar const *key, gchar const *value, SPException *ex) ++void SPObject::setAttribute(gchar const *key, gchar const *value, SPException *ex) { - g_assert(this->repr != NULL); ++ g_assert(this->repr != NULL); /* If exception is not clear, return */ g_return_if_fail(SP_EXCEPTION_IS_OK(ex)); /// \todo fixme: Exception if object is NULL? */ - object->repr->setAttribute(key, value, false); - //XML Tree being used here. ++ //XML Tree being used here. + getRepr()->setAttribute(key, value, false); } --void - sp_object_removeAttribute(SPObject *object, gchar const *key, SPException *ex) -SPObject::removeAttribute(gchar const *key, SPException *ex) ++void SPObject::removeAttribute(gchar const *key, SPException *ex) { /* If exception is not clear, return */ g_return_if_fail(SP_EXCEPTION_IS_OK(ex)); /// \todo fixme: Exception if object is NULL? */ - object->repr->setAttribute(key, NULL, false); - //XML Tree being used here. ++ //XML Tree being used here. + getRepr()->setAttribute(key, NULL, false); + } + + bool SPObject::storeAsDouble( gchar const *key, double *val ) const + { - g_assert(this->getRepr()!= NULL); - return sp_repr_get_double(((Inkscape::XML::Node *)(this->getRepr())),key,val); ++ g_assert(this->getRepr()!= NULL); ++ return sp_repr_get_double(((Inkscape::XML::Node *)(this->getRepr())),key,val); } /* Helper */ - static gchar * - sp_object_get_unique_id(SPObject *object, gchar const *id) -gchar * -SPObject::sp_object_get_unique_id(SPObject *object, gchar const *id) ++gchar * SPObject::sp_object_get_unique_id(SPObject *object, gchar const *id) { static unsigned long count = 0; @@@ -1492,7 -1553,8 +1493,8 @@@ count++; - gchar const *name = object->repr->name(); - //XML Tree being used here. ++ //XML Tree being used here. + gchar const *name = object->getRepr()->name(); g_assert(name != NULL); gchar const *local = strchr(name, ':'); @@@ -1549,14 -1611,15 +1551,14 @@@ * <use> element instead), we should probably make the caller * responsible for ascending the repr tree as necessary. */ --gchar const * - sp_object_get_style_property(SPObject const *object, gchar const *key, gchar const *def) -SPObject::getStyleProperty(gchar const *key, gchar const *def) const ++gchar const * SPObject::getStyleProperty(gchar const *key, gchar const *def) const { - g_return_val_if_fail(object != NULL, NULL); - g_return_val_if_fail(SP_IS_OBJECT(object), NULL); + //g_return_val_if_fail(object != NULL, NULL); + //g_return_val_if_fail(SP_IS_OBJECT(object), NULL); g_return_val_if_fail(key != NULL, NULL); - gchar const *style = object->repr->attribute("style"); - //XML Tree being used here. ++ //XML Tree being used here. + gchar const *style = getRepr()->attribute("style"); if (style) { size_t const len = strlen(key); char const *p; @@@ -1564,9 -1627,9 +1566,15 @@@ != NULL ) { p += len; -- while ((*p <= ' ') && *p) p++; -- if (*p++ != ':') break; -- while ((*p <= ' ') && *p) p++; ++ while ((*p <= ' ') && *p) { ++ p++; ++ } ++ if (*p++ != ':') { ++ break; ++ } ++ while ((*p <= ' ') && *p) { ++ p++; ++ } size_t const inherit_len = sizeof("inherit") - 1; if (*p && !(strneq(p, "inherit", inherit_len) @@@ -1577,7 -1640,9 +1585,9 @@@ } } } - gchar const *val = object->repr->attribute(key); + - //XML Tree being used here. ++ //XML Tree being used here. + gchar const *val = getRepr()->attribute(key); if (val && !streq(val, "inherit")) { return val; } @@@ -1591,8 -1656,8 +1601,7 @@@ /** * Lifts SVG version of all root objects to version. */ --void --SPObject::_requireSVGVersion(Inkscape::Version version) { ++void SPObject::_requireSVGVersion(Inkscape::Version version) { for ( SPObject::ParentIterator iter=this ; iter ; ++iter ) { SPObject *object=iter; if (SP_IS_ROOT(object)) { @@@ -1604,20 -1669,20 +1613,6 @@@ } } --/** -- * Returns previous object in sibling list or NULL. -- */ --SPObject * - sp_object_prev(SPObject *child) -SPObject::prev() --{ - SPObject *parent = SP_OBJECT_PARENT(child); - for ( SPObject *i = sp_object_first_child(parent); i; i = SP_OBJECT_NEXT(i) ) { - if (SP_OBJECT_NEXT(i) == child) - SPObject *parent = SP_OBJECT_PARENT(this); - for ( SPObject *i = parent->first_child(); i; i = SP_OBJECT_NEXT(i) ) { - if (SP_OBJECT_NEXT(i) == this) -- return i; -- } -- return NULL; --} -- /* Titles and descriptions */ /* Note: @@@ -1635,8 -1700,8 +1630,7 @@@ * The caller must free the returned string using g_free() - see comment * for getTitleOrDesc() below. */ --gchar * --SPObject::title() const ++gchar * SPObject::title() const { return getTitleOrDesc("svg:title"); } @@@ -1647,8 -1712,8 +1641,7 @@@ * (if any) should be deleted. * The second argument is optional - see setTitleOrDesc() below for details. */ --bool --SPObject::setTitle(gchar const *title, bool verbatim) ++bool SPObject::setTitle(gchar const *title, bool verbatim) { return setTitleOrDesc(title, "svg:title", verbatim); } @@@ -1658,8 -1723,8 +1651,7 @@@ * The caller must free the returned string using g_free() - see comment * for getTitleOrDesc() below. */ --gchar * --SPObject::desc() const ++gchar * SPObject::desc() const { return getTitleOrDesc("svg:desc"); } @@@ -1670,8 -1735,8 +1662,7 @@@ * description (if any) should be deleted. * The second argument is optional - see setTitleOrDesc() below for details. */ --bool --SPObject::setDesc(gchar const *desc, bool verbatim) ++bool SPObject::setDesc(gchar const *desc, bool verbatim) { return setTitleOrDesc(desc, "svg:desc", verbatim); } @@@ -1686,12 -1751,12 +1677,14 @@@ * Consequently, the return value is a newly allocated string (or NULL), and * must be freed (using g_free()) by the caller. */ --gchar * --SPObject::getTitleOrDesc(gchar const *svg_tagname) const ++gchar * SPObject::getTitleOrDesc(gchar const *svg_tagname) const { ++ gchar *result = 0; SPObject *elem = findFirstChild(svg_tagname); -- if (elem == NULL) return NULL; -- return g_string_free(elem->textualContent(), FALSE); ++ if ( elem ) { ++ result = g_string_free(elem->textualContent(), FALSE); ++ } ++ return result; } /** @@@ -1711,8 -1776,8 +1704,7 @@@ * The return value is true if a change was made to the title/description, * and usually false otherwise. */ --bool --SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool verbatim) ++bool SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool verbatim) { if (!verbatim) { // If the new title/description is just whitespace, @@@ -1725,7 -1790,7 +1717,9 @@@ break; } } -- if (just_whitespace) value = NULL; ++ if (just_whitespace) { ++ value = NULL; ++ } } // Don't stomp on mark-up if there is no real change. if (value) { @@@ -1733,7 -1798,7 +1727,9 @@@ if (current_value) { bool different = std::strcmp(current_value, value); g_free(current_value); -- if (!different) return false; ++ if (!different) { ++ return false; ++ } } } } @@@ -1741,7 -1806,7 +1737,9 @@@ SPObject *elem = findFirstChild(svg_tagname); if (value == NULL) { -- if (elem == NULL) return false; ++ if (elem == NULL) { ++ return false; ++ } // delete the title/description(s) while (elem) { elem->deleteObject(); @@@ -1750,7 -1815,7 +1748,7 @@@ return true; } -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); if (elem == NULL) { // create a new 'title' or 'desc' element, putting it at the @@@ -1775,13 -1840,13 +1773,14 @@@ * Find the first child of this object with a given tag name, * and return it. Returns NULL if there is no matching child. */ --SPObject * --SPObject::findFirstChild(gchar const *tagname) const ++SPObject * SPObject::findFirstChild(gchar const *tagname) const { for (SPObject *child = children; child; child = child->next) { if (child->repr->type() == Inkscape::XML::ELEMENT_NODE && -- !strcmp(child->repr->name(), tagname)) return child; ++ !strcmp(child->repr->name(), tagname)) { ++ return child; ++ } } return NULL; } @@@ -1791,8 -1856,8 +1790,7 @@@ * content except the tags). * Must not be used on anything except elements. */ --GString* --SPObject::textualContent() const ++GString * SPObject::textualContent() const { GString* text = g_string_new(""); diff --cc src/sp-object.h index 59cab2328,b7b3f9cc4..5d3183d9c --- a/src/sp-object.h +++ b/src/sp-object.h @@@ -6,6 -6,6 +6,8 @@@ * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -45,16 -53,15 +55,11 @@@ class SPObjectClass #define SP_OBJECT_WRITE_ALL (1 << 2) /* Convenience stuff */ --#define SP_OBJECT_ID(o) (((SPObject *) (o))->getId()) - #define SP_OBJECT_REPR(o) (((SPObject *) (o))->repr) + #define SP_OBJECT_REPR(o) (((SPObject *) (o))->getRepr()) #define SP_OBJECT_DOCUMENT(o) (((SPObject *) (o))->document) #define SP_OBJECT_PARENT(o) (((SPObject *) (o))->parent) --#define SP_OBJECT_NEXT(o) (((SPObject *) (o))->next) - #define SP_OBJECT_PREV(o) (sp_object_prev((SPObject *) (o))) -#define SP_OBJECT_PREV(o) (((SPObject *) (o))->prev()) --#define SP_OBJECT_HREFCOUNT(o) (((SPObject *) (o))->hrefcount) #define SP_OBJECT_STYLE(o) (((SPObject *) (o))->style) - #include <glib-object.h> #include <sigc++/connection.h> #include <sigc++/functors/slot.h> @@@ -137,7 -145,8 +143,8 @@@ SPObject *sp_object_href(SPObject *obje SPObject *sp_object_hunref(SPObject *object, gpointer owner); /// A refcounting tree node object. - struct SPObject : public GObject { + class SPObject : public GObject { - public: ++public: enum CollectionPolicy { COLLECT_WITH_PARENT, ALWAYS_COLLECT @@@ -154,7 -163,7 +161,6 @@@ SPObject *children; /* Our children */ SPObject *_last_child; /* Remembered last child */ SPObject *next; /* Next object in linked list */ - Inkscape::XML::Node *repr; /* Our xml representation */ - //Inkscape::XML::Node *repr; /* Our xml representation */ private: gchar *id; /* Our very own unique id */ @@@ -165,6 -175,19 +172,20 @@@ public */ gchar const* getId() const; - /** - * Returns the XML representation of tree - */ - //Inkscape::XML::Node const* getRepr() const; -//protected: - Inkscape::XML::Node * getRepr(); - - /** - * Returns the XML representation of tree - */ - Inkscape::XML::Node const* getRepr() const; -public: - ++ /** ++ * Returns the XML representation of tree ++ */ ++ //Inkscape::XML::Node const* getRepr() const; ++//protected: ++ Inkscape::XML::Node * getRepr(); ++ ++ /** ++ * Returns the XML representation of tree ++ */ ++ Inkscape::XML::Node const* getRepr() const; ++ ++public: ++ /** @brief cleans up an SPObject, releasing its references and * requesting that references to it be released */ @@@ -221,18 -244,18 +242,28 @@@ /* A non-const version can be similarly constructed if you want one. * (Don't just cast away the constness, which would be ill-formed.) */ -- SPObject *getNext(); ++ SPObject *getNext() {return next;} ++ SPObject const *getNext() const {return next;} ++ ++ /** ++ * Returns previous object in sibling list or NULL. ++ */ SPObject *getPrev(); bool hasChildren() const { return ( children != NULL ); } SPObject *firstChild() { return children; } SPObject const *firstChild() const { return children; } ++ SPObject *lastChild() { return _last_child; } SPObject const *lastChild() const { return _last_child; } enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow }; -- /** @brief Retrieves children as a GSList */ ++ ++ /** ++ * Retrieves the children as a GSList object, optionally ref'ing the children ++ * in the process, if add_ref is specified. ++ */ GSList *childList(bool add_ref, Action action = ActionGeneral); SPObject *appendChildRepr(Inkscape::XML::Node *repr); @@@ -482,7 -505,7 +513,9 @@@ return _modified_signal.connect(slot); } ++ /** Sends the delete signal to all children of this object recursively */ void _sendDeleteSignalRecursive(); ++ void _updateTotalHRefCount(int increment); void _requireSVGVersion(unsigned major, unsigned minor) { @@@ -498,6 -521,29 +531,25 @@@ CollectionPolicy _collection_policy; gchar *_label; mutable gchar *_default_label; - void attach(SPObject *object, SPObject *prev); - void reorder(SPObject *prev); - void detach(SPObject *object); - SPObject *get_child_by_repr(Inkscape::XML::Node *repr); - SPObject *first_child() { - return firstChild(); - } - void invoke_build(SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned); - long long int getIntAttribute(char const *key, long long int def); - unsigned getPosition(); - gchar const * getAttribute(gchar const *name,SPException *ex=0) const; - void appendChild(Inkscape::XML::Node *child); - void addChild(Inkscape::XML::Node *child,Inkscape::XML::Node *prev=0); - void setKeyValue(unsigned int key, gchar const *value); - void setAttribute(gchar const *key, gchar const *value, SPException *ex=0); - void readAttr(gchar const *key); - gchar const *getTagName(SPException *ex) const; - void removeAttribute(gchar const *key, SPException *ex=0); - gchar const *getStyleProperty(gchar const *key, gchar const *def) const; - SPObject *prev(); - void setCSS(SPCSSAttr *css, gchar const *attr); - void changeCSS(SPCSSAttr *css, gchar const *attr); - bool storeAsDouble( gchar const *key, double *val ) const; ++ void attach(SPObject *object, SPObject *prev); ++ void reorder(SPObject *prev); ++ void detach(SPObject *object); ++ SPObject *get_child_by_repr(Inkscape::XML::Node *repr); ++ void invoke_build(SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned); ++ long long int getIntAttribute(char const *key, long long int def); ++ unsigned getPosition(); ++ gchar const * getAttribute(gchar const *name,SPException *ex=0) const; ++ void appendChild(Inkscape::XML::Node *child); ++ void addChild(Inkscape::XML::Node *child,Inkscape::XML::Node *prev=0); ++ void setKeyValue(unsigned int key, gchar const *value); ++ void setAttribute(gchar const *key, gchar const *value, SPException *ex=0); ++ void readAttr(gchar const *key); ++ gchar const *getTagName(SPException *ex) const; ++ void removeAttribute(gchar const *key, SPException *ex=0); ++ gchar const *getStyleProperty(gchar const *key, gchar const *def) const; ++ void setCSS(SPCSSAttr *css, gchar const *attr); ++ void changeCSS(SPCSSAttr *css, gchar const *attr); ++ bool storeAsDouble( gchar const *key, double *val ) const; private: // Private member functions used in the definitions of setTitle(), @@@ -507,11 -553,41 +559,41 @@@ SPObject * findFirstChild(gchar const *tagname) const; GString * textualContent() const; - static void sp_object_init(SPObject *object); - static void sp_object_finalize(GObject *object); ++ static void sp_object_init(SPObject *object); ++ static void sp_object_finalize(GObject *object); + - static void sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); - static void sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child); - static void sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref); ++ static void sp_object_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); ++ static void sp_object_remove_child(SPObject *object, Inkscape::XML::Node *child); ++ static void sp_object_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref); + - static void sp_object_release(SPObject *object); - static void sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); ++ static void sp_object_release(SPObject *object); ++ static void sp_object_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); + - static void sp_object_private_set(SPObject *object, unsigned int key, gchar const *value); - static Inkscape::XML::Node *sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - static gchar *sp_object_get_unique_id(SPObject *object, gchar const *defid); ++ static void sp_object_private_set(SPObject *object, unsigned int key, gchar const *value); ++ static Inkscape::XML::Node *sp_object_private_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); ++ static gchar *sp_object_get_unique_id(SPObject *object, gchar const *defid); + - /* Real handlers of repr signals */ - - public: - static GType sp_object_get_type(); - static void sp_object_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data); ++ /* Real handlers of repr signals */ + - static void sp_object_repr_content_changed(Inkscape::XML::Node *repr, gchar const *oldcontent, gchar const *newcontent, gpointer data); ++public: ++ static GType sp_object_get_type(); ++ static void sp_object_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gchar const *oldval, gchar const *newval, bool is_interactive, gpointer data); ++ ++ static void sp_object_repr_content_changed(Inkscape::XML::Node *repr, gchar const *oldcontent, gchar const *newcontent, gpointer data); + - static void sp_object_repr_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data); - static void sp_object_repr_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void *data); ++ static void sp_object_repr_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data); ++ static void sp_object_repr_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void *data); + - static void sp_object_repr_order_changed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data); ++ static void sp_object_repr_order_changed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *newer, gpointer data); + + - friend class SPObjectClass; ++ friend class SPObjectClass; friend class SPObjectImpl; }; /// The SPObject vtable. - struct SPObjectClass { + class SPObjectClass { - public: ++public: GObjectClass parent_class; void (* build) (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr); @@@ -533,44 -609,50 +615,17 @@@ void (* modified) (SPObject *object, unsigned int flags); Inkscape::XML::Node * (* write) (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags); - }; - - /* - * Attaching/detaching - */ - - void sp_object_attach(SPObject *parent, SPObject *object, SPObject *prev); - void sp_object_reorder(SPObject *object, SPObject *prev); - void sp_object_detach(SPObject *parent, SPObject *object); - - inline SPObject *sp_object_first_child(SPObject *parent) { - return parent->firstChild(); - } - SPObject *sp_object_get_child_by_repr(SPObject *object, Inkscape::XML::Node *repr); - - void sp_object_invoke_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned); - - void sp_object_set(SPObject *object, unsigned int key, gchar const *value); - - void sp_object_read_attr(SPObject *object, gchar const *key); - - /* Public */ - - gchar const *sp_object_tagName_get(SPObject const *object, SPException *ex); - gchar const *sp_object_getAttribute(SPObject const *object, gchar const *key, SPException *ex); - void sp_object_setAttribute(SPObject *object, gchar const *key, gchar const *value, SPException *ex); - void sp_object_removeAttribute(SPObject *object, gchar const *key, SPException *ex); - private: - static GObjectClass *static_parent_class; - static void sp_object_class_init(SPObjectClass *klass); ++private: ++ static GObjectClass *static_parent_class; ++ static void sp_object_class_init(SPObjectClass *klass); - /* Style */ - friend class SPObject; ++ friend class SPObject; + }; - gchar const *sp_object_get_style_property(SPObject const *object, - gchar const *key, gchar const *def); -/* - * Attaching/detaching - */ - -//void sp_object_attach(SPObject *parent, SPObject *object, SPObject *prev); -//void sp_object_reorder(SPObject *object, SPObject *prev); -//void sp_object_detach(SPObject *parent, SPObject *object); - -/*inline SPObject *sp_object_first_child(SPObject *parent) { - return parent->firstChild(); -}*/ -//SPObject *sp_object_get_child_by_repr(SPObject *object, Inkscape::XML::Node *repr); - -//void sp_object_invoke_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned); - -//void sp_object_set(SPObject *object, unsigned int key, gchar const *value); - -//void sp_object_read_attr(SPObject *object, gchar const *key); - -/* Public */ - -//gchar const *sp_object_tagName_get(SPObject const *object, SPException *ex); -//gchar const *sp_object_getAttribute(SPObject const *object, gchar const *key, SPException *ex); -//void sp_object_setAttribute(SPObject *object, gchar const *key, gchar const *value, SPException *ex); -//void sp_object_removeAttribute(SPObject *object, gchar const *key, SPException *ex); - -/* Style */ - -//gchar const *sp_object_get_style_property(SPObject const *object, -// gchar const *key, gchar const *def); - int sp_object_compare_position(SPObject const *first, SPObject const *second); - SPObject *sp_object_prev(SPObject *child); -//SPObject *sp_object_prev(SPObject *child); -- #endif // SP_OBJECT_H_SEEN diff --cc src/sp-offset.cpp index a43bc873d,449d7d44d..51bb1e1cc --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_OFFSET_C__ -- /** \file * Implementation of <path sodipodi:type="inkscape:offset">. */ @@@ -8,6 -8,6 +6,7 @@@ * Authors: (of the sp-spiral.c upon which this file was constructed): * Mitsuru Oka <oka326@parkcity.ne.jp> * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -217,39 -217,44 +216,42 @@@ sp_offset_build(SPObject *object, SPDoc if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build (object, document, repr); - if (object->repr->attribute("inkscape:radius")) { - sp_object_read_attr (object, "inkscape:radius"); - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + if (object->getRepr()->attribute("inkscape:radius")) { - object->readAttr( "inkscape:radius"); ++ object->readAttr( "inkscape:radius" ); } else { - gchar const *oldA = object->repr->attribute("sodipodi:radius"); - object->repr->setAttribute("inkscape:radius",oldA); - object->repr->setAttribute("sodipodi:radius",NULL); - - - //XML Tree being used directly here (as object->getRepr) - //in all the below lines in the block while it shouldn't be. ++ //XML Tree being used directly here (as object->getRepr) ++ //in all the below lines in the block while it shouldn't be. + gchar const *oldA = object->getRepr()->attribute("sodipodi:radius"); + object->getRepr()->setAttribute("inkscape:radius",oldA); + object->getRepr()->setAttribute("sodipodi:radius",NULL); - sp_object_read_attr (object, "inkscape:radius"); - object->readAttr( "inkscape:radius"); ++ object->readAttr( "inkscape:radius" ); } - if (object->repr->attribute("inkscape:original")) { - sp_object_read_attr (object, "inkscape:original"); + if (object->getRepr()->attribute("inkscape:original")) { - object->readAttr( "inkscape:original"); ++ object->readAttr( "inkscape:original" ); } else { - gchar const *oldA = object->repr->attribute("sodipodi:original"); - object->repr->setAttribute("inkscape:original",oldA); - object->repr->setAttribute("sodipodi:original",NULL); + gchar const *oldA = object->getRepr()->attribute("sodipodi:original"); + object->getRepr()->setAttribute("inkscape:original",oldA); + object->getRepr()->setAttribute("sodipodi:original",NULL); - sp_object_read_attr (object, "inkscape:original"); - object->readAttr( "inkscape:original"); ++ object->readAttr( "inkscape:original" ); } - if (object->repr->attribute("xlink:href")) { - sp_object_read_attr(object, "xlink:href"); + if (object->getRepr()->attribute("xlink:href")) { - object->readAttr( "xlink:href"); ++ object->readAttr( "xlink:href" ); } else { - gchar const *oldA = object->repr->attribute("inkscape:href"); + gchar const *oldA = object->getRepr()->attribute("inkscape:href"); if (oldA) { size_t lA = strlen(oldA); char *nA=(char*)malloc((1+lA+1)*sizeof(char)); memcpy(nA+1,oldA,lA*sizeof(char)); nA[0]='#'; nA[lA+1]=0; - object->repr->setAttribute("xlink:href",nA); + object->getRepr()->setAttribute("xlink:href",nA); free(nA); - object->repr->setAttribute("inkscape:href",NULL); + object->getRepr()->setAttribute("inkscape:href",NULL); } - sp_object_read_attr (object, "xlink:href"); - object->readAttr( "xlink:href"); ++ object->readAttr( "xlink:href" ); } } @@@ -454,7 -459,8 +456,8 @@@ sp_offset_set_shape(SPShape *shape // just put the source shape as the offseted one, no one will notice // it's also useless to compute the offset with a 0 radius - const char *res_d = SP_OBJECT(shape)->repr->attribute("inkscape:original"); - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + const char *res_d = SP_OBJECT(shape)->getRepr()->attribute("inkscape:original"); if ( res_d ) { Geom::PathVector pv = sp_svg_read_pathv(res_d); SPCurve *c = new SPCurve(pv); @@@ -1145,7 -1151,8 +1148,8 @@@ refresh_offset_source(SPOffset* offset delete res; delete orig; - SP_OBJECT (offset)->repr->setAttribute("inkscape:original", res_d); - //XML Tree being used diectly here while it shouldn't be. ++ //XML Tree being used diectly here while it shouldn't be. + SP_OBJECT (offset)->getRepr()->setAttribute("inkscape:original", res_d); free (res_d); } diff --cc src/sp-path.cpp index 54d2a201a,d98647b11..66a70e0f1 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@@ -1,11 -1,11 +1,10 @@@ --#define __SP_PATH_C__ -- /* * SVG <path> implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * David Turner <novalis@gnu.org> ++ * Abhishek Sharma * * Copyright (C) 2004 David Turner * Copyright (C) 1999-2002 Lauris Kaplinski @@@ -214,10 -214,10 +213,10 @@@ static voi sp_path_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { /* Are these calls actually necessary? */ - sp_object_read_attr(object, "marker"); - sp_object_read_attr(object, "marker-start"); - sp_object_read_attr(object, "marker-mid"); - sp_object_read_attr(object, "marker-end"); - object->readAttr( "marker"); - object->readAttr( "marker-start"); - object->readAttr( "marker-mid"); - object->readAttr( "marker-end"); ++ object->readAttr( "marker" ); ++ object->readAttr( "marker-start" ); ++ object->readAttr( "marker-mid" ); ++ object->readAttr( "marker-end" ); sp_conn_end_pair_build(object); @@@ -225,13 -225,13 +224,13 @@@ ((SPObjectClass *) parent_class)->build(object, document, repr); } - sp_object_read_attr(object, "inkscape:original-d"); - sp_object_read_attr(object, "d"); - object->readAttr( "inkscape:original-d"); - object->readAttr( "d"); ++ object->readAttr( "inkscape:original-d" ); ++ object->readAttr( "d" ); /* d is a required attribute */ - gchar const *d = sp_object_getAttribute(object, "d", NULL); + gchar const *d = object->getAttribute("d", NULL); if (d == NULL) { - sp_object_set(object, sp_attribute_lookup("d"), ""); + object->setKeyValue( sp_attribute_lookup("d"), ""); } } diff --cc src/sp-pattern.cpp index a2fc9a6b2,779edc3e8..fbba4cc48 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@@ -1,11 -1,11 +1,11 @@@ --#define __SP_PATTERN_C__ -- /* * SVG <pattern> implementation * * Author: * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2002 Lauris Kaplinski * @@@ -156,18 -156,18 +156,18 @@@ sp_pattern_build (SPObject *object, SPD if (((SPObjectClass *) pattern_parent_class)->build) (* ((SPObjectClass *) pattern_parent_class)->build) (object, document, repr); - sp_object_read_attr (object, "patternUnits"); - sp_object_read_attr (object, "patternContentUnits"); - sp_object_read_attr (object, "patternTransform"); - sp_object_read_attr (object, "x"); - sp_object_read_attr (object, "y"); - sp_object_read_attr (object, "width"); - sp_object_read_attr (object, "height"); - sp_object_read_attr (object, "viewBox"); - sp_object_read_attr (object, "xlink:href"); - object->readAttr( "patternUnits"); - object->readAttr( "patternContentUnits"); - object->readAttr( "patternTransform"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "width"); - object->readAttr( "height"); - object->readAttr( "viewBox"); - object->readAttr( "xlink:href"); ++ object->readAttr( "patternUnits" ); ++ object->readAttr( "patternContentUnits" ); ++ object->readAttr( "patternTransform" ); ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "width" ); ++ object->readAttr( "height" ); ++ object->readAttr( "viewBox" ); ++ object->readAttr( "xlink:href" ); /* Register ourselves */ - sp_document_add_resource (document, "pattern", object); - document->add_resource ("pattern", object); ++ document->addResource("pattern", object); } static void @@@ -179,7 -179,7 +179,7 @@@ sp_pattern_release (SPObject *object if (SP_OBJECT_DOCUMENT (object)) { /* Unregister ourselves */ - sp_document_remove_resource (SP_OBJECT_DOCUMENT (object), "pattern", SP_OBJECT (object)); - SP_OBJECT_DOCUMENT (object)->remove_resource ("pattern", SP_OBJECT (object)); ++ SP_OBJECT_DOCUMENT (object)->removeResource("pattern", SP_OBJECT (object)); } if (pat->ref) { @@@ -347,21 -347,21 +347,20 @@@ sp_pattern_child_added (SPObject *objec /* fixme: We need ::order_changed handler too (Lauris) */ --GSList * --pattern_getchildren (SPPattern *pat) ++GSList *pattern_getchildren(SPPattern *pat) { -- GSList *l = NULL; -- -- for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (sp_object_first_child(SP_OBJECT(pat_i))) { // find the first one with children - for (SPObject *child = sp_object_first_child(SP_OBJECT (pat)) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - if (SP_OBJECT(pat_i)->first_child()) { // find the first one with children - for (SPObject *child = SP_OBJECT (pat)->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- l = g_slist_prepend (l, child); -- } -- break; // do not go further up the chain if children are found -- } ++ GSList *l = NULL; ++ ++ for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { ++ if (pat_i->firstChild()) { // find the first one with children ++ for (SPObject *child = pat->firstChild() ; child ; child = child->getNext() ) { ++ l = g_slist_prepend (l, child); ++ } ++ break; // do not go further up the chain if children are found } ++ } -- return l; ++ return l; } static void @@@ -435,47 -435,17 +434,45 @@@ pattern_ref_modified (SPObject */*ref*/ /* Conditional to avoid causing infinite loop if there's a cycle in the href chain. */ } + +/** +Count how many times pat is used by the styles of o and its descendants +*/ guint -pattern_users (SPPattern *pattern) +count_pattern_hrefs(SPObject *o, SPPattern *pat) { - return SP_OBJECT (pattern)->hrefcount; + if (!o) + return 1; + + guint i = 0; + + SPStyle *style = SP_OBJECT_STYLE(o); + if (style + && style->fill.isPaintserver() + && SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style)) + && SP_PATTERN(SP_STYLE_FILL_SERVER(style)) == pat) + { + i ++; + } + if (style + && style->stroke.isPaintserver() + && SP_IS_PATTERN(SP_STYLE_STROKE_SERVER(style)) + && SP_PATTERN(SP_STYLE_STROKE_SERVER(style)) == pat) + { + i ++; + } + - for (SPObject *child = sp_object_first_child(o); - child != NULL; child = SP_OBJECT_NEXT(child)) { ++ for ( SPObject *child = o->firstChild(); child != NULL; child = child->next ) { + i += count_pattern_hrefs(child, pat); + } + + return i; } --SPPattern * --pattern_chain (SPPattern *pattern) ++SPPattern *pattern_chain(SPPattern *pattern) { SPDocument *document = SP_OBJECT_DOCUMENT (pattern); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document)); Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern"); @@@ -495,7 -465,7 +492,7 @@@ SPPattern * sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const gchar *property) { - if (!pattern->href || SP_OBJECT_HREFCOUNT(pattern) > count_pattern_hrefs(item, pattern)) { - if (pattern_users(pattern) > 1) { ++ if (!pattern->href || pattern->hrefcount > count_pattern_hrefs(item, pattern)) { pattern = pattern_chain (pattern); gchar *href = g_strconcat ("url(#", SP_OBJECT_REPR (pattern)->attribute("id"), ")", NULL); @@@ -526,10 -496,10 +523,9 @@@ sp_pattern_transform_multiply (SPPatter g_free(c); } --const gchar * --pattern_tile (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Matrix transform, Geom::Matrix move) ++const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Matrix transform, Geom::Matrix move) { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document)); Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern"); @@@ -561,15 -531,15 +557,14 @@@ return pat_id; } --SPPattern * --pattern_getroot (SPPattern *pat) ++SPPattern *pattern_getroot(SPPattern *pat) { -- for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (sp_object_first_child(SP_OBJECT(pat_i))) { // find the first one with children - if (SP_OBJECT (pat_i)->first_child()) { // find the first one with children -- return pat_i; -- } -- } -- return pat; // document is broken, we can't get to root; but at least we can return pat which is supposedly a valid pattern ++ for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { ++ if ( pat_i->firstChild() ) { // find the first one with children ++ return pat_i; ++ } ++ } ++ return pat; // document is broken, we can't get to root; but at least we can return pat which is supposedly a valid pattern } @@@ -651,12 -621,12 +646,13 @@@ NRRect *pattern_viewBox (SPPattern *pat bool pattern_hasItemChildren (SPPattern *pat) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(pat)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = SP_OBJECT (pat)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { -- if (SP_IS_ITEM (child)) { -- return true; -- } -- } -- return false; ++ bool hasChildren = false; ++ for (SPObject *child = pat->firstChild() ; child && !hasChildren ; child = child->getNext() ) { ++ if (SP_IS_ITEM(child)) { ++ hasChildren = true; ++ } ++ } ++ return hasChildren; } @@@ -763,24 -733,24 +759,23 @@@ sp_pattern_painter_new (SPPaintServer * pp->root = NRArenaGroup::create(pp->arena); /* Show items */ -- pp->_release_connections = new std::map<SPObject *, sigc::connection>; -- for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { -- if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children - for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = SP_OBJECT (pat_i)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { -- if (SP_IS_ITEM (child)) { -- // for each item in pattern, -- NRArenaItem *cai; -- // show it on our arena, - cai = sp_item_invoke_show (SP_ITEM (child), pp->arena, pp->dkey, SP_ITEM_REFERENCE_FLAGS); - cai = SP_ITEM (child)->invoke_show (pp->arena, pp->dkey, SP_ITEM_REFERENCE_FLAGS); -- // add to the group, -- nr_arena_item_append_child (pp->root, cai); -- // and connect to the release signal in case the item gets deleted -- pp->_release_connections->insert(std::make_pair(child, child->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_pattern_painter_release), pp)))); -- } -- } -- break; // do not go further up the chain if children are found -- } -- } ++ pp->_release_connections = new std::map<SPObject *, sigc::connection>; ++ for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { ++ if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children ++ for (SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) { ++ if (SP_IS_ITEM (child)) { ++ // for each item in pattern, ++ // show it on our arena, ++ NRArenaItem *cai = SP_ITEM(child)->invoke_show(pp->arena, pp->dkey, SP_ITEM_REFERENCE_FLAGS); ++ // add to the group, ++ nr_arena_item_append_child (pp->root, cai); ++ // and connect to the release signal in case the item gets deleted ++ pp->_release_connections->insert(std::make_pair(child, child->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_pattern_painter_release), pp)))); ++ } ++ } ++ break; // do not go further up the chain if children are found ++ } ++ } { NRRect one_tile,tr_tile; @@@ -1046,3 -1016,3 +1041,15 @@@ sp_pat_fill (SPPainter *painter, NRPixB } } } ++ ++ ++/* ++ Local Variables: ++ mode:c++ ++ c-file-style:"stroustrup" ++ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) ++ indent-tabs-mode:nil ++ fill-column:99 ++ End: ++*/ ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --cc src/sp-pattern.h index cf716b2f8,be926aabb..f50504a76 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@@ -1,11 -1,11 +1,12 @@@ --#ifndef __SP_PATTERN_H__ --#define __SP_PATTERN_H__ ++#ifndef SEEN_SP_PATTERN_H ++#define SEEN_SP_PATTERN_H /* * SVG <pattern> implementation * * Author: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 2002 Lauris Kaplinski * @@@ -99,7 -99,7 +100,7 @@@ gdouble pattern_width (SPPattern *pat) gdouble pattern_height (SPPattern *pat); NRRect *pattern_viewBox (SPPattern *pat); --#endif //__SP_PATTERN_H__ ++#endif // SEEN_SP_PATTERN_H /* Local Variables: diff --cc src/sp-polygon.cpp index 014c68c9b,d5e10e10f..1067da72e --- a/src/sp-polygon.cpp +++ b/src/sp-polygon.cpp @@@ -1,10 -1,10 +1,9 @@@ --#define __SP_POLYGON_C__ -- /* * SVG <polygon> implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -84,7 -84,7 +83,7 @@@ static void sp_polygon_build(SPObject * ((SPObjectClass *) parent_class)->build(object, document, repr); } - sp_object_read_attr(object, "points"); - object->readAttr( "points"); ++ object->readAttr( "points" ); } diff --cc src/sp-polyline.cpp index 08f446d61,5bf40352d..d0954f239 --- a/src/sp-polyline.cpp +++ b/src/sp-polyline.cpp @@@ -1,10 -1,10 +1,10 @@@ --#define __SP_POLYLINE_C__ -- /* * SVG <polyline> implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma ++ * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 1999-2002 Lauris Kaplinski * @@@ -20,159 -20,161 +20,150 @@@ #include "xml/repr.h" #include "document.h" - static void sp_polyline_class_init (SPPolyLineClass *klass); - static void sp_polyline_init (SPPolyLine *polyline); -//static void sp_polyline_class_init (SPPolyLineClass *klass); -//static void sp_polyline_init (SPPolyLine *polyline); -- - static void sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); - static void sp_polyline_set (SPObject *object, unsigned int key, const gchar *value); - static Inkscape::XML::Node *sp_polyline_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -//static void sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); -//static void sp_polyline_set (SPObject *object, unsigned int key, const gchar *value); -//static Inkscape::XML::Node *sp_polyline_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -- - static gchar * sp_polyline_description (SPItem * item); -//static gchar * sp_polyline_description (SPItem * item); -- - static SPShapeClass *parent_class; -//static SPShapeClass *parent_class; - + SPShapeClass * SPPolyLineClass::static_parent_class=0; --GType - sp_polyline_get_type (void) -SPPolyLine::sp_polyline_get_type (void) ++GType SPPolyLine::sp_polyline_get_type(void) { -- static GType polyline_type = 0; -- -- if (!polyline_type) { -- GTypeInfo polyline_info = { -- sizeof (SPPolyLineClass), -- NULL, /* base_init */ -- NULL, /* base_finalize */ - (GClassInitFunc) sp_polyline_class_init, - (GClassInitFunc) SPPolyLineClass::sp_polyline_class_init, -- NULL, /* klass_finalize */ -- NULL, /* klass_data */ -- sizeof (SPPolyLine), -- 16, /* n_preallocs */ -- (GInstanceInitFunc) sp_polyline_init, -- NULL, /* value_table */ -- }; -- polyline_type = g_type_register_static (SP_TYPE_SHAPE, "SPPolyLine", &polyline_info, (GTypeFlags)0); -- } -- return polyline_type; ++ static GType polyline_type = 0; ++ ++ if (!polyline_type) { ++ GTypeInfo polyline_info = { ++ sizeof (SPPolyLineClass), ++ NULL, /* base_init */ ++ NULL, /* base_finalize */ ++ (GClassInitFunc) SPPolyLineClass::sp_polyline_class_init, ++ NULL, /* klass_finalize */ ++ NULL, /* klass_data */ ++ sizeof (SPPolyLine), ++ 16, /* n_preallocs */ ++ (GInstanceInitFunc) SPPolyLine::init, ++ NULL, /* value_table */ ++ }; ++ polyline_type = g_type_register_static (SP_TYPE_SHAPE, "SPPolyLine", &polyline_info, (GTypeFlags)0); ++ } ++ return polyline_type; } - static void - sp_polyline_class_init (SPPolyLineClass *klass) -void -SPPolyLineClass::sp_polyline_class_init (SPPolyLineClass *klass) ++void SPPolyLineClass::sp_polyline_class_init(SPPolyLineClass *klass) { -- GObjectClass * gobject_class; -- SPObjectClass * sp_object_class; -- SPItemClass * item_class; - - gobject_class = (GObjectClass *) klass; - sp_object_class = (SPObjectClass *) klass; - item_class = (SPItemClass *) klass; ++ GObjectClass * gobject_class = (GObjectClass *) klass; ++ SPObjectClass * sp_object_class = (SPObjectClass *) klass; ++ SPItemClass * item_class = (SPItemClass *) klass; - parent_class = (SPShapeClass *)g_type_class_ref (SP_TYPE_SHAPE); - gobject_class = (GObjectClass *) klass; - sp_object_class = (SPObjectClass *) klass; - item_class = (SPItemClass *) klass; ++ static_parent_class = (SPShapeClass *)g_type_class_ref(SP_TYPE_SHAPE); - sp_object_class->build = sp_polyline_build; - sp_object_class->set = sp_polyline_set; - sp_object_class->write = sp_polyline_write; - static_parent_class = (SPShapeClass *)g_type_class_ref (SP_TYPE_SHAPE); ++ sp_object_class->build = SPPolyLine::build; ++ sp_object_class->set = SPPolyLine::set; ++ sp_object_class->write = SPPolyLine::write; - item_class->description = sp_polyline_description; - sp_object_class->build = SPPolyLine::sp_polyline_build; - sp_object_class->set = SPPolyLine::sp_polyline_set; - sp_object_class->write = SPPolyLine::sp_polyline_write; - - item_class->description = SPPolyLine::sp_polyline_description; ++ item_class->description = SPPolyLine::getDescription; } - static void - sp_polyline_init (SPPolyLine * /*polyline*/) -void -SPPolyLine::sp_polyline_init (SPPolyLine * /*polyline*/) ++void SPPolyLine::init(SPPolyLine * /*polyline*/) { /* Nothing here */ } - static void - sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) -void -SPPolyLine::sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) ++void SPPolyLine::build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { - if (((SPObjectClass *) parent_class)->build) - ((SPObjectClass *) parent_class)->build (object, document, repr); - if (((SPObjectClass *) SPPolyLineClass::static_parent_class)->build) - ((SPObjectClass *) SPPolyLineClass::static_parent_class)->build (object, document, repr); ++ if (((SPObjectClass *) SPPolyLineClass::static_parent_class)->build) { ++ ((SPObjectClass *) SPPolyLineClass::static_parent_class)->build (object, document, repr); ++ } - sp_object_read_attr (object, "points"); - object->readAttr( "points"); ++ object->readAttr( "points" ); } - static void - sp_polyline_set (SPObject *object, unsigned int key, const gchar *value) -void -SPPolyLine::sp_polyline_set (SPObject *object, unsigned int key, const gchar *value) ++void SPPolyLine::set(SPObject *object, unsigned int key, const gchar *value) { -- SPPolyLine *polyline; -- -- polyline = SP_POLYLINE (object); ++ SPPolyLine *polyline = SP_POLYLINE(object); -- switch (key) { ++ switch (key) { case SP_ATTR_POINTS: { -- SPCurve * curve; -- const gchar * cptr; -- char * eptr; -- gboolean hascpt; -- -- if (!value) break; -- curve = new SPCurve (); -- hascpt = FALSE; -- -- cptr = value; -- eptr = NULL; -- -- while (TRUE) { -- gdouble x, y; -- -- while (*cptr != '\0' && (*cptr == ',' || *cptr == '\x20' || *cptr == '\x9' || *cptr == '\xD' || *cptr == '\xA')) { -- cptr++; -- } -- if (!*cptr) break; -- -- x = g_ascii_strtod (cptr, &eptr); -- if (eptr == cptr) break; -- cptr = eptr; -- -- while (*cptr != '\0' && (*cptr == ',' || *cptr == '\x20' || *cptr == '\x9' || *cptr == '\xD' || *cptr == '\xA')) { -- cptr++; -- } -- if (!*cptr) break; -- -- y = g_ascii_strtod (cptr, &eptr); -- if (eptr == cptr) break; -- cptr = eptr; -- if (hascpt) { -- curve->lineto(x, y); -- } else { -- curve->moveto(x, y); -- hascpt = TRUE; -- } -- } ++ SPCurve * curve; ++ const gchar * cptr; ++ char * eptr; ++ gboolean hascpt; ++ ++ if (!value) break; ++ curve = new SPCurve (); ++ hascpt = FALSE; ++ ++ cptr = value; ++ eptr = NULL; ++ ++ while (TRUE) { ++ gdouble x, y; ++ ++ while (*cptr != '\0' && (*cptr == ',' || *cptr == '\x20' || *cptr == '\x9' || *cptr == '\xD' || *cptr == '\xA')) { ++ cptr++; ++ } ++ if (!*cptr) break; ++ ++ x = g_ascii_strtod (cptr, &eptr); ++ if (eptr == cptr) break; ++ cptr = eptr; ++ ++ while (*cptr != '\0' && (*cptr == ',' || *cptr == '\x20' || *cptr == '\x9' || *cptr == '\xD' || *cptr == '\xA')) { ++ cptr++; ++ } ++ if (!*cptr) break; ++ ++ y = g_ascii_strtod (cptr, &eptr); ++ if (eptr == cptr) break; ++ cptr = eptr; ++ if (hascpt) { ++ curve->lineto(x, y); ++ } else { ++ curve->moveto(x, y); ++ hascpt = TRUE; ++ } ++ } - sp_shape_set_curve (SP_SHAPE (polyline), curve, TRUE); - (SP_SHAPE (polyline))->setCurve (curve, TRUE); -- curve->unref(); -- break; ++ (SP_SHAPE (polyline))->setCurve (curve, TRUE); ++ curve->unref(); ++ break; } default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); - if (((SPObjectClass *) SPPolyLineClass::static_parent_class)->set) - ((SPObjectClass *) SPPolyLineClass::static_parent_class)->set (object, key, value); -- break; -- } ++ if (((SPObjectClass *) SPPolyLineClass::static_parent_class)->set) { ++ ((SPObjectClass *) SPPolyLineClass::static_parent_class)->set (object, key, value); ++ } ++ break; ++ } } - static Inkscape::XML::Node * - sp_polyline_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) -Inkscape::XML::Node * -SPPolyLine::sp_polyline_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) ++Inkscape::XML::Node *SPPolyLine::write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { -- SPPolyLine *polyline; -- -- polyline = SP_POLYLINE (object); ++ SPPolyLine *polyline = SP_POLYLINE (object); -- if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { -- repr = xml_doc->createElement("svg:polyline"); -- } ++ if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { ++ repr = xml_doc->createElement("svg:polyline"); ++ } -- if (repr != SP_OBJECT_REPR (object)) { -- repr->mergeFrom(SP_OBJECT_REPR (object), "id"); -- } ++ if (repr != SP_OBJECT_REPR (object)) { ++ repr->mergeFrom(SP_OBJECT_REPR (object), "id"); ++ } - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); - if (((SPObjectClass *) (SPPolyLineClass::static_parent_class))->write) - ((SPObjectClass *) (SPPolyLineClass::static_parent_class))->write (object, xml_doc, repr, flags); ++ if (((SPObjectClass *) (SPPolyLineClass::static_parent_class))->write) { ++ ((SPObjectClass *) (SPPolyLineClass::static_parent_class))->write (object, xml_doc, repr, flags); ++ } -- return repr; ++ return repr; } - static gchar * - sp_polyline_description(SPItem */*item*/) -gchar * -SPPolyLine::sp_polyline_description(SPItem */*item*/) ++gchar *SPPolyLine::getDescription(SPItem * /*item*/) { return g_strdup(_("<b>Polyline</b>")); } ++ ++ ++/* ++ Local Variables: ++ mode:c++ ++ c-file-style:"stroustrup" ++ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) ++ indent-tabs-mode:nil ++ fill-column:99 ++ End: ++*/ ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --cc src/sp-polyline.h index 3ee18d6a5,b7657288c..277529b49 --- a/src/sp-polyline.h +++ b/src/sp-polyline.h @@@ -1,5 -1,5 +1,5 @@@ --#ifndef SP_POLYLINE_H --#define SP_POLYLINE_H ++#ifndef SEEN_SP_POLYLINE_H ++#define SEEN_SP_POLYLINE_H #include "sp-shape.h" @@@ -14,15 -14,33 +14,42 @@@ class SPPolyLine; class SPPolyLineClass; - struct SPPolyLine : public SPShape { - }; + class SPPolyLine : public SPShape { - public: - static GType sp_polyline_get_type (void); - private: - static void sp_polyline_init (SPPolyLine *polyline); ++public: ++ static GType sp_polyline_get_type (void); + - static void sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); - static void sp_polyline_set (SPObject *object, unsigned int key, const gchar *value); - static Inkscape::XML::Node *sp_polyline_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); ++private: ++ static void init(SPPolyLine *polyline); + - static gchar * sp_polyline_description (SPItem * item); ++ static void build(SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); ++ static void set(SPObject *object, unsigned int key, const gchar *value); ++ static Inkscape::XML::Node *write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - struct SPPolyLineClass { - SPShapeClass parent_class; - friend class SPPolyLineClass; ++ static gchar * getDescription(SPItem * item); + ++ friend class SPPolyLineClass; }; - GType sp_polyline_get_type (void); + class SPPolyLineClass { - public: - SPShapeClass parent_class; - private: - static SPShapeClass *static_parent_class; - static void sp_polyline_class_init (SPPolyLineClass *klass); - - friend class SPPolyLine; -}; - ++public: ++ SPShapeClass parent_class; ++private: ++ static SPShapeClass *static_parent_class; ++ static void sp_polyline_class_init (SPPolyLineClass *klass); ++ friend class SPPolyLine; ++}; --#endif ++#endif // SEEN_SP_POLYLINE_H ++ ++/* ++ Local Variables: ++ mode:c++ ++ c-file-style:"stroustrup" ++ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) ++ indent-tabs-mode:nil ++ fill-column:99 ++ End: ++*/ ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --cc src/sp-rect.cpp index bdfae7c99,5b75269dc..94be7551b --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@@ -113,12 -113,12 +113,12 @@@ sp_rect_build(SPObject *object, SPDocum if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build(object, document, repr); - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "width"); - sp_object_read_attr(object, "height"); - sp_object_read_attr(object, "rx"); - sp_object_read_attr(object, "ry"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "width"); - object->readAttr( "height"); - object->readAttr( "rx"); - object->readAttr( "ry"); ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "width" ); ++ object->readAttr( "height" ); ++ object->readAttr( "rx" ); ++ object->readAttr( "ry" ); } static void diff --cc src/sp-rect.h index 9a97bc217,9a97bc217..09d96739b --- a/src/sp-rect.h +++ b/src/sp-rect.h @@@ -1,11 -1,11 +1,12 @@@ --#ifndef __SP_RECT_H__ --#define __SP_RECT_H__ ++#ifndef SEEN_SP_RECT_H ++#define SEEN_SP_RECT_H /* * SVG <rect> implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -64,4 -64,4 +65,15 @@@ gdouble sp_rect_get_visible_height (SPR void sp_rect_compensate_rxry (SPRect *rect, Geom::Matrix xform); --#endif ++#endif // SEEN_SP_RECT_H ++ ++/* ++ Local Variables: ++ mode:c++ ++ c-file-style:"stroustrup" ++ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) ++ indent-tabs-mode:nil ++ fill-column:99 ++ End: ++*/ ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --cc src/sp-root.cpp index d5a1e0640,ad43bb3db..5f868539b --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@@ -1,11 -1,11 +1,11 @@@ --#define __SP_ROOT_C__ -- /** \file * SVG \<svg\> implementation. */ /* * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -146,26 -146,27 +146,27 @@@ sp_root_build(SPObject *object, SPDocum SPGroup *group = (SPGroup *) object; SPRoot *root = (SPRoot *) object; - if ( !object->repr->attribute("version") ) { - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + if ( !object->getRepr()->attribute("version") ) { repr->setAttribute("version", SVG_VERSION); } - sp_object_read_attr(object, "version"); - sp_object_read_attr(object, "inkscape:version"); - object->readAttr( "version"); - object->readAttr( "inkscape:version"); ++ object->readAttr( "version" ); ++ object->readAttr( "inkscape:version" ); /* It is important to parse these here, so objects will have viewport build-time */ - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "width"); - sp_object_read_attr(object, "height"); - sp_object_read_attr(object, "viewBox"); - sp_object_read_attr(object, "preserveAspectRatio"); - sp_object_read_attr(object, "onload"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "width"); - object->readAttr( "height"); - object->readAttr( "viewBox"); - object->readAttr( "preserveAspectRatio"); - object->readAttr( "onload"); ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "width" ); ++ object->readAttr( "height" ); ++ object->readAttr( "viewBox" ); ++ object->readAttr( "preserveAspectRatio" ); ++ object->readAttr( "onload" ); if (((SPObjectClass *) parent_class)->build) (* ((SPObjectClass *) parent_class)->build) (object, document, repr); -- /* Search for first <defs> node */ - for (SPObject *o = sp_object_first_child(SP_OBJECT(group)) ; o != NULL; o = SP_OBJECT_NEXT(o) ) { - for (SPObject *o = SP_OBJECT(group)->first_child() ; o != NULL; o = SP_OBJECT_NEXT(o) ) { ++ // Search for first <defs> node ++ for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { if (SP_IS_DEFS(o)) { root->defs = SP_DEFS(o); break; @@@ -345,22 -346,22 +346,21 @@@ sp_root_set(SPObject *object, unsigned * This routine is for adding a child SVG object to an SPRoot object. * The SPRoot object is taken to be an SPGroup. */ --static void --sp_root_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) ++static void sp_root_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { SPRoot *root = (SPRoot *) object; SPGroup *group = (SPGroup *) object; -- if (((SPObjectClass *) (parent_class))->child_added) ++ if (((SPObjectClass *) (parent_class))->child_added) { (* ((SPObjectClass *) (parent_class))->child_added)(object, child, ref); ++ } SPObject *co = object->document->getObjectByRepr(child); g_assert (co != NULL || !strcmp("comment", child->name())); // comment repr node has no object if (co && SP_IS_DEFS(co)) { -- SPObject *c; -- /* We search for first <defs> node - it is not beautiful, but works */ - for (c = sp_object_first_child(SP_OBJECT(group)) ; c != NULL; c = SP_OBJECT_NEXT(c) ) { - for (c = SP_OBJECT(group)->first_child() ; c != NULL; c = SP_OBJECT_NEXT(c) ) { ++ // We search for first <defs> node - it is not beautiful, but works ++ for (SPObject *c = group->firstChild() ; c ; c = c->getNext() ) { if (SP_IS_DEFS(c)) { root->defs = SP_DEFS(c); break; @@@ -377,9 -378,9 +377,9 @@@ static void sp_root_remove_child(SPObje SPRoot *root = (SPRoot *) object; if ( root->defs && SP_OBJECT_REPR(root->defs) == child ) { -- SPObject *iter; -- /* We search for first remaining <defs> node - it is not beautiful, but works */ - for ( iter = sp_object_first_child(object) ; iter ; iter = SP_OBJECT_NEXT(iter) ) { - for ( iter = object->first_child() ; iter ; iter = SP_OBJECT_NEXT(iter) ) { ++ SPObject *iter = 0; ++ // We search for first remaining <defs> node - it is not beautiful, but works ++ for ( iter = object->firstChild() ; iter ; iter = iter->getNext() ) { if ( SP_IS_DEFS(iter) && (SPDefs *)iter != root->defs ) { root->defs = (SPDefs *)iter; break; @@@ -391,8 -392,8 +391,9 @@@ } } -- if (((SPObjectClass *) (parent_class))->remove_child) ++ if (((SPObjectClass *) (parent_class))->remove_child) { (* ((SPObjectClass *) (parent_class))->remove_child)(object, child); ++ } } /** @@@ -566,7 -567,7 +567,7 @@@ sp_root_modified(SPObject *object, guin /* fixme: (Lauris) */ if (!object->parent && (flags & SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { - sp_document_resized_signal_emit (SP_OBJECT_DOCUMENT(root), root->width.computed, root->height.computed); - SP_OBJECT_DOCUMENT(root)->resized_signal_emit (root->width.computed, root->height.computed); ++ SP_OBJECT_DOCUMENT(root)->emitResizedSignal(root->width.computed, root->height.computed); } } diff --cc src/sp-script.cpp index ad41b8021,6cf120a65..3b6a8796d --- a/src/sp-script.cpp +++ b/src/sp-script.cpp @@@ -1,10 -1,10 +1,10 @@@ --#define __SP_SCRIPT_C__ -- /* * SVG <script> implementation * * Authors: * Felipe Corrêa da Silva Sanches <juca@members.fsf.org> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2008 authors * @@@ -83,16 -83,16 +83,16 @@@ sp_script_build(SPObject *object, SPDoc } //Read values of key attributes from XML nodes into object. - sp_object_read_attr(object, "xlink:href"); - object->readAttr( "xlink:href"); ++ object->readAttr( "xlink:href" ); - sp_document_add_resource(document, "script", object); - document->add_resource("script", object); ++ document->addResource("script", object); } static void sp_script_release(SPObject *object) { if (SP_OBJECT_DOCUMENT(object)) { /* Unregister ourselves */ - sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "script", SP_OBJECT(object)); - SP_OBJECT_DOCUMENT(object)->remove_resource("script", SP_OBJECT(object)); ++ SP_OBJECT_DOCUMENT(object)->removeResource("script", SP_OBJECT(object)); } if (((SPObjectClass *) parent_class)->release) @@@ -139,9 -139,9 +139,11 @@@ TODO } GSList *l = NULL; -- for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = object->firstChild() ; child; child = child->getNext() ) { Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); -- if (crepr) l = g_slist_prepend(l, crepr); ++ if (crepr) { ++ l = g_slist_prepend(l, crepr); ++ } } while (l) { @@@ -151,7 -151,7 +153,7 @@@ } } else { -- for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = object->firstChild() ; child; child = child->getNext() ) { child->updateRepr(flags); } } diff --cc src/sp-shape.cpp index 4bbfbc1e1,3b3e1108b..35364692b --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@@ -3,11 -3,11 +3,13 @@@ * * Author: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. * Copyright (C) 2004 John Cliff * Copyright (C) 2007-2008 Johan Engelen ++ * Copyright (C) 2010 Jon A. Cruz <jon@joncruz.org> * * Released under GNU GPL, read the file 'COPYING' for more information */ @@@ -55,33 -54,35 +57,14 @@@ #define noSHAPE_VERBOSE - static void sp_shape_class_init (SPShapeClass *klass); -/*static void sp_shape_class_init (SPShapeClass *klass); --static void sp_shape_init (SPShape *shape); --static void sp_shape_finalize (GObject *object); -- --static void sp_shape_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); --static void sp_shape_release (SPObject *object); -- --static void sp_shape_set(SPObject *object, unsigned key, gchar const *value); --static void sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags); --static void sp_shape_modified (SPObject *object, unsigned int flags); --static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -- - static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); -static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);*/ void sp_shape_print (SPItem * item, SPPrintContext * ctx); - static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); -/*static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); --static void sp_shape_hide (SPItem *item, unsigned int key); --static void sp_shape_snappoints (SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); -- --static void sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai); - -static SPLPEItemClass *parent_class;*/ - static SPLPEItemClass *parent_class; -SPLPEItemClass * SPShapeClass::parent_class=0; ++SPLPEItemClass * SPShapeClass::parent_class = 0; /** * Registers the SPShape class with Gdk and returns its type number. */ --GType - sp_shape_get_type (void) -SPShape::getType (void) ++GType SPShape::getType(void) { static GType type = 0; if (!type) { @@@ -104,8 -105,8 +87,7 @@@ * Initializes a SPShapeClass object. Establishes the function pointers to the class' * member routines in the class vtable, and sets pointers to parent classes. */ - static void - sp_shape_class_init (SPShapeClass *klass) -void -SPShapeClass::sp_shape_class_init (SPShapeClass *klass) ++void SPShapeClass::sp_shape_class_init(SPShapeClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); SPObjectClass *sp_object_class = SP_OBJECT_CLASS(klass); @@@ -136,8 -137,8 +118,7 @@@ /** * Initializes an SPShape object. */ - static void - sp_shape_init (SPShape *shape) -void -SPShape::sp_shape_init (SPShape *shape) ++void SPShape::sp_shape_init(SPShape *shape) { for ( int i = 0 ; i < SP_MARKER_LOC_QTY ; i++ ) { new (&shape->release_connect[i]) sigc::connection(); @@@ -147,8 -148,8 +128,7 @@@ shape->curve = NULL; } - static void - sp_shape_finalize (GObject *object) -void -SPShape::sp_shape_finalize (GObject *object) ++void SPShape::sp_shape_finalize(GObject *object) { SPShape *shape=(SPShape *)object; @@@ -171,11 -172,11 +151,10 @@@ * * \see sp_object_build() */ - static void - sp_shape_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -void -SPShape::sp_shape_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) ++void SPShape::sp_shape_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) (parent_class))->build) { - (*((SPObjectClass *) (parent_class))->build) (object, document, repr); + if (((SPObjectClass *) (SPShapeClass::parent_class))->build) { + (*((SPObjectClass *) (SPShapeClass::parent_class))->build) (object, document, repr); } for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) { @@@ -193,8 -194,8 +172,7 @@@ * * \see sp_object_release() */ - static void - sp_shape_release (SPObject *object) -void -SPShape::sp_shape_release (SPObject *object) ++void SPShape::sp_shape_release(SPObject *object) { SPItem *item; SPShape *shape; @@@ -225,19 -226,19 +203,17 @@@ - static void - sp_shape_set(SPObject *object, unsigned int key, gchar const *value) -void -SPShape::sp_shape_set(SPObject *object, unsigned int key, gchar const *value) ++void SPShape::sp_shape_set(SPObject *object, unsigned int key, gchar const *value) { - if (((SPObjectClass *) parent_class)->set) { - ((SPObjectClass *) parent_class)->set(object, key, value); + if (((SPObjectClass *) SPShapeClass::parent_class)->set) { + ((SPObjectClass *) SPShapeClass::parent_class)->set(object, key, value); } } - static Inkscape::XML::Node * - sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) -Inkscape::XML::Node * -SPShape::sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) ++Inkscape::XML::Node * SPShape::sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { - if (((SPObjectClass *)(parent_class))->write) { - ((SPObjectClass *)(parent_class))->write(object, doc, repr, flags); + if (((SPObjectClass *)(SPShapeClass::parent_class))->write) { + ((SPObjectClass *)(SPShapeClass::parent_class))->write(object, doc, repr, flags); } return repr; @@@ -247,8 -248,8 +223,7 @@@ * Updates the shape when its attributes have changed. Also establishes * marker objects to match the style settings. */ - static void - sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags) -void -SPShape::sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags) ++void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) { SPItem *item = (SPItem *) object; SPShape *shape = (SPShape *) object; @@@ -332,8 -333,8 +307,7 @@@ * Reference for behaviour of zero-length segments: * http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes */ --Geom::Matrix --sp_shape_marker_get_transform(Geom::Curve const & c1, Geom::Curve const & c2) ++Geom::Matrix sp_shape_marker_get_transform(Geom::Curve const & c1, Geom::Curve const & c2) { Geom::Point p = c1.pointAt(1); Geom::Curve * c1_reverse = c1.reverse(); @@@ -359,8 -360,8 +333,8 @@@ return Geom::Rotate(ret_angle) * Geom::Translate(p); } --Geom::Matrix --sp_shape_marker_get_transform_at_start(Geom::Curve const & c) ++ ++Geom::Matrix sp_shape_marker_get_transform_at_start(Geom::Curve const & c) { Geom::Point p = c.pointAt(0); Geom::Matrix ret = Geom::Translate(p); @@@ -376,8 -377,8 +350,8 @@@ return ret; } --Geom::Matrix --sp_shape_marker_get_transform_at_end(Geom::Curve const & c) ++ ++Geom::Matrix sp_shape_marker_get_transform_at_end(Geom::Curve const & c) { Geom::Point p = c.pointAt(1); Geom::Matrix ret = Geom::Translate(p); @@@ -403,8 -404,8 +377,7 @@@ * * @todo figure out what to do when both 'marker' and for instance 'marker-end' are set. */ - static void - sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai) -void -SPShape::sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai) ++void SPShape::sp_shape_update_marker_view(SPShape *shape, NRArenaItem *ai) { SPStyle *style = ((SPObject *) shape)->style; @@@ -514,8 -513,8 +487,7 @@@ /** * Sets modified flag for all sub-item views. */ - static void - sp_shape_modified (SPObject *object, unsigned int flags) -void -SPShape::sp_shape_modified (SPObject *object, unsigned int flags) ++void SPShape::sp_shape_modified(SPObject *object, unsigned int flags) { SPShape *shape = SP_SHAPE (object); @@@ -588,7 -587,7 +560,7 @@@ void SPShape::sp_shape_bbox(SPItem cons } // Union with bboxes of the markers, if any - if (sp_shape_has_markers (shape) && !shape->curve->get_pathvector().empty()) { - if (shape->hasMarkers ()) { ++ if ( shape->hasMarkers() && !shape->curve->get_pathvector().empty() ) { /** \todo make code prettier! */ Geom::PathVector const & pathv = shape->curve->get_pathvector(); // START marker @@@ -876,8 -873,8 +848,7 @@@ sp_shape_print (SPItem *item, SPPrintCo /** * Sets style, path, and paintbox. Updates marker views, including dimensions. */ - static NRArenaItem * - sp_shape_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/) -NRArenaItem * -SPShape::sp_shape_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/) ++NRArenaItem * SPShape::sp_shape_show(SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/) { SPObject *object = SP_OBJECT(item); SPShape *shape = SP_SHAPE(item); @@@ -925,8 -922,8 +896,7 @@@ /** * Hides/removes marker views from the shape. */ - static void - sp_shape_hide (SPItem *item, unsigned int key) -void -SPShape::sp_shape_hide (SPItem *item, unsigned int key) ++void SPShape::sp_shape_hide(SPItem *item, unsigned int key) { SPShape *shape; SPItemView *v; @@@ -954,8 -951,8 +924,7 @@@ * \param shape Shape. * \return TRUE if the shape has any markers, or FALSE if not. */ --int - sp_shape_has_markers (SPShape const *shape) -SPShape::hasMarkers () const ++int SPShape::hasMarkers() const { /* Note, we're ignoring 'marker' settings, which technically should apply for all three settings. This should be fixed later such that if 'marker' is @@@ -976,10 -973,10 +945,9 @@@ * \param type Marker type (e.g. SP_MARKER_LOC_START) * \return Number of markers that the shape has of this type. */ --int - sp_shape_number_of_markers (SPShape *shape, int type) -SPShape::numberOfMarkers (int type) ++int SPShape::numberOfMarkers(int type) { - Geom::PathVector const & pathv = shape->curve->get_pathvector(); + Geom::PathVector const & pathv = this->curve->get_pathvector(); if (pathv.size() == 0) { return 0; } @@@ -1062,7 -1059,7 +1030,7 @@@ static voi sp_shape_marker_modified (SPObject */*marker*/, guint /*flags*/, SPItem */*item*/) { /* I think mask does update automagically */ -- /* g_warning ("Item %s mask %s modified", SP_OBJECT_ID (item), SP_OBJECT_ID (mask)); */ ++ /* g_warning ("Item %s mask %s modified", item->getId(), mask->getId()); */ } /** @@@ -1117,14 -1114,14 +1085,10 @@@ sp_shape_set_marker (SPObject *object, /** * Calls any registered handlers for the set_shape action */ --void - sp_shape_set_shape (SPShape *shape) -SPShape::setShape () ++void SPShape::setShape() { - g_return_if_fail (shape != NULL); - g_return_if_fail (SP_IS_SHAPE (shape)); - //g_return_if_fail (shape != NULL); - //g_return_if_fail (SP_IS_SHAPE (shape)); -- - if (SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (shape))->set_shape) { - SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (shape))->set_shape (shape); + if (SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (this))->set_shape) { + SP_SHAPE_CLASS (G_OBJECT_GET_CLASS (this))->set_shape (this); } } @@@ -1134,11 -1131,11 +1098,10 @@@ * Any existing curve in the shape will be unreferenced first. * This routine also triggers a request to update the display. */ --void - sp_shape_set_curve (SPShape *shape, SPCurve *curve, unsigned int owner) -SPShape::setCurve (SPCurve *curve, unsigned int owner) ++void SPShape::setCurve(SPCurve *curve, unsigned int owner) { - if (shape->curve) { - shape->curve = shape->curve->unref(); + if (this->curve) { + this->curve = this->curve->unref(); } if (curve) { if (owner) { @@@ -1153,11 -1150,11 +1116,10 @@@ /** * Return duplicate of curve (if any exists) or NULL if there is no curve */ --SPCurve * - sp_shape_get_curve (SPShape *shape) -SPShape::getCurve () ++SPCurve * SPShape::getCurve() { - if (shape->curve) { - return shape->curve->copy(); + if (this->curve) { + return this->curve->copy(); } return NULL; } @@@ -1165,11 -1162,11 +1127,10 @@@ /** * Same as sp_shape_set_curve but without updating the display */ --void - sp_shape_set_curve_insync (SPShape *shape, SPCurve *curve, unsigned int owner) -SPShape::setCurveInsync (SPCurve *curve, unsigned int owner) ++void SPShape::setCurveInsync(SPCurve *curve, unsigned int owner) { - if (shape->curve) { - shape->curve = shape->curve->unref(); + if (this->curve) { + this->curve = this->curve->unref(); } if (curve) { if (owner) { diff --cc src/sp-shape.h index 4b1ded236,0a3b3e37f..78855c1c7 --- a/src/sp-shape.h +++ b/src/sp-shape.h @@@ -1,11 -1,11 +1,13 @@@ --#ifndef __SP_SHAPE_H__ --#define __SP_SHAPE_H__ ++#ifndef SEEN_SP_SHAPE_H ++#define SEEN_SP_SHAPE_H /* * Base class for shapes, including <path> element * * Author: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma ++ * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -31,41 -31,81 +33,75 @@@ struct SPDesktop; - struct SPShape : public SPLPEItem { -//struct SPShape : public SPLPEItem { + class SPShape : public SPLPEItem { - public: - SPCurve *curve; ++public: + SPCurve *curve; - SPObject *marker[SP_MARKER_LOC_QTY]; - sigc::connection release_connect [SP_MARKER_LOC_QTY]; - sigc::connection modified_connect [SP_MARKER_LOC_QTY]; - }; - SPObject *marker[SP_MARKER_LOC_QTY]; - sigc::connection release_connect [SP_MARKER_LOC_QTY]; - sigc::connection modified_connect [SP_MARKER_LOC_QTY]; ++ SPObject *marker[SP_MARKER_LOC_QTY]; ++ sigc::connection release_connect [SP_MARKER_LOC_QTY]; ++ sigc::connection modified_connect [SP_MARKER_LOC_QTY]; + - static GType getType (void); - void setShape (); - SPCurve * getCurve (); - void setCurve (SPCurve *curve, unsigned int owner); - void setCurveInsync (SPCurve *curve, unsigned int owner); - int hasMarkers () const; - int numberOfMarkers (int type); - private: - static void sp_shape_init (SPShape *shape); - static void sp_shape_finalize (GObject *object); ++ static GType getType (void); ++ void setShape (); ++ SPCurve * getCurve (); ++ void setCurve (SPCurve *curve, unsigned int owner); ++ void setCurveInsync (SPCurve *curve, unsigned int owner); ++ int hasMarkers () const; ++ int numberOfMarkers (int type); - struct SPShapeClass { - SPLPEItemClass item_class; - static void sp_shape_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); - static void sp_shape_release (SPObject *object); ++private: ++ static void sp_shape_init (SPShape *shape); ++ static void sp_shape_finalize (GObject *object); - /* Build bpath from extra shape attributes */ - void (* set_shape) (SPShape *shape); - }; - static void sp_shape_set(SPObject *object, unsigned key, gchar const *value); - static void sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags); - static void sp_shape_modified (SPObject *object, unsigned int flags); - static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); ++ static void sp_shape_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); ++ static void sp_shape_release (SPObject *object); + - static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); - static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); - static void sp_shape_hide (SPItem *item, unsigned int key); - static void sp_shape_snappoints (SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); ++ static void sp_shape_set(SPObject *object, unsigned key, gchar const *value); ++ static void sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags); ++ static void sp_shape_modified (SPObject *object, unsigned int flags); ++ static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - GType sp_shape_get_type (void); - static void sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai); ++ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); ++ static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); ++ static void sp_shape_hide (SPItem *item, unsigned int key); ++ static void sp_shape_snappoints (SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); - void sp_shape_set_shape (SPShape *shape); ++ static void sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai); - /* Return duplicate of curve or NULL */ - SPCurve *sp_shape_get_curve (SPShape *shape); - // sets a curve, updates display - void sp_shape_set_curve (SPShape *shape, SPCurve *curve, unsigned int owner); - friend class SPShapeClass; + - // same as sp_shape_set_curve, but without updating display - void sp_shape_set_curve_insync (SPShape *shape, SPCurve *curve, unsigned int owner); ++ friend class SPShapeClass; + }; + -//struct SPShapeClass { + class SPShapeClass { - public: - SPLPEItemClass item_class; ++public: ++ SPLPEItemClass item_class; + - /* Build bpath from extra shape attributes */ - void (* set_shape) (SPShape *shape); ++ /* Build bpath from extra shape attributes */ ++ void (* set_shape) (SPShape *shape); + - private: - static SPLPEItemClass *parent_class; - static void sp_shape_class_init (SPShapeClass *klass); ++private: ++ static SPLPEItemClass *parent_class; ++ static void sp_shape_class_init (SPShapeClass *klass); + - friend class SPShape; ++ friend class SPShape; + }; -//GType sp_shape_get_type (void); - -//void sp_shape_set_shape (SPShape *shape); - -/* Return duplicate of curve or NULL */ -//SPCurve *sp_shape_get_curve (SPShape *shape); - -// sets a curve, updates display -//void sp_shape_set_curve (SPShape *shape, SPCurve *curve, unsigned int owner); - -// same as sp_shape_set_curve, but without updating display -//void sp_shape_set_curve_insync (SPShape *shape, SPCurve *curve, unsigned int owner); - --// markers API void sp_shape_set_marker (SPObject *object, unsigned int key, const gchar *value); - int sp_shape_has_markers (SPShape const *shape); - int sp_shape_number_of_markers (SPShape* Shape, int type); -//int sp_shape_has_markers (SPShape const *shape); -//int sp_shape_number_of_markers (SPShape* Shape, int type); Geom::Matrix sp_shape_marker_get_transform(Geom::Curve const & c1, Geom::Curve const & c2); Geom::Matrix sp_shape_marker_get_transform_at_start(Geom::Curve const & c); Geom::Matrix sp_shape_marker_get_transform_at_end(Geom::Curve const & c); --#endif ++#endif // SEEN_SP_SHAPE_H ++ ++/* ++ Local Variables: ++ mode:c++ ++ c-file-style:"stroustrup" ++ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) ++ indent-tabs-mode:nil ++ fill-column:99 ++ End: ++*/ ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --cc src/sp-skeleton.cpp index 329df8eb6,f67341826..42fc5289f --- a/src/sp-skeleton.cpp +++ b/src/sp-skeleton.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_SKELETON_CPP__ -- /** \file * SVG <skeleton> implementation, used as an example for a base starting class * when implementing new sp-objects. @@@ -14,6 -14,6 +12,7 @@@ /* * Authors: * Kees Cook <kees@outflux.net> ++ * Abhishek Sharma * * Copyright (C) 2004 Kees Cook * @@@ -110,18 -110,18 +109,18 @@@ sp_skeleton_build(SPObject *object, SPD /* Pay attention to certain settings here - sp_object_read_attr(object, "xlink:href"); - sp_object_read_attr(object, "attributeName"); - sp_object_read_attr(object, "attributeType"); - sp_object_read_attr(object, "begin"); - sp_object_read_attr(object, "dur"); - sp_object_read_attr(object, "end"); - sp_object_read_attr(object, "min"); - sp_object_read_attr(object, "max"); - sp_object_read_attr(object, "restart"); - sp_object_read_attr(object, "repeatCount"); - sp_object_read_attr(object, "repeatDur"); - sp_object_read_attr(object, "fill"); - object->readAttr( "xlink:href"); - object->readAttr( "attributeName"); - object->readAttr( "attributeType"); - object->readAttr( "begin"); - object->readAttr( "dur"); - object->readAttr( "end"); - object->readAttr( "min"); - object->readAttr( "max"); - object->readAttr( "restart"); - object->readAttr( "repeatCount"); - object->readAttr( "repeatDur"); - object->readAttr( "fill"); ++ object->readAttr( "xlink:href" ); ++ object->readAttr( "attributeName" ); ++ object->readAttr( "attributeType" ); ++ object->readAttr( "begin" ); ++ object->readAttr( "dur" ); ++ object->readAttr( "end" ); ++ object->readAttr( "min" ); ++ object->readAttr( "max" ); ++ object->readAttr( "restart" ); ++ object->readAttr( "repeatCount" ); ++ object->readAttr( "repeatDur" ); ++ object->readAttr( "fill" ); */ } diff --cc src/sp-spiral.cpp index c309c60cc,499500c44..cfe02947a --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_SPIRAL_C__ -- /** \file * <sodipodi:spiral> implementation */ @@@ -7,6 -7,6 +5,7 @@@ * Authors: * Mitsuru Oka <oka326@parkcity.ne.jp> * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -129,13 -129,13 +128,13 @@@ sp_spiral_build (SPObject * object, SPD if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build (object, document, repr); - sp_object_read_attr (object, "sodipodi:cx"); - sp_object_read_attr (object, "sodipodi:cy"); - sp_object_read_attr (object, "sodipodi:expansion"); - sp_object_read_attr (object, "sodipodi:revolution"); - sp_object_read_attr (object, "sodipodi:radius"); - sp_object_read_attr (object, "sodipodi:argument"); - sp_object_read_attr (object, "sodipodi:t0"); - object->readAttr( "sodipodi:cx"); - object->readAttr( "sodipodi:cy"); - object->readAttr( "sodipodi:expansion"); - object->readAttr( "sodipodi:revolution"); - object->readAttr( "sodipodi:radius"); - object->readAttr( "sodipodi:argument"); - object->readAttr( "sodipodi:t0"); ++ object->readAttr( "sodipodi:cx" ); ++ object->readAttr( "sodipodi:cy" ); ++ object->readAttr( "sodipodi:expansion" ); ++ object->readAttr( "sodipodi:revolution" ); ++ object->readAttr( "sodipodi:radius" ); ++ object->readAttr( "sodipodi:argument" ); ++ object->readAttr( "sodipodi:t0" ); } /** diff --cc src/sp-star.cpp index 3694a7cd1,b956019d4..b94e2dbc4 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_STAR_C__ -- /* * <sodipodi:star> implementation * @@@ -7,6 -7,6 +5,7 @@@ * Mitsuru Oka <oka326@parkcity.ne.jp> * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -118,16 -118,16 +117,16 @@@ sp_star_build (SPObject * object, SPDoc if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build (object, document, repr); - sp_object_read_attr (object, "sodipodi:cx"); - sp_object_read_attr (object, "sodipodi:cy"); - sp_object_read_attr (object, "sodipodi:sides"); - sp_object_read_attr (object, "sodipodi:r1"); - sp_object_read_attr (object, "sodipodi:r2"); - sp_object_read_attr (object, "sodipodi:arg1"); - sp_object_read_attr (object, "sodipodi:arg2"); - sp_object_read_attr (object, "inkscape:flatsided"); - sp_object_read_attr (object, "inkscape:rounded"); - sp_object_read_attr (object, "inkscape:randomized"); - object->readAttr( "sodipodi:cx"); - object->readAttr( "sodipodi:cy"); - object->readAttr( "sodipodi:sides"); - object->readAttr( "sodipodi:r1"); - object->readAttr( "sodipodi:r2"); - object->readAttr( "sodipodi:arg1"); - object->readAttr( "sodipodi:arg2"); - object->readAttr( "inkscape:flatsided"); - object->readAttr( "inkscape:rounded"); - object->readAttr( "inkscape:randomized"); ++ object->readAttr( "sodipodi:cx" ); ++ object->readAttr( "sodipodi:cy" ); ++ object->readAttr( "sodipodi:sides" ); ++ object->readAttr( "sodipodi:r1" ); ++ object->readAttr( "sodipodi:r2" ); ++ object->readAttr( "sodipodi:arg1" ); ++ object->readAttr( "sodipodi:arg2" ); ++ object->readAttr( "inkscape:flatsided" ); ++ object->readAttr( "inkscape:rounded" ); ++ object->readAttr( "inkscape:randomized" ); } static Inkscape::XML::Node * diff --cc src/sp-stop.cpp index 15fc93e2f,740cfef78..0c0a3b03a --- a/src/sp-stop.cpp +++ b/src/sp-stop.cpp @@@ -52,34 -52,6 +52,34 @@@ SPStop* SPStop::getPrevStop( return result; } +SPColor SPStop::readStopColor( Glib::ustring const &styleStr, guint32 dfl ) +{ + SPColor color(dfl); + SPStyle* style = sp_style_new(0); + SPIPaint paint; + paint.read( styleStr.c_str(), *style ); + if ( paint.isColor() ) { + color = paint.value.color; + } + sp_style_unref(style); + return color; +} + +SPColor SPStop::getEffectiveColor() const +{ + SPColor ret; + if (currentColor) { - char const *str = sp_object_get_style_property(this, "color", NULL); ++ char const *str = getStyleProperty("color", NULL); + /* Default value: arbitrarily black. (SVG1.1 and CSS2 both say that the initial + * value depends on user agent, and don't give any further restrictions that I can + * see.) */ + ret = readStopColor( str, 0 ); + } else { + ret = specified_color; + } + return ret; +} + /* diff --cc src/sp-string.cpp index b424ac3d8,8cf8d3291..c116e8dd8 --- a/src/sp-string.cpp +++ b/src/sp-string.cpp @@@ -1,10 -1,10 +1,10 @@@ --#define __SP_STRING_C__ -- /* * SVG <text> and <tspan> implementation * * Author: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -116,12 -116,14 +116,16 @@@ sp_string_read_content(SPObject *object SPString *string = SP_STRING(object); string->string.clear(); - gchar const *xml_string = string->repr->content(); + - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + gchar const *xml_string = string->getRepr()->content(); // see algorithms described in svg 1.1 section 10.15 if (object->xml_space.value == SP_XML_SPACE_PRESERVE) { for ( ; *xml_string ; xml_string = g_utf8_next_char(xml_string) ) { gunichar c = g_utf8_get_char(xml_string); -- if (c == 0xa || c == 0xd || c == '\t') c = ' '; ++ if ((c == 0xa) || (c == 0xd) || (c == '\t')) { ++ c = ' '; ++ } string->string += c; } } @@@ -129,17 -131,17 +133,22 @@@ bool whitespace = false; for ( ; *xml_string ; xml_string = g_utf8_next_char(xml_string) ) { gunichar c = g_utf8_get_char(xml_string); -- if (c == 0xa || c == 0xd) continue; -- if (c == ' ' || c == '\t') whitespace = true; -- else { -- if (whitespace && (!string->string.empty() || SP_OBJECT_PREV(object) != NULL)) ++ if ((c == 0xa) || (c == 0xd)) { ++ continue; ++ } ++ if ((c == ' ') || (c == '\t')) { ++ whitespace = true; ++ } else { ++ if (whitespace && (!string->string.empty() || (object->getPrev() != NULL))) { string->string += ' '; ++ } string->string += c; whitespace = false; } } -- if (whitespace && SP_OBJECT_REPR(object)->next() != NULL) // can't use SP_OBJECT_NEXT() when the SPObject tree is still being built ++ if (whitespace && SP_OBJECT_REPR(object)->next() != NULL) { // can't use SPObject::getNext() when the SPObject tree is still being built string->string += ' '; ++ } } object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } diff --cc src/sp-style-elem-test.h index 0c01136f6,9b096c861..53362d3e3 --- a/src/sp-style-elem-test.h +++ b/src/sp-style-elem-test.h @@@ -1,4 -1,4 +1,3 @@@ -- #ifndef SEEN_SP_STYLE_ELEM_TEST_H #define SEEN_SP_STYLE_ELEM_TEST_H diff --cc src/sp-style-elem.cpp index 5a57d548b,68d8e8870..02ed80445 --- a/src/sp-style-elem.cpp +++ b/src/sp-style-elem.cpp @@@ -317,7 -317,8 +317,8 @@@ sp_style_elem_read_content(SPObject *co * Dodji replies "right, that's *bug*"; just an unexpected oversight. */ - GString *const text = concat_children(*style_elem.repr); - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + GString *const text = concat_children(*style_elem.getRepr()); CRParser *parser = cr_parser_new_from_buf(reinterpret_cast<guchar *>(text->str), text->len, CR_UTF_8, FALSE); @@@ -389,8 -390,8 +390,8 @@@ sp_style_elem_build(SPObject *object, S { sp_style_elem_read_content(object); - sp_object_read_attr(object, "type"); - sp_object_read_attr(object, "media"); - object->readAttr( "type"); - object->readAttr( "media"); ++ object->readAttr( "type" ); ++ object->readAttr( "media" ); static Inkscape::XML::NodeEventVector const nodeEventVector = { child_add_rm_cb, // child_added diff --cc src/sp-switch.cpp index 37be6f75e,2d67b8637..19c014b9b --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@@ -1,11 -1,11 +1,11 @@@ --#define __SP_SWITCH_CPP__ -- /* * SVG <switch> implementation * * Authors: * Andrius R. <knutux@gmail.com> * MenTaLguY <mental@rydia.net> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2006 authors * @@@ -72,11 -72,11 +72,13 @@@ CSwitch::~CSwitch() } SPObject *CSwitch::_evaluateFirst() { - for (SPObject *child = sp_object_first_child(_group) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = _group->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- if (SP_IS_ITEM(child) && sp_item_evaluate(SP_ITEM(child))) -- return child; ++ SPObject *first = 0; ++ for (SPObject *child = _group->firstChild() ; child && !first ; child = child->getNext() ) { ++ if (SP_IS_ITEM(child) && sp_item_evaluate(SP_ITEM(child))) { ++ first = child; ++ } } -- return NULL; ++ return first; } GSList *CSwitch::_childList(bool add_ref, SPObject::Action action) { @@@ -177,3 -177,3 +179,14 @@@ void CSwitch::_showChildren (NRArena *a l = g_slist_remove (l, o); } } ++ ++/* ++ Local Variables: ++ mode:c++ ++ c-file-style:"stroustrup" ++ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) ++ indent-tabs-mode:nil ++ fill-column:99 ++ End: ++*/ ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --cc src/sp-symbol.cpp index 41004db6e,262cfa6a0..6c8d3cd82 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@@ -1,10 -1,10 +1,9 @@@ --#define __SP_SYMBOL_C__ -- /* * SVG <symbol> implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 1999-2003 Lauris Kaplinski * @@@ -110,8 -110,8 +109,8 @@@ sp_symbol_build (SPObject *object, SPDo group = (SPGroup *) object; symbol = (SPSymbol *) object; - sp_object_read_attr (object, "viewBox"); - sp_object_read_attr (object, "preserveAspectRatio"); - object->readAttr( "viewBox"); - object->readAttr( "preserveAspectRatio"); ++ object->readAttr( "viewBox" ); ++ object->readAttr( "preserveAspectRatio" ); if (((SPObjectClass *) parent_class)->build) ((SPObjectClass *) parent_class)->build (object, document, repr); @@@ -393,11 -393,14 +392,15 @@@ sp_symbol_write (SPObject *object, Inks repr = xml_doc->createElement("svg:symbol"); } - repr->setAttribute("viewBox", object->repr->attribute("viewBox")); - repr->setAttribute("preserveAspectRatio", object->repr->attribute("preserveAspectRatio")); - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + repr->setAttribute("viewBox", object->getRepr()->attribute("viewBox")); + - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio")); -- if (((SPObjectClass *) (parent_class))->write) ++ if (((SPObjectClass *) (parent_class))->write) { ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); ++ } return repr; } diff --cc src/sp-text.cpp index 4b896db9c,dcf9160ff..80eb786f2 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@@ -4,6 -4,6 +4,8 @@@ * Author: * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -149,16 -149,16 +151,16 @@@ sp_text_release (SPObject *object static void sp_text_build (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "dx"); - sp_object_read_attr(object, "dy"); - sp_object_read_attr(object, "rotate"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "dx"); - object->readAttr( "dy"); - object->readAttr( "rotate"); ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "dx" ); ++ object->readAttr( "dy" ); ++ object->readAttr( "rotate" ); if (((SPObjectClass *) text_parent_class)->build) ((SPObjectClass *) text_parent_class)->build(object, doc, repr); - sp_object_read_attr(object, "sodipodi:linespacing"); // has to happen after the styles are read - object->readAttr( "sodipodi:linespacing"); // has to happen after the styles are read ++ object->readAttr( "sodipodi:linespacing" ); // has to happen after the styles are read } static void @@@ -211,8 -211,8 +213,7 @@@ sp_text_remove_child (SPObject *object text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } --static void --sp_text_update (SPObject *object, SPCtx *ctx, guint flags) ++static void sp_text_update(SPObject *object, SPCtx *ctx, guint flags) { SPText *text = SP_TEXT (object); @@@ -223,9 -223,9 +224,9 @@@ if (flags & SP_OBJECT_MODIFIED_FLAG) cflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; -- /* Create temporary list of children */ ++ // Create temporary list of children GSList *l = NULL; - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { sp_object_ref (SP_OBJECT (child), object); l = g_slist_prepend (l, child); } @@@ -259,14 -259,14 +260,16 @@@ } } --static void --sp_text_modified (SPObject *object, guint flags) ++static void sp_text_modified(SPObject *object, guint flags) { -- if (((SPObjectClass *) text_parent_class)->modified) ++ if (((SPObjectClass *) text_parent_class)->modified) { ((SPObjectClass *) text_parent_class)->modified (object, flags); ++ } guint cflags = (flags & SP_OBJECT_MODIFIED_CASCADE); -- if (flags & SP_OBJECT_MODIFIED_FLAG) cflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ cflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } // FIXME: all that we need to do here is nr_arena_glyphs_[group_]set_style, to set the changed // style, but there's no easy way to access the arena glyphs or glyph groups corresponding to a @@@ -283,16 -283,16 +286,15 @@@ } } -- /* Create temporary list of children */ ++ // Create temporary list of children GSList *l = NULL; -- SPObject *child; - for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { sp_object_ref (SP_OBJECT (child), object); l = g_slist_prepend (l, child); } l = g_slist_reverse (l); while (l) { -- child = SP_OBJECT (l->data); ++ SPObject *child = SP_OBJECT (l->data); l = g_slist_remove (l, child); if (cflags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(cflags); @@@ -301,24 -301,24 +303,28 @@@ } } --static Inkscape::XML::Node * --sp_text_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) ++static Inkscape::XML::Node *sp_text_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPText *text = SP_TEXT (object); if (flags & SP_OBJECT_WRITE_BUILD) { -- if (!repr) ++ if (!repr) { repr = xml_doc->createElement("svg:text"); ++ } GSList *l = NULL; - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; ++ for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { ++ continue; ++ } Inkscape::XML::Node *crepr = NULL; if (SP_IS_STRING(child)) { crepr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); } else { crepr = child->updateRepr(xml_doc, NULL, flags); } -- if (crepr) l = g_slist_prepend (l, crepr); ++ if (crepr) { ++ l = g_slist_prepend (l, crepr); ++ } } while (l) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); @@@ -326,8 -326,8 +332,10 @@@ l = g_slist_remove (l, l->data); } } else { - for (SPObject *child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue; ++ for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { ++ if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { ++ continue; ++ } if (SP_IS_STRING(child)) { SP_OBJECT_REPR(child)->setContent(SP_STRING(child)->string.c_str()); } else { @@@ -343,12 -343,12 +351,13 @@@ Inkscape::SVGOStringStream os; os << (text->style->line_height.value * 100.0) << "%"; SP_OBJECT_REPR(text)->setAttribute("sodipodi:linespacing", os.str().c_str()); -- } -- else ++ } else { SP_OBJECT_REPR(text)->setAttribute("sodipodi:linespacing", NULL); ++ } -- if (((SPObjectClass *) (text_parent_class))->write) ++ if (((SPObjectClass *) (text_parent_class))->write) { ((SPObjectClass *) (text_parent_class))->write (object, xml_doc, repr, flags); ++ } return repr; } @@@ -550,14 -550,14 +559,16 @@@ unsigned SPText::_buildLayoutInput(SPOb if (SP_IS_TSPAN(root)) if (SP_TSPAN(root)->role != SP_TSPAN_ROLE_UNSPECIFIED) { // we need to allow the first line not to have role=line, but still set the source_cookie to the right value -- SPObject *prev_object = SP_OBJECT_PREV(root); ++ SPObject *prev_object = root->getPrev(); if (prev_object && SP_IS_TSPAN(prev_object)) { -- if (!layout.inputExists()) ++ if (!layout.inputExists()) { layout.appendText("", prev_object->style, prev_object, &optional_attrs); ++ } layout.appendControlCode(Inkscape::Text::Layout::PARAGRAPH_BREAK, prev_object); } -- if (!root->hasChildren()) ++ if (!root->hasChildren()) { layout.appendText("", root->style, root, &optional_attrs); ++ } length++; // interpreting line breaks as a character for the purposes of x/y/etc attributes // is a liberal interpretation of the svg spec, but a strict reading would mean // that if the first line is empty the second line would take its place at the @@@ -565,7 -565,7 +576,7 @@@ child_attrs_offset--; } - for (SPObject *child = sp_object_first_child(root) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = root->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = root->firstChild() ; child ; child = child->getNext() ) { if (SP_IS_STRING(child)) { Glib::ustring const &string = SP_STRING(child)->string; layout.appendText(string, root->style, child, &optional_attrs, child_attrs_offset + length); @@@ -584,7 -584,7 +595,7 @@@ void SPText::rebuildLayout( Inkscape::Text::Layout::OptionalTextTagAttrs optional_attrs; _buildLayoutInput(this, optional_attrs, 0, false); layout.calculateFlow(); -- for (SPObject *child = firstChild() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = firstChild() ; child ; child = child->getNext() ) { if (SP_IS_TEXTPATH(child)) { SPTextPath const *textpath = SP_TEXTPATH(child); if (textpath->originalPath != NULL) { @@@ -596,14 -596,14 +607,16 @@@ //g_print(layout.dumpAsText().c_str()); // set the x,y attributes on role:line spans -- for (SPObject *child = firstChild() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { -- if (!SP_IS_TSPAN(child)) continue; -- SPTSpan *tspan = SP_TSPAN(child); -- if (tspan->role == SP_TSPAN_ROLE_UNSPECIFIED) continue; -- if (!tspan->attributes.singleXYCoordinates()) continue; -- Inkscape::Text::Layout::iterator iter = layout.sourceToIterator(tspan); -- Geom::Point anchor_point = layout.chunkAnchorPoint(iter); -- tspan->attributes.setFirstXY(anchor_point); ++ for (SPObject *child = firstChild() ; child ; child = child->getNext() ) { ++ if (SP_IS_TSPAN(child)) { ++ SPTSpan *tspan = SP_TSPAN(child); ++ if ( (tspan->role != SP_TSPAN_ROLE_UNSPECIFIED) ++ && tspan->attributes.singleXYCoordinates() ) { ++ Inkscape::Text::Layout::iterator iter = layout.sourceToIterator(tspan); ++ Geom::Point anchor_point = layout.chunkAnchorPoint(iter); ++ tspan->attributes.setFirstXY(anchor_point); ++ } ++ } } } diff --cc src/sp-textpath.h index 76d236cc9,6642587d2..2f30f6023 --- a/src/sp-textpath.h +++ b/src/sp-textpath.h @@@ -31,7 -31,7 +31,7 @@@ struct SPTextPathClass GType sp_textpath_get_type(); - #define SP_IS_TEXT_TEXTPATH(obj) (SP_IS_TEXT(obj) && sp_object_first_child(obj) && SP_IS_TEXTPATH(sp_object_first_child(obj))) -#define SP_IS_TEXT_TEXTPATH(obj) (SP_IS_TEXT(obj) && obj->first_child() && SP_IS_TEXTPATH(obj->first_child())) ++#define SP_IS_TEXT_TEXTPATH(obj) (SP_IS_TEXT(obj) && obj->firstChild() && SP_IS_TEXTPATH(obj->firstChild())) SPItem *sp_textpath_get_path_item(SPTextPath *tp); void sp_textpath_to_text(SPObject *tp); diff --cc src/sp-tref-reference.h index 37a5e21ce,f3c645942..c2264f83e --- a/src/sp-tref-reference.h +++ b/src/sp-tref-reference.h @@@ -7,6 -7,6 +7,7 @@@ * This file was created based on sp-use-reference.h * * Copyright (C) 2007 Gail Banaszkiewicz ++ * Abhishek Sharma * * Released under GNU GPL, read the file 'COPYING' for more information. */ diff --cc src/sp-tref.cpp index 66a8c1e79,ef9c89486..eddcd270c --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_TREF_CPP__ -- /** \file * SVG <tref> implementation - All character data within the referenced * element, including character data enclosed within additional markup, @@@ -10,6 -10,6 +8,8 @@@ /* * Authors: * Gail Banaszkiewicz <Gail.Banaszkiewicz@gmail.com> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2007 Gail Banaszkiewicz * @@@ -154,12 -154,12 +154,12 @@@ sp_tref_build(SPObject *object, SPDocum ((SPObjectClass *) tref_parent_class)->build(object, document, repr); } - sp_object_read_attr(object, "xlink:href"); - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "dx"); - sp_object_read_attr(object, "dy"); - sp_object_read_attr(object, "rotate"); - object->readAttr( "xlink:href"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "dx"); - object->readAttr( "dy"); - object->readAttr( "rotate"); ++ object->readAttr( "xlink:href" ); ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "dx" ); ++ object->readAttr( "dy" ); ++ object->readAttr( "rotate" ); } /** @@@ -507,8 -507,8 +507,7 @@@ sp_tref_fully_contained(SPObject *start } --void --sp_tref_update_text(SPTRef *tref) ++void sp_tref_update_text(SPTRef *tref) { if (tref) { // Get the character data that will be used with this tref @@@ -521,7 -521,7 +520,7 @@@ } // Create the node and SPString to be the tref's child -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(tref)); ++ Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(tref)->getReprDoc(); Inkscape::XML::Node *newStringRepr = xml_doc->createTextNode(charData.c_str()); tref->stringChild = SP_OBJECT(g_object_new(sp_repr_type_lookup(newStringRepr), NULL)); @@@ -586,7 -586,7 +585,7 @@@ sp_tref_convert_to_tspan(SPObject *obj Inkscape::XML::Node *tref_parent = sp_repr_parent(tref_repr); SPDocument *document = SP_OBJECT(tref)->document; -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *new_tspan_repr = xml_doc->createElement("svg:tspan"); @@@ -633,7 -633,7 +632,7 @@@ //////////////////// else { GSList *l = NULL; - for (SPObject *child = sp_object_first_child(obj) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = obj->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = obj->firstChild() ; child != NULL ; child = child->getNext() ) { sp_object_ref (SP_OBJECT (child), obj); l = g_slist_prepend (l, child); } diff --cc src/sp-tspan.cpp index 056436ed3,8cddc6e5e..2afd75e75 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@@ -1,11 -1,11 +1,11 @@@ --#define __SP_TSPAN_C__ -- /* * SVG <text> and <tspan> implementation * * Author: * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -133,12 -133,12 +133,12 @@@ sp_tspan_build(SPObject *object, SPDocu { //SPTSpan *tspan = SP_TSPAN(object); - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "dx"); - sp_object_read_attr(object, "dy"); - sp_object_read_attr(object, "rotate"); - sp_object_read_attr(object, "sodipodi:role"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "dx"); - object->readAttr( "dy"); - object->readAttr( "rotate"); - object->readAttr( "sodipodi:role"); ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "dx" ); ++ object->readAttr( "dy" ); ++ object->readAttr( "rotate" ); ++ object->readAttr( "sodipodi:role" ); if (((SPObjectClass *) tspan_parent_class)->build) ((SPObjectClass *) tspan_parent_class)->build(object, doc, repr); @@@ -168,35 -168,35 +168,36 @@@ sp_tspan_set(SPObject *object, unsigne } } --static void --sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags) ++static void sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags) { -- if (((SPObjectClass *) tspan_parent_class)->update) ++ if (((SPObjectClass *) tspan_parent_class)->update) { ((SPObjectClass *) tspan_parent_class)->update(object, ctx, flags); ++ } -- if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } flags &= SP_OBJECT_MODIFIED_CASCADE; -- SPObject *ochild; - for ( ochild = sp_object_first_child(object) ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { - for ( ochild = object->first_child() ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { ++ for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) { if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) { ochild->updateDisplay(ctx, flags); } } } --static void --sp_tspan_modified(SPObject *object, unsigned flags) ++static void sp_tspan_modified(SPObject *object, unsigned flags) { -- if (((SPObjectClass *) tspan_parent_class)->modified) ++ if (((SPObjectClass *) tspan_parent_class)->modified) { ((SPObjectClass *) tspan_parent_class)->modified(object, flags); ++ } -- if (flags & SP_OBJECT_MODIFIED_FLAG) ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } flags &= SP_OBJECT_MODIFIED_CASCADE; -- SPObject *ochild; - for ( ochild = sp_object_first_child(object) ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { - for ( ochild = object->first_child() ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { ++ for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) { if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) { ochild->emitModified(flags); } @@@ -242,7 -242,7 +243,7 @@@ sp_tspan_write(SPObject *object, Inksca if ( flags&SP_OBJECT_WRITE_BUILD ) { GSList *l = NULL; - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject* child = object->firstChild() ; child ; child = child->getNext() ) { Inkscape::XML::Node* c_repr=NULL; if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { c_repr = child->updateRepr(xml_doc, NULL, flags); @@@ -251,7 -251,7 +252,9 @@@ } else if ( SP_IS_STRING(child) ) { c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); } -- if ( c_repr ) l = g_slist_prepend(l, c_repr); ++ if ( c_repr ) { ++ l = g_slist_prepend(l, c_repr); ++ } } while ( l ) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); @@@ -259,7 -259,7 +262,7 @@@ l = g_slist_remove(l, l->data); } } else { - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject* child = object->firstChild() ; child ; child = child->getNext() ) { if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { child->updateRepr(flags); } else if ( SP_IS_TEXTPATH(child) ) { @@@ -270,8 -270,8 +273,9 @@@ } } -- if (((SPObjectClass *) tspan_parent_class)->write) ++ if (((SPObjectClass *) tspan_parent_class)->write) { ((SPObjectClass *) tspan_parent_class)->write(object, xml_doc, repr, flags); ++ } return repr; } @@@ -387,32 -387,32 +391,34 @@@ sp_textpath_release(SPObject *object ((SPObjectClass *) textpath_parent_class)->release(object); } --static void --sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) ++static void sp_textpath_build(SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) { -- //SPTextPath *textpath = SP_TEXTPATH(object); -- - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "dx"); - sp_object_read_attr(object, "dy"); - sp_object_read_attr(object, "rotate"); - sp_object_read_attr(object, "startOffset"); - sp_object_read_attr(object, "xlink:href"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "dx"); - object->readAttr( "dy"); - object->readAttr( "rotate"); - object->readAttr( "startOffset"); - object->readAttr( "xlink:href"); -- -- bool no_content=true; ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "dx" ); ++ object->readAttr( "dy" ); ++ object->readAttr( "rotate" ); ++ object->readAttr( "startOffset" ); ++ object->readAttr( "xlink:href" ); ++ ++ bool no_content = true; for (Inkscape::XML::Node* rch = repr->firstChild() ; rch != NULL; rch = rch->next()) { -- if ( rch->type() == Inkscape::XML::TEXT_NODE ) {no_content=false;break;} ++ if ( rch->type() == Inkscape::XML::TEXT_NODE ) ++ { ++ no_content = false; ++ break; ++ } } if ( no_content ) { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node* rch = xml_doc->createTextNode(""); repr->addChild(rch, NULL); } -- if (((SPObjectClass *) textpath_parent_class)->build) ++ if (((SPObjectClass *) textpath_parent_class)->build) { ((SPObjectClass *) textpath_parent_class)->build(object, doc, repr); ++ } } static void @@@ -439,23 -439,23 +445,26 @@@ sp_textpath_set(SPObject *object, unsig } } --static void --sp_textpath_update(SPObject *object, SPCtx *ctx, guint flags) ++static void sp_textpath_update(SPObject *object, SPCtx *ctx, guint flags) { SPTextPath *textpath = SP_TEXTPATH(object); -- textpath->isUpdating=true; -- if ( textpath->sourcePath->sourceDirty ) refresh_textpath_source(textpath); -- textpath->isUpdating=false; ++ textpath->isUpdating = true; ++ if ( textpath->sourcePath->sourceDirty ) { ++ refresh_textpath_source(textpath); ++ } ++ textpath->isUpdating = false; -- if (((SPObjectClass *) textpath_parent_class)->update) ++ if (((SPObjectClass *) textpath_parent_class)->update) { ((SPObjectClass *) textpath_parent_class)->update(object, ctx, flags); ++ } -- if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { ++ flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } flags &= SP_OBJECT_MODIFIED_CASCADE; -- SPObject *ochild; - for ( ochild = sp_object_first_child(object) ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { - for ( ochild = object->first_child() ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { ++ for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) { if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) { ochild->updateDisplay(ctx, flags); } @@@ -483,18 -483,18 +492,18 @@@ void refresh_textpath_source(SPTextPa } } --static void --sp_textpath_modified(SPObject *object, unsigned flags) ++static void sp_textpath_modified(SPObject *object, unsigned flags) { -- if (((SPObjectClass *) textpath_parent_class)->modified) ++ if (((SPObjectClass *) textpath_parent_class)->modified) { ((SPObjectClass *) textpath_parent_class)->modified(object, flags); ++ } -- if (flags & SP_OBJECT_MODIFIED_FLAG) ++ if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; ++ } flags &= SP_OBJECT_MODIFIED_CASCADE; -- SPObject *ochild; - for ( ochild = sp_object_first_child(object) ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { - for ( ochild = object->first_child() ; ochild ; ochild = SP_OBJECT_NEXT(ochild) ) { ++ for ( SPObject *ochild = object->firstChild() ; ochild ; ochild = ochild->getNext() ) { if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) { ochild->emitModified(flags); } @@@ -526,7 -526,7 +535,7 @@@ sp_textpath_write(SPObject *object, Ink if ( flags&SP_OBJECT_WRITE_BUILD ) { GSList *l = NULL; - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject* child = object->firstChild() ; child ; child = child->getNext() ) { Inkscape::XML::Node* c_repr=NULL; if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { c_repr = child->updateRepr(xml_doc, NULL, flags); @@@ -535,7 -535,7 +544,9 @@@ } else if ( SP_IS_STRING(child) ) { c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); } -- if ( c_repr ) l = g_slist_prepend(l, c_repr); ++ if ( c_repr ) { ++ l = g_slist_prepend(l, c_repr); ++ } } while ( l ) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); @@@ -543,7 -543,7 +554,7 @@@ l = g_slist_remove(l, l->data); } } else { - for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject* child = object->firstChild() ; child ; child = child->getNext() ) { if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { child->updateRepr(flags); } else if ( SP_IS_TEXTPATH(child) ) { @@@ -554,8 -554,8 +565,9 @@@ } } -- if (((SPObjectClass *) textpath_parent_class)->write) ++ if (((SPObjectClass *) textpath_parent_class)->write) { ((SPObjectClass *) textpath_parent_class)->write(object, xml_doc, repr, flags); ++ } return repr; } diff --cc src/sp-use.cpp index ecb7eb788,075c7f804..505c64fd2 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@@ -1,11 -1,11 +1,11 @@@ --#define __SP_USE_C__ -- /* * SVG <use> implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2005 authors * Copyright (C) 2000-2001 Ximian, Inc. @@@ -160,11 -160,11 +160,11 @@@ sp_use_build(SPObject *object, SPDocume (* ((SPObjectClass *) parent_class)->build)(object, document, repr); } - sp_object_read_attr(object, "x"); - sp_object_read_attr(object, "y"); - sp_object_read_attr(object, "width"); - sp_object_read_attr(object, "height"); - sp_object_read_attr(object, "xlink:href"); - object->readAttr( "x"); - object->readAttr( "y"); - object->readAttr( "width"); - object->readAttr( "height"); - object->readAttr( "xlink:href"); ++ object->readAttr( "x" ); ++ object->readAttr( "y" ); ++ object->readAttr( "width" ); ++ object->readAttr( "height" ); ++ object->readAttr( "xlink:href" ); // We don't need to create child here: // reading xlink:href will attach ref, and that will cause the changed signal to be emitted, @@@ -664,21 -664,21 +664,26 @@@ sp_use_modified(SPObject *object, guin } } --SPItem * --sp_use_unlink(SPUse *use) ++SPItem *sp_use_unlink(SPUse *use) { -- if (!use) return NULL; ++ if (!use) { ++ return NULL; ++ } Inkscape::XML::Node *repr = SP_OBJECT_REPR(use); -- if (!repr) return NULL; ++ if (!repr) { ++ return NULL; ++ } Inkscape::XML::Node *parent = sp_repr_parent(repr); SPDocument *document = SP_OBJECT(use)->document; -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); // Track the ultimate source of a chain of uses. SPItem *orig = sp_use_root(use); - if (!orig) return NULL ; - g_return_val_if_fail(orig, NULL); ++ if (!orig) { ++ return NULL; ++ } // Calculate the accumulated transform, starting from the original. Geom::Matrix t = sp_use_get_root_transform(use); diff --cc src/spiral-context.cpp index 6730ab63b,13407b80b..754885192 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_SPIRAL_CONTEXT_C__ -- /* * Spiral drawing context * @@@ -7,6 -7,6 +5,8 @@@ * Mitsuru Oka * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2001 Lauris Kaplinski * Copyright (C) 2001-2002 Mitsuru Oka @@@ -42,6 -42,6 +42,8 @@@ #include "context-fns.h" #include "shape-editor.h" ++using Inkscape::DocumentUndo; ++ static void sp_spiral_context_class_init(SPSpiralContextClass * klass); static void sp_spiral_context_init(SPSpiralContext *spiral_context); static void sp_spiral_context_dispose(GObject *object); @@@ -397,8 -396,8 +399,7 @@@ sp_spiral_context_root_handler(SPEventC return ret; } --static void --sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state) ++static void sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state) { SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop; @@@ -411,12 -410,12 +412,12 @@@ return; } -- /* Create object */ -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(sc)); ++ // Create object ++ Inkscape::XML::Document *xml_doc = SP_EVENT_CONTEXT_DOCUMENT(sc)->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); repr->setAttribute("sodipodi:type", "spiral"); -- /* Set style */ ++ // Set style sp_desktop_apply_style_tool(desktop, repr, "/tools/shapes/spiral", false); sc->item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr); @@@ -481,8 -480,8 +482,8 @@@ sp_spiral_finish(SPSpiralContext *sc sp_canvas_end_forced_full_redraws(desktop->canvas); sp_desktop_selection(desktop)->set(sc->item); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL, -- _("Create spiral")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL, ++ _("Create spiral")); sc->item = NULL; } @@@ -507,7 -506,7 +508,7 @@@ static void sp_spiral_cancel(SPSpiralCo sp_canvas_end_forced_full_redraws(desktop->canvas); - sp_document_cancel(sp_desktop_document(desktop)); - SPDocumentUndo::cancel(sp_desktop_document(desktop)); ++ DocumentUndo::cancel(sp_desktop_document(desktop)); } /* diff --cc src/splivarot.cpp index e7787813d,b2fe45e19..5f32e591e --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@@ -1,4 -1,4 +1,3 @@@ --#define __SP_LIVAROT_C__ /* * splivarot.cpp * Inkscape @@@ -54,6 -54,6 +53,8 @@@ #include "splivarot.h" ++using Inkscape::DocumentUndo; ++ bool Ancetre(Inkscape::XML::Node *a, Inkscape::XML::Node *who); void sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb=SP_VERB_NONE, const Glib::ustring description=""); @@@ -419,8 -419,8 +420,8 @@@ sp_selected_path_boolop(SPDesktop *desk { SP_OBJECT(l->data)->deleteObject(); } - sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, -- description); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, ++ description); selection->clear(); delete res; @@@ -513,7 -513,7 +514,7 @@@ for (int i=0;i<nbRP;i++) { gchar *d = resPath[i]->svg_dump_path(); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); repr->setAttribute("style", style); if (mask) @@@ -559,7 -559,7 +560,7 @@@ } else { gchar *d = res->svg_dump_path(); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); repr->setAttribute("style", style); @@@ -593,7 -593,7 +594,7 @@@ if (desc) g_free(desc); if (verb != SP_VERB_NONE) { - sp_document_done(sp_desktop_document(desktop), verb, description); - SPDocumentUndo::done(sp_desktop_document(desktop), verb, description); ++ DocumentUndo::done(sp_desktop_document(desktop), verb, description); } delete res; @@@ -1065,7 -1058,7 +1066,7 @@@ sp_selected_path_outline(SPDesktop *des if (res->descr_cmd.size() > 1) { // if there's 0 or 1 node left, drop this path altogether SPDocument * doc = sp_desktop_document(desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); // restore old style, but set old stroke style on fill @@@ -1082,9 -1075,9 +1083,9 @@@ if (clip_path) repr->setAttribute("clip-path", clip_path); - if (SP_IS_SHAPE(item) && sp_shape_has_markers (SP_SHAPE(item))) { + if (SP_IS_SHAPE(item) && SP_SHAPE(item)->hasMarkers ()) { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *g_repr = xml_doc->createElement("svg:g"); // add the group to the parent @@@ -1223,8 -1216,8 +1224,8 @@@ } if (did) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_OUTLINE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_OUTLINE, -- _("Convert stroke to path")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_OUTLINE, ++ _("Convert stroke to path")); } else { // TRANSLATORS: "to outline" means "to convert stroke to path" desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No stroked paths</b> in the selection.")); @@@ -1426,11 -1420,11 +1428,11 @@@ sp_selected_path_create_offset_object(S { // pas vraiment de points sur le resultat // donc il ne reste rien - sp_document_done(sp_desktop_document(desktop), - SPDocumentUndo::done(sp_desktop_document(desktop), -- (updating ? SP_VERB_SELECTION_LINKED_OFFSET -- : SP_VERB_SELECTION_DYNAMIC_OFFSET), -- (updating ? _("Create linked offset") -- : _("Create dynamic offset"))); ++ DocumentUndo::done(sp_desktop_document(desktop), ++ (updating ? SP_VERB_SELECTION_LINKED_OFFSET ++ : SP_VERB_SELECTION_DYNAMIC_OFFSET), ++ (updating ? _("Create linked offset") ++ : _("Create dynamic offset"))); selection->clear(); delete res; @@@ -1444,7 -1438,7 +1446,7 @@@ tstr[79] = '\0'; -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); repr = xml_doc->createElement("svg:path"); repr->setAttribute("sodipodi:type", "inkscape:offset"); sp_repr_set_svg_double(repr, "inkscape:radius", ( expand > 0 @@@ -1495,11 -1491,11 +1499,11 @@@ selection->set(nitem); } - sp_document_done(sp_desktop_document(desktop), - SPDocumentUndo::done(sp_desktop_document(desktop), -- (updating ? SP_VERB_SELECTION_LINKED_OFFSET -- : SP_VERB_SELECTION_DYNAMIC_OFFSET), -- (updating ? _("Create linked offset") -- : _("Create dynamic offset"))); ++ DocumentUndo::done(sp_desktop_document(desktop), ++ (updating ? SP_VERB_SELECTION_LINKED_OFFSET ++ : SP_VERB_SELECTION_DYNAMIC_OFFSET), ++ (updating ? _("Create linked offset") ++ : _("Create dynamic offset"))); delete res; delete orig; @@@ -1708,7 -1704,7 +1712,7 @@@ sp_selected_path_do_offset(SPDesktop *d tstr[79] = '\0'; -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); repr->setAttribute("style", style); @@@ -1740,9 -1736,9 +1744,9 @@@ } if (did) { - sp_document_done(sp_desktop_document(desktop), - SPDocumentUndo::done(sp_desktop_document(desktop), -- (expand ? SP_VERB_SELECTION_OFFSET : SP_VERB_SELECTION_INSET), -- (expand ? _("Outset path") : _("Inset path"))); ++ DocumentUndo::done(sp_desktop_document(desktop), ++ (expand ? SP_VERB_SELECTION_OFFSET : SP_VERB_SELECTION_INSET), ++ (expand ? _("Outset path") : _("Inset path"))); } else { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No paths</b> to inset/outset in the selection.")); return; @@@ -1845,7 -1841,7 +1849,7 @@@ sp_selected_path_simplify_item(SPDeskto orig->Simplify(threshold * size); } -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); // restore style, mask and clip-path @@@ -2000,8 -1996,8 +2004,8 @@@ sp_selected_path_simplify_selection(SPD breakableAngles, true); if (didSomething) - sp_document_done(sp_desktop_document(desktop), SP_VERB_SELECTION_SIMPLIFY, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_SIMPLIFY, -- _("Simplify")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_SIMPLIFY, ++ _("Simplify")); else desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No paths</b> to simplify in the selection.")); diff --cc src/spray-context.cpp index e7172acd4,ebdf56673..0cf74f59b --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_SPRAY_CONTEXT_C__ -- /* * Spray Tool * @@@ -12,6 -12,6 +10,8 @@@ * Vincent MONTAGNE * Pierre BARBRY-BLOT * Steren GIANNINI (steren.giannini@gmail.com) ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2009 authors * @@@ -81,6 -81,6 +81,8 @@@ #include "helper/action.h" #include <iostream> ++ ++using Inkscape::DocumentUndo; using namespace std; @@@ -486,7 -486,7 +488,7 @@@ bool sp_spray_recursive(SPDesktop *desk { // duplicate SPDocument *doc = SP_OBJECT_DOCUMENT(item); -- Inkscape::XML::Document* xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document* xml_doc = doc->getReprDoc(); Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(item); Inkscape::XML::Node *parent = old_repr->parent(); Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); @@@ -527,7 -527,7 +529,7 @@@ i++; } SPDocument *doc = SP_OBJECT_DOCUMENT(father); -- Inkscape::XML::Document* xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document* xml_doc = doc->getReprDoc(); Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(father); Inkscape::XML::Node *parent = old_repr->parent(); @@@ -574,7 -574,7 +576,7 @@@ if(_fid<=population) { SPItem *item_copied; SPDocument *doc = SP_OBJECT_DOCUMENT(item); -- Inkscape::XML::Document* xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document* xml_doc = doc->getReprDoc(); Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(item); Inkscape::XML::Node *parent = old_repr->parent(); @@@ -877,16 -877,16 +879,16 @@@ case GDK_SCROLL_LEFT tc->has_dilated = false; switch (tc->mode) { case SPRAY_MODE_COPY: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_SPRAY, _("Spray with copies")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_SPRAY, _("Spray with copies")); break; case SPRAY_MODE_CLONE: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_SPRAY, _("Spray with clones")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_SPRAY, _("Spray with clones")); break; case SPRAY_MODE_SINGLE_PATH: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_SPRAY, _("Spray in single path")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_SPRAY, _("Spray in single path")); break; } } diff --cc src/star-context.cpp index 910c048b6,61646ceee..0fb20a2ab --- a/src/star-context.cpp +++ b/src/star-context.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_STAR_CONTEXT_C__ -- /* * Star drawing context * @@@ -7,6 -7,6 +5,8 @@@ * Mitsuru Oka <oka326@parkcity.ne.jp> * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2001-2002 Mitsuru Oka @@@ -47,6 -47,6 +47,8 @@@ #include "star-context.h" ++using Inkscape::DocumentUndo; ++ static void sp_star_context_class_init (SPStarContextClass * klass); static void sp_star_context_init (SPStarContext * star_context); static void sp_star_context_dispose (GObject *object); @@@ -425,12 -422,12 +427,12 @@@ static void sp_star_drag(SPStarContext return; } -- /* Create object */ -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(sc)); ++ // Create object ++ Inkscape::XML::Document *xml_doc = SP_EVENT_CONTEXT_DOCUMENT(sc)->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); repr->setAttribute("sodipodi:type", "star"); -- /* Set style */ ++ // Set style sp_desktop_apply_style_tool(desktop, repr, "/tools/shapes/star", false); sc->item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); @@@ -502,8 -499,8 +504,8 @@@ sp_star_finish (SPStarContext * sc sp_canvas_end_forced_full_redraws(desktop->canvas); sp_desktop_selection(desktop)->set(sc->item); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, -- _("Create star")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, ++ _("Create star")); sc->item = NULL; } @@@ -528,7 -525,7 +530,7 @@@ static void sp_star_cancel(SPStarContex sp_canvas_end_forced_full_redraws(desktop->canvas); - sp_document_cancel(sp_desktop_document(desktop)); - SPDocumentUndo::cancel(sp_desktop_document(desktop)); ++ DocumentUndo::cancel(sp_desktop_document(desktop)); } /* diff --cc src/style-test.h index 67a4d7014,0bc47906c..064773d1d --- a/src/style-test.h +++ b/src/style-test.h @@@ -1,4 -1,4 +1,3 @@@ -- #ifndef SEEN_STYLE_TEST_H #define SEEN_STYLE_TEST_H diff --cc src/style.cpp index 551dd6585,13967ec0c..d254ab6f4 --- a/src/style.cpp +++ b/src/style.cpp @@@ -5,6 -7,6 +5,7 @@@ * Lauris Kaplinski <lauris@kaplinski.com> * Peter Moulder <pmoulder@mail.csse.monash.edu.au> * bulia byak <buliabyak@users.sf.net> ++ * Abhishek Sharma * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. @@@ -1284,9 -1292,11 +1289,11 @@@ sp_style_merge_from_object_stylesheet(S } CRPropList *props = NULL; + - //XML Tree being directly used here while it shouldn't be. ++ //XML Tree being directly used here while it shouldn't be. CRStatus status = cr_sel_eng_get_matched_properties_from_cascade(sel_eng, object->document->style_cascade, - object->repr, + object->getRepr(), &props); g_return_if_fail(status == CR_OK); /// \todo Check what errors can occur, and handle them properly. diff --cc src/svg-view-widget.cpp index 10d997656,a60c93f0b..d2a31966a --- a/src/svg-view-widget.cpp +++ b/src/svg-view-widget.cpp @@@ -1,11 -1,11 +1,10 @@@ --#define __SP_SVG_VIEW_C__ -- /** \file * Functions and callbacks for generic SVG view and widget * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> ++ * Abhishek Sharma * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. diff --cc src/svg-view.cpp index bd46dd17a,6d989a8f5..ef87b38ef --- a/src/svg-view.cpp +++ b/src/svg-view.cpp @@@ -1,11 -1,11 +1,11 @@@ --#define __SP_SVG_VIEW_C__ -- /** \file * Functions and callbacks for generic SVG view and widget * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. @@@ -41,7 -41,7 +41,7 @@@ SPSVGView::~SPSVGView( { if (doc() && _drawing) { - sp_item_invoke_hide (SP_ITEM (sp_document_root (doc())), _dkey); - SP_ITEM (sp_document_root (doc()))->invoke_hide (_dkey); ++ SP_ITEM( doc()->getRoot() )->invoke_hide(_dkey); _drawing = NULL; } } @@@ -191,7 -191,7 +191,7 @@@ voi SPSVGView::setDocument (SPDocument *document) { if (doc()) { - sp_item_invoke_hide (SP_ITEM (sp_document_root (doc())), _dkey); - SP_ITEM (sp_document_root (doc()))->invoke_hide (_dkey); ++ SP_ITEM( doc()->getRoot() )->invoke_hide(_dkey); } if (!_drawing) { @@@ -200,8 -200,7 +200,7 @@@ } if (document) { - NRArenaItem *ai = sp_item_invoke_show ( - SP_ITEM (sp_document_root (document)), - NRArenaItem *ai = SP_ITEM (sp_document_root (document))->invoke_show ( ++ NRArenaItem *ai = SP_ITEM( document->getRoot() )->invoke_show( SP_CANVAS_ARENA (_drawing)->arena, _dkey, SP_ITEM_SHOW_DISPLAY); diff --cc src/test-helpers.h index 19dacd9c8,280935900..e1b852162 --- a/src/test-helpers.h +++ b/src/test-helpers.h @@@ -1,4 -1,4 +1,3 @@@ -- #ifndef SEEN_TEST_HELPERS_H #define SEEN_TEST_HELPERS_H diff --cc src/text-chemistry.cpp index cc02c656e,9d4c23b25..f2ea4367b --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@@ -1,10 -1,10 +1,10 @@@ --#define __SP_TEXT_CHEMISTRY_C__ -- /* * Text commands * * Authors: * bulia byak ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2004 authors * @@@ -37,6 -37,6 +37,7 @@@ #include "sp-flowdiv.h" #include "sp-tspan.h" ++using Inkscape::DocumentUndo; SPItem * text_in_selection(Inkscape::Selection *selection) @@@ -98,7 -98,7 +99,7 @@@ text_put_on_path( SPItem *text = text_or_flowtext_in_selection(selection); SPItem *shape = shape_in_selection(selection); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); if (!text || !shape || g_slist_length((GSList *) selection->itemList()) != 2) { sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select <b>a text and a path</b> to put text on path.")); @@@ -139,7 -139,7 +140,7 @@@ Inkscape::GC::release(repr); text->deleteObject(); // delete the orignal flowtext - sp_document_ensure_up_to_date(sp_desktop_document(desktop)); - sp_desktop_document(desktop)->ensure_up_to_date(); ++ sp_desktop_document(desktop)->ensureUpToDate(); selection->clear(); @@@ -188,8 -188,8 +189,8 @@@ SP_OBJECT_REPR(text)->setAttribute("x", NULL); SP_OBJECT_REPR(text)->setAttribute("y", NULL); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, -- _("Put text on path")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, ++ _("Put text on path")); g_slist_free(text_reprs); } @@@ -215,7 -215,7 +216,7 @@@ text_remove_from_path( continue; } - SPObject *tp = sp_object_first_child(SP_OBJECT(items->data)); - SPObject *tp = SP_OBJECT(items->data)->first_child(); ++ SPObject *tp = SP_OBJECT(items->data)->firstChild(); did = true; @@@ -225,8 -225,8 +226,8 @@@ if (!did) { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("<b>No texts-on-paths</b> in the selection.")); } else { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, -- _("Remove text from path")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, ++ _("Remove text from path")); selection->setList(g_slist_copy((GSList *) selection->itemList())); // reselect to update statusbar description } } @@@ -252,7 -252,7 +253,7 @@@ text_remove_all_kerns_recursively(SPObj g_strfreev(xa_comma); } - for (SPObject *i = sp_object_first_child(o); i != NULL; i = SP_OBJECT_NEXT(i)) { - for (SPObject *i = o->first_child(); i != NULL; i = SP_OBJECT_NEXT(i)) { ++ for (SPObject *i = o->firstChild(); i != NULL; i = i->getNext()) { text_remove_all_kerns_recursively(i); } } @@@ -289,8 -289,8 +290,8 @@@ text_remove_all_kerns( if (!did) { sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE, _("Select <b>text(s)</b> to remove kerns from.")); } else { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, -- _("Remove manual kerns")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, ++ _("Remove manual kerns")); } } @@@ -302,7 -302,7 +303,7 @@@ text_flow_into_shape( return; SPDocument *doc = sp_desktop_document (desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::Selection *selection = sp_desktop_selection(desktop); @@@ -377,8 -377,8 +378,8 @@@ SP_OBJECT(text)->deleteObject (true); - sp_document_done(doc, SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(doc, SP_VERB_CONTEXT_TEXT, -- _("Flow text into shape")); ++ DocumentUndo::done(doc, SP_VERB_CONTEXT_TEXT, ++ _("Flow text into shape")); sp_desktop_selection(desktop)->set(SP_ITEM(root_object)); @@@ -394,7 -394,7 +395,7 @@@ text_unflow ( return; SPDocument *doc = sp_desktop_document (desktop); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::Selection *selection = sp_desktop_selection(desktop); @@@ -473,8 -473,8 +474,8 @@@ g_slist_free (old_objs); g_slist_free (new_objs); - sp_document_done(doc, SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(doc, SP_VERB_CONTEXT_TEXT, -- _("Unflow flowed text")); ++ DocumentUndo::done(doc, SP_VERB_CONTEXT_TEXT, ++ _("Unflow flowed text")); } void @@@ -530,9 -530,9 +531,9 @@@ flowtext_to_text( g_slist_free(items); if (did) { - sp_document_done(sp_desktop_document(desktop), - SPDocumentUndo::done(sp_desktop_document(desktop), -- SP_VERB_OBJECT_FLOWTEXT_TO_TEXT, -- _("Convert flowed text to text")); ++ DocumentUndo::done(sp_desktop_document(desktop), ++ SP_VERB_OBJECT_FLOWTEXT_TO_TEXT, ++ _("Convert flowed text to text")); selection->setReprList(reprs); } else { sp_desktop_message_stack(desktop)-> diff --cc src/text-context.cpp index 9d94e0e78,cfde60a0d..66e5f9450 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@@ -1,11 -1,11 +1,11 @@@ --#define __SP_TEXT_CONTEXT_C__ -- /* * SPTextContext * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2005 authors * Copyright (C) 2001 Ximian, Inc. @@@ -54,6 -54,6 +54,7 @@@ #include "text-context.h" ++using Inkscape::DocumentUndo; static void sp_text_context_class_init(SPTextContextClass *klass); static void sp_text_context_init(SPTextContext *text_context); @@@ -340,7 -340,7 +341,7 @@@ sp_text_context_item_handler(SPEventCon case GDK_BUTTON_PRESS: if (event->button.button == 1 && !event_context->space_panning) { // find out clicked item, disregarding groups -- item_ungrouped = desktop->item_at_point(Geom::Point(event->button.x, event->button.y), TRUE); ++ item_ungrouped = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), TRUE); if (SP_IS_TEXT(item_ungrouped) || SP_IS_FLOWTEXT(item_ungrouped)) { sp_desktop_selection(desktop)->set(item_ungrouped); if (tc->text) { @@@ -423,7 -423,7 +424,7 @@@ break; } // find out item under mouse, disregarding groups -- item_ungrouped = desktop->item_at_point(Geom::Point(event->button.x, event->button.y), TRUE); ++ item_ungrouped = desktop->getItemAtPoint(Geom::Point(event->button.x, event->button.y), TRUE); if (SP_IS_TEXT(item_ungrouped) || SP_IS_FLOWTEXT(item_ungrouped)) { Inkscape::Text::Layout const *layout = te_get_layout(item_ungrouped); @@@ -473,7 -473,7 +474,7 @@@ sp_text_context_setup_text(SPTextContex SPEventContext *ec = SP_EVENT_CONTEXT(tc); /* Create <text> */ -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DESKTOP(ec)->doc()); ++ Inkscape::XML::Document *xml_doc = SP_EVENT_CONTEXT_DESKTOP(ec)->doc()->getReprDoc(); Inkscape::XML::Node *rtext = xml_doc->createElement("svg:text"); rtext->setAttribute("xml:space", "preserve"); // we preserve spaces in the text objects we create @@@ -498,11 -498,11 +499,11 @@@ /* yes, it's immediate .. why does it matter? */ sp_desktop_selection(ec->desktop)->set(text_item); Inkscape::GC::release(rtext); - text_item->transform = sp_item_i2doc_affine(SP_ITEM(ec->desktop->currentLayer())).inverse(); + text_item->transform = SP_ITEM(ec->desktop->currentLayer())->i2doc_affine().inverse(); text_item->updateRepr(); - sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, -- _("Create text")); ++ DocumentUndo::done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, ++ _("Create text")); } /** @@@ -540,8 -540,8 +541,8 @@@ insert_uni_char(SPTextContext *const tc tc->text_sel_start = tc->text_sel_end = sp_te_replace(tc->text, tc->text_sel_start, tc->text_sel_end, u); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); - sp_document_done(sp_desktop_document(tc->desktop), SP_VERB_DIALOG_TRANSFORM, - SPDocumentUndo::done(sp_desktop_document(tc->desktop), SP_VERB_DIALOG_TRANSFORM, -- _("Insert Unicode character")); ++ DocumentUndo::done(sp_desktop_document(tc->desktop), SP_VERB_DIALOG_TRANSFORM, ++ _("Insert Unicode character")); } } @@@ -723,8 -699,8 +724,8 @@@ sp_text_context_root_handler(SPEventCon sp_desktop_apply_style_tool(desktop, SP_OBJECT_REPR(ft), "/tools/text", true); sp_desktop_selection(desktop)->set(ft); desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Flowed text is created.")); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, -- _("Create flowed text")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, ++ _("Create flowed text")); } else { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The frame is <b>too small</b> for the current font size. Flowed text not created.")); } @@@ -863,8 -839,8 +864,8 @@@ sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("No-break space")); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, -- _("Insert no-break space")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, ++ _("Insert no-break space")); return TRUE; } break; @@@ -900,8 -876,8 +901,8 @@@ sp_repr_css_set_property(css, "font-weight", "normal"); sp_te_apply_style(tc->text, tc->text_sel_start, tc->text_sel_end, css); sp_repr_css_attr_unref(css); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, -- _("Make bold")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, ++ _("Make bold")); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); return TRUE; @@@ -918,8 -894,8 +919,8 @@@ sp_repr_css_set_property(css, "font-style", "italic"); sp_te_apply_style(tc->text, tc->text_sel_start, tc->text_sel_end, css); sp_repr_css_attr_unref(css); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, -- _("Make italic")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, ++ _("Make italic")); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); return TRUE; @@@ -957,8 -933,8 +958,8 @@@ sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, -- _("New line")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, ++ _("New line")); return TRUE; } case GDK_BackSpace: @@@ -991,8 -967,8 +992,8 @@@ sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, -- _("Backspace")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, ++ _("Backspace")); } return TRUE; case GDK_Delete: @@@ -1022,8 -998,8 +1023,8 @@@ sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, -- _("Delete")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, ++ _("Delete")); } return TRUE; case GDK_Left: @@@ -1039,8 -1015,8 +1040,8 @@@ sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(mul*-1, 0)); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); - sp_document_maybe_done(sp_desktop_document(desktop), "kern:left", SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "kern:left", SP_VERB_CONTEXT_TEXT, -- _("Kern to the left")); ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:left", SP_VERB_CONTEXT_TEXT, ++ _("Kern to the left")); } else { if (MOD__CTRL) tc->text_sel_end.cursorLeftWithControl(); @@@ -1064,8 -1040,8 +1065,8 @@@ sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(mul*1, 0)); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); - sp_document_maybe_done(sp_desktop_document(desktop), "kern:right", SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "kern:right", SP_VERB_CONTEXT_TEXT, -- _("Kern to the right")); ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:right", SP_VERB_CONTEXT_TEXT, ++ _("Kern to the right")); } else { if (MOD__CTRL) tc->text_sel_end.cursorRightWithControl(); @@@ -1089,9 -1065,9 +1090,8 @@@ sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(0, mul*-1)); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); - sp_document_maybe_done(sp_desktop_document(desktop), "kern:up", SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "kern:up", SP_VERB_CONTEXT_TEXT, -- _("Kern up")); -- ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:up", SP_VERB_CONTEXT_TEXT, ++ _("Kern up")); } else { if (MOD__CTRL) tc->text_sel_end.cursorUpWithControl(); @@@ -1115,9 -1091,9 +1115,8 @@@ sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, Geom::Point(0, mul*1)); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); - sp_document_maybe_done(sp_desktop_document(desktop), "kern:down", SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "kern:down", SP_VERB_CONTEXT_TEXT, -- _("Kern down")); -- ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), "kern:down", SP_VERB_CONTEXT_TEXT, ++ _("Kern down")); } else { if (MOD__CTRL) tc->text_sel_end.cursorDownWithControl(); @@@ -1192,8 -1168,8 +1191,8 @@@ } else { sp_te_adjust_rotation(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, -90); } - sp_document_maybe_done(sp_desktop_document(desktop), "textrot:ccw", SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "textrot:ccw", SP_VERB_CONTEXT_TEXT, -- _("Rotate counterclockwise")); ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), "textrot:ccw", SP_VERB_CONTEXT_TEXT, ++ _("Rotate counterclockwise")); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); return TRUE; @@@ -1213,8 -1189,8 +1212,8 @@@ } else { sp_te_adjust_rotation(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, 90); } - sp_document_maybe_done(sp_desktop_document(desktop), "textrot:cw", SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "textrot:cw", SP_VERB_CONTEXT_TEXT, -- _("Rotate clockwise")); ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), "textrot:cw", SP_VERB_CONTEXT_TEXT, ++ _("Rotate clockwise")); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); return TRUE; @@@ -1230,17 -1206,17 +1229,15 @@@ sp_te_adjust_linespacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, -10); else sp_te_adjust_linespacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, -1); - sp_document_maybe_done(sp_desktop_document(desktop), "linespacing:dec", SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "linespacing:dec", SP_VERB_CONTEXT_TEXT, -- _("Contract line spacing")); -- ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), "linespacing:dec", SP_VERB_CONTEXT_TEXT, ++ _("Contract line spacing")); } else { if (MOD__SHIFT) sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, -10); else sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, -1); - sp_document_maybe_done(sp_desktop_document(desktop), "letterspacing:dec", SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "letterspacing:dec", SP_VERB_CONTEXT_TEXT, -- _("Contract letter spacing")); -- ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), "letterspacing:dec", SP_VERB_CONTEXT_TEXT, ++ _("Contract letter spacing")); } sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); @@@ -1257,17 -1233,17 +1254,15 @@@ sp_te_adjust_linespacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, 10); else sp_te_adjust_linespacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, 1); - sp_document_maybe_done(sp_desktop_document(desktop), "linespacing:inc", SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "linespacing:inc", SP_VERB_CONTEXT_TEXT, -- _("Expand line spacing")); -- ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), "linespacing:inc", SP_VERB_CONTEXT_TEXT, ++ _("Expand line spacing")); } else { if (MOD__SHIFT) sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, 10); else sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, desktop, 1); - sp_document_maybe_done(sp_desktop_document(desktop), "letterspacing:inc", SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), "letterspacing:inc", SP_VERB_CONTEXT_TEXT, -- _("Expand letter spacing")); -- ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), "letterspacing:inc", SP_VERB_CONTEXT_TEXT, ++ _("Expand letter spacing"));\ } sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); @@@ -1395,8 -1371,8 +1390,8 @@@ sp_text_paste_inline(SPEventContext *ec tc->text_sel_start = tc->text_sel_end = sp_te_insert_line(tc->text, tc->text_sel_start); begin = end + 1; } - sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, -- _("Paste text")); ++ DocumentUndo::done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, ++ _("Paste text")); return true; } @@@ -1520,8 -1496,8 +1515,8 @@@ sp_text_context_style_set(SPCSSAttr con return false; // will get picked up by the parent and applied to the whole text object sp_te_apply_style(tc->text, tc->text_sel_start, tc->text_sel_end, css); - sp_document_done(sp_desktop_document(tc->desktop), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(sp_desktop_document(tc->desktop), SP_VERB_CONTEXT_TEXT, -- _("Set text style")); ++ DocumentUndo::done(sp_desktop_document(tc->desktop), SP_VERB_CONTEXT_TEXT, ++ _("Set text style")); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); @@@ -1761,8 -1737,8 +1756,8 @@@ sptc_commit(GtkIMContext */*imc*/, gcha sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); - sp_document_done(SP_OBJECT_DOCUMENT(tc->text), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done(SP_OBJECT_DOCUMENT(tc->text), SP_VERB_CONTEXT_TEXT, -- _("Type text")); ++ DocumentUndo::done(SP_OBJECT_DOCUMENT(tc->text), SP_VERB_CONTEXT_TEXT, ++ _("Type text")); } void diff --cc src/text-editing.cpp index 5bad33d29,a307e5e27..2e6e2f9fa --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@@ -4,6 -4,6 +4,8 @@@ * Authors: * bulia byak * Richard Hughes ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2004-5 authors * @@@ -57,25 -57,24 +59,29 @@@ static void te_update_layout_now (SPIte SP_TEXT(item)->rebuildLayout(); else if (SP_IS_FLOWTEXT (item)) SP_FLOWTEXT(item)->rebuildLayout(); + item->updateRepr(); } --/** Returns true if there are no visible characters on the canvas */ --bool --sp_te_output_is_empty (SPItem const *item) ++bool sp_te_output_is_empty(SPItem const *item) { Inkscape::Text::Layout const *layout = te_get_layout(item); return layout->begin() == layout->end(); } --/** Returns true if the user has typed nothing in the text box */ --bool --sp_te_input_is_empty (SPObject const *item) ++bool sp_te_input_is_empty(SPObject const *item) { -- if (SP_IS_STRING(item)) return SP_STRING(item)->string.empty(); -- for (SPObject const *child = item->firstChild() ; child ; child = SP_OBJECT_NEXT(child)) -- if (!sp_te_input_is_empty(child)) return false; -- return true; ++ bool empty = true; ++ if (SP_IS_STRING(item)) { ++ empty = SP_STRING(item)->string.empty(); ++ } else { ++ for (SPObject const *child = item->firstChild() ; child ; child = child->getNext()) { ++ if (!sp_te_input_is_empty(child)) { ++ empty = false; ++ break; ++ } ++ } ++ } ++ return empty; } Inkscape::Text::Layout::iterator @@@ -200,25 -199,25 +206,29 @@@ static const char * span_name_for_text_ return NULL; } --/** Recursively gets the length of all the SPStrings at or below the given --\a item. Also adds 1 for each line break encountered. */ unsigned sp_text_get_length(SPObject const *item) { unsigned length = 0; -- if (SP_IS_STRING(item)) return SP_STRING(item)->string.length(); -- -- if (is_line_break_object(item)) length++; ++ if (SP_IS_STRING(item)) { ++ length = SP_STRING(item)->string.length(); ++ } else { ++ if (is_line_break_object(item)) { ++ length++; ++ } -- for (SPObject const *child = item->firstChild() ; child ; child = SP_OBJECT_NEXT(child)) { -- if (SP_IS_STRING(child)) length += SP_STRING(child)->string.length(); -- else length += sp_text_get_length(child); ++ for (SPObject const *child = item->firstChild() ; child ; child = child->getNext()) { ++ if (SP_IS_STRING(child)) { ++ length += SP_STRING(child)->string.length(); ++ } else { ++ length += sp_text_get_length(child); ++ } ++ } } ++ return length; } --/** Recursively gets the length of all the SPStrings at or below the given --\a item, before and not including \a upto. Also adds 1 for each line break encountered. */ unsigned sp_text_get_length_upto(SPObject const *item, SPObject const *upto) { unsigned length = 0; @@@ -237,7 -236,7 +247,7 @@@ } // Count the length of the children -- for (SPObject const *child = item->firstChild() ; child ; child = SP_OBJECT_NEXT(child)) { ++ for (SPObject const *child = item->firstChild() ; child ; child = child->getNext()) { if (upto && child == upto) { // hit upto, return immediately return length; @@@ -293,8 -292,8 +303,9 @@@ to \a item at the same level. * static unsigned sum_sibling_text_lengths_before(SPObject const *item) { unsigned char_index = 0; -- for (SPObject *sibling = SP_OBJECT_PARENT(item)->firstChild() ; sibling && sibling != item ; sibling = SP_OBJECT_NEXT(sibling)) ++ for (SPObject *sibling = SP_OBJECT_PARENT(item)->firstChild() ; sibling && sibling != item ; sibling = sibling->getNext()) { char_index += sp_text_get_length(sibling); ++ } return char_index; } @@@ -316,13 -315,13 +327,13 @@@ parent of the first line break node enc */ static SPObject* split_text_object_tree_at(SPObject *split_obj, unsigned char_index) { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(split_obj)); ++ Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(split_obj)->getReprDoc(); if (is_line_break_object(split_obj)) { Inkscape::XML::Node *new_node = duplicate_node_without_children(xml_doc, SP_OBJECT_REPR(split_obj)); SP_OBJECT_REPR(SP_OBJECT_PARENT(split_obj))->addChild(new_node, SP_OBJECT_REPR(split_obj)); Inkscape::GC::release(new_node); -- split_attributes(split_obj, SP_OBJECT_NEXT(split_obj), char_index); -- return SP_OBJECT_NEXT(split_obj); ++ split_attributes(split_obj, split_obj->getNext(), char_index); ++ return split_obj->getNext(); } unsigned char_count_before = sum_sibling_text_lengths_before(split_obj); @@@ -336,10 -335,10 +347,10 @@@ split_attributes(split_obj, duplicate_obj->firstChild(), char_index); // then move all the subsequent nodes -- split_obj = SP_OBJECT_NEXT(split_obj); ++ split_obj = split_obj->getNext(); while (split_obj) { Inkscape::XML::Node *move_repr = SP_OBJECT_REPR(split_obj); -- SPObject *next_obj = SP_OBJECT_NEXT(split_obj); // this is about to become invalidated by removeChild() ++ SPObject *next_obj = split_obj->getNext(); // this is about to become invalidated by removeChild() Inkscape::GC::anchor(move_repr); SP_OBJECT_REPR(SP_OBJECT_PARENT(split_obj))->removeChild(move_repr); SP_OBJECT_REPR(duplicate_obj)->appendChild(move_repr); @@@ -376,12 -375,12 +387,12 @@@ Inkscape::Text::Layout::iterator sp_te_ if (split_obj == 0) split_obj = item->lastChild(); if (SP_IS_TREF(split_obj)) { -- desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, tref_edit_message); ++ desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, tref_edit_message); return position; } if (split_obj) { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(split_obj)); ++ Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(split_obj)->getReprDoc(); Inkscape::XML::Node *new_node = duplicate_node_without_children(xml_doc, SP_OBJECT_REPR(split_obj)); SP_OBJECT_REPR(SP_OBJECT_PARENT(split_obj))->addChild(new_node, SP_OBJECT_REPR(split_obj)); Inkscape::GC::release(new_node); @@@ -420,12 -419,12 +431,17 @@@ static SPString* sp_te_seek_next_string while (start_obj) { if (start_obj->hasChildren()) { SPString *found_string = sp_te_seek_next_string_recursive(start_obj->firstChild()); -- if (found_string) return found_string; ++ if (found_string) { ++ return found_string; ++ } + } - if (SP_IS_STRING(start_obj)) return SP_STRING(start_obj); - start_obj = SP_OBJECT_NEXT(start_obj); - if (is_line_break_object(start_obj)) ++ if (SP_IS_STRING(start_obj)) { ++ return SP_STRING(start_obj); + } - if (SP_IS_STRING(start_obj)) return SP_STRING(start_obj); - start_obj = SP_OBJECT_NEXT(start_obj); - if (is_line_break_object(start_obj)) ++ start_obj = start_obj->getNext(); ++ if (is_line_break_object(start_obj)) { break; // don't cross line breaks ++ } } return NULL; } @@@ -495,10 -494,10 +511,12 @@@ sp_te_insert(SPItem *item, Inkscape::Te if (source_obj->hasChildren()) { source_obj = source_obj->firstChild(); if (SP_IS_FLOWTEXT(item)) { -- while (SP_IS_FLOWREGION(source_obj) || SP_IS_FLOWREGIONEXCLUDE(source_obj)) -- source_obj = SP_OBJECT_NEXT(source_obj); -- if (source_obj == NULL) ++ while (SP_IS_FLOWREGION(source_obj) || SP_IS_FLOWREGIONEXCLUDE(source_obj)) { ++ source_obj = source_obj->getNext(); ++ } ++ if (source_obj == NULL) { source_obj = item; ++ } } } if (source_obj == item && SP_IS_FLOWTEXT(item)) { @@@ -507,7 -506,7 +525,7 @@@ source_obj = item->lastChild(); } } else -- source_obj = SP_OBJECT_NEXT(source_obj); ++ source_obj = source_obj->getNext(); if (source_obj) { // never fails SPString *string_item = sp_te_seek_next_string_recursive(source_obj); @@@ -607,16 -606,16 +625,16 @@@ static SPObject* delete_line_break(SPOb new_span_repr->setAttribute("rotate", a); SPObject *following_item = item; -- while (SP_OBJECT_NEXT(following_item) == NULL) { ++ while (following_item->getNext() == NULL) { following_item = SP_OBJECT_PARENT(following_item); g_assert(following_item != root); } -- following_item = SP_OBJECT_NEXT(following_item); ++ following_item = following_item->getNext(); SPObject *new_parent_item; if (SP_IS_STRING(following_item)) { new_parent_item = SP_OBJECT_PARENT(following_item); -- SP_OBJECT_REPR(new_parent_item)->addChild(new_span_repr, SP_OBJECT_PREV(following_item) ? SP_OBJECT_REPR(SP_OBJECT_PREV(following_item)) : NULL); ++ SP_OBJECT_REPR(new_parent_item)->addChild(new_span_repr, following_item->getPrev() ? SP_OBJECT_REPR(following_item->getPrev()) : NULL); next_item = following_item; *next_is_sibling = true; } else { @@@ -771,7 -770,7 +789,7 @@@ sp_te_delete (SPItem *item, Inkscape::T SPObject *next_item; do { bool is_sibling = true; -- next_item = SP_OBJECT_NEXT(sub_item); ++ next_item = sub_item->getNext(); if (next_item == NULL) { next_item = SP_OBJECT_PARENT(sub_item); is_sibling = false; @@@ -804,16 -803,16 +822,19 @@@ replacing line break elements with '\n'. */ static void sp_te_get_ustring_multiline(SPObject const *root, Glib::ustring *string, bool *pending_line_break) { -- if (*pending_line_break) ++ if (*pending_line_break) { *string += '\n'; -- for (SPObject const *child = root->firstChild() ; child ; child = SP_OBJECT_NEXT(child)) { -- if (SP_IS_STRING(child)) ++ } ++ for (SPObject const *child = root->firstChild() ; child ; child = child->getNext()) { ++ if (SP_IS_STRING(child)) { *string += SP_STRING(child)->string; -- else ++ } else { sp_te_get_ustring_multiline(child, string, pending_line_break); ++ } } -- if (!SP_IS_TEXT(root) && !SP_IS_TEXTPATH(root) && is_line_break_object(root)) ++ if (!SP_IS_TEXT(root) && !SP_IS_TEXTPATH(root) && is_line_break_object(root)) { *pending_line_break = true; ++ } } /** Gets a text-only representation of the given text or flowroot object, @@@ -873,8 -872,8 +894,8 @@@ sp_te_set_repr_text_multiline(SPItem *t SPObject *object; bool is_textpath = false; if (SP_IS_TEXT_TEXTPATH (text)) { - repr = SP_OBJECT_REPR (sp_object_first_child(SP_OBJECT (text))); - object = sp_object_first_child(SP_OBJECT (text)); - repr = SP_OBJECT_REPR (SP_OBJECT (text)->first_child()); - object = SP_OBJECT (text)->first_child(); ++ repr = SP_OBJECT_REPR(text->firstChild()); ++ object = text->firstChild(); is_textpath = true; } else { repr = SP_OBJECT_REPR (text); @@@ -887,9 -886,9 +908,10 @@@ repr->setContent(""); SPObject *child = object->firstChild(); while (child) { -- SPObject *next = SP_OBJECT_NEXT(child); -- if (!SP_IS_FLOWREGION(child) && !SP_IS_FLOWREGIONEXCLUDE(child)) ++ SPObject *next = child->getNext(); ++ if (!SP_IS_FLOWREGION(child) && !SP_IS_FLOWREGIONEXCLUDE(child)) { repr->removeChild(SP_OBJECT_REPR(child)); ++ } child = next; } @@@ -1341,7 -1331,7 +1363,7 @@@ static void apply_css_recursive(SPObjec { sp_repr_css_change(SP_OBJECT_REPR(o), const_cast<SPCSSAttr*>(css), "style"); - for (SPObject *child = sp_object_first_child(SP_OBJECT(o)) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = SP_OBJECT(o)->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = o->firstChild() ; child ; child = child->getNext() ) { if (sp_repr_css_property(const_cast<SPCSSAttr*>(css), "opacity", NULL) != NULL) { // Unset properties which are accumulating and thus should not be set recursively. // For example, setting opacity 0.5 on a group recursively would result in the visible opacity of 0.25 for an item in the group. @@@ -1364,11 -1354,11 +1386,12 @@@ name of the xml for a text span (ie tsp static void recursively_apply_style(SPObject *common_ancestor, SPCSSAttr const *css, SPObject *start_item, Glib::ustring::iterator start_text_iter, SPObject *end_item, Glib::ustring::iterator end_text_iter, char const *span_object_name) { bool passed_start = start_item == NULL ? true : false; -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(common_ancestor)); ++ Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(common_ancestor)->getReprDoc(); -- for (SPObject *child = common_ancestor->firstChild() ; child != NULL ; child = SP_OBJECT_NEXT(child)) { -- if (start_item == child) ++ for (SPObject *child = common_ancestor->firstChild() ; child ; child = child->getNext()) { ++ if (start_item == child) { passed_start = true; ++ } if (passed_start) { if (end_item && child->isAncestorOf(end_item)) { @@@ -1385,7 -1375,7 +1408,7 @@@ Inkscape::XML::Node *child_span = xml_doc->createElement(span_object_name); sp_repr_css_set(child_span, const_cast<SPCSSAttr*>(css), "style"); // better hope that prototype wasn't nonconst for a good reason -- SPObject *prev_item = SP_OBJECT_PREV(child); ++ SPObject *prev_item = child->getPrev(); Inkscape::XML::Node *prev_repr = prev_item ? SP_OBJECT_REPR(prev_item) : NULL; if (child == start_item || child == end_item) { @@@ -1493,13 -1483,13 +1516,17 @@@ static SPObject* ascend_while_first(SPO -> abcdef */ static bool tidy_operator_empty_spans(SPObject **item) { -- if ((*item)->hasChildren()) return false; -- if (is_line_break_object(*item)) return false; -- if (SP_IS_STRING(*item) && !SP_STRING(*item)->string.empty()) return false; -- SPObject *next = SP_OBJECT_NEXT(*item); -- (*item)->deleteObject(); -- *item = next; -- return true; ++ bool result = false; ++ if ( !(*item)->hasChildren() ++ && !is_line_break_object(*item) ++ && !(SP_IS_STRING(*item) && !SP_STRING(*item)->string.empty()) ++ ) { ++ SPObject *next = (*item)->getNext(); ++ (*item)->deleteObject(); ++ *item = next; ++ result = true; ++ } ++ return result; } /** inexplicable spans: abc<span style="">def</span>ghi @@@ -1507,7 -1497,8 +1534,8 @@@ the repeated strings will be merged by another operator. */ static bool tidy_operator_inexplicable_spans(SPObject **item) { - if (*item && sp_repr_is_meta_element((*item)->repr)) return false; - //XML Tree being directly used here while it shouldn't be. ++ //XML Tree being directly used here while it shouldn't be. + if (*item && sp_repr_is_meta_element((*item)->getRepr())) return false; if (SP_IS_STRING(*item)) return false; if (is_line_break_object(*item)) return false; TextTagAttributes *attrs = attributes_for_object(*item); @@@ -1520,7 -1511,7 +1548,7 @@@ SP_OBJECT_REPR(*item)->removeChild(repr); SP_OBJECT_REPR(SP_OBJECT_PARENT(*item))->addChild(repr, SP_OBJECT_REPR(next)); Inkscape::GC::release(repr); -- next = SP_OBJECT_NEXT(next); ++ next = next->getNext(); } (*item)->deleteObject(); *item = next; @@@ -1532,7 -1523,7 +1560,7 @@@ static bool tidy_operator_repeated_spans(SPObject **item) { SPObject *first = *item; -- SPObject *second = SP_OBJECT_NEXT(first); ++ SPObject *second = first->getNext(); if (second == NULL) return false; Inkscape::XML::Node *first_repr = SP_OBJECT_REPR(first); @@@ -1605,10 -1596,10 +1633,12 @@@ static bool redundant_double_nesting_pr if (attrs && attrs->anyAttributesSet()) return false; if (!objects_have_equal_style(SP_OBJECT_PARENT(*item), child)) return false; -- Inkscape::XML::Node *insert_after_repr; -- if (!prepend) insert_after_repr = SP_OBJECT_REPR(*item); -- else if (SP_OBJECT_PREV(*item)) insert_after_repr = SP_OBJECT_REPR(SP_OBJECT_PREV(*item)); -- else insert_after_repr = NULL; ++ Inkscape::XML::Node *insert_after_repr = 0; ++ if (!prepend) { ++ insert_after_repr = SP_OBJECT_REPR(*item); ++ } else if ((*item)->getPrev()) { ++ insert_after_repr = SP_OBJECT_REPR((*item)->getPrev()); ++ } while (SP_OBJECT_REPR(child)->childCount()) { Inkscape::XML::Node *move_repr = SP_OBJECT_REPR(child)->firstChild(); Inkscape::GC::anchor(move_repr); @@@ -1673,7 -1664,7 +1703,7 @@@ static bool redundant_semi_nesting_proc Inkscape::XML::Document *xml_doc = SP_OBJECT_REPR(*item)->document(); Inkscape::XML::Node *new_span = xml_doc->createElement(SP_OBJECT_REPR(*item)->name()); if (prepend) { -- SPObject *prev = SP_OBJECT_PREV(*item); ++ SPObject *prev = (*item)->getPrev(); SP_OBJECT_REPR(SP_OBJECT_PARENT(*item))->addChild(new_span, prev ? SP_OBJECT_REPR(prev) : NULL); } else SP_OBJECT_REPR(SP_OBJECT_PARENT(*item))->addChild(new_span, SP_OBJECT_REPR(*item)); @@@ -1703,7 -1694,7 +1733,7 @@@ static bool tidy_operator_redundant_sem in a paragraph which is not \a not_obj. */ static SPString* find_last_string_child_not_equal_to(SPObject *root, SPObject *not_obj) { -- for (SPObject *child = root->lastChild() ; child ; child = SP_OBJECT_PREV(child)) ++ for (SPObject *child = root->lastChild() ; child ; child = child->getPrev()) { if (child == not_obj) continue; if (child->hasChildren()) { @@@ -1729,7 -1720,7 +1759,7 @@@ static bool tidy_operator_styled_whites SPObject *test_item = *item; SPString *next_string; for ( ; ; ) { // find the next string -- next_string = sp_te_seek_next_string_recursive(SP_OBJECT_NEXT(test_item)); ++ next_string = sp_te_seek_next_string_recursive(test_item->getNext()); if (next_string) { next_string->string.insert(0, str); break; @@@ -1738,7 -1729,7 +1768,7 @@@ test_item = SP_OBJECT_PARENT(test_item); if (is_line_break_object(test_item)) break; if (SP_IS_FLOWTEXT(test_item)) return false; -- SPObject *next = SP_OBJECT_NEXT(test_item); ++ SPObject *next = test_item->getNext(); if (next) { test_item = next; break; @@@ -1753,7 -1744,7 +1783,7 @@@ } SP_OBJECT_REPR(next_string)->setContent(next_string->string.c_str()); SPObject *delete_obj = *item; -- *item = SP_OBJECT_NEXT(*item); ++ *item = (*item)->getNext(); delete_obj->deleteObject(); return true; } @@@ -1796,11 -1787,11 +1826,12 @@@ static bool tidy_xml_tree_recursively(S for (SPObject *child = root->firstChild() ; child != NULL ; ) { if (SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child) || SP_IS_TREF(child)) { -- child = SP_OBJECT_NEXT(child); ++ child = child->getNext(); continue; } -- if (child->hasChildren()) ++ if (child->hasChildren()) { changes |= tidy_xml_tree_recursively(child); ++ } unsigned i; for (i = 0 ; i < sizeof(tidy_operators) / sizeof(tidy_operators[0]) ; i++) { @@@ -1809,8 -1800,8 +1840,9 @@@ break; } } -- if (i == sizeof(tidy_operators) / sizeof(tidy_operators[0])) -- child = SP_OBJECT_NEXT(child); ++ if (i == sizeof(tidy_operators) / sizeof(tidy_operators[0])) { ++ child = child->getNext(); ++ } } return changes; } @@@ -1838,13 -1829,13 +1870,18 @@@ void sp_te_apply_style(SPItem *text, In start_item = SP_OBJECT(rawptr); layout->getSourceOfCharacter(last, &rawptr, &end_text_iter); end_item = SP_OBJECT(rawptr); -- if (start_item == 0) ++ if (start_item == 0) { return; // start is at end of text -- if (is_line_break_object(start_item)) -- start_item = SP_OBJECT_NEXT(start_item); -- if (is_line_break_object(end_item)) -- end_item = SP_OBJECT_NEXT(end_item); -- if (end_item == 0) end_item = text; ++ } ++ if (is_line_break_object(start_item)) { ++ start_item = start_item->getNext(); ++ } ++ if (is_line_break_object(end_item)) { ++ end_item = end_item->getNext(); ++ } ++ if (end_item == 0) { ++ end_item = text; ++ } /* Special case: With a tref, we only want to change its style when the whole @@@ -1920,17 -1911,17 +1957,22 @@@ bool is_top_level_text_object (SPObjec || SP_IS_FLOWTEXT(obj)); } --bool has_visible_text (SPObject *obj) ++bool has_visible_text(SPObject *obj) { -- if (SP_IS_STRING(obj) && !SP_STRING(obj)->string.empty()) -- return true; // maybe we should also check that it's not all whitespace? ++ bool hasVisible = false; -- for (SPObject const *child = obj->firstChild() ; child ; child = SP_OBJECT_NEXT(child)) { -- if (has_visible_text((SPObject *) child)) -- return true; ++ if (SP_IS_STRING(obj) && !SP_STRING(obj)->string.empty()) { ++ hasVisible = true; // maybe we should also check that it's not all whitespace? ++ } else { ++ for (SPObject const *child = obj->firstChild() ; child ; child = child->getNext()) { ++ if (has_visible_text((SPObject *) child)) { ++ hasVisible = true; ++ break; ++ } ++ } } -- return false; ++ return hasVisible; } /* @@@ -1942,4 -1933,4 +1984,4 @@@ fill-column:99 End: */ --// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : ++// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --cc src/text-editing.h index 038458ff7,038458ff7..3d5efbbec --- a/src/text-editing.h +++ b/src/text-editing.h @@@ -1,5 -1,5 +1,5 @@@ --#ifndef __SP_TEXT_EDITING_H__ --#define __SP_TEXT_EDITING_H__ ++#ifndef SEEN_SP_TEXT_EDITING_H ++#define SEEN_SP_TEXT_EDITING_H /* * Text editing functions common for for text and flowtext @@@ -28,11 -28,11 +28,21 @@@ typedef std::pair<Inkscape::Text::Layou Inkscape::Text::Layout const * te_get_layout (SPItem const *item); --bool sp_te_output_is_empty (SPItem const *item); --bool sp_te_input_is_empty (SPObject const *item); ++/** Returns true if there are no visible characters on the canvas. */ ++bool sp_te_output_is_empty(SPItem const *item); ++ ++/** Returns true if the user has typed nothing in the text box. */ ++bool sp_te_input_is_empty(SPObject const *item); ++ ++/** Recursively gets the length of all the SPStrings at or below the given ++\a item. Also adds 1 for each line break encountered. */ unsigned sp_text_get_length(SPObject const *item); ++ ++/** Recursively gets the length of all the SPStrings at or below the given ++\a item, before and not including \a upto. Also adds 1 for each line break encountered. */ unsigned sp_text_get_length_upto(SPObject const *item, SPObject const *upto); ++ std::vector<Geom::Point> sp_te_create_selection_quads(SPItem const *item, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, Geom::Matrix const &transform); Inkscape::Text::Layout::iterator sp_te_get_position_by_coords (SPItem const *item, Geom::Point const &i_p); @@@ -70,4 -70,4 +80,4 @@@ bool is_part_of_text_subtree (SPObject bool is_top_level_text_object (SPObject *obj); bool has_visible_text (SPObject *obj); --#endif ++#endif // SEEN_SP_TEXT_EDITING_H diff --cc src/trace/trace.cpp index e2bd0e9f5,cff464e9f..48d25d0c4 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@@ -4,6 -4,6 +4,8 @@@ * * Authors: * Bob Jamison <rjamison@earthlink.net> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2004-2006 Bob Jamison * @@@ -443,7 -443,7 +445,7 @@@ void Tracer::traceThread( return; } SPDocument *doc = SP_ACTIVE_DOCUMENT; - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); SPImage *img = getSelectedSPImage(); @@@ -482,7 -482,8 +484,8 @@@ } //### Get pointers to the <image> and its parent - Inkscape::XML::Node *imgRepr = SP_OBJECT(img)->repr; - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + Inkscape::XML::Node *imgRepr = SP_OBJECT(img)->getRepr(); Inkscape::XML::Node *par = sp_repr_parent(imgRepr); //### Get some information for the new transform() @@@ -518,7 -519,7 +521,7 @@@ //#OK. Now let's start making new nodes -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *groupRepr = NULL; //# if more than 1, make a <g>roup of <path>s @@@ -568,7 -569,7 +571,7 @@@ } //## inform the document, so we can undo - sp_document_done(doc, SP_VERB_SELECTION_TRACE, _("Trace bitmap")); - SPDocumentUndo::done(doc, SP_VERB_SELECTION_TRACE, _("Trace bitmap")); ++ DocumentUndo::done(doc, SP_VERB_SELECTION_TRACE, _("Trace bitmap")); engine = NULL; diff --cc src/tweak-context.cpp index 29289e053,775e7aec3..1d0c004a4 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@@ -1,10 -1,10 +1,10 @@@ --#define __SP_TWEAK_CONTEXT_C__ -- /* * tweaking paths without node editing * * Authors: * bulia byak ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2007 authors * @@@ -77,6 -77,6 +77,8 @@@ #include "tweak-context.h" ++using Inkscape::DocumentUndo; ++ #define DDC_RED_RGBA 0xff0000ff #define DYNA_MIN_WIDTH 1.0e-6 @@@ -425,7 -425,7 +427,7 @@@ sp_tweak_dilate_recursive (Inkscape::Se if (SP_IS_GROUP(item) && !SP_IS_BOX3D(item)) { GSList *children = NULL; - for (SPObject *child = sp_object_first_child(SP_OBJECT(item)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = SP_OBJECT(item)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM(child)) { children = g_slist_prepend(children, child); } @@@ -524,7 -524,7 +526,7 @@@ sp_object_unref(SP_OBJECT(item), NULL); } else { // duplicate SPDocument *doc = SP_OBJECT_DOCUMENT(item); -- Inkscape::XML::Document* xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document* xml_doc = doc->getReprDoc(); Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(item); SPObject *old_obj = doc->getObjectByRepr(old_repr); Inkscape::XML::Node *parent = old_repr->parent(); @@@ -863,10 -863,10 +865,10 @@@ tweak_colors_in_gradient (SPItem *item double offset_l = 0; double offset_h = 0; SPObject *child_prev = NULL; - for (SPObject *child = sp_object_first_child(vector); - for (SPObject *child = vector->first_child(); -- child != NULL; child = SP_OBJECT_NEXT(child)) { -- if (!SP_IS_STOP(child)) ++ for (SPObject *child = vector->firstChild(); child; child = child->getNext()) { ++ if (!SP_IS_STOP(child)) { continue; ++ } SPStop *stop = SP_STOP (child); offset_h = stop->offset; @@@ -923,7 -923,7 +925,7 @@@ sp_tweak_color_recursive (guint mode, S bool did = false; if (SP_IS_GROUP(item)) { - for (SPObject *child = sp_object_first_child(SP_OBJECT(item)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = SP_OBJECT(item)->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) { ++ for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM(child)) { if (sp_tweak_color_recursive (mode, SP_ITEM(child), item_at_point, fill_goal, do_fill, @@@ -1060,7 -1060,7 +1062,7 @@@ sp_tweak_dilate (SPTweakContext *tc, Ge bool did = false; double radius = get_dilate_radius(tc); -- SPItem *item_at_point = SP_EVENT_CONTEXT(tc)->desktop->item_at_point(event_p, TRUE); ++ SPItem *item_at_point = SP_EVENT_CONTEXT(tc)->desktop->getItemAtPoint(event_p, TRUE); bool do_fill = false, do_stroke = false, do_opacity = false; guint32 fill_goal = sp_desktop_get_color_tool(desktop, "/tools/tweak", true, &do_fill); @@@ -1258,56 -1258,56 +1260,56 @@@ sp_tweak_context_root_handler(SPEventCo tc->has_dilated = false; switch (tc->mode) { case TWEAK_MODE_MOVE: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_TWEAK, _("Move tweak")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_TWEAK, _("Move tweak")); break; case TWEAK_MODE_MOVE_IN_OUT: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_TWEAK, _("Move in/out tweak")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_TWEAK, _("Move in/out tweak")); break; case TWEAK_MODE_MOVE_JITTER: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_TWEAK, _("Move jitter tweak")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_TWEAK, _("Move jitter tweak")); break; case TWEAK_MODE_SCALE: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_TWEAK, _("Scale tweak")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_TWEAK, _("Scale tweak")); break; case TWEAK_MODE_ROTATE: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_TWEAK, _("Rotate tweak")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_TWEAK, _("Rotate tweak")); break; case TWEAK_MODE_MORELESS: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_TWEAK, _("Duplicate/delete tweak")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_TWEAK, _("Duplicate/delete tweak")); break; case TWEAK_MODE_PUSH: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_TWEAK, _("Push path tweak")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_TWEAK, _("Push path tweak")); break; case TWEAK_MODE_SHRINK_GROW: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_TWEAK, _("Shrink/grow path tweak")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_TWEAK, _("Shrink/grow path tweak")); break; case TWEAK_MODE_ATTRACT_REPEL: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_TWEAK, _("Attract/repel path tweak")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_TWEAK, _("Attract/repel path tweak")); break; case TWEAK_MODE_ROUGHEN: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_TWEAK, _("Roughen path tweak")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_TWEAK, _("Roughen path tweak")); break; case TWEAK_MODE_COLORPAINT: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_TWEAK, _("Color paint tweak")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_TWEAK, _("Color paint tweak")); break; case TWEAK_MODE_COLORJITTER: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_TWEAK, _("Color jitter tweak")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_TWEAK, _("Color jitter tweak")); break; case TWEAK_MODE_BLUR: - sp_document_done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), - SPDocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), -- SP_VERB_CONTEXT_TWEAK, _("Blur tweak")); ++ DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), ++ SP_VERB_CONTEXT_TWEAK, _("Blur tweak")); break; } } diff --cc src/ui/clipboard.cpp index 90a9ba0f5,e050d69b4..d405afb8f --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@@ -5,6 -5,6 +5,7 @@@ * Krzysztof Kosiński <tweenk@o2.pl> * Jon A. Cruz <jon@joncruz.org> * Incorporates some code from selection-chemistry.cpp, see that file for more credits. ++ * Abhishek Sharma * * Copyright (C) 2008 authors * Copyright (C) 2010 Jon A. Cruz @@@ -350,8 -350,8 +351,7 @@@ const gchar *ClipboardManagerImpl::getF return NULL; } -- Inkscape::XML::Node -- *root = sp_document_repr_root(tempdoc); ++ Inkscape::XML::Node *root = tempdoc->getReprRoot(); if (!root) { return NULL; @@@ -405,9 -405,9 +405,8 @@@ bool ClipboardManagerImpl::pasteStyle(S } } -- Inkscape::XML::Node -- *root = sp_document_repr_root(tempdoc), -- *clipnode = sp_repr_lookup_name(root, "inkscape:clipboard", 1); ++ Inkscape::XML::Node *root = tempdoc->getReprRoot(); ++ Inkscape::XML::Node *clipnode = sp_repr_lookup_name(root, "inkscape:clipboard", 1); bool pasted = false; @@@ -455,7 -455,7 +454,7 @@@ bool ClipboardManagerImpl::pasteSize(SP } // retrieve size ifomration from the clipboard -- Inkscape::XML::Node *root = sp_document_repr_root(tempdoc); ++ Inkscape::XML::Node *root = tempdoc->getReprRoot(); Inkscape::XML::Node *clipnode = sp_repr_lookup_name(root, "inkscape:clipboard", 1); bool pasted = false; if (clipnode) { @@@ -509,7 -509,7 +508,7 @@@ bool ClipboardManagerImpl::pastePathEff SPDocument *tempdoc = _retrieveClipboard("image/x-inkscape-svg"); if ( tempdoc ) { -- Inkscape::XML::Node *root = sp_document_repr_root(tempdoc); ++ Inkscape::XML::Node *root = tempdoc->getReprRoot(); Inkscape::XML::Node *clipnode = sp_repr_lookup_name(root, "inkscape:clipboard", 1); if ( clipnode ) { gchar const *effectstack = clipnode->attribute("inkscape:path-effect"); @@@ -544,12 -544,12 +543,11 @@@ Glib::ustring ClipboardManagerImpl::get _userWarn(desktop, _("Nothing on the clipboard.")); return ""; } -- Inkscape::XML::Node -- *root = sp_document_repr_root(tempdoc), -- *path = sp_repr_lookup_name(root, "svg:path", -1); // unlimited search depth ++ Inkscape::XML::Node *root = tempdoc->getReprRoot(); ++ Inkscape::XML::Node *path = sp_repr_lookup_name(root, "svg:path", -1); // unlimited search depth if ( path == NULL ) { _userWarn(desktop, _("Clipboard does not contain a path.")); - sp_document_unref(tempdoc); + tempdoc->doUnref(); return ""; } gchar const *svgd = path->attribute("d"); @@@ -568,7 -568,7 +566,7 @@@ Glib::ustring ClipboardManagerImpl::get _userWarn(desktop, _("Nothing on the clipboard.")); return ""; } -- Inkscape::XML::Node *root = sp_document_repr_root(tempdoc); ++ Inkscape::XML::Node *root = tempdoc->getReprRoot(); Inkscape::XML::Node *repr = sp_repr_lookup_name(root, "svg:path", -1); // unlimited search depth if ( repr == NULL ) { @@@ -702,7 -702,7 +700,7 @@@ void ClipboardManagerImpl::_copyUsedDef } // Copy text paths if (SP_IS_TEXT_TEXTPATH(item)) { - _copyTextPath(SP_TEXTPATH(sp_object_first_child(SP_OBJECT(item)))); - _copyTextPath(SP_TEXTPATH(SP_OBJECT(item)->first_child())); ++ _copyTextPath(SP_TEXTPATH(item->firstChild())); } // Copy clipping objects if (item->clip_ref->getObject()) { @@@ -759,7 -759,7 +757,7 @@@ void ClipboardManagerImpl::_copyPattern _copyNode(SP_OBJECT_REPR(pattern), _doc, _defs); // items in the pattern may also use gradients and other patterns, so recurse - for (SPObject *child = sp_object_first_child(SP_OBJECT(pattern)) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { - for (SPObject *child = SP_OBJECT(pattern)->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { ++ for ( SPObject *child = pattern->firstChild() ; child ; child = child->getNext() ) { if (!SP_IS_ITEM (child)) { continue; } @@@ -814,10 -814,10 +812,9 @@@ Inkscape::XML::Node *ClipboardManagerIm void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) { SPDocument *target_document = sp_desktop_document(desktop); -- Inkscape::XML::Node -- *root = sp_document_repr_root(clipdoc), -- *target_parent = SP_OBJECT_REPR(desktop->currentLayer()); -- Inkscape::XML::Document *target_xmldoc = sp_document_repr_doc(target_document); ++ Inkscape::XML::Node *root = clipdoc->getReprRoot(); ++ Inkscape::XML::Node *target_parent = SP_OBJECT_REPR(desktop->currentLayer()); ++ Inkscape::XML::Document *target_xmldoc = target_document->getReprDoc(); // copy definitions _pasteDefs(desktop, clipdoc); @@@ -851,7 -851,7 +848,7 @@@ sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false); // Update (among other things) all curves in paths, for bounds() to work - sp_document_ensure_up_to_date(target_document); - target_document->ensure_up_to_date(); ++ target_document->ensureUpToDate(); // move selection either to original position (in_place) or to mouse pointer Geom::OptRect sel_bbox = selection->bounds(); @@@ -894,11 -893,11 +891,10 @@@ void ClipboardManagerImpl::_pasteDefs(S { // boilerplate vars copied from _pasteDocument SPDocument *target_document = sp_desktop_document(desktop); -- Inkscape::XML::Node -- *root = sp_document_repr_root(clipdoc), -- *defs = sp_repr_lookup_name(root, "svg:defs", 1), -- *target_defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(target_document)); -- Inkscape::XML::Document *target_xmldoc = sp_document_repr_doc(target_document); ++ Inkscape::XML::Node *root = clipdoc->getReprRoot(); ++ Inkscape::XML::Node *defs = sp_repr_lookup_name(root, "svg:defs", 1); ++ Inkscape::XML::Node *target_defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(target_document)); ++ Inkscape::XML::Document *target_xmldoc = target_document->getReprDoc(); prevent_id_clashes(clipdoc, target_document); @@@ -1255,11 -1254,11 +1251,11 @@@ void ClipboardManagerImpl::_onClear( void ClipboardManagerImpl::_createInternalClipboard() { if ( _clipboardSPDoc == NULL ) { - _clipboardSPDoc = sp_document_new(NULL, false, true); + _clipboardSPDoc = SPDocument::createNewDoc(NULL, false, true); //g_assert( _clipboardSPDoc != NULL ); _defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(_clipboardSPDoc)); -- _doc = sp_document_repr_doc(_clipboardSPDoc); -- _root = sp_document_repr_root(_clipboardSPDoc); ++ _doc = _clipboardSPDoc->getReprDoc(); ++ _root = _clipboardSPDoc->getReprRoot(); _clipnode = _doc->createElement("inkscape:clipboard"); _root->appendChild(_clipnode); diff --cc src/ui/context-menu.cpp index 262fdcf32,1ffbf1fd0..c544d1999 --- a/src/ui/context-menu.cpp +++ b/src/ui/context-menu.cpp @@@ -1,10 -1,10 +1,10 @@@ --#define __CONTEXT_MENU_C__ -- /* * Unser-interface related object extension * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * This code is in public domain */ @@@ -21,6 -21,6 +21,8 @@@ #include "preferences.h" #include "ui/dialog/dialog-manager.h" ++using Inkscape::DocumentUndo; ++ static void sp_object_type_menu(GType type, SPObject *object, SPDesktop *desktop, GtkMenu *menu); /* Append object-specific part to context menu */ @@@ -274,7 -269,7 +276,7 @@@ sp_item_create_link(GtkMenuItem *menuit SPDesktop *desktop = (SPDesktop*)gtk_object_get_data(GTK_OBJECT(menuitem), "desktop"); g_return_if_fail(desktop != NULL); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:a"); SP_OBJECT_REPR(SP_OBJECT_PARENT(item))->addChild(repr, SP_OBJECT_REPR(item)); SPObject *object = SP_OBJECT_DOCUMENT(item)->getObjectByRepr(repr); @@@ -289,8 -284,8 +291,8 @@@ Inkscape::GC::release(repr); Inkscape::GC::release(child); - sp_document_done(SP_OBJECT_DOCUMENT(object), SP_VERB_NONE, - SPDocumentUndo::done(SP_OBJECT_DOCUMENT(object), SP_VERB_NONE, -- _("Create link")); ++ DocumentUndo::done(SP_OBJECT_DOCUMENT(object), SP_VERB_NONE, ++ _("Create link")); sp_object_attributes_dialog(object, "SPAnchor"); diff --cc src/ui/context-menu.h index c66cd4e96,46a1e8941..36846edc3 --- a/src/ui/context-menu.h +++ b/src/ui/context-menu.h @@@ -1,11 -1,11 +1,12 @@@ --#ifndef __CONTEXT_MENU_H__ --#define __CONTEXT_MENU_H__ ++#ifndef SEEN_CONTEXT_MENU_H ++#define SEEN_CONTEXT_MENU_H /* * Unser-interface related object extension * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * This code is in public domain */ diff --cc src/ui/dialog/aboutbox.cpp index 8d467d53f,8c102b57f..8db5e7c0b --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@@ -6,6 -6,6 +6,7 @@@ * MenTaLguY <mental@rydia.net> * Kees Cook <kees@outflux.net> * Jon Phillips <jon@rejon.org> ++ * Abhishek Sharma * * Copyright (C) 2004 Derek P. Moore * Copyright 2004 Kees Cook @@@ -155,7 -155,7 +156,7 @@@ Gtk::Widget *build_splash_widget() if ( version && SP_IS_TEXT(version) ) { sp_te_set_repr_text_multiline (SP_TEXT (version), Inkscape::version_string); } - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); GtkWidget *v=sp_svg_view_widget_new(doc); diff --cc src/ui/dialog/align-and-distribute.cpp index ba8cc939b,af1671b04..48f0fbf22 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@@ -7,6 -7,6 +7,8 @@@ * Frank Felfe <innerspace@iname.com> * Lauris Kaplinski <lauris@kaplinski.com> * Tim Dwyer <tgdwyer@gmail.com> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2004, 2005 Authors * @@@ -169,8 -169,7 +171,7 @@@ private case AlignAndDistribute::DRAWING: { - Geom::OptRect b = sp_item_bbox_desktop - ( (SPItem *) sp_document_root (sp_desktop_document (desktop)) ); - Geom::OptRect b = static_cast<SPItem *>( sp_document_root (sp_desktop_document (desktop)))->getBboxDesktop(); ++ Geom::OptRect b = static_cast<SPItem *>( sp_desktop_document(desktop)->getRoot() )->getBboxDesktop(); if (b) { mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); @@@ -216,9 -215,9 +217,9 @@@ it != selected.end(); it++) { - sp_document_ensure_up_to_date(sp_desktop_document (desktop)); - sp_desktop_document (desktop)->ensure_up_to_date(); ++ sp_desktop_document (desktop)->ensureUpToDate(); if (!sel_as_group) - b = sp_item_bbox_desktop (*it); + b = (*it)->getBboxDesktop(); if (b) { Geom::Point const sp(a.sx0 * b->min()[Geom::X] + a.sx1 * b->max()[Geom::X], a.sy0 * b->min()[Geom::Y] + a.sy1 * b->max()[Geom::Y]); @@@ -234,8 -233,8 +235,8 @@@ prefs->setInt("/options/clonecompensation/value", saved_compensation); if (changed) { - sp_document_done ( sp_desktop_document (desktop) , SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - SPDocumentUndo::done ( sp_desktop_document (desktop) , SP_VERB_DIALOG_ALIGN_DISTRIBUTE, -- _("Align")); ++ DocumentUndo::done( sp_desktop_document(desktop) , SP_VERB_DIALOG_ALIGN_DISTRIBUTE, ++ _("Align")); } @@@ -393,8 -392,8 +394,8 @@@ private prefs->setInt("/options/clonecompensation/value", saved_compensation); if (changed) { - sp_document_done ( sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - SPDocumentUndo::done ( sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, -- _("Distribute")); ++ DocumentUndo::done( sp_desktop_document(desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, ++ _("Distribute")); } } guint _index; @@@ -504,8 -505,8 +505,8 @@@ private // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); - sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - SPDocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, -- _("Remove overlaps")); ++ DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, ++ _("Remove overlaps")); } }; @@@ -535,106 -536,11 +536,107 @@@ private // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); - sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - SPDocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, -- _("Arrange connector network")); ++ DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, ++ _("Arrange connector network")); + } +}; + +class ActionExchangePositions : public Action { +public: + enum SortOrder { + None, + ZOrder, + Clockwise + }; + + ActionExchangePositions(Glib::ustring const &id, + Glib::ustring const &tiptext, + guint row, + guint column, + AlignAndDistribute &dialog, SortOrder order = None) : + Action(id, tiptext, row, column, + dialog.rearrange_table(), dialog.tooltips(), dialog), + sortOrder(order) + {}; + + +private : + const SortOrder sortOrder; + static boost::optional<Geom::Point> center; + + static bool sort_compare(const SPItem * a,const SPItem * b) { + if (a == NULL) return false; + if (b == NULL) return true; + if (center) { + Geom::Point point_a = a->getCenter() - (*center); + Geom::Point point_b = b->getCenter() - (*center); + // First criteria: Sort according to the angle to the center point + double angle_a = atan2(double(point_a[Geom::Y]), double(point_a[Geom::X])); + double angle_b = atan2(double(point_b[Geom::Y]), double(point_b[Geom::X])); + if (angle_a != angle_b) return (angle_a < angle_b); + // Second criteria: Sort according to the distance the center point + Geom::Coord length_a = point_a.length(); + Geom::Coord length_b = point_b.length(); + if (length_a != length_b) return (length_a > length_b); + } + // Last criteria: Sort according to the z-coordinate + return (a->isSiblingOf(b)); + } + + virtual void on_button_click() + { + SPDesktop *desktop = _dialog.getDesktop(); + if (!desktop) return; + + Inkscape::Selection *selection = sp_desktop_selection(desktop); + if (!selection) return; + + using Inkscape::Util::GSListConstIterator; + std::list<SPItem *> selected; + selected.insert<GSListConstIterator<SPItem *> >(selected.end(), selection->itemList(), NULL); + if (selected.empty()) return; + + //Check 2 or more selected objects + if (selected.size() < 2) return; + + // see comment in ActionAlign above + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); + prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); + + // sort the list + if (sortOrder != None) { + if (sortOrder == Clockwise) { + center = selection->center(); + } else { // sorting by ZOrder is outomatically done by not setting the center + center.reset(); + } + selected.sort(ActionExchangePositions::sort_compare); + } + std::list<SPItem *>::iterator it(selected.begin()); + Geom::Point p1 = (*it)->getCenter(); + for (++it ;it != selected.end(); ++it) + { + Geom::Point p2 = (*it)->getCenter(); + Geom::Point delta = p1 - p2; + sp_item_move_rel((*it),Geom::Translate(delta[Geom::X],delta[Geom::Y] )); + p1 = p2; + } + Geom::Point p2 = selected.front()->getCenter(); + Geom::Point delta = p1 - p2; + sp_item_move_rel(selected.front(),Geom::Translate(delta[Geom::X],delta[Geom::Y] )); + + // restore compensation setting + prefs->setInt("/options/clonecompensation/value", saved_compensation); + - sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - _("Exchange Positions")); ++ DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, ++ _("Exchange Positions")); } }; + +// instantiae the private static member +boost::optional<Geom::Point> ActionExchangePositions::center; + class ActionUnclump : public Action { public : ActionUnclump(const Glib::ustring &id, @@@ -661,8 -567,8 +663,8 @@@ private // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); - sp_document_done (sp_desktop_document (_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - SPDocumentUndo::done (sp_desktop_document (_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, -- _("Unclump")); ++ DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, ++ _("Unclump")); } }; @@@ -715,8 -621,8 +717,8 @@@ private it != selected.end(); ++it) { - sp_document_ensure_up_to_date(sp_desktop_document (desktop)); - Geom::OptRect item_box = sp_item_bbox_desktop (*it); - sp_desktop_document (desktop)->ensure_up_to_date(); ++ sp_desktop_document (desktop)->ensureUpToDate(); + Geom::OptRect item_box = (*it)->getBboxDesktop (); if (item_box) { // find new center, staying within bbox double x = _dialog.randomize_bbox->min()[Geom::X] + (*item_box)[Geom::X].extent() /2 + @@@ -732,8 -638,8 +734,8 @@@ // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); - sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, -- _("Randomize positions")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, ++ _("Randomize positions")); } }; @@@ -831,8 -737,8 +833,8 @@@ private } if (changed) { - sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, -- _("Distribute text baselines")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, ++ _("Distribute text baselines")); } } else { @@@ -854,8 -760,8 +856,8 @@@ } if (changed) { - sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, - SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, -- _("Align text baselines")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, ++ _("Align text baselines")); } } } diff --cc src/ui/dialog/color-item.cpp index 97603a8a2,a8445c66c..9f163c00c --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@@ -3,6 -3,6 +3,7 @@@ */ /* Authors: * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2010 Jon A. Cruz * @@@ -458,7 -458,7 +459,7 @@@ void ColorItem::_updatePreviews( SPDesktop *desktop = SP_ACTIVE_DESKTOP; if ( desktop ) { SPDocument* document = sp_desktop_document( desktop ); -- Inkscape::XML::Node *rroot = sp_document_repr_root( document ); ++ Inkscape::XML::Node *rroot = document->getReprRoot(); if ( rroot ) { // Find where this thing came from @@@ -720,7 -720,7 +721,7 @@@ void ColorItem::buttonClicked(bool seco sp_desktop_set_style(desktop, css); sp_repr_css_attr_unref(css); - sp_document_done( sp_desktop_document(desktop), SP_VERB_DIALOG_SWATCHES, descr.c_str() ); - SPDocumentUndo::done( sp_desktop_document(desktop), SP_VERB_DIALOG_SWATCHES, descr.c_str() ); ++ DocumentUndo::done( sp_desktop_document(desktop), SP_VERB_DIALOG_SWATCHES, descr.c_str() ); } } diff --cc src/ui/dialog/document-properties.cpp index f22509496,4e1ddda2e..16212bef7 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@@ -8,6 -8,6 +8,8 @@@ * Jon Phillips <jon@rejon.org> * Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm) * Diederik van Lierop <mail@diedenrezi.nl> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2006-2008 Johan Engelen <johan@shouraizou.nl> * Copyright (C) 2000 - 2008 Authors @@@ -404,7 -428,7 +406,7 @@@ DocumentProperties::linkSelectedProfile g_warning("No color profile available."); return; } -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *cprofRepr = xml_doc->createElement("svg:color-profile"); gchar* tmp = static_cast<gchar*>(_menu.get_active()->get_data("name")); Glib::ustring nameStr = tmp ? tmp : "profile"; // TODO add some auto-numbering to avoid collisions @@@ -426,7 -450,7 +428,7 @@@ //Inkscape::GC::release(defsRepr); // inform the document, so we can undo - sp_document_done(desktop->doc(), SP_VERB_EDIT_LINK_COLOR_PROFILE, _("Link Color Profile")); - SPDocumentUndo::done(desktop->doc(), SP_VERB_EDIT_LINK_COLOR_PROFILE, _("Link Color Profile")); ++ DocumentUndo::done(desktop->doc(), SP_VERB_EDIT_LINK_COLOR_PROFILE, _("Link Color Profile")); populate_linked_profiles_box(); } @@@ -436,7 -460,7 +438,7 @@@ voi DocumentProperties::populate_linked_profiles_box() { _LinkedProfilesListStore->clear(); - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "iccprofile" ); - const GSList *current = SP_ACTIVE_DOCUMENT->get_resource_list( "iccprofile" ); ++ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); if (current) _emb_profiles_observer.set(SP_OBJECT(current->data)->parent); while ( current ) { SPObject* obj = SP_OBJECT(current->data); @@@ -493,13 -517,15 +495,15 @@@ void DocumentProperties::removeSelected } } - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "iccprofile" ); - const GSList *current = SP_ACTIVE_DOCUMENT->get_resource_list( "iccprofile" ); ++ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); while ( current ) { SPObject* obj = SP_OBJECT(current->data); Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj); if (!name.compare(prof->name)){ - sp_repr_unparent(obj->repr); - sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_COLOR_PROFILE, _("Remove linked color profile")); + - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(obj->getRepr()); - SPDocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_COLOR_PROFILE, _("Remove linked color profile")); ++ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_COLOR_PROFILE, _("Remove linked color profile")); } current = g_slist_next(current); } @@@ -565,7 -591,7 +569,7 @@@ DocumentProperties::build_cms( _LinkedProfilesList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::linked_profiles_list_button_release)); cms_create_popup_menu(_LinkedProfilesList, sigc::mem_fun(*this, &DocumentProperties::removeSelectedProfile)); - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "defs" ); - const GSList *current = SP_ACTIVE_DOCUMENT->get_resource_list( "defs" ); ++ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "defs" ); if (current) { _emb_profiles_observer.set(SP_OBJECT(current->data)->parent); } @@@ -623,7 -649,7 +627,7 @@@ DocumentProperties::build_scripting( #endif // ENABLE_LCMS //TODO: review this observers code: - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "script" ); - const GSList *current = SP_ACTIVE_DOCUMENT->get_resource_list( "script" ); ++ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); if (current) { _ext_scripts_observer.set(SP_OBJECT(current->data)->parent); } @@@ -636,7 -662,7 +640,7 @@@ void DocumentProperties::addExternalScr if (!desktop){ g_warning("No active desktop"); } else { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); ++ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *scriptRepr = xml_doc->createElement("svg:script"); scriptRepr->setAttribute("xlink:href", (gchar*) _script_entry.get_text().c_str()); _script_entry.set_text(""); @@@ -644,7 -670,7 +648,7 @@@ xml_doc->root()->addChild(scriptRepr, NULL); // inform the document, so we can undo - sp_document_done(desktop->doc(), SP_VERB_EDIT_ADD_EXTERNAL_SCRIPT, _("Add external script...")); - SPDocumentUndo::done(desktop->doc(), SP_VERB_EDIT_ADD_EXTERNAL_SCRIPT, _("Add external script...")); ++ DocumentUndo::done(desktop->doc(), SP_VERB_EDIT_ADD_EXTERNAL_SCRIPT, _("Add external script...")); populate_external_scripts_box(); } @@@ -662,13 -688,15 +666,15 @@@ void DocumentProperties::removeExternal } } - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "script" ); - const GSList *current = SP_ACTIVE_DOCUMENT->get_resource_list( "script" ); ++ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); while ( current ) { SPObject* obj = SP_OBJECT(current->data); SPScript* script = (SPScript*) obj; if (name == script->xlinkhref){ - sp_repr_unparent(obj->repr); - sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); + - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(obj->getRepr()); - SPDocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); ++ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script")); } current = g_slist_next(current); } @@@ -679,7 -707,7 +685,7 @@@ void DocumentProperties::populate_external_scripts_box(){ _ExternalScriptsListStore->clear(); - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "script" ); - const GSList *current = SP_ACTIVE_DOCUMENT->get_resource_list( "script" ); ++ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); if (current) _ext_scripts_observer.set(SP_OBJECT(current->data)->parent); while ( current ) { SPObject* obj = SP_OBJECT(current->data); @@@ -961,7 -989,7 +967,7 @@@ DocumentProperties::onRemoveGrid( // delete the grid that corresponds with the selected tab // when the grid is deleted from SVG, the SPNamedview handler automatically deletes the object, so found_grid becomes an invalid pointer! found_grid->repr->parent()->removeChild(found_grid->repr); - sp_document_done(sp_desktop_document(dt), SP_VERB_DIALOG_NAMEDVIEW, _("Remove grid")); - SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_DIALOG_NAMEDVIEW, _("Remove grid")); ++ DocumentUndo::done(sp_desktop_document(dt), SP_VERB_DIALOG_NAMEDVIEW, _("Remove grid")); } } diff --cc src/ui/dialog/filedialogimpl-gtkmm.cpp index fbfdc4a9b,5a9f37bf0..855d5a223 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@@ -6,6 -6,6 +6,7 @@@ * Joel Holdsworth * Bruno Dilly * Other dudes from The Inkscape Organization ++ * Abhishek Sharma * * Copyright (C) 2004-2007 Bob Jamison * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> diff --cc src/ui/dialog/filedialogimpl-win32.cpp index e2bf47db9,aabb3c2df..65bb49f13 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@@ -4,6 -4,6 +4,7 @@@ /* Authors: * Joel Holdsworth * The Inkscape Organization ++ * Abhishek Sharma * * Copyright (C) 2004-2008 The Inkscape Organization * @@@ -936,9 -917,9 +937,9 @@@ bool FileOpenDialogImplWin32::set_svg_p // write object bbox to area Geom::OptRect maybeArea(area); - sp_document_ensure_up_to_date (svgDoc); - sp_item_invoke_bbox((SPItem *) svgDoc->root, maybeArea, - sp_item_i2d_affine((SPItem *)(svgDoc->root)), TRUE); - svgDoc->ensure_up_to_date (); ++ svgDoc->ensureUpToDate (); + static_cast<(SPItem *)>(svgDoc->root)->invoke_bbox( maybeArea, + static_cast<(SPItem *)>(svgDoc->root)->i2d_affine(), TRUE); NRArena *const arena = NRArena::create(); diff --cc src/ui/dialog/filter-effects-dialog.cpp index bee6b7c9d,07b8a4159..ed7103be3 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@@ -5,6 -5,6 +5,8 @@@ * Nicholas Bishop <nicholasbishop@gmail.org> * Rodrigo Kumpera <kumpera@gmail.com> * Felipe C. da S. Sanches <juca@members.fsf.org> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2007 Authors * @@@ -1021,16 -1023,18 +1023,18 @@@ private !(ls == 1 && SP_IS_FEPOINTLIGHT(child)) && !(ls == 2 && SP_IS_FESPOTLIGHT(child))) { if(child) - sp_repr_unparent(child->repr); - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(child->getRepr()); if(ls != -1) { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(prim->document); - Inkscape::XML::Node *repr = xml_doc->createElement(_light_source.get_active_data()->key.c_str()); ++ Inkscape::XML::Document *xml_doc = prim->document->getReprDoc(); + Inkscape::XML::Node *repr = xml_doc->createElement(_light_source.get_active_data()->key.c_str()); - prim->repr->appendChild(repr); + //XML Tree being used directly here while it shouldn't be. + prim->getRepr()->appendChild(repr); Inkscape::GC::release(repr); } - sp_document_done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("New light source")); - SPDocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("New light source")); ++ DocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("New light source")); update(); } @@@ -1142,8 -1146,7 +1146,7 @@@ void FilterEffectsDialog::FilterModifie me->_resource_changed.disconnect(); me->_resource_changed = - sp_document_resources_changed_connect(sp_desktop_document(desktop), "filter", - sigc::mem_fun(me, &FilterModifier::update_filters)); - sp_desktop_document(desktop)->resources_changed_connect("filter",sigc::mem_fun(me, &FilterModifier::update_filters)); ++ sp_desktop_document(desktop)->connectResourcesChanged("filter",sigc::mem_fun(me, &FilterModifier::update_filters)); me->_dialog.setDesktop(desktop); @@@ -1214,7 -1217,7 +1217,7 @@@ void FilterEffectsDialog::FilterModifie if(iter) { SPFilter* filter = (*iter)[_columns.filter]; filter->setLabel(text.c_str()); - sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Rename filter")); - SPDocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Rename filter")); ++ DocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Rename filter")); if(iter) (*iter)[_columns.label] = text; } @@@ -1250,7 -1253,7 +1253,7 @@@ void FilterEffectsDialog::FilterModifie } update_selection(sel); - sp_document_done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Apply filter")); - SPDocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Apply filter")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Apply filter")); } } @@@ -1260,7 -1263,7 +1263,7 @@@ void FilterEffectsDialog::FilterModifie { SPDesktop* desktop = _dialog.getDesktop(); SPDocument* document = sp_desktop_document(desktop); - const GSList* filters = sp_document_get_resource_list(document, "filter"); - const GSList* filters = document->get_resource_list("filter"); ++ const GSList* filters = document->getResourceList("filter"); _model->clear(); @@@ -1326,7 -1329,7 +1329,7 @@@ void FilterEffectsDialog::FilterModifie select_filter(filter); - sp_document_done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter")); - SPDocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter")); } void FilterEffectsDialog::FilterModifier::remove_filter() @@@ -1335,9 -1338,11 +1338,11 @@@ if(filter) { SPDocument* doc = filter->document; - sp_repr_unparent(filter->repr); - sp_document_done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove filter")); - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(filter->getRepr()); + - SPDocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove filter")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove filter")); update_filters(); } @@@ -1352,7 -1357,7 +1357,7 @@@ void FilterEffectsDialog::FilterModifie repr = repr->duplicate(repr->document()); parent->appendChild(repr); - sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Duplicate filter")); - SPDocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Duplicate filter")); ++ DocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Duplicate filter")); update_filters(); } @@@ -1487,7 -1492,9 +1492,9 @@@ void FilterEffectsDialog::PrimitiveList if(prim) { Gtk::TreeModel::Row row = *_model->append(); row[_columns.primitive] = prim; - row[_columns.type_id] = FPConverter.get_id_from_key(prim->repr->name()); + - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + row[_columns.type_id] = FPConverter.get_id_from_key(prim->getRepr()->name()); row[_columns.type] = _(FPConverter.get_label(row[_columns.type_id]).c_str()); row[_columns.id] = prim->getId(); @@@ -1540,10 -1547,11 +1547,11 @@@ void FilterEffectsDialog::PrimitiveList if(prim) { _observer->set(0); - sp_repr_unparent(prim->repr); + //XML Tree being used directly here while it shouldn't be. - sp_repr_unparent(prim->getRepr()); ++ sp_repr_unparent(prim->getRepr()); - sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_FILTER_EFFECTS, - SPDocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_FILTER_EFFECTS, -- _("Remove filter primitive")); ++ DocumentUndo::done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_FILTER_EFFECTS, ++ _("Remove filter primitive")); update(); } @@@ -1913,9 -1921,11 +1921,11 @@@ bool FilterEffectsDialog::PrimitiveList if(c == _in_drag && SP_IS_FEMERGENODE(o)) { // If input is null, delete it if(!in_val) { - sp_repr_unparent(o->repr); - sp_document_done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, - _("Remove merge node")); + - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + sp_repr_unparent(o->getRepr()); - SPDocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, - _("Remove merge node")); ++ DocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, ++ _("Remove merge node")); (*get_selection()->get_selected())[_columns.primitive] = prim; } else @@@ -1925,10 -1935,12 +1935,12 @@@ } // Add new input? if(!handled && c == _in_drag && in_val) { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(prim->document); ++ Inkscape::XML::Document *xml_doc = prim->document->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:feMergeNode"); repr->setAttribute("inkscape:collect", "always"); - prim->repr->appendChild(repr); + - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + prim->getRepr()->appendChild(repr); SPFeMergeNode *node = SP_FEMERGENODE(prim->document->getObjectByRepr(repr)); Inkscape::GC::release(repr); _dialog.set_attr(node, SP_ATTR_IN, in_val); @@@ -2031,7 -2043,7 +2043,7 @@@ void FilterEffectsDialog::PrimitiveList filter->requestModified(SP_OBJECT_MODIFIED_FLAG); - sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Reorder filter primitive")); - SPDocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Reorder filter primitive")); ++ DocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Reorder filter primitive")); } // If a connection is dragged towards the top or bottom of the list, the list should scroll to follow. @@@ -2263,7 -2274,7 +2275,7 @@@ void FilterEffectsDialog::add_primitive _primitive_list.select(prim); - sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter primitive")); - SPDocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter primitive")); ++ DocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Add filter primitive")); } } @@@ -2359,7 -2370,7 +2371,7 @@@ void FilterEffectsDialog::duplicate_pri repr = SP_OBJECT_REPR(origprim)->duplicate(SP_OBJECT_REPR(origprim)->document()); SP_OBJECT_REPR(filter)->appendChild(repr); - sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Duplicate filter primitive")); - SPDocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Duplicate filter primitive")); ++ DocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Duplicate filter primitive")); _primitive_list.update(); } @@@ -2411,8 -2422,8 +2423,8 @@@ void FilterEffectsDialog::set_attr(SPOb Glib::ustring undokey = "filtereffects:"; undokey += name; - sp_document_maybe_done(filter->document, undokey.c_str(), SP_VERB_DIALOG_FILTER_EFFECTS, - SPDocumentUndo::maybe_done(filter->document, undokey.c_str(), SP_VERB_DIALOG_FILTER_EFFECTS, -- _("Set filter primitive attribute")); ++ DocumentUndo::maybeDone(filter->document, undokey.c_str(), SP_VERB_DIALOG_FILTER_EFFECTS, ++ _("Set filter primitive attribute")); } _attr_lock = false; @@@ -2467,7 -2478,9 +2479,9 @@@ void FilterEffectsDialog::update_settin SPFilterPrimitive* prim = _primitive_list.get_selected(); if(prim) { - _settings->show_and_update(FPConverter.get_id_from_key(prim->repr->name()), prim); + - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + _settings->show_and_update(FPConverter.get_id_from_key(prim->getRepr()->name()), prim); _empty_settings.hide(); } diff --cc src/ui/dialog/find.cpp index 7fad00f56,5068e3bf4..b6d6a0319 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@@ -4,6 -4,6 +4,8 @@@ * Authors: * Bryce W. Harrington <bryce@bryceharrington.org> * Johan Engelen <goejendaagh@zonnet.nl> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2004-2006 Authors * @@@ -76,8 -76,10 +78,8 @@@ Find::Find( _check_texts(_("Texts"), _("Search text objects")), _check_groups(_("Groups"), _("Search groups")), _check_clones( - //TRANSLATORS: "Clones" is a noun indicating type of object to find - C_("Find dialog", "Clones"), _("Search clones")), - //TRANSLATORS: only translate "string" in "context|string". - // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS - // "Clones" is a noun indicating type of object to find - Q_("find|Clones"), _("Search clones")), ++ //TRANSLATORS: "Clones" is a noun indicating type of object to find ++ C_("Find dialog", "Clones"), _("Search clones")), _check_images(_("Images"), _("Search images")), _check_offsets(_("Offsets"), _("Search offset objects")), @@@ -346,7 -348,7 +348,7 @@@ Find::all_items (SPObject *r, GSList *l if (!strcmp (SP_OBJECT_REPR (r)->name(), "svg:metadata")) return l; // we're not interested in metadata - for (SPObject *child = sp_object_first_child(r); child; child = SP_OBJECT_NEXT (child)) { - for (SPObject *child = r->first_child(); child; child = SP_OBJECT_NEXT (child)) { ++ for (SPObject *child = r->firstChild(); child; child = child->getNext()) { if (SP_IS_ITEM (child) && !SP_OBJECT_IS_CLONED (child) && !desktop->isLayer(SP_ITEM(child))) { if ((hidden || !desktop->itemIsHidden(SP_ITEM(child))) && (locked || !SP_ITEM(child)->isLocked())) { l = g_slist_prepend (l, child); @@@ -415,7 -417,7 +417,7 @@@ Find::onFind( if (_check_search_layer.get_active()) { l = all_items (desktop->currentLayer(), l, hidden, locked); } else { -- l = all_items (SP_DOCUMENT_ROOT (sp_desktop_document (desktop)), l, hidden, locked); ++ l = all_items(sp_desktop_document(desktop)->getRoot(), l, hidden, locked); } } guint all = g_slist_length (l); diff --cc src/ui/dialog/glyphs.cpp index 5e66ca9b8,8193b4384..f3d7ed971 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@@ -4,6 -4,6 +4,7 @@@ /* Authors: * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2010 Jon A. Cruz * Released under GNU GPL, read the file 'COPYING' for more information @@@ -571,7 -571,7 +572,7 @@@ void GlyphsPanel::insertText( } combined += glyphs; sp_te_set_repr_text_multiline(textItem, combined.c_str()); - sp_document_done(targetDesktop->doc(), SP_VERB_CONTEXT_TEXT, _("Append text")); - SPDocumentUndo::done(targetDesktop->doc(), SP_VERB_CONTEXT_TEXT, _("Append text")); ++ DocumentUndo::done(targetDesktop->doc(), SP_VERB_CONTEXT_TEXT, _("Append text")); } } } diff --cc src/ui/dialog/guides.cpp index aac6024b9,9c3422167..1ab0d51bc --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@@ -5,6 -5,6 +5,7 @@@ * Lauris Kaplinski <lauris@kaplinski.com> * Andrius R. <knutux@gmail.com> * Johan Engelen ++ * Abhishek Sharma * * Copyright (C) 1999-2007 Authors * @@@ -108,8 -108,8 +109,8 @@@ void GuidelinePropertiesDialog::_onAppl sp_guide_moveto(*_guide, newpos, true); - sp_document_done(SP_OBJECT_DOCUMENT(_guide), SP_VERB_NONE, - SPDocumentUndo::done(SP_OBJECT_DOCUMENT(_guide), SP_VERB_NONE, -- _("Set guide properties")); ++ DocumentUndo::done(SP_OBJECT_DOCUMENT(_guide), SP_VERB_NONE, ++ _("Set guide properties")); } void GuidelinePropertiesDialog::_onOK() @@@ -121,8 -121,8 +122,8 @@@ void GuidelinePropertiesDialog::_onDele { SPDocument *doc = SP_OBJECT_DOCUMENT(_guide); sp_guide_remove(_guide); - sp_document_done(doc, SP_VERB_NONE, - SPDocumentUndo::done(doc, SP_VERB_NONE, -- _("Delete guide")); ++ DocumentUndo::done(doc, SP_VERB_NONE, ++ _("Delete guide")); } void GuidelinePropertiesDialog::_response(gint response) @@@ -225,9 -225,9 +226,9 @@@ void GuidelinePropertiesDialog::_setup( // initialize dialog _oldpos = _guide->point_on_line; -- if (_guide->is_vertical()) { ++ if (_guide->isVertical()) { _oldangle = 90; -- } else if (_guide->is_horizontal()) { ++ } else if (_guide->isHorizontal()) { _oldangle = 0; } else { _oldangle = Geom::rad_to_deg( std::atan2( - _guide->normal_to_line[Geom::X], _guide->normal_to_line[Geom::Y] ) ); diff --cc src/ui/dialog/icon-preview.cpp index 07e1ff430,e74e47ca3..b507d9f9a --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@@ -5,6 -5,6 +5,7 @@@ * Jon A. Cruz * Bob Jamison * Other dudes from The Inkscape Organization ++ * Abhishek Sharma * * Copyright (C) 2004 Bob Jamison * Copyright (C) 2005,2010 Jon A. Cruz @@@ -443,10 -378,9 +444,9 @@@ void IconPreviewPanel::renderPreview( S NRArena *arena = NRArena::create(); /* Create ArenaItem and set transform */ - unsigned int visionkey = sp_item_display_key_new(1); + unsigned int visionkey = SPItem::display_key_new(1); - root = sp_item_invoke_show ( SP_ITEM( SP_DOCUMENT_ROOT(doc) ), - arena, visionkey, SP_ITEM_SHOW_DISPLAY ); - root = SP_ITEM( SP_DOCUMENT_ROOT(doc) )->invoke_show ( arena, visionkey, SP_ITEM_SHOW_DISPLAY ); ++ root = SP_ITEM( doc->getRoot() )->invoke_show( arena, visionkey, SP_ITEM_SHOW_DISPLAY ); for ( int i = 0; i < numEntries; i++ ) { guchar * px = sp_icon_doc_icon( doc, root, id, sizes[i] ); @@@ -462,13 -396,8 +462,13 @@@ } updateMagnify(); - sp_item_invoke_hide(SP_ITEM(sp_document_root(doc)), visionkey); - SP_ITEM(sp_document_root(doc))->invoke_hide(visionkey); ++ SP_ITEM(doc->getRoot())->invoke_hide(visionkey); nr_object_unref((NRObject *) arena); + renderTimer->stop(); + minDelay = std::max( 0.1, renderTimer->elapsed() * 3.0 ); +#if ICON_VERBOSE + g_message(" render took %f seconds.", renderTimer->elapsed()); +#endif // ICON_VERBOSE } void IconPreviewPanel::updateMagnify() diff --cc src/ui/dialog/layer-properties.cpp index 1728ff3a6,80c943e39..bf15bcd76 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@@ -4,6 -4,6 +4,7 @@@ /* Author: * Bryce W. Harrington <bryce@bryceharrington.com> * Andrius R. <knutux@gmail.com> ++ * Abhishek Sharma * * Copyright (C) 2004 Bryce Harrington * Copyright (C) 2006 Andrius R. @@@ -105,8 -105,8 +106,8 @@@ LayerPropertiesDialog::_apply( g_assert(_strategy != NULL); _strategy->perform(*this); - sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, - SPDocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, -- _("Add layer")); ++ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, ++ _("Add layer")); _close(); } @@@ -188,8 -188,8 +189,8 @@@ void LayerPropertiesDialog::Rename::per (gchar *)name.c_str(), FALSE ); - sp_document_done(sp_desktop_document(desktop), SP_VERB_NONE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, -- _("Rename layer")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, ++ _("Rename layer")); // TRANSLATORS: This means "The layer has been renamed" desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Renamed layer")); } diff --cc src/ui/dialog/layers.cpp index c3c0ae3c5,962d78df8..0eca5bbca --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@@ -3,6 -3,6 +3,7 @@@ * * Authors: * Jon A. Cruz ++ * Abhishek Sharma * * Copyright (C) 2006,2010 Jon A. Cruz * @@@ -468,8 -468,8 +469,8 @@@ void LayersPanel::_toggled( Glib::ustri row[_model->_colVisible] = newValue; item->setHidden( !newValue ); item->updateRepr(); - sp_document_done( _desktop->doc() , SP_VERB_DIALOG_LAYERS, - SPDocumentUndo::done( _desktop->doc() , SP_VERB_DIALOG_LAYERS, -- newValue? _("Unhide layer") : _("Hide layer")); ++ DocumentUndo::done( _desktop->doc() , SP_VERB_DIALOG_LAYERS, ++ newValue? _("Unhide layer") : _("Hide layer")); } break; @@@ -479,8 -479,8 +480,8 @@@ row[_model->_colLocked] = newValue; item->setLocked( newValue ); item->updateRepr(); - sp_document_done( _desktop->doc() , SP_VERB_DIALOG_LAYERS, - SPDocumentUndo::done( _desktop->doc() , SP_VERB_DIALOG_LAYERS, -- newValue? _("Lock layer") : _("Unlock layer")); ++ DocumentUndo::done( _desktop->doc() , SP_VERB_DIALOG_LAYERS, ++ newValue? _("Lock layer") : _("Unlock layer")); } break; } @@@ -766,7 -768,7 +767,7 @@@ void LayersPanel::setDesktop( SPDesktop } } /* -- GSList const *layers=sp_document_get_resource_list( _desktop->doc(), "layer" ); ++ GSList const *layers = _desktop->doc()->getResourceList( "layer" ); g_message( "layers list starts at %p", layers ); for ( GSList const *iter=layers ; iter ; iter = iter->next ) { SPObject *layer=static_cast<SPObject *>(iter->data); diff --cc src/ui/dialog/livepatheffect-editor.cpp index 706a84733,d05790b3e..bf60fe059 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@@ -5,6 -5,6 +5,7 @@@ * Johan Engelen <j.b.c.engelen@utwente.nl> * Steren Giannini <steren.giannini@gmail.com> * Bastien Bouclet <bgkweb@gmail.com> ++ * Abhishek Sharma * * Copyright (C) 2007 Authors * Released under GNU GPL. Read the file 'COPYING' for more information. @@@ -376,8 -372,8 +377,8 @@@ LivePathEffectEditor::onApply( LivePathEffect::Effect::createAndApply(data->key.c_str(), doc, item); - sp_document_done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT, - SPDocumentUndo::done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT, -- _("Create and apply path effect")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT, ++ _("Create and apply path effect")); lpe_list_locked = false; onSelectionChanged(sel); @@@ -394,8 -390,8 +395,8 @@@ LivePathEffectEditor::onRemove( if ( item && SP_IS_LPE_ITEM(item) ) { sp_lpe_item_remove_current_path_effect(SP_LPE_ITEM(item), false); - sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, - SPDocumentUndo::done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, -- _("Remove path effect") ); ++ DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, ++ _("Remove path effect") ); effect_list_reload(SP_LPE_ITEM(item)); } @@@ -410,8 -406,8 +411,8 @@@ void LivePathEffectEditor::onUp( if ( item && SP_IS_LPE_ITEM(item) ) { sp_lpe_item_up_current_path_effect(SP_LPE_ITEM(item)); - sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, - SPDocumentUndo::done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, -- _("Move path effect up") ); ++ DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, ++ _("Move path effect up") ); effect_list_reload(SP_LPE_ITEM(item)); } @@@ -426,8 -422,8 +427,8 @@@ void LivePathEffectEditor::onDown( if ( item && SP_IS_LPE_ITEM(item) ) { sp_lpe_item_down_current_path_effect(SP_LPE_ITEM(item)); - sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, - SPDocumentUndo::done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, -- _("Move path effect down") ); ++ DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, ++ _("Move path effect down") ); effect_list_reload(SP_LPE_ITEM(item)); } @@@ -465,8 -461,8 +466,8 @@@ void LivePathEffectEditor::on_visibilit /* FIXME: this explicit writing to SVG is wrong. The lpe_item should have a method to disable/enable an effect within its stack. * So one can call: lpe_item->setActive(lpeobjref->lpeobject); */ lpeobjref->lpeobject->get_lpe()->getRepr()->setAttribute("is_visible", newValue ? "true" : "false"); - sp_document_done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, - SPDocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, -- newValue ? _("Activate path effect") : _("Deactivate path effect")); ++ DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, ++ newValue ? _("Activate path effect") : _("Deactivate path effect")); } } diff --cc src/ui/dialog/print.cpp index 2456e10da,808386171..a56cbfd9d --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@@ -3,6 -3,6 +3,7 @@@ */ /* Authors: * Kees Cook <kees@outflux.net> ++ * Abhishek Sharma * * Copyright (C) 2007 Kees Cook * Released under GNU GPL. Read the file 'COPYING' for more information. @@@ -181,7 -181,7 +182,7 @@@ Print::Print(SPDocument *doc, SPItem *b _printop = gtk_print_operation_new (); // set up dialog title, based on document name -- gchar *jobname = _doc->name ? _doc->name : _("SVG Document"); ++ gchar const *jobname = _doc->getName() ? _doc->getName() : _("SVG Document"); Glib::ustring title = _("Print"); title += " "; title += jobname; diff --cc src/ui/dialog/session-player.cpp index 51b206a85,01560733f..d8ff8ca56 --- a/src/ui/dialog/session-player.cpp +++ b/src/ui/dialog/session-player.cpp @@@ -3,6 -3,6 +3,7 @@@ */ /* Authors: * David Yip <yipdw@rose-hulman.edu> ++ * Abhishek Sharma * * Copyright (c) 2005 Authors * Released under GNU GPL, read the file 'COPYING' for more information diff --cc src/ui/dialog/svg-fonts-dialog.cpp index 1f11a412e,9f9f91bd1..042acb6e1 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@@ -3,6 -3,6 +3,8 @@@ */ /* Authors: * Felipe C. da S. Sanches <juca@members.fsf.org> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2008 Authors * Released under GNU GPLv2 (or later). Read the file 'COPYING' for more information. @@@ -117,8 -117,8 +119,8 @@@ void SvgFontsDialog::AttrEntry::on_attr Glib::ustring undokey = "svgfonts:"; undokey += name; - sp_document_maybe_done(o->document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, - SPDocumentUndo::maybe_done(o->document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, -- _("Set SVG Font attribute")); ++ DocumentUndo::maybeDone(o->document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, ++ _("Set SVG Font attribute")); } } @@@ -170,8 -170,10 +172,10 @@@ void SvgFontsDialog::on_kerning_value_c undokey += this->kerning_pair->u2->attribute_string(); //slider values increase from right to left so that they match the kerning pair preview - this->kerning_pair->repr->setAttribute("k", Glib::Ascii::dtostr(get_selected_spfont()->horiz_adv_x - kerning_slider.get_value()).c_str()); - sp_document_maybe_done(document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, _("Adjust kerning value")); + - //XML Tree being directly used here while it shouldn't be. ++ //XML Tree being directly used here while it shouldn't be. + this->kerning_pair->getRepr()->setAttribute("k", Glib::Ascii::dtostr(get_selected_spfont()->horiz_adv_x - kerning_slider.get_value()).c_str()); - SPDocumentUndo::maybe_done(document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, _("Adjust kerning value")); ++ DocumentUndo::maybeDone(document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, _("Adjust kerning value")); //populate_kerning_pairs_box(); kerning_preview.redraw(); @@@ -243,7 -245,7 +247,7 @@@ void SvgFontsDialog::update_fonts( { SPDesktop* desktop = this->getDesktop(); SPDocument* document = sp_desktop_document(desktop); - const GSList* fonts = sp_document_get_resource_list(document, "font"); - const GSList* fonts = document->get_resource_list("font"); ++ const GSList* fonts = document->getResourceList("font"); _model->clear(); for(const GSList *l = fonts; l; l = l->next) { @@@ -423,7 -425,7 +427,7 @@@ SvgFontsDialog::populate_kerning_pairs_ SPGlyph *new_glyph(SPDocument* document, SPFont *font, const int count) { g_return_val_if_fail(font != NULL, NULL); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); // create a new glyph Inkscape::XML::Node *repr; @@@ -462,7 -464,7 +466,7 @@@ void SvgFontsDialog::add_glyph() SPDocument* doc = sp_desktop_document(this->getDesktop()); /* SPGlyph* glyph =*/ new_glyph(doc, get_selected_spfont(), count+1); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add glyph")); - SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add glyph")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add glyph")); update_glyphs(); } @@@ -505,8 -507,9 +509,9 @@@ void SvgFontsDialog::set_glyph_descript msgStack->flash(Inkscape::ERROR_MESSAGE, msg); return; } - glyph->repr->setAttribute("d", (char*) sp_svg_write_path (pathv)); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); + //XML Tree being directly used here while it shouldn't be. + glyph->getRepr()->setAttribute("d", (char*) sp_svg_write_path (pathv)); - SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); update_glyphs(); } @@@ -547,8 -550,10 +552,10 @@@ void SvgFontsDialog::missing_glyph_desc SPObject* obj; for (obj = get_selected_spfont()->children; obj; obj=obj->next){ if (SP_IS_MISSING_GLYPH(obj)){ - obj->repr->setAttribute("d", (char*) sp_svg_write_path (pathv)); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); + - //XML Tree being directly used here while it shouldn't be. ++ //XML Tree being directly used here while it shouldn't be. + obj->getRepr()->setAttribute("d", (char*) sp_svg_write_path (pathv)); - SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); } } @@@ -566,8 -571,9 +573,9 @@@ void SvgFontsDialog::reset_missing_glyp SPObject* obj; for (obj = get_selected_spfont()->children; obj; obj=obj->next){ if (SP_IS_MISSING_GLYPH(obj)){ - obj->repr->setAttribute("d", (char*) "M0,0h1000v1024h-1000z"); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph")); - //XML Tree being directly used here while it shouldn't be. ++ //XML Tree being directly used here while it shouldn't be. + obj->getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z"); - SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph")); } } @@@ -579,10 -585,11 +587,11 @@@ void SvgFontsDialog::glyph_name_edit(co if (!i) return; SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node]; - glyph->repr->setAttribute("glyph-name", str.c_str()); - //XML Tree being directly used here while it shouldn't be. ++ //XML Tree being directly used here while it shouldn't be. + glyph->getRepr()->setAttribute("glyph-name", str.c_str()); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Edit glyph name")); - SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Edit glyph name")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Edit glyph name")); update_glyphs(); } @@@ -592,21 -599,22 +601,23 @@@ void SvgFontsDialog::glyph_unicode_edit if (!i) return; SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node]; - glyph->repr->setAttribute("unicode", str.c_str()); - //XML Tree being directly used here while it shouldn't be. ++ //XML Tree being directly used here while it shouldn't be. + glyph->getRepr()->setAttribute("unicode", str.c_str()); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph unicode")); - SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph unicode")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph unicode")); update_glyphs(); } void SvgFontsDialog::remove_selected_font(){ SPFont* font = get_selected_spfont(); + if (!font) return; - sp_repr_unparent(font->repr); - //XML Tree being directly used here while it shouldn't be. ++ //XML Tree being directly used here while it shouldn't be. + sp_repr_unparent(font->getRepr()); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove font")); - SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove font")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove font")); update_fonts(); } @@@ -618,10 -626,12 +629,12 @@@ void SvgFontsDialog::remove_selected_gl if(!i) return; SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node]; - sp_repr_unparent(glyph->repr); + + //XML Tree being directly used here while it shouldn't be. + sp_repr_unparent(glyph->getRepr()); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove glyph")); - SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove glyph")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove glyph")); update_glyphs(); } @@@ -633,10 -643,12 +646,12 @@@ void SvgFontsDialog::remove_selected_ke if(!i) return; SPGlyphKerning* pair = (*i)[_KerningPairsListColumns.spnode]; - sp_repr_unparent(pair->repr); + + //XML Tree being directly used here while it shouldn't be. + sp_repr_unparent(pair->getRepr()); SPDocument* doc = sp_desktop_document(this->getDesktop()); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove kerning pair")); - SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove kerning pair")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Remove kerning pair")); update_glyphs(); } @@@ -707,11 -719,11 +722,10 @@@ void SvgFontsDialog::add_kerning_pair() if (this->kerning_pair) return; //We already have this kerning pair SPDocument* document = sp_desktop_document(this->getDesktop()); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); // create a new hkern node -- Inkscape::XML::Node *repr; -- repr = xml_doc->createElement("svg:hkern"); ++ Inkscape::XML::Node *repr = xml_doc->createElement("svg:hkern"); repr->setAttribute("u1", first_glyph.get_active_text().c_str()); repr->setAttribute("u2", second_glyph.get_active_text().c_str()); @@@ -724,7 -736,7 +738,7 @@@ // get corresponding object this->kerning_pair = SP_HKERN( document->getObjectByRepr(repr) ); - sp_document_done(document, SP_VERB_DIALOG_SVG_FONTS, _("Add kerning pair")); - SPDocumentUndo::done(document, SP_VERB_DIALOG_SVG_FONTS, _("Add kerning pair")); ++ DocumentUndo::done(document, SP_VERB_DIALOG_SVG_FONTS, _("Add kerning pair")); } Gtk::VBox* SvgFontsDialog::kerning_tab(){ @@@ -774,11 -786,11 +788,10 @@@ SPFont *new_font(SPDocument *document SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); ++ Inkscape::XML::Document *xml_doc = document->getReprDoc(); // create a new font -- Inkscape::XML::Node *repr; -- repr = xml_doc->createElement("svg:font"); ++ Inkscape::XML::Node *repr = xml_doc->createElement("svg:font"); //By default, set the horizontal advance to 1024 units repr->setAttribute("horiz-adv-x", "1024"); @@@ -813,11 -825,12 +826,12 @@@ void set_font_family(SPFont* font, char SPObject* obj; for (obj=font->children; obj; obj=obj->next){ if (SP_IS_FONTFACE(obj)){ - obj->repr->setAttribute("font-family", str); - //XML Tree being directly used here while it shouldn't be. ++ //XML Tree being directly used here while it shouldn't be. + obj->getRepr()->setAttribute("font-family", str); } } - sp_document_done(font->document, SP_VERB_DIALOG_SVG_FONTS, _("Set font family")); - SPDocumentUndo::done(font->document, SP_VERB_DIALOG_SVG_FONTS, _("Set font family")); ++ DocumentUndo::done(font->document, SP_VERB_DIALOG_SVG_FONTS, _("Set font family")); } void SvgFontsDialog::add_font(){ @@@ -833,14 -846,15 +847,15 @@@ SPObject* obj; for (obj=font->children; obj; obj=obj->next){ if (SP_IS_FONTFACE(obj)){ - obj->repr->setAttribute("font-family", os2.str().c_str()); - //XML Tree being directly used here while it shouldn't be. ++ //XML Tree being directly used here while it shouldn't be. + obj->getRepr()->setAttribute("font-family", os2.str().c_str()); } } update_fonts(); // select_font(font); - sp_document_done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add font")); - SPDocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add font")); ++ DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Add font")); } SvgFontsDialog::SvgFontsDialog() diff --cc src/ui/dialog/swatches.cpp index 4c8a018fa,6cef5bedd..b2b1b26da --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@@ -5,6 -5,6 +5,7 @@@ /* Authors: * Jon A. Cruz * John Bintz ++ * Abhishek Sharma * * Copyright (C) 2005 Jon A. Cruz * Copyright (C) 2008 John Bintz @@@ -155,7 -127,7 +156,7 @@@ static void editGradient( GtkMenuItem * SPDocument *doc = desktop ? desktop->doc() : 0; if (doc) { std::string targetName(bounceTarget->def.descr); - const GSList *gradients = sp_document_get_resource_list(doc, "gradient"); - const GSList *gradients = doc->get_resource_list("gradient"); ++ const GSList *gradients = doc->getResourceList("gradient"); for (const GSList *item = gradients; item; item = item->next) { SPGradient* grad = SP_GRADIENT(item->data); if ( targetName == grad->getId() ) { @@@ -173,20 -145,25 +174,20 @@@ void SwatchesPanelHook::convertGradient SwatchesPanel* swp = bouncePanel; SPDesktop* desktop = swp ? swp->getDesktop() : 0; SPDocument *doc = desktop ? desktop->doc() : 0; - if (doc) { - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); - - Inkscape::XML::Node *repr = xml_doc->createElement("svg:linearGradient"); - repr->setAttribute("osb:paint", "solid"); - Inkscape::XML::Node *stop = xml_doc->createElement("svg:stop"); - stop->setAttribute("offset", "0"); - stop->setAttribute("style", "stop-color:#000;stop-opacity:1;"); - repr->appendChild(stop); - Inkscape::GC::release(stop); - - SP_OBJECT_REPR( SP_DOCUMENT_DEFS(doc) )->addChild(repr, NULL); - - SPGradient * gr = static_cast<SPGradient *>(doc->getObjectByRepr(repr)); - - Inkscape::GC::release(repr); - + gint index = GPOINTER_TO_INT(userData); + if ( doc && (index >= 0) && (static_cast<guint>(index) < popupItems.size()) ) { + Glib::ustring targetName = popupItems[index]; - const GSList *gradients = sp_document_get_resource_list(doc, "gradient"); - editGradientImpl( gr ); ++ const GSList *gradients = doc->getResourceList("gradient"); + for (const GSList *item = gradients; item; item = item->next) { + SPGradient* grad = SP_GRADIENT(item->data); + if ( targetName == grad->getId() ) { + grad->setSwatch(); - sp_document_done(doc, SP_VERB_CONTEXT_GRADIENT, - _("Add gradient stop")); ++ DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, ++ _("Add gradient stop")); + break; + } + } } } } @@@ -197,15 -174,21 +198,15 @@@ void SwatchesPanelHook::deleteGradient SwatchesPanel* swp = bouncePanel; SPDesktop* desktop = swp ? swp->getDesktop() : 0; SPDocument *doc = desktop ? desktop->doc() : 0; - gint index = GPOINTER_TO_INT(userData); - if ( doc && (index >= 0) && (static_cast<guint>(index) < popupItems.size()) ) { - Glib::ustring targetName = popupItems[index]; - - const GSList *gradients = doc->get_resource_list("gradient"); + if (doc) { + std::string targetName(bounceTarget->def.descr); - const GSList *gradients = sp_document_get_resource_list(doc, "gradient"); ++ const GSList *gradients = doc->getResourceList("gradient"); for (const GSList *item = gradients; item; item = item->next) { SPGradient* grad = SP_GRADIENT(item->data); if ( targetName == grad->getId() ) { - //XML Tree being used directly here while it shouldn't be - grad->getRepr()->setAttribute("osb:paint", "solid"); // TODO make conditional - - SPDocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, - _("Add gradient stop")); - - handleGradientsChange(doc); // work-around for signal not being emitted + grad->setSwatch(false); - sp_document_done(doc, SP_VERB_CONTEXT_GRADIENT, - _("Delete")); ++ DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, ++ _("Delete")); break; } } @@@ -320,7 -307,7 +321,7 @@@ gboolean colorItemHandleButtonPress( Gt SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(wdgt); if ( dtw && dtw->desktop ) { // Pick up all gradients with vectors - const GSList *gradients = sp_document_get_resource_list(dtw->desktop->doc(), "gradient"); - const GSList *gradients = (dtw->desktop->doc())->get_resource_list("gradient"); ++ const GSList *gradients = (dtw->desktop->doc())->getResourceList("gradient"); gint index = 0; for (const GSList *curr = gradients; curr; curr = curr->next) { SPGradient* grad = SP_GRADIENT(curr->data); @@@ -773,7 -760,7 +774,7 @@@ void SwatchesPanel::_trackDocument( Swa } docPerPanel[panel] = document; if (!found) { - sigc::connection conn1 = sp_document_resources_changed_connect( document, "gradient", sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleGradientsChange), document) ); - sigc::connection conn1 = document->resources_changed_connect( "gradient", sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleGradientsChange), document) ); ++ sigc::connection conn1 = document->connectResourcesChanged( "gradient", sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleGradientsChange), document) ); sigc::connection conn2 = SP_DOCUMENT_DEFS(document)->connectRelease( sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document)) ); sigc::connection conn3 = SP_DOCUMENT_DEFS(document)->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document))) ); @@@ -811,7 -798,7 +812,7 @@@ static void recalcSwatchContents(SPDocu { std::vector<SPGradient*> newList; - const GSList *gradients = sp_document_get_resource_list(doc, "gradient"); - const GSList *gradients = doc->get_resource_list("gradient"); ++ const GSList *gradients = doc->getResourceList("gradient"); for (const GSList *item = gradients; item; item = item->next) { SPGradient* grad = SP_GRADIENT(item->data); if ( grad->isSwatch() ) { @@@ -967,7 -949,8 +968,8 @@@ void SwatchesPanel::_updateFromSelectio } } if ( target ) { - gchar const* id = target->repr->attribute("id"); - //XML Tree being used directly here while it shouldn't be ++ //XML Tree being used directly here while it shouldn't be + gchar const* id = target->getRepr()->attribute("id"); if ( id ) { fillId = id; } @@@ -998,7 -981,9 +1000,8 @@@ } } if ( target ) { - gchar const* id = target->repr->attribute("id"); - - //XML Tree being used directly here while it shouldn't be ++ //XML Tree being used directly here while it shouldn't be + gchar const* id = target->getRepr()->attribute("id"); if ( id ) { strokeId = id; } diff --cc src/ui/dialog/tile.cpp index b50610938,cf29ed77f..fccf5c105 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@@ -5,6 -5,6 +5,7 @@@ * Bob Jamison ( based off trace dialog) * John Cliff * Other dudes from The Inkscape Organization ++ * Abhishek Sharma * * Copyright (C) 2004 Bob Jamison * Copyright (C) 2004 John Cliff @@@ -159,7 -159,7 +160,7 @@@ void TileDialog::Grid_Arrange ( grid_top = 99999; SPDesktop *desktop = getDesktop(); - sp_document_ensure_up_to_date(sp_desktop_document(desktop)); - sp_desktop_document(desktop)->ensure_up_to_date(); ++ sp_desktop_document(desktop)->ensureUpToDate(); Inkscape::Selection *selection = sp_desktop_selection (desktop); const GSList *items = selection ? selection->itemList() : 0; @@@ -344,8 -344,8 +345,8 @@@ g_print("\n row = %f col = %f selec g_slist_free (current_row); } - sp_document_done (sp_desktop_document (desktop), SP_VERB_SELECTION_GRIDTILE, - SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_SELECTION_GRIDTILE, -- _("Arrange in a grid")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_GRIDTILE, ++ _("Arrange in a grid")); } diff --cc src/ui/dialog/transformation.cpp index 338e11d38,62f0f38aa..c895f0be9 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@@ -4,6 -4,6 +4,7 @@@ /* Authors: * Bryce W. Harrington <bryce@bryceharrington.org> * buliabyak@gmail.com ++ * Abhishek Sharma * * Copyright (C) 2004, 2005 Authors * Released under GNU GPL. Read the file 'COPYING' for more information. @@@ -687,8 -677,8 +688,8 @@@ Transformation::applyPageMove(Inkscape: } } - sp_document_done ( sp_desktop_document (selection->desktop()) , SP_VERB_DIALOG_TRANSFORM, - SPDocumentUndo::done ( sp_desktop_document (selection->desktop()) , SP_VERB_DIALOG_TRANSFORM, -- _("Move")); ++ DocumentUndo::done( sp_desktop_document(selection->desktop()) , SP_VERB_DIALOG_TRANSFORM, ++ _("Move")); } void @@@ -744,8 -734,8 +745,8 @@@ Transformation::applyPageScale(Inkscape } } - sp_document_done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, - SPDocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, -- _("Scale")); ++ DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, ++ _("Scale")); } void @@@ -766,8 -756,8 +767,8 @@@ Transformation::applyPageRotate(Inkscap } } - sp_document_done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, - SPDocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, -- _("Rotate")); ++ DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, ++ _("Rotate")); } void @@@ -825,8 -815,8 +826,8 @@@ Transformation::applyPageSkew(Inkscape: } } - sp_document_done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, - SPDocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, -- _("Skew")); ++ DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, ++ _("Skew")); } @@@ -852,8 -842,8 +853,8 @@@ Transformation::applyPageTransform(Inks sp_selection_apply_affine(selection, displayed); // post-multiply each object's transform } - sp_document_done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, - SPDocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, -- _("Edit transformation matrix")); ++ DocumentUndo::done(sp_desktop_document(selection->desktop()), SP_VERB_DIALOG_TRANSFORM, ++ _("Edit transformation matrix")); } diff --cc src/ui/dialog/undo-history.cpp index 111dc014d,9e0922072..17d032758 --- a/src/ui/dialog/undo-history.cpp +++ b/src/ui/dialog/undo-history.cpp @@@ -3,6 -3,6 +3,7 @@@ */ /* Author: * Gustav Broberg <broberg@kth.se> ++ * Abhishek Sharma * * Copyright (C) 2006 Authors * Released under GNU GPL. Read the file 'COPYING' for more information. @@@ -214,7 -214,7 +215,7 @@@ UndoHistory::_onListSelectionChange( _event_log->blockNotifications(); for ( --last ; curr_event != last ; ++curr_event ) { - sp_document_redo(_document); - SPDocumentUndo::redo(_document); ++ DocumentUndo::redo(_document); } _event_log->blockNotifications(false); @@@ -248,7 -248,7 +249,7 @@@ while ( selected != last_selected ) { - sp_document_undo(_document); - SPDocumentUndo::undo(_document); ++ DocumentUndo::undo(_document); if ( last_selected->parent() && last_selected == last_selected->parent()->children().begin() ) @@@ -273,7 -273,7 +274,7 @@@ while ( selected != last_selected ) { - sp_document_redo(_document); - SPDocumentUndo::redo(_document); ++ DocumentUndo::redo(_document); if ( !last_selected->children().empty() ) { _event_log->setCurrEventParent(last_selected); @@@ -317,10 -317,10 +318,10 @@@ UndoHistory::_onCollapseEvent(const Gtk EventLog::const_iterator last = curr_event_parent->children().end(); _event_log->blockNotifications(); - sp_document_redo(_document); - SPDocumentUndo::redo(_document); ++ DocumentUndo::redo(_document); for ( --last ; curr_event != last ; ++curr_event ) { - sp_document_redo(_document); - SPDocumentUndo::redo(_document); ++ DocumentUndo::redo(_document); } _event_log->blockNotifications(false); diff --cc src/ui/tool/multi-path-manipulator.cpp index 82446b7b4,a455567e8..ef1c764bb --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@@ -3,6 -3,6 +3,7 @@@ */ /* Authors: * Krzysztof Kosiński <tweenk.pl@gmail.com> ++ * Abhishek Sharma * * Copyright (C) 2009 Authors * Released under GNU GPL, read the file 'COPYING' for more information @@@ -706,9 -662,9 +707,9 @@@ void MultiPathManipulator::_commit(Comm _selection.signal_update.emit(); invokeForAll(&PathManipulator::writeXML); if (key) { - sp_document_maybe_done(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE, reason); - SPDocumentUndo::maybe_done(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE, reason); ++ DocumentUndo::maybeDone(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE, reason); } else { - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); - SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); } signal_coords_changed.emit(); } @@@ -717,7 -673,7 +718,7 @@@ void MultiPathManipulator::_done(gchar const *reason) { invokeForAll(&PathManipulator::update); invokeForAll(&PathManipulator::writeXML); - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); - SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, reason); signal_coords_changed.emit(); } diff --cc src/ui/tool/node-tool.cpp index e046fb573,0b6d2168f..8661e7946 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@@ -3,6 -3,6 +3,7 @@@ */ /* Authors: * Krzysztof Kosiński <tweenk@gmail.com> ++ * Abhishek Sharma * * Copyright (C) 2009 Authors * Released under GNU GPL, read the file 'COPYING' for more information @@@ -365,7 -359,8 +366,8 @@@ void gather_items(InkNodeTool *nt, SPIt using namespace Inkscape::UI; if (!obj) return; - if (SP_IS_PATH(obj) && obj->repr->attribute("inkscape:original-d") != NULL) { - //XML Tree being used directly here while it shouldn't be. ++ //XML Tree being used directly here while it shouldn't be. + if (SP_IS_PATH(obj) && obj->getRepr()->attribute("inkscape:original-d") != NULL) { ShapeRecord r; r.item = static_cast<SPItem*>(obj); r.edit_transform = Geom::identity(); // TODO wrong? @@@ -612,8 -596,7 +614,7 @@@ void ink_node_tool_select_area(InkNodeT if (nt->_multipath->empty()) { // if multipath is empty, select rubberbanded items rather than nodes Inkscape::Selection *selection = nt->desktop->selection; - GSList *items = sp_document_items_in_box( - sp_desktop_document(nt->desktop), nt->desktop->dkey, sel); - GSList *items = sp_desktop_document(nt->desktop)->items_in_box(nt->desktop->dkey, sel); ++ GSList *items = sp_desktop_document(nt->desktop)->getItemsInBox(nt->desktop->dkey, sel); selection->setList(items); g_slist_free(items); } else { diff --cc src/ui/tool/path-manipulator.cpp index bb8ce0fb5,f102be1f7..5ae9c4137 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@@ -3,6 -3,6 +3,7 @@@ */ /* Authors: * Krzysztof Kosiński <tweenk.pl@gmail.com> ++ * Abhishek Sharma * * Copyright (C) 2009 Authors * Released under GNU GPL, read the file 'COPYING' for more information @@@ -1104,7 -1069,9 +1105,9 @@@ void PathManipulator::_createControlPoi // so that pickBestType works correctly // TODO maybe migrate to inkscape:node-types? // TODO move this into SPPath - do not manipulate directly - gchar const *nts_raw = _path ? _path->repr->attribute(_nodetypesKey().data()) : 0; + - //XML Tree being used here directly while it shouldn't be. ++ //XML Tree being used here directly while it shouldn't be. + gchar const *nts_raw = _path ? _path->getRepr()->attribute(_nodetypesKey().data()) : 0; std::string nodetype_string = nts_raw ? nts_raw : ""; /* Calculate the needed length of the nodetype string. * For closed paths, the entry is duplicated for the starting node, @@@ -1279,10 -1246,11 +1282,11 @@@ void PathManipulator::_setGeometry( LIVEPATHEFFECT(_path)->requestModified(SP_OBJECT_MODIFIED_FLAG); } } else { - if (_path->repr->attribute("inkscape:original-d")) - //XML Tree being used here directly while it shouldn't be. ++ //XML Tree being used here directly while it shouldn't be. + if (_path->getRepr()->attribute("inkscape:original-d")) sp_path_set_original_curve(_path, _spcurve, false, false); else - sp_shape_set_curve(SP_SHAPE(_path), _spcurve, false); + SP_SHAPE(_path)->setCurve(_spcurve, false); } } @@@ -1297,8 -1265,10 +1301,10 @@@ Glib::ustring PathManipulator::_nodetyp * This method is wrong but necessary at the moment. */ Inkscape::XML::Node *PathManipulator::_getXMLNode() { - if (_lpe_key.empty()) return _path->repr; - return LIVEPATHEFFECT(_path)->repr; - //XML Tree being used here directly while it shouldn't be. ++ //XML Tree being used here directly while it shouldn't be. + if (_lpe_key.empty()) return _path->getRepr(); - //XML Tree being used here directly while it shouldn't be. ++ //XML Tree being used here directly while it shouldn't be. + return LIVEPATHEFFECT(_path)->getRepr(); } bool PathManipulator::_nodeClicked(Node *n, GdkEventButton *event) @@@ -1416,14 -1392,14 +1422,14 @@@ void PathManipulator::_removeNodesFromS void PathManipulator::_commit(Glib::ustring const &annotation) { writeXML(); - sp_document_done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, annotation.data()); - SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, annotation.data()); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_NODE, annotation.data()); } void PathManipulator::_commit(Glib::ustring const &annotation, gchar const *key) { writeXML(); - sp_document_maybe_done(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE, - SPDocumentUndo::maybe_done(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE, -- annotation.data()); ++ DocumentUndo::maybeDone(sp_desktop_document(_desktop), key, SP_VERB_CONTEXT_NODE, ++ annotation.data()); } /** Update the position of the curve drag point such that it is over the nearest diff --cc src/ui/view/view.cpp index 1b498a846,1b498a846..f05e024d1 --- a/src/ui/view/view.cpp +++ b/src/ui/view/view.cpp @@@ -1,11 -1,11 +1,10 @@@ --#define __SP_VIEW_C__ -- /** \file * View implementation * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> * Ralf Stephan <ralf@ark.in-berlin.de> ++ * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. @@@ -156,7 -156,7 +155,7 @@@ void View::setDocument(SPDocument *doc _doc->connectURISet(sigc::bind(sigc::ptr_fun(&_onDocumentURISet), this)); _document_resized_connection = _doc->connectResized(sigc::bind(sigc::ptr_fun(&_onDocumentResized), this)); -- _document_uri_set_signal.emit (SP_DOCUMENT_URI(_doc)); ++ _document_uri_set_signal.emit( _doc->getURI() ); } }}} diff --cc src/ui/widget/color-picker.cpp index b7a67b744,48dd59685..650ed10f6 --- a/src/ui/widget/color-picker.cpp +++ b/src/ui/widget/color-picker.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __COLOR_PICKER_C__ -- /** \file * \brief Color picker button & window * @@@ -7,6 -7,6 +5,7 @@@ * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> * Ralf Stephan <ralf@ark.in-berlin.de> ++ * Abhishek Sharma * * Copyright (C) Authors 2000-2005 * @@@ -132,8 -132,8 +131,8 @@@ sp_color_picker_color_mod(SPColorSelect (ptr->_preview).setRgba32 (rgba); if (ptr->_undo && SP_ACTIVE_DESKTOP) - sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, - SPDocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, -- /* TODO: annotate */ "color-picker.cpp:130"); ++ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, ++ /* TODO: annotate */ "color-picker.cpp:130"); ptr->on_changed (rgba); _in_use = false; diff --cc src/ui/widget/entity-entry.cpp index 968e35b6c,cc38de24f..e191a9360 --- a/src/ui/widget/entity-entry.cpp +++ b/src/ui/widget/entity-entry.cpp @@@ -6,6 -6,6 +6,8 @@@ * Lauris Kaplinski <lauris@kaplinski.com> * Jon Phillips <jon@rejon.org> * Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm) ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2000 - 2005 Authors * @@@ -20,6 -20,6 +22,7 @@@ #include <gtkmm/entry.h> #include "inkscape.h" ++#include "sp-object.h" #include "rdf.h" #include "ui/widget/registry.h" @@@ -80,10 -80,10 +83,14 @@@ EntityLineEntry::~EntityLineEntry( delete static_cast<Gtk::Entry*>(_packable); } --void --EntityLineEntry::update (SPDocument *doc) ++void EntityLineEntry::update(SPDocument *doc) { const char *text = rdf_get_work_entity (doc, _entity); ++ // If RDF title is not set, get the document's <title> and set the RDF: ++ if ( !text && !strcmp(_entity->name, "title") && doc->root ) { ++ text = doc->root->title(); ++ rdf_set_work_entity(doc, _entity, text); ++ } static_cast<Gtk::Entry*>(_packable)->set_text (text ? text : ""); } @@@ -95,9 -95,9 +102,10 @@@ EntityLineEntry::on_changed( _wr->setUpdating (true); SPDocument *doc = SP_ACTIVE_DOCUMENT; Glib::ustring text = static_cast<Gtk::Entry*>(_packable)->get_text(); -- if (rdf_set_work_entity (doc, _entity, text.c_str())) - sp_document_done (doc, SP_VERB_NONE, - SPDocumentUndo::done (doc, SP_VERB_NONE, -- /* TODO: annotate */ "entity-entry.cpp:101"); ++ if (rdf_set_work_entity (doc, _entity, text.c_str())) { ++ DocumentUndo::done(doc, SP_VERB_NONE, ++ /* TODO: annotate */ "entity-entry.cpp:101"); ++ } _wr->setUpdating (false); } @@@ -121,10 -121,10 +129,14 @@@ EntityMultiLineEntry::~EntityMultiLineE delete static_cast<Gtk::ScrolledWindow*>(_packable); } --void --EntityMultiLineEntry::update (SPDocument *doc) ++void EntityMultiLineEntry::update(SPDocument *doc) { const char *text = rdf_get_work_entity (doc, _entity); ++ // If RDF title is not set, get the document's <title> and set the RDF: ++ if ( !text && !strcmp(_entity->name, "title") && doc->root ) { ++ text = doc->root->title(); ++ rdf_set_work_entity(doc, _entity, text); ++ } Gtk::ScrolledWindow *s = static_cast<Gtk::ScrolledWindow*>(_packable); Gtk::TextView *tv = static_cast<Gtk::TextView*>(s->get_child()); tv->get_buffer()->set_text (text ? text : ""); @@@ -140,9 -140,9 +152,10 @@@ EntityMultiLineEntry::on_changed( Gtk::ScrolledWindow *s = static_cast<Gtk::ScrolledWindow*>(_packable); Gtk::TextView *tv = static_cast<Gtk::TextView*>(s->get_child()); Glib::ustring text = tv->get_buffer()->get_text(); -- if (rdf_set_work_entity (doc, _entity, text.c_str())) - sp_document_done (doc, SP_VERB_NONE, - SPDocumentUndo::done (doc, SP_VERB_NONE, -- /* TODO: annotate */ "entity-entry.cpp:146"); ++ if (rdf_set_work_entity (doc, _entity, text.c_str())) { ++ DocumentUndo::done(doc, SP_VERB_NONE, ++ /* TODO: annotate */ "entity-entry.cpp:146"); ++ } _wr->setUpdating (false); } diff --cc src/ui/widget/imageicon.cpp index 71ba4428c,f5dd3e9fa..c60e94ab7 --- a/src/ui/widget/imageicon.cpp +++ b/src/ui/widget/imageicon.cpp @@@ -4,6 -4,6 +4,7 @@@ * Authors: * Bob Jamison * Other dudes from The Inkscape Organization ++ * Abhishek Sharma * * Copyright (C) 2004 The Inkscape Organization * diff --cc src/ui/widget/layer-selector.cpp index 5fb8089b4,da096f25d..6d1da0af0 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@@ -3,6 -3,6 +3,7 @@@ * * Authors: * MenTaLguY <mental@rydia.net> ++ * Abhishek Sharma * * Copyright (C) 2004 MenTaLguY * @@@ -583,16 -583,16 +584,16 @@@ void LayerSelector::_prepareLabelRender void LayerSelector::_lockLayer(bool lock) { if ( _layer && SP_IS_ITEM(_layer) ) { SP_ITEM(_layer)->setLocked(lock); - sp_document_done(sp_desktop_document(_desktop), SP_VERB_NONE, - SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_NONE, -- lock? _("Lock layer") : _("Unlock layer")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_NONE, ++ lock? _("Lock layer") : _("Unlock layer")); } } void LayerSelector::_hideLayer(bool hide) { if ( _layer && SP_IS_ITEM(_layer) ) { SP_ITEM(_layer)->setHidden(hide); - sp_document_done(sp_desktop_document(_desktop), SP_VERB_NONE, - SPDocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_NONE, -- hide? _("Hide layer") : _("Unhide layer")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_NONE, ++ hide? _("Hide layer") : _("Unhide layer")); } } diff --cc src/ui/widget/licensor.cpp index a5f1d89be,a4a789840..c9550bb27 --- a/src/ui/widget/licensor.cpp +++ b/src/ui/widget/licensor.cpp @@@ -6,6 -6,6 +6,7 @@@ * Lauris Kaplinski <lauris@kaplinski.com> * Jon Phillips <jon@rejon.org> * Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm) ++ * Abhishek Sharma * * Copyright (C) 2000 - 2005 Authors * @@@ -64,8 -64,8 +65,8 @@@ LicenseItem::on_toggled( _wr.setUpdating (true); rdf_set_license (SP_ACTIVE_DOCUMENT, _lic->details ? _lic : 0); - sp_document_done (SP_ACTIVE_DOCUMENT, SP_VERB_NONE, - SPDocumentUndo::done (SP_ACTIVE_DOCUMENT, SP_VERB_NONE, -- /* TODO: annotate */ "licensor.cpp:65"); ++ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_NONE, ++ /* TODO: annotate */ "licensor.cpp:65"); _wr.setUpdating (false); static_cast<Gtk::Entry*>(_eep->_packable)->set_text (_lic->uri); _eep->on_changed(); diff --cc src/ui/widget/object-composite-settings.cpp index a9b4fe83e,f5e4657b1..1de425da3 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@@ -5,6 -5,6 +5,7 @@@ * Bryce W. Harrington <bryce@bryceharrington.org> * Gustav Broberg <broberg@kth.se> * Niko Kiirala <niko@kiirala.com> ++ * Abhishek Sharma * * Copyright (C) 2004--2008 Authors * @@@ -168,7 -168,7 +169,7 @@@ ObjectCompositeSettings::_blendBlurValu SP_OBJECT_STYLE_MODIFIED_FLAG )); } - sp_document_maybe_done (document, _blur_tag.c_str(), _verb_code, - SPDocumentUndo::maybe_done (document, _blur_tag.c_str(), _verb_code, ++ DocumentUndo::maybeDone(document, _blur_tag.c_str(), _verb_code, _("Change blur")); // resume interruptibility @@@ -208,7 -208,7 +209,7 @@@ ObjectCompositeSettings::_opacityValueC sp_repr_css_attr_unref (css); - sp_document_maybe_done (sp_desktop_document (desktop), _opacity_tag.c_str(), _verb_code, - SPDocumentUndo::maybe_done (sp_desktop_document (desktop), _opacity_tag.c_str(), _verb_code, ++ DocumentUndo::maybeDone(sp_desktop_document (desktop), _opacity_tag.c_str(), _verb_code, _("Change opacity")); // resume interruptibility diff --cc src/ui/widget/page-sizer.cpp index 724848ca5,33adc85d0..f7cb6f145 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@@ -8,6 -8,6 +8,7 @@@ * Jon Phillips <jon@rejon.org> * Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm) * Bob Jamison <ishmal@users.sf.net> ++ * Abhishek Sharma * * Copyright (C) 2000 - 2006 Authors * @@@ -422,7 -413,7 +423,7 @@@ PageSizer::setDim (double w, double h, // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this Geom::Translate const vert_offset(Geom::Point(0, (old_height - h))); SP_GROUP(SP_ROOT(doc->root))->translateChildItems(vert_offset); - sp_document_done (doc, SP_VERB_NONE, _("Set page size")); - SPDocumentUndo::done (doc, SP_VERB_NONE, _("Set page size")); ++ DocumentUndo::done(doc, SP_VERB_NONE, _("Set page size")); } if ( w != h ) { diff --cc src/ui/widget/registered-widget.cpp index db31d08d3,16422f1b2..04bd27285 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@@ -8,6 -8,6 +8,7 @@@ * Lauris Kaplinski <lauris@kaplinski.com> * Jon Phillips <jon@rejon.org> * Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm) ++ * Abhishek Sharma * * Copyright (C) 2000 - 2007 Authors * @@@ -349,15 -349,15 +350,15 @@@ RegisteredColorPicker::on_changed (guin gchar c[32]; sp_svg_write_color(c, sizeof(c), rgba); - bool saved = sp_document_get_undo_sensitive (local_doc); - sp_document_set_undo_sensitive (local_doc, false); - bool saved = SPDocumentUndo::get_undo_sensitive (local_doc); - SPDocumentUndo::set_undo_sensitive (local_doc, false); ++ bool saved = DocumentUndo::getUndoSensitive(local_doc); ++ DocumentUndo::setUndoSensitive(local_doc, false); local_repr->setAttribute(_ckey.c_str(), c); sp_repr_set_css_double(local_repr, _akey.c_str(), (rgba & 0xff) / 255.0); - sp_document_set_undo_sensitive (local_doc, saved); - SPDocumentUndo::set_undo_sensitive (local_doc, saved); ++ DocumentUndo::setUndoSensitive(local_doc, saved); local_doc->setModifiedSinceSave(); - sp_document_done (local_doc, SP_VERB_NONE, - SPDocumentUndo::done (local_doc, SP_VERB_NONE, -- /* TODO: annotate */ "registered-widget.cpp: RegisteredColorPicker::on_changed"); ++ DocumentUndo::done(local_doc, SP_VERB_NONE, ++ /* TODO: annotate */ "registered-widget.cpp: RegisteredColorPicker::on_changed"); _wr->setUpdating (false); } diff --cc src/ui/widget/registered-widget.h index 7aefbb90e,dec8cd111..efb5eb70e --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@@ -4,6 -4,6 +4,7 @@@ * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * Johan Engelen <j.b.c.engelen@utwente.nl> ++ * Abhishek Sharma * * Copyright (C) 2005-2008 Authors * @@@ -104,16 -104,16 +105,18 @@@ protected local_doc = sp_desktop_document(dt); } - bool saved = sp_document_get_undo_sensitive (local_doc); - sp_document_set_undo_sensitive (local_doc, false); - bool saved = SPDocumentUndo::get_undo_sensitive (local_doc); - SPDocumentUndo::set_undo_sensitive (local_doc, false); -- if (!write_undo) local_repr->setAttribute(_key.c_str(), svgstr); - sp_document_set_undo_sensitive (local_doc, saved); - SPDocumentUndo::set_undo_sensitive (local_doc, saved); ++ bool saved = DocumentUndo::getUndoSensitive(local_doc); ++ DocumentUndo::setUndoSensitive(local_doc, false); ++ if (!write_undo) { ++ local_repr->setAttribute(_key.c_str(), svgstr); ++ } ++ DocumentUndo::setUndoSensitive(local_doc, saved); local_doc->setModifiedSinceSave(); if (write_undo) { local_repr->setAttribute(_key.c_str(), svgstr); - sp_document_done (local_doc, event_type, event_description); - SPDocumentUndo::done (local_doc, event_type, event_description); ++ DocumentUndo::done(local_doc, event_type, event_description); } } diff --cc src/ui/widget/ruler.cpp index 7f260680b,9fac48145..107f4e8c6 --- a/src/ui/widget/ruler.cpp +++ b/src/ui/widget/ruler.cpp @@@ -6,6 -6,6 +6,8 @@@ * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> * Lauris Kaplinski ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2005 Ralf Stephan * @@@ -145,15 -145,15 +147,15 @@@ Ruler::on_button_release_event(GdkEvent _dragging = false; if ( (_horiz_f ? wy : wx ) >= 0 ) { -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(_dt->doc()); ++ Inkscape::XML::Document *xml_doc = _dt->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide"); repr->setAttribute("orientation", _horiz_f ? "horizontal" : "vertical"); double const guide_pos_dt = event_dt[ _horiz_f ? Geom::Y : Geom::X ]; sp_repr_set_svg_double(repr, "position", guide_pos_dt); SP_OBJECT_REPR(_dt->namedview)->appendChild(repr); Inkscape::GC::release(repr); - sp_document_done(sp_desktop_document(_dt), SP_VERB_NONE, - SPDocumentUndo::done(sp_desktop_document(_dt), SP_VERB_NONE, -- /* TODO: annotate */ "ruler.cpp:157"); ++ DocumentUndo::done(sp_desktop_document(_dt), SP_VERB_NONE, ++ /* TODO: annotate */ "ruler.cpp:157"); } _dt->set_coordinate_status(event_dt); } diff --cc src/ui/widget/selected-style.cpp index 8e11c8308,9a94113eb..e7d8ac5a3 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@@ -3,6 -3,6 +3,7 @@@ * * Author: * buliabyak@gmail.com ++ * Abhishek Sharma * * Copyright (C) 2005 author * @@@ -464,8 -464,8 +465,8 @@@ void SelectedStyle::dragDataReceived( G sp_repr_css_set_property( css, (tracker->item == SS_FILL) ? "fill":"stroke", c ); sp_desktop_set_style( tracker->parent->_desktop, css ); sp_repr_css_attr_unref( css ); - sp_document_done( sp_desktop_document(tracker->parent->_desktop) , SP_VERB_NONE, - SPDocumentUndo::done( sp_desktop_document(tracker->parent->_desktop) , SP_VERB_NONE, -- _("Drop color")); ++ DocumentUndo::done( sp_desktop_document(tracker->parent->_desktop) , SP_VERB_NONE, ++ _("Drop color")); } } break; @@@ -477,8 -477,8 +478,8 @@@ void SelectedStyle::on_fill_remove() sp_repr_css_set_property (css, "fill", "none"); sp_desktop_set_style (_desktop, css, true, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Remove fill")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Remove fill")); } void SelectedStyle::on_stroke_remove() { @@@ -486,8 -486,8 +487,8 @@@ sp_repr_css_set_property (css, "stroke", "none"); sp_desktop_set_style (_desktop, css, true, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Remove stroke")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Remove stroke")); } void SelectedStyle::on_fill_unset() { @@@ -495,8 -495,8 +496,8 @@@ sp_repr_css_unset_property (css, "fill"); sp_desktop_set_style (_desktop, css, true, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Unset fill")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Unset fill")); } void SelectedStyle::on_stroke_unset() { @@@ -511,8 -511,8 +512,8 @@@ sp_repr_css_unset_property (css, "stroke-dasharray"); sp_desktop_set_style (_desktop, css, true, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Unset stroke")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Unset stroke")); } void SelectedStyle::on_fill_opaque() { @@@ -520,8 -520,8 +521,8 @@@ sp_repr_css_set_property (css, "fill-opacity", "1"); sp_desktop_set_style (_desktop, css, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Make fill opaque")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Make fill opaque")); } void SelectedStyle::on_stroke_opaque() { @@@ -529,8 -529,8 +530,8 @@@ sp_repr_css_set_property (css, "stroke-opacity", "1"); sp_desktop_set_style (_desktop, css, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Make fill opaque")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Make fill opaque")); } void SelectedStyle::on_fill_lastused() { @@@ -541,8 -541,8 +542,8 @@@ sp_repr_css_set_property (css, "fill", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Apply last set color to fill")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Apply last set color to fill")); } void SelectedStyle::on_stroke_lastused() { @@@ -553,8 -553,8 +554,8 @@@ sp_repr_css_set_property (css, "stroke", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Apply last set color to stroke")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Apply last set color to stroke")); } void SelectedStyle::on_fill_lastselected() { @@@ -564,8 -564,8 +565,8 @@@ sp_repr_css_set_property (css, "fill", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Apply last selected color to fill")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Apply last selected color to fill")); } void SelectedStyle::on_stroke_lastselected() { @@@ -575,8 -575,8 +576,8 @@@ sp_repr_css_set_property (css, "stroke", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Apply last selected color to stroke")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Apply last selected color to stroke")); } void SelectedStyle::on_fill_invert() { @@@ -595,8 -595,8 +596,8 @@@ sp_repr_css_set_property (css, "fill", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Invert fill")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Invert fill")); } void SelectedStyle::on_stroke_invert() { @@@ -615,8 -615,8 +616,8 @@@ sp_repr_css_set_property (css, "stroke", c); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Invert stroke")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Invert stroke")); } void SelectedStyle::on_fill_white() { @@@ -627,8 -627,8 +628,8 @@@ sp_repr_css_set_property (css, "fill-opacity", "1"); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("White fill")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("White fill")); } void SelectedStyle::on_stroke_white() { @@@ -639,8 -639,8 +640,8 @@@ sp_repr_css_set_property (css, "stroke-opacity", "1"); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("White stroke")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("White stroke")); } void SelectedStyle::on_fill_black() { @@@ -651,8 -651,8 +652,8 @@@ sp_repr_css_set_property (css, "fill-opacity", "1.0"); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Black fill")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Black fill")); } void SelectedStyle::on_stroke_black() { @@@ -663,8 -663,8 +664,8 @@@ sp_repr_css_set_property (css, "stroke-opacity", "1.0"); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Black stroke")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Black stroke")); } void SelectedStyle::on_fill_copy() { @@@ -706,8 -706,8 +707,8 @@@ void SelectedStyle::on_fill_paste() sp_repr_css_set_property (css, "fill", text.c_str()); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Paste fill")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Paste fill")); } } @@@ -724,8 -724,8 +725,8 @@@ void SelectedStyle::on_stroke_paste() sp_repr_css_set_property (css, "stroke", text.c_str()); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Paste stroke")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Paste stroke")); } } @@@ -778,8 -778,8 +779,8 @@@ void SelectedStyle::on_fillstroke_swap( sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Swap fill and stroke")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Swap fill and stroke")); } void SelectedStyle::on_fill_edit() { @@@ -853,8 -853,8 +854,8 @@@ SelectedStyle::on_opacity_click(GdkEven sp_repr_css_set_property (css, "opacity", opacity); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document (_desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done (sp_desktop_document (_desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Change opacity")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Change opacity")); return true; } @@@ -888,8 -888,8 +889,8 @@@ void SelectedStyle::on_popup_preset(in // FIXME: update dash patterns! sp_desktop_set_style (_desktop, css, true); sp_repr_css_attr_unref (css); - sp_document_done (sp_desktop_document(_desktop), SP_VERB_DIALOG_SWATCHES, - SPDocumentUndo::done (sp_desktop_document(_desktop), SP_VERB_DIALOG_SWATCHES, -- _("Change stroke width")); ++ DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_DIALOG_SWATCHES, ++ _("Change stroke width")); } void @@@ -1147,8 -1147,8 +1148,8 @@@ void SelectedStyle::on_opacity_changed sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(_desktop), 0); sp_desktop_set_style (_desktop, css); sp_repr_css_attr_unref (css); - sp_document_maybe_done (sp_desktop_document (_desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::maybe_done (sp_desktop_document (_desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE, -- _("Change opacity")); ++ DocumentUndo::maybeDone(sp_desktop_document(_desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE, ++ _("Change opacity")); // resume interruptibility sp_canvas_end_forced_full_redraws(sp_desktop_canvas(_desktop)); spinbutton_defocus(GTK_OBJECT(_opacity_sb.gobj())); @@@ -1274,19 -1274,19 +1275,19 @@@ RotateableSwatch::do_motion(double by, if (modifier == 3) { // Alt, do nothing } else if (modifier == 2) { // saturation - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, - SPDocumentUndo::maybe_done (sp_desktop_document(parent->getDesktop()), undokey, ++ DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust saturation"))); double ch = hsl[1]; parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>saturation</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, without modifiers to adjust hue"), ch - diff, ch, diff); } else if (modifier == 1) { // lightness - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, - SPDocumentUndo::maybe_done (sp_desktop_document(parent->getDesktop()), undokey, ++ DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust lightness"))); double ch = hsl[2]; parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>lightness</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff); } else { // hue - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, - SPDocumentUndo::maybe_done (sp_desktop_document(parent->getDesktop()), undokey, ++ DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust hue"))); double ch = hsl[0]; parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>hue</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Ctrl</b> to adjust lightness"), ch - diff, ch, diff); @@@ -1315,15 -1315,15 +1316,15 @@@ RotateableSwatch::do_release(double by if (modifier == 3) { // Alt, do nothing } else if (modifier == 2) { // saturation - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, - SPDocumentUndo::maybe_done (sp_desktop_document(parent->getDesktop()), undokey, ++ DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, ("Adjust saturation")); } else if (modifier == 1) { // lightness - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, - SPDocumentUndo::maybe_done (sp_desktop_document(parent->getDesktop()), undokey, ++ DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, ("Adjust lightness")); } else { // hue - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, - SPDocumentUndo::maybe_done (sp_desktop_document(parent->getDesktop()), undokey, ++ DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, ("Adjust hue")); } @@@ -1397,7 -1397,7 +1398,7 @@@ RotateableStrokeWidth::do_motion(doubl if (modifier == 3) { // Alt, do nothing } else { double diff = value_adjust(startvalue, by, modifier, false); - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, - SPDocumentUndo::maybe_done (sp_desktop_document(parent->getDesktop()), undokey, ++ DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust stroke width"))); parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>stroke width</b>: was %.3g, now <b>%.3g</b> (diff %.3g)"), startvalue, startvalue + diff, diff); } @@@ -1411,7 -1411,7 +1412,7 @@@ RotateableStrokeWidth::do_release(doubl } else { value_adjust(startvalue, by, modifier, true); startvalue_set = false; - sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, - SPDocumentUndo::maybe_done (sp_desktop_document(parent->getDesktop()), undokey, ++ DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust stroke width"))); } diff --cc src/ui/widget/style-subject.cpp index 09001a993,ab21ecf32..f4780896b --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@@ -2,6 -2,6 +2,7 @@@ * \brief Abstraction for different style widget operands * * Copyright (C) 2007 MenTaLguY <mental@rydia.net> ++ * Abhishek Sharma * * Released under GNU GPL. Read the file 'COPYING' for more information. */ diff --cc src/ui/widget/tolerance-slider.cpp index 3a36127f4,84c6a0de2..cc179ddbc --- a/src/ui/widget/tolerance-slider.cpp +++ b/src/ui/widget/tolerance-slider.cpp @@@ -4,6 -4,6 +4,7 @@@ * * Authors: * Ralf Stephan <ralf@ark.in-berlin.de> ++ * Abhishek Sharma * * Copyright (C) 2006 Authors * @@@ -186,11 -186,11 +187,11 @@@ ToleranceSlider::update (double val _wr->setUpdating (true); SPDocument *doc = sp_desktop_document(dt); - bool saved = sp_document_get_undo_sensitive (doc); - sp_document_set_undo_sensitive (doc, false); - bool saved = SPDocumentUndo::get_undo_sensitive (doc); - SPDocumentUndo::set_undo_sensitive (doc, false); ++ bool saved = DocumentUndo::getUndoSensitive(doc); ++ DocumentUndo::setUndoSensitive(doc, false); Inkscape::XML::Node *repr = SP_OBJECT_REPR (sp_desktop_namedview(dt)); repr->setAttribute(_key.c_str(), os.str().c_str()); - sp_document_set_undo_sensitive (doc, saved); - SPDocumentUndo::set_undo_sensitive (doc, saved); ++ DocumentUndo::setUndoSensitive(doc, saved); doc->setModifiedSinceSave(); diff --cc src/unclump.cpp index 3226160dc,1d051bc62..1039351a3 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@@ -3,6 -3,6 +3,8 @@@ */ /* Authors: * bulia byak ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2005 Authors * Released under GNU GPL, read the file 'COPYING' for more information @@@ -292,10 -292,10 +294,10 @@@ unclump_push (SPItem *from, SPItem *wha i->second *= move; } -- //g_print ("push %s at %g,%g from %g,%g by %g,%g, dist %g\n", SP_OBJECT_ID(what), it[Geom::X],it[Geom::Y], p[Geom::X],p[Geom::Y], by[Geom::X],by[Geom::Y], dist); ++ //g_print ("push %s at %g,%g from %g,%g by %g,%g, dist %g\n", what->getId(), it[Geom::X],it[Geom::Y], p[Geom::X],p[Geom::Y], by[Geom::X],by[Geom::Y], dist); - sp_item_set_i2d_affine(what, sp_item_i2d_affine(what) * move); - sp_item_write_transform(what, SP_OBJECT_REPR(what), what->transform, NULL); + what->set_i2d_affine(what->i2d_affine() * move); + what->doWriteTransform(SP_OBJECT_REPR(what), what->transform, NULL); } /** @@@ -315,10 -315,10 +317,10 @@@ unclump_pull (SPItem *to, SPItem *what i->second *= move; } -- //g_print ("pull %s at %g,%g to %g,%g by %g,%g, dist %g\n", SP_OBJECT_ID(what), it[Geom::X],it[Geom::Y], p[Geom::X],p[Geom::Y], by[Geom::X],by[Geom::Y], dist); ++ //g_print ("pull %s at %g,%g to %g,%g by %g,%g, dist %g\n", what->getId(), it[Geom::X],it[Geom::Y], p[Geom::X],p[Geom::Y], by[Geom::X],by[Geom::Y], dist); - sp_item_set_i2d_affine(what, sp_item_i2d_affine(what) * move); - sp_item_write_transform(what, SP_OBJECT_REPR(what), what->transform, NULL); + what->set_i2d_affine(what->i2d_affine() * move); + what->doWriteTransform(SP_OBJECT_REPR(what), what->transform, NULL); } @@@ -364,7 -364,7 +366,7 @@@ unclump (GSList *items double dist_closest = unclump_dist (closest, item); double dist_farest = unclump_dist (farest, item); -- //g_print ("NEI %d for item %s closest %s at %g farest %s at %g ave %g\n", g_slist_length(nei), SP_OBJECT_ID(item), SP_OBJECT_ID(closest), dist_closest, SP_OBJECT_ID(farest), dist_farest, ave); ++ //g_print ("NEI %d for item %s closest %s at %g farest %s at %g ave %g\n", g_slist_length(nei), item->getId(), closest->getId(), dist_closest, farest->getId(), dist_farest, ave); 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 diff --cc src/uri-references.h index a98c84153,e6399bfd9..c0f9190b1 --- a/src/uri-references.h +++ b/src/uri-references.h @@@ -6,6 -6,6 +6,7 @@@ * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Abhishek Sharma * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. diff --cc src/vanishing-point.cpp index d8e27debd,80f15fc5a..f8e991623 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __VANISHING_POINT_C__ -- /* * Vanishing point for 3D perspectives * @@@ -7,6 -7,6 +5,7 @@@ * bulia byak <buliabyak@users.sf.net> * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> * Maximilian Albert <Anhalter42@gmx.de> ++ * Abhishek Sharma * * Copyright (C) 2005-2007 authors * @@@ -22,9 -22,7 +21,11 @@@ #include "xml/repr.h" #include "perspective-line.h" #include "shape-editor.h" +#include "snap.h" +#include "sp-namedview.h" + ++using Inkscape::DocumentUndo; + namespace Box3D { #define VP_KNOT_COLOR_NORMAL 0xffffff00 @@@ -121,8 -119,8 +122,8 @@@ vp_knot_moved_handler (SPKnot *knot, Ge } // FIXME: Do we need to create a new dragger as well? dragger->updateZOrders (); - sp_document_done (sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, - SPDocumentUndo::done (sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, -- _("Split vanishing points")); ++ DocumentUndo::done(sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, ++ _("Split vanishing points")); return; } } @@@ -166,8 -164,8 +167,8 @@@ // deleted according to changes in the svg representation, not based on any user input // as is currently the case. - sp_document_done (sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, - SPDocumentUndo::done (sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, -- _("Merge vanishing points")); ++ DocumentUndo::done(sp_desktop_document (inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX, ++ _("Merge vanishing points")); return; } @@@ -232,8 -220,8 +233,8 @@@ vp_knot_ungrabbed_handler (SPKnot *knot // TODO: Undo machinery!! g_return_if_fail (dragger->parent); g_return_if_fail (dragger->parent->document); - sp_document_done(dragger->parent->document, SP_VERB_CONTEXT_3DBOX, - SPDocumentUndo::done(dragger->parent->document, SP_VERB_CONTEXT_3DBOX, -- _("3D box: Move vanishing point")); ++ DocumentUndo::done(dragger->parent->document, SP_VERB_CONTEXT_3DBOX, ++ _("3D box: Move vanishing point")); } unsigned int VanishingPoint::global_counter = 0; diff --cc src/verbs.cpp index 8b5ec9b3b,5c35c1e51..a218e85db --- a/src/verbs.cpp +++ b/src/verbs.cpp @@@ -1,4 -1,4 +1,3 @@@ --#define __SP_VERBS_C__ /** * \file verbs.cpp * @@@ -17,6 -17,6 +16,7 @@@ * David Turner <novalis@gnu.org> * bulia byak <buliabyak@users.sf.net> * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl> * Copyright (C) (date unspecified) Authors @@@ -82,6 -81,6 +82,8 @@@ #include "ui/icon-names.h" #include "ui/tool/node-tool.h" ++using Inkscape::DocumentUndo; ++ //#ifdef WITH_INKBOARD //#include "jabber_whiteboard/session-manager.h" //#endif @@@ -638,30 -628,10 +640,30 @@@ Verb::sensitive(SPDocument *in_doc, boo } /** \brief Accessor to get the tooltip for verb as localised string */ -gchar const * -Verb::get_tip (void) +gchar const *Verb::get_tip(void) { - return _(_tip); + gchar const *result = 0; + if (_tip) { + unsigned int shortcut = sp_shortcut_get_primary(this); + if ( (shortcut != _shortcut) || !_full_tip) { + if (_full_tip) { + g_free(_full_tip); + _full_tip = 0; + } + _shortcut = shortcut; + gchar* shortcutString = sp_shortcut_get_label(shortcut); + if (shortcutString) { + _full_tip = g_strdup_printf("%s (%s)", _(_tip), shortcutString); + g_free(shortcutString); + shortcutString = 0; + } else { - _full_tip = g_strdup(_(_tip)); ++ _full_tip = g_strdup(_(_tip)); + } + } + result = _full_tip; + } + + return result; } void @@@ -1128,8 -1098,8 +1130,8 @@@ LayerVerb::perform(SPAction *action, vo SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); if (next) { dt->setCurrentLayer(next); - sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_NEXT, - SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_NEXT, -- _("Switch to next layer")); ++ DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_NEXT, ++ _("Switch to next layer")); dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Switched to next layer.")); } else { dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot go past last layer.")); @@@ -1140,8 -1110,8 +1142,8 @@@ SPObject *prev=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); if (prev) { dt->setCurrentLayer(prev); - sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_PREV, - SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_PREV, -- _("Switch to previous layer")); ++ DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_PREV, ++ _("Switch to previous layer")); dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Switched to previous layer.")); } else { dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot go before first layer.")); @@@ -1168,7 -1138,7 +1170,7 @@@ SPItem *layer=SP_ITEM(dt->currentLayer()); g_return_if_fail(layer != NULL); -- SPObject *old_pos=SP_OBJECT_NEXT(layer); ++ SPObject *old_pos = layer->getNext(); switch (verb) { case SP_VERB_LAYER_TO_TOP: @@@ -1185,7 -1155,7 +1187,7 @@@ break; } -- if ( SP_OBJECT_NEXT(layer) != old_pos ) { ++ if ( layer->getNext() != old_pos ) { char const *message = NULL; Glib::ustring description = ""; switch (verb) { @@@ -1206,7 -1176,7 +1208,7 @@@ description = _("Lower layer"); break; }; - sp_document_done(sp_desktop_document(dt), verb, description); - SPDocumentUndo::done(sp_desktop_document(dt), verb, description); ++ DocumentUndo::done(sp_desktop_document(dt), verb, description); if (message) { dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, message); g_free((void *) message); @@@ -1237,7 -1207,8 +1239,8 @@@ sp_edit_select_all(dt); #else // Copies everything, regardless of locks, visibility, sublayers. - Inkscape::XML::Node *selected = dt->currentLayer()->repr; + //XML Tree being directly used here while it shouldn't be. - Inkscape::XML::Node *selected = dt->currentLayer()->getRepr(); ++ Inkscape::XML::Node *selected = dt->currentLayer()->getRepr(); Inkscape::XML::Node *parent = sp_repr_parent(selected); Inkscape::XML::Node *dup = selected->duplicate(parent->document()); parent->addChild(dup, selected); @@@ -1251,8 -1222,8 +1254,8 @@@ dt->setCurrentLayer(new_layer); } #endif - sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_DUPLICATE, - SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_DUPLICATE, -- _("Duplicate layer")); ++ DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_DUPLICATE, ++ _("Duplicate layer")); // TRANSLATORS: this means "The layer has been duplicated." dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Duplicated layer.")); @@@ -1283,8 -1254,8 +1286,8 @@@ dt->setCurrentLayer(survivor); } - sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_DELETE, - SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_DELETE, -- _("Delete layer")); ++ DocumentUndo::done(sp_desktop_document(dt), SP_VERB_LAYER_DELETE, ++ _("Delete layer")); // TRANSLATORS: this means "The layer has been deleted." dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Deleted layer.")); @@@ -1298,7 -1269,7 +1301,7 @@@ dt->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No current layer.")); } else { dt->toggleLayerSolo( dt->currentLayer() ); - sp_document_maybe_done(sp_desktop_document(dt), "layer:solo", SP_VERB_LAYER_SOLO, _("Toggle layer solo")); - SPDocumentUndo::maybe_done(sp_desktop_document(dt), "layer:solo", SP_VERB_LAYER_SOLO, _("Toggle layer solo")); ++ DocumentUndo::maybeDone(sp_desktop_document(dt), "layer:solo", SP_VERB_LAYER_SOLO, _("Toggle layer solo")); } break; } @@@ -1358,13 -1329,13 +1361,13 @@@ ObjectVerb::perform( SPAction *action, break; case SP_VERB_OBJECT_FLIP_HORIZONTAL: sp_selection_scale_relative(sel, center, Geom::Scale(-1.0, 1.0)); - sp_document_done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_HORIZONTAL, - SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_HORIZONTAL, -- _("Flip horizontally")); ++ DocumentUndo::done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_HORIZONTAL, ++ _("Flip horizontally")); break; case SP_VERB_OBJECT_FLIP_VERTICAL: sp_selection_scale_relative(sel, center, Geom::Scale(1.0, -1.0)); - sp_document_done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_VERTICAL, - SPDocumentUndo::done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_VERTICAL, -- _("Flip vertically")); ++ DocumentUndo::done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_VERTICAL, ++ _("Flip vertically")); break; case SP_VERB_OBJECT_SET_MASK: sp_selection_set_mask(dt, false, false); @@@ -2192,19 -2163,19 +2195,19 @@@ LockAndHideVerb::perform(SPAction *acti switch (reinterpret_cast<std::size_t>(data)) { case SP_VERB_UNLOCK_ALL: unlock_all(dt); - sp_document_done(doc, SP_VERB_UNLOCK_ALL, _("Unlock all objects in the current layer")); - SPDocumentUndo::done(doc, SP_VERB_UNLOCK_ALL, _("Unlock all objects in the current layer")); ++ DocumentUndo::done(doc, SP_VERB_UNLOCK_ALL, _("Unlock all objects in the current layer")); break; case SP_VERB_UNLOCK_ALL_IN_ALL_LAYERS: unlock_all_in_all_layers(dt); - sp_document_done(doc, SP_VERB_UNLOCK_ALL_IN_ALL_LAYERS, _("Unlock all objects in all layers")); - SPDocumentUndo::done(doc, SP_VERB_UNLOCK_ALL_IN_ALL_LAYERS, _("Unlock all objects in all layers")); ++ DocumentUndo::done(doc, SP_VERB_UNLOCK_ALL_IN_ALL_LAYERS, _("Unlock all objects in all layers")); break; case SP_VERB_UNHIDE_ALL: unhide_all(dt); - sp_document_done(doc, SP_VERB_UNHIDE_ALL, _("Unhide all objects in the current layer")); - SPDocumentUndo::done(doc, SP_VERB_UNHIDE_ALL, _("Unhide all objects in the current layer")); ++ DocumentUndo::done(doc, SP_VERB_UNHIDE_ALL, _("Unhide all objects in the current layer")); break; case SP_VERB_UNHIDE_ALL_IN_ALL_LAYERS: unhide_all_in_all_layers(dt); - sp_document_done(doc, SP_VERB_UNHIDE_ALL_IN_ALL_LAYERS, _("Unhide all objects in all layers")); - SPDocumentUndo::done(doc, SP_VERB_UNHIDE_ALL_IN_ALL_LAYERS, _("Unhide all objects in all layers")); ++ DocumentUndo::done(doc, SP_VERB_UNHIDE_ALL_IN_ALL_LAYERS, _("Unhide all objects in all layers")); break; default: return; diff --cc src/widgets/desktop-widget.cpp index d447abf2e,591ea6253..7a3e337de --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_DESKTOP_WIDGET_C__ -- /** \file * Desktop widget implementation */ @@@ -10,6 -10,6 +8,8 @@@ * Ralf Stephan <ralf@ark.in-berlin.de> * John Bintz <jcoswell@coswellproductions.org> * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2007 Johan Engelen * Copyright (C) 2006 John Bintz @@@ -731,7 -730,7 +731,7 @@@ void SPDesktopWidget::updateNamedview( modified_connection = desktop->namedview->connectModified(sigc::mem_fun(*this, &SPDesktopWidget::namedviewModified)); namedviewModified(desktop->namedview, SP_OBJECT_MODIFIED_FLAG); -- updateTitle(SP_DOCUMENT_NAME (desktop->doc())); ++ updateTitle( desktop->doc()->getName() ); } /** @@@ -858,7 -857,7 +858,7 @@@ SPDesktopWidget::shutdown( GTK_BUTTONS_NONE, _("<span weight=\"bold\" size=\"larger\">Save changes to document \"%s\" before closing?</span>\n\n" "If you close without saving, your changes will be discarded."), -- SP_DOCUMENT_NAME(doc)); ++ doc->getName()); // fix for bug 1767940: GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(GTK_MESSAGE_DIALOG(dialog)->label), GTK_CAN_FOCUS); @@@ -900,7 -899,7 +900,7 @@@ } /* Code to check data loss */ bool allow_data_loss = FALSE; -- while (sp_document_repr_root(doc)->attribute("inkscape:dataloss") != NULL && allow_data_loss == FALSE) { ++ while (doc->getReprRoot()->attribute("inkscape:dataloss") != NULL && allow_data_loss == FALSE) { GtkWidget *dialog; /** \todo @@@ -914,7 -913,7 +914,7 @@@ GTK_BUTTONS_NONE, _("<span weight=\"bold\" size=\"larger\">The file \"%s\" was saved with a format (%s) that may cause data loss!</span>\n\n" "Do you want to save this file as Inkscape SVG?"), -- SP_DOCUMENT_NAME(doc)? SP_DOCUMENT_NAME(doc) : "Unnamed", ++ doc->getName() ? doc->getName() : "Unnamed", SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE); // fix for bug 1767940: GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(GTK_MESSAGE_DIALOG(dialog)->label), GTK_CAN_FOCUS); @@@ -1575,7 -1540,7 +1575,7 @@@ bool SPDesktopWidget::onFocusInEvent(Gd { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/options/bitmapautoreload/value", true)) { - GSList const *imageList = sp_document_get_resource_list(desktop->doc(), "image"); - GSList const *imageList = (desktop->doc())->get_resource_list("image"); ++ GSList const *imageList = (desktop->doc())->getResourceList("image"); for (GSList const *p = imageList; p; p = p->next) { SPImage* image = SP_IMAGE(p->data); sp_image_refresh_if_outdated( image ); diff --cc src/widgets/desktop-widget.h index 33f2a6ae7,6aa2a1ed5..4edd434af --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@@ -8,6 -8,6 +8,7 @@@ * Jon A. Cruz <jon@joncruz.org> (c) 2010 * John Bintz <jcoswell@coswellproductions.org> (c) 2006 * Ralf Stephan <ralf@ark.in-berlin.de> (c) 2005, distrib. under GPL2 ++ * Abhishek Sharma * ? -2004 */ diff --cc src/widgets/fill-style.cpp index b70c8f47d,e4db09c90..b4272a3a4 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@@ -6,6 -6,6 +6,7 @@@ * Frank Felfe <innerspace@iname.com> * bulia byak <buliabyak@users.sf.net> * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 1999-2005 authors * Copyright (C) 2001-2002 Ximian, Inc. @@@ -332,8 -332,8 +333,8 @@@ void FillNStroke::setFillrule( SPPaintS sp_repr_css_attr_unref(css); css = 0; - sp_document_done(desktop->doc(), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done(desktop->doc(), SP_VERB_DIALOG_FILL_STROKE, -- _("Change fill rule")); ++ DocumentUndo::done(desktop->doc(), SP_VERB_DIALOG_FILL_STROKE, ++ _("Change fill rule")); } } @@@ -417,8 -417,8 +418,8 @@@ void FillNStroke::dragFromPaint( // local change, do not update from selection dragId = g_timeout_add_full(G_PRIORITY_DEFAULT, 100, dragDelayCB, this, 0); psel->setFlatColor( desktop, (kind == FILL) ? "fill" : "stroke", (kind == FILL) ? "fill-opacity" : "stroke-opacity" ); - sp_document_maybe_done(desktop->doc(), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::maybe_done(desktop->doc(), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE, -- (kind == FILL) ? _("Set fill color") : _("Set stroke color")); ++ DocumentUndo::maybeDone(desktop->doc(), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE, ++ (kind == FILL) ? _("Set fill color") : _("Set stroke color")); break; } @@@ -480,8 -480,8 +481,8 @@@ void FillNStroke::updateFromPaint( sp_repr_css_attr_unref(css); css = 0; - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, -- (kind == FILL) ? _("Remove fill") : _("Remove stroke")); ++ DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, ++ (kind == FILL) ? _("Remove fill") : _("Remove stroke")); break; } @@@ -496,8 -496,8 +497,8 @@@ psel->setFlatColor( desktop, (kind == FILL) ? "fill" : "stroke", (kind == FILL) ? "fill-opacity" : "stroke-opacity" ); - sp_document_maybe_done(sp_desktop_document(desktop), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE, -- (kind == FILL) ? _("Set fill color") : _("Set stroke color")); ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE, ++ (kind == FILL) ? _("Set fill color") : _("Set stroke color")); if (kind == FILL) { // resume interruptibility @@@ -556,7 -552,7 +557,7 @@@ for (GSList const *i = items; i != NULL; i = i->next) { //FIXME: see above if (kind == FILL) { - sp_repr_css_change_recursive(reinterpret_cast<SPObject*>(i->data)->repr, css, "style"); - sp_repr_css_change_recursive(SP_OBJECT_REPR(i->data), css, "style"); ++ sp_repr_css_change_recursive(reinterpret_cast<SPObject*>(i->data)->getRepr(), css, "style"); } if (!vector) { @@@ -578,7 -570,7 +579,7 @@@ for (GSList const *i = items; i != NULL; i = i->next) { //FIXME: see above if (kind == FILL) { - sp_repr_css_change_recursive(reinterpret_cast<SPObject*>(i->data)->repr, css, "style"); - sp_repr_css_change_recursive(SP_OBJECT_REPR(i->data), css, "style"); ++ sp_repr_css_change_recursive(reinterpret_cast<SPObject*>(i->data)->getRepr(), css, "style"); } SPGradient *gr = sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, kind == FILL); @@@ -591,8 -583,8 +592,8 @@@ css = 0; } - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, -- (kind == FILL) ? _("Set gradient on fill") : _("Set gradient on stroke")); ++ DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, ++ (kind == FILL) ? _("Set gradient on fill") : _("Set gradient on stroke")); } break; @@@ -608,7 -600,7 +609,7 @@@ */ } else { - Inkscape::XML::Node *patrepr = pattern->repr; - Inkscape::XML::Node *patrepr = SP_OBJECT_REPR(pattern); ++ Inkscape::XML::Node *patrepr = pattern->getRepr(); SPCSSAttr *css = sp_repr_css_attr_new(); gchar *urltext = g_strdup_printf("url(#%s)", patrepr->attribute("id")); sp_repr_css_set_property(css, (kind == FILL) ? "fill" : "stroke", urltext); @@@ -622,7 -614,7 +623,7 @@@ // objects who already have the same root pattern but through a different href // chain. FIXME: move this to a sp_item_set_pattern for (GSList const *i = items; i != NULL; i = i->next) { - Inkscape::XML::Node *selrepr = reinterpret_cast<SPObject*>(i->data)->repr; - Inkscape::XML::Node *selrepr = SP_OBJECT_REPR(i->data); ++ Inkscape::XML::Node *selrepr = reinterpret_cast<SPObject*>(i->data)->getRepr(); if ( (kind == STROKE) && !selrepr) { continue; } @@@ -651,9 -643,9 +652,9 @@@ } // end if - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, -- (kind == FILL) ? _("Set pattern on fill") : -- _("Set pattern on stroke")); ++ DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, ++ (kind == FILL) ? _("Set pattern on fill") : ++ _("Set pattern on stroke")); } // end if break; @@@ -678,8 -670,8 +679,8 @@@ sp_repr_css_attr_unref(css); css = 0; - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, -- (kind == FILL) ? _("Unset fill") : _("Unset stroke")); ++ DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, ++ (kind == FILL) ? _("Unset fill") : _("Unset stroke")); } break; diff --cc src/widgets/gradient-selector.cpp index 5b663c493,77defa5c9..49549de1c --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@@ -340,7 -327,7 +340,7 @@@ sp_gradient_selector_add_vector_clicke SPGradient *gr = sp_gradient_vector_selector_get_gradient( SP_GRADIENT_VECTOR_SELECTOR (sel->vectors)); -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); ++ Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *repr = NULL; diff --cc src/widgets/gradient-toolbar.cpp index ce5f5fb8f,a55439908..e7596ead4 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@@ -4,6 -4,6 +4,7 @@@ * Authors: * bulia byak <bulia@dr.com> * Johan Engelen <j.b.c.engelen@ewi.utwente.nl> ++ * Abhishek Sharma * * Copyright (C) 2007 Johan Engelen * Copyright (C) 2005 authors @@@ -42,6 -42,6 +43,7 @@@ #include "toolbox.h" ++using Inkscape::DocumentUndo; //######################## //## Gradient ## @@@ -150,8 -151,8 +152,8 @@@ gr_item_activate (GtkMenuItem *menuitem gr_apply_gradient (selection, ev? ev->get_drag() : NULL, gr); - sp_document_done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, - SPDocumentUndo::done (sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, -- _("Assign gradient to object")); ++ DocumentUndo::done(sp_desktop_document (desktop), SP_VERB_CONTEXT_GRADIENT, ++ _("Assign gradient to object")); } gchar * @@@ -171,7 -172,7 +173,7 @@@ GtkWidget *gr_vector_list(SPDesktop *de GtkWidget *m = gtk_menu_new (); GSList *gl = NULL; - const GSList *gradients = sp_document_get_resource_list (document, "gradient"); - const GSList *gradients = document->get_resource_list ("gradient"); ++ const GSList *gradients = document->getResourceList("gradient"); for (const GSList *i = gradients; i != NULL; i = i->next) { SPGradient *grad = SP_GRADIENT(i->data); if ( grad->hasStops() && !grad->isSolid() ) { diff --cc src/widgets/gradient-vector.cpp index 76bb9b8e1,ffa5b12dd..1be0aae8e --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@@ -6,6 -6,6 +6,7 @@@ * bulia byak <buliabyak@users.sf.net> * MenTaLguY <mental@rydia.net> * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. @@@ -43,6 -43,6 +44,8 @@@ #include <sigc++/functors/ptr_fun.h> #include <sigc++/adaptors/bind.h> ++using Inkscape::DocumentUndo; ++ enum { VECTOR_SET, LAST_SIGNAL @@@ -253,7 -249,7 +256,7 @@@ static void sp_gvs_rebuild_gui_full(SPG /* Pick up all gradients with vectors */ GSList *gl = NULL; if (gvs->gr) { - const GSList *gradients = sp_document_get_resource_list(SP_OBJECT_DOCUMENT(gvs->gr), "gradient"); - const GSList *gradients = SP_OBJECT_DOCUMENT(gvs->gr)->get_resource_list("gradient"); ++ const GSList *gradients = SP_OBJECT_DOCUMENT(gvs->gr)->getResourceList("gradient"); for (const GSList *curr = gradients; curr; curr = curr->next) { SPGradient* grad = SP_GRADIENT(curr->data); if ( grad->hasStops() && (grad->isSwatch() == gvs->swatched) ) { @@@ -340,12 -336,11 +343,12 @@@ static void sp_gvs_gradient_activate(Gt /* Namely - menuitems etc. will be fucked up */ /* Hmmm - probably we can just re-set it as menuitem data (Lauris) */ -- //g_print("SPGradientVectorSelector: gradient %s activated\n", SP_OBJECT_ID(gr)); ++ //g_print("SPGradientVectorSelector: gradient %s activated\n", gr->getId()); + //g_message("Setting to gradient %p swatch:%d solid:%d", gr, gr->isSwatch(), gr->isSolid()); norm = sp_gradient_ensure_vector_normalized(gr); if (norm != gr) { -- //g_print("SPGradientVectorSelector: become %s after normalization\n", SP_OBJECT_ID(norm)); ++ //g_print("SPGradientVectorSelector: become %s after normalization\n", norm->getId()); /* But be careful that we do not have gradient saved anywhere else */ g_object_set_data(G_OBJECT(mi), "gradient", norm); } @@@ -368,8 -363,8 +371,8 @@@ /* We do extra undo push here */ /* If handler has already done it, it is just NOP */ // FIXME: looks like this is never a valid undo step, consider removing this - sp_document_done(SP_OBJECT_DOCUMENT(norm), SP_VERB_CONTEXT_GRADIENT, - SPDocumentUndo::done(SP_OBJECT_DOCUMENT(norm), SP_VERB_CONTEXT_GRADIENT, -- /* TODO: annotate */ "gradient-vector.cpp:350"); ++ DocumentUndo::done(SP_OBJECT_DOCUMENT(norm), SP_VERB_CONTEXT_GRADIENT, ++ /* TODO: annotate */ "gradient-vector.cpp:350"); } } @@@ -468,7 -463,7 +471,7 @@@ static void verify_grad(SPGradient *gra int i = 0; SPStop *stop = NULL; /* count stops */ - for ( SPObject *ochild = sp_object_first_child(SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) { - for ( SPObject *ochild = SP_OBJECT(gradient)->first_child() ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) { ++ for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) { if (SP_IS_STOP(ochild)) { i++; stop = SP_STOP(ochild); @@@ -508,7 -506,7 +511,7 @@@ static void select_stop_in_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_stop) { int i = 0; - for ( SPObject *ochild = sp_object_first_child(SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) { - for ( SPObject *ochild = SP_OBJECT(gradient)->first_child() ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) { ++ for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) { if (SP_IS_STOP(ochild)) { if (SP_OBJECT(ochild) == SP_OBJECT(new_stop)) { gtk_option_menu_set_history(GTK_OPTION_MENU(mnu), i); @@@ -538,7 -536,7 +541,7 @@@ static void update_stop_list( GtkWidge gtk_widget_show(m); GSList *sl = NULL; if ( gradient->hasStops() ) { - for ( SPObject *ochild = sp_object_first_child(SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) { - for ( SPObject *ochild = SP_OBJECT(gradient)->first_child() ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) { ++ for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) { if (SP_IS_STOP(ochild)) { sl = g_slist_append(sl, ochild); } @@@ -648,22 -651,25 +651,22 @@@ static void sp_grad_edit_select(GtkOpti static void offadjustmentChanged( GtkAdjustment *adjustment, GtkWidget *vb) { - if (blocked) { - return; - } - - blocked = TRUE; + if (!blocked) { + blocked = TRUE; - GtkOptionMenu *mnu = static_cast<GtkOptionMenu *>(g_object_get_data(G_OBJECT(vb), "stopmenu")); - if (!g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop")) { - return; - } - SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop")); + GtkOptionMenu *mnu = static_cast<GtkOptionMenu *>(g_object_get_data(G_OBJECT(vb), "stopmenu")); + if ( g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop") ) { + SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop")); - stop->offset = adjustment->value; - sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", stop->offset); + stop->offset = adjustment->value; + sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", stop->offset); - sp_document_maybe_done(SP_OBJECT_DOCUMENT(stop), "gradient:stop:offset", SP_VERB_CONTEXT_GRADIENT, - _("Change gradient stop offset")); - SPDocumentUndo::done(SP_OBJECT_DOCUMENT(stop), SP_VERB_CONTEXT_GRADIENT, - _("Change gradient stop offset")); ++ DocumentUndo::maybeDone(SP_OBJECT_DOCUMENT(stop), "gradient:stop:offset", SP_VERB_CONTEXT_GRADIENT, ++ _("Change gradient stop offset")); - blocked = FALSE; + blocked = FALSE; + } + } } guint32 sp_average_color(guint32 c1, guint32 c2, gdouble p = 0.5) @@@ -733,8 -739,8 +736,8 @@@ static void sp_grd_ed_add_stop(GtkWidge GtkWidget *offslide =GTK_WIDGET(g_object_get_data(G_OBJECT(vb), "offslide")); gtk_widget_set_sensitive(offslide, TRUE); gtk_widget_set_sensitive(GTK_WIDGET(offspin), TRUE); - sp_document_done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT, - SPDocumentUndo::done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT, -- _("Add gradient stop")); ++ DocumentUndo::done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT, ++ _("Add gradient stop")); } static void sp_grd_ed_del_stop(GtkWidget */*widget*/, GtkWidget *vb) @@@ -764,8 -770,8 +767,8 @@@ SP_OBJECT_REPR(gradient)->removeChild(SP_OBJECT_REPR(stop)); sp_gradient_vector_widget_load_gradient(vb, gradient); update_stop_list(GTK_WIDGET(mnu), gradient, NULL); - sp_document_done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT, - SPDocumentUndo::done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT, -- _("Delete gradient stop")); ++ DocumentUndo::done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT, ++ _("Delete gradient stop")); } } @@@ -1030,10 -1040,10 +1033,10 @@@ static void sp_gradient_vector_widget_l // Once the user edits a gradient, it stops being auto-collectable if (SP_OBJECT_REPR(gradient)->attribute("inkscape:collect")) { SPDocument *document = SP_OBJECT_DOCUMENT(gradient); - bool saved = sp_document_get_undo_sensitive(document); - sp_document_set_undo_sensitive(document, false); - bool saved = SPDocumentUndo::get_undo_sensitive(document); - SPDocumentUndo::set_undo_sensitive(document, false); ++ bool saved = DocumentUndo::getUndoSensitive(document); ++ DocumentUndo::setUndoSensitive(document, false); SP_OBJECT_REPR(gradient)->setAttribute("inkscape:collect", NULL); - sp_document_set_undo_sensitive(document, saved); - SPDocumentUndo::set_undo_sensitive(document, saved); ++ DocumentUndo::setUndoSensitive(document, saved); } } else { // no gradient, disable everything gtk_widget_set_sensitive(widget, FALSE); @@@ -1182,8 -1197,8 +1185,8 @@@ static void sp_gradient_vector_color_ch // g_snprintf(c, 256, "stop-color:#%06x;stop-opacity:%g;", rgb >> 8, static_cast<gdouble>(alpha)); //SP_OBJECT_REPR(stop)->setAttribute("style", c); - sp_document_done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT, - SPDocumentUndo::done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT, -- _("Change gradient stop color")); ++ DocumentUndo::done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT, ++ _("Change gradient stop color")); blocked = FALSE; diff --cc src/widgets/icon.cpp index c25e6aac2,570502253..15900d340 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@@ -5,6 -5,6 +5,7 @@@ * Author: * Lauris Kaplinski <lauris@kaplinski.com> * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2002 Lauris Kaplinski * @@@ -1109,7 -1109,7 +1110,7 @@@ static guchar *load_svg_pixels(gchar co //g_message("Loaded icon file %s", doc_filename); // prep the document - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); /* Create new arena */ NRArena *arena = NRArena::create(); /* Create ArenaItem and set transform */ @@@ -1135,8 -1135,7 +1136,7 @@@ ==7014== by 0x5E9DDE: nr_arena_group_render(_cairo*, NRArenaItem*, NRRectL*, NRPixBlock*, unsigned int) (nr-arena-group.cpp:228) ==7014== by 0x5E72FB: nr_arena_item_invoke_render(_cairo*, NRArenaItem*, NRRectL const*, NRPixBlock*, unsigned int) (nr-arena-item.cpp:578) */ - root = sp_item_invoke_show( SP_ITEM(SP_DOCUMENT_ROOT(doc)), - arena, visionkey, SP_ITEM_SHOW_DISPLAY ); - root = SP_ITEM(SP_DOCUMENT_ROOT(doc))->invoke_show(arena, visionkey, SP_ITEM_SHOW_DISPLAY ); ++ root = SP_ITEM(doc->getRoot())->invoke_show(arena, visionkey, SP_ITEM_SHOW_DISPLAY ); // store into the cache info = new svg_doc_cache_t; diff --cc src/widgets/paint-selector.cpp index a7bed9e94,aadda9e20..1d8acb40a --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@@ -8,6 -8,6 +8,7 @@@ * bulia byak <buliabyak@users.sf.net> * John Cliff <simarilius@yahoo.com> * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) Lauris Kaplinski 2002 * Copyright (C) 2010 Authors @@@ -784,7 -784,7 +785,7 @@@ ink_pattern_list_get (SPDocument *sourc return NULL; GSList *pl = NULL; - GSList const *patterns = sp_document_get_resource_list(source, "pattern"); - GSList const *patterns = source->get_resource_list("pattern"); ++ GSList const *patterns = source->getResourceList("pattern"); for (GSList *l = (GSList *) patterns; l != NULL; l = l->next) { if (SP_PATTERN(l->data) == pattern_getroot(SP_PATTERN(l->data))) { // only if this is a root pattern pl = g_slist_prepend(pl, l->data); @@@ -894,7 -894,7 +895,7 @@@ ink_pattern_menu_populate_menu(GtkWidge // suck in from patterns.svg if (patterns_doc) { - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); sp_pattern_list_from_doc ( m, doc, patterns_doc, NULL ); } diff --cc src/widgets/select-toolbar.cpp index ed54857f8,a5bf81821..a0ec248ca --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@@ -5,6 -5,6 +5,7 @@@ * Lauris Kaplinski <lauris@kaplinski.com> * bulia byak <buliabyak@users.sf.net> * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2003-2005 authors * @@@ -52,6 -52,6 +53,7 @@@ #include "ui/icon-names.h" using Inkscape::UnitTracker; ++using Inkscape::DocumentUndo; static void sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) @@@ -155,7 -155,7 +157,7 @@@ sp_object_layout_any_value_changed(GtkA Inkscape::Selection *selection = sp_desktop_selection(desktop); SPDocument *document = sp_desktop_document(desktop); - sp_document_ensure_up_to_date (document); - document->ensure_up_to_date (); ++ document->ensureUpToDate (); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getInt("/tools/bounding_box"); SPItem::BBoxType bbox_type = (prefs_bbox ==0)? @@@ -243,7 -243,7 +245,7 @@@ Geom::Matrix scaler = get_scale_transform_with_stroke (*bbox, strokewidth, transform_stroke, x0, y0, x1, y1); sp_selection_apply_affine(selection, scaler); - sp_document_maybe_done (document, actionkey, SP_VERB_CONTEXT_SELECT, - SPDocumentUndo::maybe_done (document, actionkey, SP_VERB_CONTEXT_SELECT, ++ DocumentUndo::maybeDone(document, actionkey, SP_VERB_CONTEXT_SELECT, _("Transform by toolbar")); // resume interruptibility diff --cc src/widgets/sp-attribute-widget.cpp index 3473d8f31,8a46001b1..0c31c2f74 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@@ -3,6 -3,6 +3,7 @@@ */ /* Authors: * Lauris Kaplinski <lauris@ximian.com> ++ * Abhishek Sharma * * Copyright (C) 2001 Ximian, Inc. * Released under GNU GPL, read the file 'COPYING' for more information @@@ -21,6 -21,6 +22,8 @@@ #include "sp-attribute-widget.h" ++using Inkscape::DocumentUndo; ++ static void sp_attribute_widget_class_init (SPAttributeWidgetClass *klass); static void sp_attribute_widget_init (SPAttributeWidget *widget); static void sp_attribute_widget_destroy (GtkObject *object); @@@ -154,8 -154,8 +157,8 @@@ sp_attribute_widget_changed (GtkEditabl if (spaw->hasobj && spaw->src.object) { SP_OBJECT_REPR (spaw->src.object)->setAttribute(spaw->attribute, text, false); - sp_document_done (SP_OBJECT_DOCUMENT (spaw->src.object), SP_VERB_NONE, - SPDocumentUndo::done (SP_OBJECT_DOCUMENT (spaw->src.object), SP_VERB_NONE, -- _("Set attribute")); ++ DocumentUndo::done(SP_OBJECT_DOCUMENT (spaw->src.object), SP_VERB_NONE, ++ _("Set attribute")); } else if (spaw->src.repr) { @@@ -761,8 -761,8 +764,8 @@@ sp_attribute_table_entry_changed ( GtkE if (spat->hasobj && spat->src.object) { SP_OBJECT_REPR (spat->src.object)->setAttribute(spat->attributes[i], text, false); - sp_document_done (SP_OBJECT_DOCUMENT (spat->src.object), SP_VERB_NONE, - SPDocumentUndo::done (SP_OBJECT_DOCUMENT (spat->src.object), SP_VERB_NONE, -- _("Set attribute")); ++ DocumentUndo::done(SP_OBJECT_DOCUMENT (spat->src.object), SP_VERB_NONE, ++ _("Set attribute")); } else if (spat->src.repr) { diff --cc src/widgets/sp-color-icc-selector.cpp index 4b565d1a3,17324967e..12467041c --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@@ -581,7 -581,7 +581,7 @@@ void ColorICCSelector::_profilesChanged gtk_combo_box_set_active( combo, 0 ); int index = 1; - const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "iccprofile" ); - const GSList *current = SP_ACTIVE_DOCUMENT->get_resource_list( "iccprofile" ); ++ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); while ( current ) { SPObject* obj = SP_OBJECT(current->data); Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj); diff --cc src/widgets/sp-xmlview-content.cpp index 7150b07fd,239f6e6e1..75d68d25c --- a/src/widgets/sp-xmlview-content.cpp +++ b/src/widgets/sp-xmlview-content.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_XMLVIEW_CONTENT_C__ -- /* * Specialization of GtkTextView for the XML tree view * @@@ -7,6 -7,6 +5,7 @@@ * MenTaLguY <mental@rydia.net> * * Copyright (C) 2002 MenTaLguY ++ * Abhishek Sharma * * Released under the GNU GPL; see COPYING for details */ @@@ -20,6 -20,6 +19,8 @@@ #include "document-private.h" #include "inkscape.h" ++using Inkscape::DocumentUndo; ++ static void sp_xmlview_content_class_init (SPXMLViewContentClass * klass); static void sp_xmlview_content_init (SPXMLViewContent * text); static void sp_xmlview_content_destroy (GtkObject * object); @@@ -165,7 -165,7 +166,7 @@@ sp_xmlview_content_changed (GtkTextBuff text->repr->setContent(data); g_free (data); text->blocked = FALSE; - sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_XML_EDITOR, - SPDocumentUndo::done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_XML_EDITOR, -- _("Type text in a text node")); ++ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_XML_EDITOR, ++ _("Type text in a text node")); } } diff --cc src/widgets/stroke-style.cpp index 2c5506273,65732d488..ffcbe48f8 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@@ -7,6 -7,6 +7,8 @@@ * bulia byak <buliabyak@users.sf.net> * Maximilian Albert <maximilian.albert@gmail.com> * Josh Andler <scislac@users.sf.net> ++ * Jon A. Cruz <jon@joncruz.org> ++ * Abhishek Sharma * * Copyright (C) 2001-2005 authors * Copyright (C) 2001 Ximian, Inc. @@@ -59,6 -59,6 +61,8 @@@ #include "fill-style.h" // to get sp_fill_style_widget_set_desktop #include "fill-n-stroke-factory.h" ++using Inkscape::DocumentUndo; ++ /** Marker selection option menus */ static Gtk::OptionMenu * marker_start_menu = NULL; static Gtk::OptionMenu * marker_mid_menu = NULL; @@@ -156,7 -156,7 +160,7 @@@ sp_marker_prev_new(unsigned psize, gcha return NULL; // Create a copy repr of the marker with id="sample" -- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(sandbox); ++ Inkscape::XML::Document *xml_doc = sandbox->getReprDoc(); Inkscape::XML::Node *mrepr = SP_OBJECT_REPR (marker)->duplicate(xml_doc); mrepr->setAttribute("id", "sample"); @@@ -170,13 -170,13 +174,13 @@@ // Uncomment this to get the sandbox documents saved (useful for debugging) //FILE *fp = fopen (g_strconcat(menu_id, mname, ".svg", NULL), "w"); -- //sp_repr_save_stream (sp_document_repr_doc (sandbox), fp); ++ //sp_repr_save_stream(sandbox->getReprDoc(), fp); //fclose (fp); // object to render; note that the id is the same as that of the menu we're building SPObject *object = sandbox->getObjectById(menu_id); -- sp_document_root (sandbox)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); - sp_document_ensure_up_to_date(sandbox); - sandbox->ensure_up_to_date(); ++ sandbox->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); ++ sandbox->ensureUpToDate(); if (object == NULL || !SP_IS_ITEM(object)) return NULL; // sandbox broken? @@@ -193,7 -193,7 +197,7 @@@ double sf = 0.8; gchar *cache_name = g_strconcat(menu_id, mname, NULL); -- Glib::ustring key = svg_preview_cache.cache_key(source->uri, cache_name, psize); ++ Glib::ustring key = svg_preview_cache.cache_key(source->getURI(), cache_name, psize); g_free (cache_name); // TODO: is this correct? Glib::RefPtr<Gdk::Pixbuf> pixbuf = Glib::wrap(svg_preview_cache.get_preview_from_cache(key)); @@@ -221,9 -221,9 +225,7 @@@ ink_marker_list_get (SPDocument *source GSList *ml = NULL; SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS (source); - for ( SPObject *child = sp_object_first_child(SP_OBJECT(defs)); - for ( SPObject *child = SP_OBJECT(defs)->first_child(); -- child != NULL; -- child = SP_OBJECT_NEXT (child) ) ++ for ( SPObject *child = SP_OBJECT(defs)->firstChild(); child; child = child->getNext() ) { if (SP_IS_MARKER(child)) { ml = g_slist_prepend (ml, child); @@@ -242,8 -242,8 +244,8 @@@ sp_marker_menu_build (Gtk::Menu *m, GSL { // Do this here, outside of loop, to speed up preview generation: NRArena const *arena = NRArena::create(); - unsigned const visionkey = sp_item_display_key_new(1); - NRArenaItem *root = sp_item_invoke_show(SP_ITEM(SP_DOCUMENT_ROOT (sandbox)), (NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY); + unsigned const visionkey = SPItem::display_key_new(1); - NRArenaItem *root = SP_ITEM(SP_DOCUMENT_ROOT (sandbox))->invoke_show((NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY); ++ NRArenaItem *root = SP_ITEM(sandbox->getRoot())->invoke_show((NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY); for (; marker_list != NULL; marker_list = marker_list->next) { Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) marker_list->data); @@@ -280,7 -280,7 +282,7 @@@ m->append(*i); } - sp_item_invoke_hide(SP_ITEM(sp_document_root(sandbox)), visionkey); - SP_ITEM(sp_document_root(sandbox))->invoke_hide(visionkey); ++ SP_ITEM(sandbox->getRoot())->invoke_hide(visionkey); nr_object_unref((NRObject *) arena); } @@@ -391,7 -391,7 +393,7 @@@ ink_marker_menu_create_menu(Gtk::Menu * // suck in from markers.svg if (markers_doc) { - sp_document_ensure_up_to_date(doc); - doc->ensure_up_to_date(); ++ doc->ensureUpToDate(); sp_marker_list_from_doc(m, doc, markers_doc, NULL, sandbox, menu_id); } @@@ -498,8 -498,8 +500,8 @@@ sp_marker_select(Gtk::OptionMenu *mnu, sp_repr_css_attr_unref(css); css = 0; - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, -- _("Set markers")); ++ DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, ++ _("Set markers")); }; @@@ -1200,8 -1203,8 +1202,8 @@@ sp_stroke_style_scale_line(Gtk::Contain sp_repr_css_attr_unref(css); css = 0; - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, -- _("Set stroke style")); ++ DocumentUndo::done(document, SP_VERB_DIALOG_FILL_STROKE, ++ _("Set stroke style")); spw->set_data("update", GINT_TO_POINTER(FALSE)); } @@@ -1297,8 -1300,8 +1299,8 @@@ sp_stroke_style_any_toggled(Gtk::Toggle sp_repr_css_attr_unref(css); css = 0; - sp_document_done(sp_desktop_document(desktop), SP_VERB_DIALOG_FILL_STROKE, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_FILL_STROKE, -- _("Set stroke style")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_DIALOG_FILL_STROKE, ++ _("Set stroke style")); } } diff --cc src/widgets/swatch-selector.cpp index 3c209a45d,b1329b92a..935282a3a --- a/src/widgets/swatch-selector.cpp +++ b/src/widgets/swatch-selector.cpp @@@ -135,8 -135,8 +135,8 @@@ void SwatchSelector::_changedCb(SPColor os << "stop-color:" << c << ";stop-opacity:" << static_cast<gdouble>(alpha) <<";"; SP_OBJECT_REPR(stop)->setAttribute("style", os.str().c_str()); - sp_document_done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT, - SPDocumentUndo::done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT, -- _("Change swatch color")); ++ DocumentUndo::done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT, ++ _("Change swatch color")); } } } diff --cc src/widgets/toolbox.cpp index ce71a097e,6da23a696..8a616d002 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@@ -13,6 -13,6 +13,7 @@@ * Jon A. Cruz <jon@joncruz.org> * Maximilian Albert <maximilian.albert@gmail.com> * Tavmjong Bah <tavmjong@free.fr> ++ * Abhishek Sharma * * Copyright (C) 2004 David Turner * Copyright (C) 2003 MenTaLguY @@@ -112,6 -112,6 +113,7 @@@ using Inkscape::UnitTracker; using Inkscape::UI::UXManager; ++using Inkscape::DocumentUndo; typedef void (*SetupFunction)(GtkWidget *toolbox, SPDesktop *desktop); typedef void (*UpdateFunction)(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox); @@@ -1271,7 -1270,7 +1273,7 @@@ static void sp_node_path_value_changed( UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" )); SPUnit const *unit = tracker->getActiveUnit(); - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { - if (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { ++ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { prefs->setDouble(Glib::ustring("/tools/nodes/") + (d == Geom::X ? "x" : "y"), sp_units_get_pixels(adj->value, *unit)); } @@@ -2053,8 -2051,8 +2055,8 @@@ static void toggle_snap_callback(GtkTog return; } - bool saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive(doc, false); - bool saved = SPDocumentUndo::get_undo_sensitive(doc); - SPDocumentUndo::set_undo_sensitive(doc, false); ++ bool saved = DocumentUndo::getUndoSensitive(doc); ++ DocumentUndo::setUndoSensitive(doc, false); bool v = false; SPAttributeEnum attr = (SPAttributeEnum) GPOINTER_TO_INT(g_object_get_data(G_OBJECT(act), "SP_ATTR_INKSCAPE")); @@@ -2139,7 -2137,7 +2141,7 @@@ // The snapping preferences are stored in the document, and therefore toggling makes the document dirty doc->setModifiedSinceSave(); - sp_document_set_undo_sensitive(doc, saved); - SPDocumentUndo::set_undo_sensitive(doc, saved); ++ DocumentUndo::setUndoSensitive(doc, saved); } void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) @@@ -2498,7 -2491,7 +2500,7 @@@ static void sp_stb_magnitude_value_chan { SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" ); - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { - if (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { ++ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { // do not remember prefs if this call is initiated by an undo change, because undoing object // creation sets bogus values to its attributes before it is deleted Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@@ -2529,8 -2522,8 +2531,8 @@@ } } if (modmade) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, -- _("Star: Change number of corners")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, ++ _("Star: Change number of corners")); } g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) ); @@@ -2540,7 -2533,7 +2542,7 @@@ static void sp_stb_proportion_value_cha { SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" ); - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { - if (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { ++ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { if (!IS_NAN(adj->value)) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble("/tools/shapes/star/proportion", adj->value); @@@ -2576,8 -2569,8 +2578,8 @@@ } if (modmade) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, -- _("Star: Change spoke ratio")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, ++ _("Star: Change spoke ratio")); } g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) ); @@@ -2588,7 -2581,7 +2590,7 @@@ static void sp_stb_sides_flat_state_cha SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" ); bool flat = ege_select_one_action_get_active( act ) == 0; - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { - if (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { ++ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool( "/tools/shapes/star/isflatsided", flat); } @@@ -2620,8 -2613,8 +2622,8 @@@ } if (modmade) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, -- flat ? _("Make polygon") : _("Make star")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, ++ flat ? _("Make polygon") : _("Make star")); } g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) ); @@@ -2631,7 -2624,7 +2633,7 @@@ static void sp_stb_rounded_value_change { SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" ); - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { - if (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { ++ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble("/tools/shapes/star/rounded", (gdouble) adj->value); } @@@ -2657,8 -2650,8 +2659,8 @@@ } } if (modmade) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, -- _("Star: Change rounding")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, ++ _("Star: Change rounding")); } g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) ); @@@ -2668,7 -2661,7 +2670,7 @@@ static void sp_stb_randomized_value_cha { SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" ); - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { - if (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { ++ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble("/tools/shapes/star/randomized", (gdouble) adj->value); } @@@ -2694,8 -2687,8 +2696,8 @@@ } } if (modmade) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, -- _("Star: Change randomization")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR, ++ _("Star: Change randomization")); } g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) ); @@@ -3033,7 -3026,7 +3035,7 @@@ static void sp_rtb_value_changed(GtkAdj UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" )); SPUnit const *unit = tracker->getActiveUnit(); - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { - if (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { ++ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble(Glib::ustring("/tools/shapes/rect/") + value_name, sp_units_get_pixels(adj->value, *unit)); } @@@ -3062,8 -3055,8 +3064,8 @@@ sp_rtb_sensitivize( tbl ); if (modmade) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT, -- _("Change rectangle")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT, ++ _("Change rectangle")); } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@@ -3430,7 -3423,7 +3432,7 @@@ static void box3d_persp_tb_event_attr_c } // set freeze so that it can be caught in box3d_angle_z_value_changed() (to avoid calling - // sp_document_maybe_done() when the document is undo insensitive) - // SPDocumentUndo::maybe_done() when the document is undo insensitive) ++ // SPDocumentUndo::maybeDone() when the document is undo insensitive) g_object_set_data(G_OBJECT(tbl), "freeze", GINT_TO_POINTER(TRUE)); // TODO: Only update the appropriate part of the toolbar @@@ -3514,7 -3507,7 +3516,7 @@@ static void box3d_angle_value_changed(G SP_OBJECT(persp)->updateRepr(); // TODO: use the correct axis here, too - sp_document_maybe_done(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)")); - SPDocumentUndo::maybe_done(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)")); ++ DocumentUndo::maybeDone(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)")); g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) ); } @@@ -3709,7 -3702,7 +3711,7 @@@ static void sp_spl_tb_value_changed(Gtk { SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { - if (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { ++ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble("/tools/shapes/spiral/" + value_name, adj->value); } @@@ -3740,8 -3733,8 +3742,8 @@@ g_free(namespaced_name); if (modmade) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL, -- _("Change spiral")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL, ++ _("Change spiral")); } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@@ -5303,7 -5296,7 +5305,7 @@@ sp_arctb_startend_value_changed(GtkAdju { SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { - if (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { ++ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble(Glib::ustring("/tools/shapes/arc/") + value_name, adj->value); } @@@ -5351,8 -5344,8 +5353,8 @@@ sp_arctb_sensitivize( tbl, adj->value, other->value ); if (modmade) { - sp_document_maybe_done(sp_desktop_document(desktop), value_name, SP_VERB_CONTEXT_ARC, - SPDocumentUndo::maybe_done(sp_desktop_document(desktop), value_name, SP_VERB_CONTEXT_ARC, -- _("Arc: Change start/end")); ++ DocumentUndo::maybeDone(sp_desktop_document(desktop), value_name, SP_VERB_CONTEXT_ARC, ++ _("Arc: Change start/end")); } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@@ -5373,7 -5366,7 +5375,7 @@@ static void sp_arctb_end_value_changed( static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) { SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { - if (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { ++ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool("/tools/shapes/arc/open", ege_select_one_action_get_active(act) != 0); } @@@ -5415,8 -5408,8 +5417,8 @@@ } if (modmade) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC, - SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC, -- _("Arc: Change open/closed")); ++ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ARC, ++ _("Arc: Change open/closed")); } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@@ -5746,7 -5739,7 +5748,7 @@@ static void sp_lpetool_mode_changed(Ege SP_LPETOOL_CONTEXT(desktop->event_context)->mode = type; } - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { - if (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { ++ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setInt( "/tools/lpetool/mode", mode ); } @@@ -6083,7 -6076,7 +6085,7 @@@ static void sp_erasertb_mode_changed( E { SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); bool eraserMode = ege_select_one_action_get_active( act ) != 0; - if (sp_document_get_undo_sensitive(sp_desktop_document(desktop))) { - if (SPDocumentUndo::get_undo_sensitive(sp_desktop_document(desktop))) { ++ if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool( "/tools/eraser/mode", eraserMode ); } @@@ -6383,8 -6376,8 +6385,8 @@@ static void sp_text_fontfamily_value_ch g_free (family); // Save for undo - sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, -- _("Text: Change font family")); ++ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, ++ _("Text: Change font family")); sp_repr_css_attr_unref (css); // unfreeze @@@ -6430,8 -6423,8 +6432,8 @@@ static void sp_text_fontsize_value_chan sp_desktop_set_style (desktop, css, true, true); // Save for undo - sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:size", SP_VERB_NONE, - SPDocumentUndo::maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:size", SP_VERB_NONE, -- _("Text: Change font size")); ++ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:size", SP_VERB_NONE, ++ _("Text: Change font size")); // If no selected objects, set default. SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); @@@ -6576,8 -6569,8 +6578,8 @@@ static void sp_text_style_changed( InkT // Do we need to update other CSS values? SPDesktop *desktop = SP_ACTIVE_DESKTOP; sp_desktop_set_style (desktop, css, true, true); - sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, -- _("Text: Change font style")); ++ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, ++ _("Text: Change font style")); sp_repr_css_attr_unref (css); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@@ -6653,8 -6646,8 +6655,8 @@@ static void sp_text_script_changed( Ink sp_desktop_set_style (desktop, css, true, false); // Save for undo - sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:script", SP_VERB_NONE, - SPDocumentUndo::maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:script", SP_VERB_NONE, -- _("Text: Change superscript or subscript")); ++ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:script", SP_VERB_NONE, ++ _("Text: Change superscript or subscript")); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } @@@ -6797,8 -6790,8 +6799,8 @@@ static void sp_text_align_mode_changed sp_style_unref(query); sp_desktop_set_style (desktop, css, true, true); - sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, -- _("Text: Change alignment")); ++ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, ++ _("Text: Change alignment")); sp_repr_css_attr_unref (css); gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas)); @@@ -6836,8 -6829,8 +6838,8 @@@ static void sp_text_lineheight_value_ch } // Save for undo - sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:line-height", SP_VERB_NONE, - SPDocumentUndo::maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:line-height", SP_VERB_NONE, -- _("Text: Change line-height")); ++ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:line-height", SP_VERB_NONE, ++ _("Text: Change line-height")); // If no selected objects, set default. SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); @@@ -6875,8 -6868,8 +6877,8 @@@ static void sp_text_wordspacing_value_c sp_desktop_set_style (desktop, css, true, false); // Save for undo - sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:word-spacing", SP_VERB_NONE, - SPDocumentUndo::maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:word-spacing", SP_VERB_NONE, -- _("Text: Change word-spacing")); ++ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:word-spacing", SP_VERB_NONE, ++ _("Text: Change word-spacing")); // If no selected objects, set default. SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); @@@ -6914,8 -6907,8 +6916,8 @@@ static void sp_text_letterspacing_value sp_desktop_set_style (desktop, css, true, false); // Save for undo - sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:letter-spacing", SP_VERB_NONE, - SPDocumentUndo::maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:letter-spacing", SP_VERB_NONE, -- _("Text: Change letter-spacing")); ++ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:letter-spacing", SP_VERB_NONE, ++ _("Text: Change letter-spacing")); // If no selected objects, set default. SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); @@@ -6959,8 -6952,8 +6961,8 @@@ static void sp_text_dx_value_changed( G } // Save for undo - sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:dx", SP_VERB_NONE, - SPDocumentUndo::maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:dx", SP_VERB_NONE, -- _("Text: Change dx (kern)")); ++ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:dx", SP_VERB_NONE, ++ _("Text: Change dx (kern)")); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } @@@ -6990,8 -6983,8 +6992,8 @@@ static void sp_text_dy_value_changed( G } // Save for undo - sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:dy", SP_VERB_NONE, - SPDocumentUndo::maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:dy", SP_VERB_NONE, -- _("Text: Change dy")); ++ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:dy", SP_VERB_NONE, ++ _("Text: Change dy")); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } @@@ -7021,8 -7014,8 +7023,8 @@@ static void sp_text_rotation_value_chan } // Save for undo - sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:rotate", SP_VERB_NONE, - SPDocumentUndo::maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "ttb:rotate", SP_VERB_NONE, -- _("Text: Change rotate")); ++ DocumentUndo::maybeDone(sp_desktop_document(SP_ACTIVE_DESKTOP), "ttb:rotate", SP_VERB_NONE, ++ _("Text: Change rotate")); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } @@@ -7066,8 -7059,8 +7068,8 @@@ static void sp_text_orientation_mode_ch } sp_desktop_set_style (SP_ACTIVE_DESKTOP, css, true, true); - sp_document_done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, - SPDocumentUndo::done (sp_desktop_document (SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, -- _("Text: Change orientation")); ++ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_CONTEXT_TEXT, ++ _("Text: Change orientation")); sp_repr_css_attr_unref (css); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); @@@ -7093,7 -7086,7 +7095,7 @@@ static void sp_text_toolbox_selection_c items != NULL; items = items->next) { -- const gchar* id = SP_OBJECT_ID((SPItem *) items->data); ++ const gchar* id = reinterpret_cast<SPItem *>(items->data)->getId(); std::cout << " " << id << std::endl; } Glib::ustring selected_text = sp_text_get_selected_text((SP_ACTIVE_DESKTOP)->event_context); @@@ -7118,7 -7111,7 +7120,7 @@@ for (GSList const *items = sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList(); items != NULL; items = items->next) { -- // const gchar* id = SP_OBJECT_ID((SPItem *) items->data); ++ // const gchar* id = reinterpret_cast<SPItem *>(items->data)->getId(); // std::cout << " " << id << std::endl; if( SP_IS_FLOWTEXT(( SPItem *) items->data )) { isFlow = true; @@@ -7876,7 -7869,7 +7878,7 @@@ static void sp_connector_orthogonal_tog Inkscape::Selection * selection = sp_desktop_selection(desktop); SPDocument *doc = sp_desktop_document(desktop); - if (!sp_document_get_undo_sensitive(doc)) { - if (!SPDocumentUndo::get_undo_sensitive(doc)) { ++ if (!DocumentUndo::getUndoSensitive(doc)) { return; } @@@ -7913,8 -7906,8 +7915,8 @@@ prefs->setBool("/tools/connector/orthogonal", is_orthog); } - sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, - SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, -- is_orthog ? _("Set connector type: orthogonal"): _("Set connector type: polyline")); ++ DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, ++ is_orthog ? _("Set connector type: orthogonal"): _("Set connector type: polyline")); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } @@@ -7925,7 -7918,7 +7927,7 @@@ static void connector_curvature_changed Inkscape::Selection * selection = sp_desktop_selection(desktop); SPDocument *doc = sp_desktop_document(desktop); - if (!sp_document_get_undo_sensitive(doc)) { - if (!SPDocumentUndo::get_undo_sensitive(doc)) { ++ if (!DocumentUndo::getUndoSensitive(doc)) { return; } @@@ -7961,8 -7954,8 +7963,8 @@@ prefs->setDouble(Glib::ustring("/tools/connector/curvature"), newValue); } - sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, - SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, -- _("Change connector curvature")); ++ DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, ++ _("Change connector curvature")); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } @@@ -7973,7 -7966,7 +7975,7 @@@ static void connector_spacing_changed(G SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); SPDocument *doc = sp_desktop_document(desktop); - if (!sp_document_get_undo_sensitive(doc)) { - if (!SPDocumentUndo::get_undo_sensitive(doc)) { ++ if (!DocumentUndo::getUndoSensitive(doc)) { return; } @@@ -8009,8 -8002,8 +8011,8 @@@ g_slist_free(items); } - sp_document_done(doc, SP_VERB_CONTEXT_CONNECTOR, - SPDocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, -- _("Change connector spacing")); ++ DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, ++ _("Change connector spacing")); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); } @@@ -8030,7 -8023,7 +8032,7 @@@ static void sp_connector_graph_layout(v prefs->setInt("/options/clonecompensation/value", saved_compensation); - sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Arrange connector network")); - SPDocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Arrange connector network")); ++ DocumentUndo::done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Arrange connector network")); } static void sp_directed_graph_layout_toggled( GtkToggleAction* act, GtkObject * /*tbl*/ ) diff --cc src/xml/helper-observer.cpp index 620a88d8c,976a8a7ec..ce902ba75 --- a/src/xml/helper-observer.cpp +++ b/src/xml/helper-observer.cpp @@@ -11,10 -11,12 +11,12 @@@ SignalObserver::SignalObserver( // Add this observer to the SPObject and remove it from any previous object void SignalObserver::set(SPObject* o) { - if(_oldsel && _oldsel->repr) - _oldsel->repr->removeObserver(*this); - if(o && o->repr) - o->repr->addObserver(*this); - /* XML Tree being used direcly in this function in the following code - while it shouldn't be */ ++ // XML Tree being used direcly in this function in the following code ++ // while it shouldn't be + if(_oldsel && _oldsel->getRepr()) + _oldsel->getRepr()->removeObserver(*this); + if(o && o->getRepr()) + o->getRepr()->addObserver(*this); _oldsel = o; } diff --cc src/xml/node-iterators.h index 3d09dfd1b,0868fb2ab..389d70be0 --- a/src/xml/node-iterators.h +++ b/src/xml/node-iterators.h @@@ -23,6 -23,6 +23,7 @@@ struct NodeSiblingIteratorStrategy return ( node ? node->next() : NULL ); } }; ++ struct NodeParentIteratorStrategy { static Node const *next(Node const *node) { return ( node ? node->parent() : NULL ); diff --cc src/xml/rebase-hrefs.cpp index c3876725d,33978420c..065517160 --- a/src/xml/rebase-hrefs.cpp +++ b/src/xml/rebase-hrefs.cpp @@@ -201,10 -201,10 +201,11 @@@ Inkscape::XML::calc_abs_doc_base(gchar */ void Inkscape::XML::rebase_hrefs(SPDocument *const doc, gchar const *const new_base, bool const spns) { -- if (!doc->base) ++ if (!doc->getBase()) { return; ++ } -- gchar *const old_abs_base = calc_abs_doc_base(doc->base); ++ gchar *const old_abs_base = calc_abs_doc_base(doc->getBase()); gchar *const new_abs_base = calc_abs_doc_base(new_base); /* TODO: Should handle not just image but also: @@@ -227,7 -227,7 +228,7 @@@ * * Note also that Inkscape only supports fragment hrefs (href="#pattern257") for many of these * cases. */ - GSList const *images = sp_document_get_resource_list(doc, "image"); - GSList const *images = doc->get_resource_list("image"); ++ GSList const *images = doc->getResourceList("image"); for (GSList const *l = images; l != NULL; l = l->next) { Inkscape::XML::Node *ir = SP_OBJECT_REPR(l->data); diff --cc src/xml/repr-io.cpp index b1320a4a3,fa5e9b6ed..5f7654ba8 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_REPR_IO_C__ -- /* * Dirty DOM-like tree * diff --cc src/xml/repr-sorting.cpp index df1d2cbb8,27293d3c2..056236d33 --- a/src/xml/repr-sorting.cpp +++ b/src/xml/repr-sorting.cpp @@@ -3,18 -3,18 +3,16 @@@ #include "xml/repr.h" #include "xml/node-iterators.h" --static bool --same_repr(Inkscape::XML::Node &a, Inkscape::XML::Node &b) ++static bool same_repr(Inkscape::XML::Node const &a, Inkscape::XML::Node const &b) { /* todo: I'm not certain that it's legal to take the address of a reference. Check the exact wording of the spec on this matter. */ return &a == &b; } --Inkscape::XML::Node * --LCA(Inkscape::XML::Node *a, Inkscape::XML::Node *b) ++Inkscape::XML::Node const *LCA(Inkscape::XML::Node const *a, Inkscape::XML::Node const *b) { using Inkscape::Algorithms::longest_common_suffix; -- Inkscape::XML::Node *ancestor = longest_common_suffix<Inkscape::XML::NodeParentIterator>( ++ Inkscape::XML::Node const *ancestor = longest_common_suffix<Inkscape::XML::NodeConstParentIterator>( a, b, NULL, &same_repr ); if ( ancestor && ancestor->type() != Inkscape::XML::DOCUMENT_NODE ) { @@@ -24,22 -24,22 +22,30 @@@ } } --/** -- * Returns a child of \a ancestor such that ret is itself an ancestor of \a descendent. -- * -- * The current version returns NULL if ancestor or descendent is NULL, though future versions may -- * call g_log. Please update this comment if you rely on the current behaviour. -- */ --Inkscape::XML::Node * --AncetreFils(Inkscape::XML::Node *descendent, Inkscape::XML::Node *ancestor) ++Inkscape::XML::Node *LCA(Inkscape::XML::Node *a, Inkscape::XML::Node *b) { -- if (descendent == NULL || ancestor == NULL) -- return NULL; -- if (sp_repr_parent(descendent) == ancestor) -- return descendent; -- return AncetreFils(sp_repr_parent(descendent), ancestor); ++ Inkscape::XML::Node const *tmp = LCA(const_cast<Inkscape::XML::Node const *>(a), const_cast<Inkscape::XML::Node const *>(b)); ++ return const_cast<Inkscape::XML::Node *>(tmp); } ++Inkscape::XML::Node const *AncetreFils(Inkscape::XML::Node const *descendent, Inkscape::XML::Node const *ancestor) ++{ ++ Inkscape::XML::Node const *result = 0; ++ if ( descendent && ancestor ) { ++ if (descendent->parent() == ancestor) { ++ result = descendent; ++ } else { ++ result = AncetreFils(descendent->parent(), ancestor); ++ } ++ } ++ return result; ++} ++ ++Inkscape::XML::Node *AncetreFils(Inkscape::XML::Node *descendent, Inkscape::XML::Node *ancestor) ++{ ++ Inkscape::XML::Node const * tmp = AncetreFils(const_cast<Inkscape::XML::Node const*>(descendent), const_cast<Inkscape::XML::Node const*>(ancestor)); ++ return const_cast<Inkscape::XML::Node *>(tmp); ++} /* Local Variables: diff --cc src/xml/repr-sorting.h index 7d5542f67,37f719622..d560dfa26 --- a/src/xml/repr-sorting.h +++ b/src/xml/repr-sorting.h @@@ -10,6 -10,6 +10,16 @@@ #include "xml/xml-forward.h" Inkscape::XML::Node *LCA(Inkscape::XML::Node *a, Inkscape::XML::Node *b); ++Inkscape::XML::Node const *LCA(Inkscape::XML::Node const *a, Inkscape::XML::Node const *b); ++ ++/** ++ * Returns a child of \a ancestor such that ret is itself an ancestor of \a descendent. ++ * ++ * The current version returns NULL if ancestor or descendent is NULL, though future versions may ++ * call g_log. Please update this comment if you rely on the current behaviour. ++ */ ++Inkscape::XML::Node const *AncetreFils(Inkscape::XML::Node const *descendent, Inkscape::XML::Node const *ancestor); ++ Inkscape::XML::Node *AncetreFils(Inkscape::XML::Node *descendent, Inkscape::XML::Node *ancestor); #endif // SEEN_XML_REPR_SOTRING_H diff --cc src/xml/repr-util.cpp index d310639ba,d78f6a927..07a25ca6d --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_REPR_UTIL_C__ -- /** \file * Miscellaneous helpers for reprs. */ @@@ -7,6 -7,6 +5,7 @@@ /* * Authors: * Lauris Kaplinski <lauris@ximian.com> ++ * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 1999-2000 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@@ -354,8 -354,8 +353,7 @@@ long long int sp_repr_get_int_attribute * -1 first object's position is less than the second * @todo Rewrite this function's description to be understandable */ --int --sp_repr_compare_position(Inkscape::XML::Node *first, Inkscape::XML::Node *second) ++int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second) { int p1, p2; if (sp_repr_parent(first) == sp_repr_parent(second)) { @@@ -368,7 -368,7 +366,7 @@@ instance. */ // Find the lowest common ancestor(LCA) -- Inkscape::XML::Node *ancestor = LCA(first, second); ++ Inkscape::XML::Node const *ancestor = LCA(first, second); g_assert(ancestor != NULL); if (ancestor == first) { @@@ -433,40 -433,40 +431,35 @@@ sp_repr_lookup_child(Inkscape::XML::Nod return NULL; } --/** -- * @brief Find an element node with the given name -- * -- * This function searches the descendants of the specified node depth-first for -- * the first XML node with the specified name. -- * -- * @param repr The node to start from -- * @param name The name of the element node to find -- * @param maxdepth Maximum search depth, or -1 for an unlimited depth -- * @return A pointer to the matching Inkscape::XML::Node -- * @relatesalso Inkscape::XML::Node -- */ --Inkscape::XML::Node * --sp_repr_lookup_name( Inkscape::XML::Node *repr, gchar const *name, gint maxdepth ) ++Inkscape::XML::Node const *sp_repr_lookup_name( Inkscape::XML::Node const *repr, gchar const *name, gint maxdepth ) { ++ Inkscape::XML::Node const *found = 0; g_return_val_if_fail(repr != NULL, NULL); g_return_val_if_fail(name != NULL, NULL); GQuark const quark = g_quark_from_string(name); -- if ( (GQuark)repr->code() == quark ) return repr; -- if ( maxdepth == 0 ) return NULL; -- -- // maxdepth == -1 means unlimited -- if ( maxdepth == -1 ) maxdepth = 0; ++ if ( (GQuark)repr->code() == quark ) { ++ found = repr; ++ } else if ( maxdepth != 0 ) { ++ // maxdepth == -1 means unlimited ++ if ( maxdepth == -1 ) { ++ maxdepth = 0; ++ } -- Inkscape::XML::Node *found = NULL; -- for (Inkscape::XML::Node *child = repr->firstChild() ; child && !found; child = child->next() ) { -- found = sp_repr_lookup_name( child, name, maxdepth-1 ); ++ for (Inkscape::XML::Node const *child = repr->firstChild() ; child && !found; child = child->next() ) { ++ found = sp_repr_lookup_name( child, name, maxdepth - 1 ); ++ } } -- return found; } ++Inkscape::XML::Node *sp_repr_lookup_name( Inkscape::XML::Node *repr, gchar const *name, gint maxdepth ) ++{ ++ Inkscape::XML::Node const *found = sp_repr_lookup_name( const_cast<Inkscape::XML::Node *>(repr), name, maxdepth ); ++ return const_cast<Inkscape::XML::Node *>(found); ++} ++ /** * Determine if the node is a 'title', 'desc' or 'metadata' element. */ diff --cc src/xml/repr.cpp index 4494d3fe6,4494d3fe6..0a384c9c1 --- a/src/xml/repr.cpp +++ b/src/xml/repr.cpp @@@ -1,5 -1,5 +1,3 @@@ --#define __SP_REPR_C__ -- /** \file * A few non-inline functions of the C facade to Inkscape::XML::Node. */ diff --cc src/xml/repr.h index 3b8d532fd,549822e4e..bde3e533f --- a/src/xml/repr.h +++ b/src/xml/repr.h @@@ -3,6 -3,6 +3,7 @@@ */ /* Authors: * Lauris Kaplinski <lauris@kaplinski.com> ++ * Jon A. Cruz <jon@joncruz.org> * * Copyright (C) 1999-2002 authors * Copyright (C) 2000-2002 Ximian, Inc. @@@ -10,8 -10,8 +11,8 @@@ * Released under GNU GPL, read the file 'COPYING' for more information */ --#ifndef __SP_REPR_H__ --#define __SP_REPR_H__ ++#ifndef SEEN_SP_REPR_H ++#define SEEN_SP_REPR_H #include <stdio.h> #include <glib/gtypes.h> @@@ -137,12 -137,12 +138,29 @@@ double sp_repr_get_double_attribute(Ink /// \deprecated Use sp_repr_get_int to check for success long long int sp_repr_get_int_attribute(Inkscape::XML::Node *repr, gchar const *key, long long int def); --int sp_repr_compare_position(Inkscape::XML::Node *first, Inkscape::XML::Node *second); ++int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second); --/* Searching */ ++// Searching ++/** ++ * @brief Find an element node with the given name ++ * ++ * This function searches the descendants of the specified node depth-first for ++ * the first XML node with the specified name. ++ * ++ * @param repr The node to start from ++ * @param name The name of the element node to find ++ * @param maxdepth Maximum search depth, or -1 for an unlimited depth ++ * @return A pointer to the matching Inkscape::XML::Node ++ * @relatesalso Inkscape::XML::Node ++ */ Inkscape::XML::Node *sp_repr_lookup_name(Inkscape::XML::Node *repr, gchar const *name, gint maxdepth = -1); ++ ++Inkscape::XML::Node const *sp_repr_lookup_name(Inkscape::XML::Node const *repr, ++ gchar const *name, ++ gint maxdepth = -1); ++ Inkscape::XML::Node *sp_repr_lookup_child(Inkscape::XML::Node *repr, gchar const *key, gchar const *value); @@@ -152,7 -152,7 +170,7 @@@ inline Inkscape::XML::Node *sp_repr_doc return const_cast<Inkscape::XML::Node *>(doc->firstChild()); } --#endif ++#endif // SEEN_SP_REPR_H /* Local Variables: mode:c++